1 Motivating Questions. 2 An Illustrating Example. 3 Software Quality. 4 An Example of OOP

Size: px
Start display at page:

Download "1 Motivating Questions. 2 An Illustrating Example. 3 Software Quality. 4 An Example of OOP"

Transcription

1 Qinghai Zhang An Introduction to Software Engineering for Mathematicians 2014-SEP-30 1 Motivating Questions Q1. What is math? Q2. Why do we care about math? Q3. What is software and software engineering? Q4. Why do we care about software engineering? 2 An Illustrating Example Consider numerically solving the diffusion equation φ t = f(x, t) + ν 2 φ, (1) on a rectangular domain Ω R D, where u is a given velocity field and f a given forcing term. The initial condition is φ(x, t) = φ 0 (x) and the boundary condition is Dirichlet, Neumann, Robin, or a mixed one of the above. The problem domain Ω is discretized into square control volumes, each of which denoted by a multi-index i Z D ; the region of cell i is represented by C i := [ x O + ih, x O + (i + 1) h ], (2) where x O is some fixed origin of the coordinates, h the uniform grid size, and 1 Z D the multi-index with all its components equal to one. The averaged φ over cell i is denoted by φ i := 1 h D φ (x) dx. (3) C i A fourth-order finite-volume discretization of the Laplacian is L φ i = 2 φ C i + O(h 4 ) with L φ i := 1 ( 12h 2 d φ i+2e d + 16 φ i+e d (4) 30 φ i + 16 φ i e d φ i 2e d where e d Z D is a multi-index with 1 as its d-th component and 0 otherwise. Integrating (1) and applying (3) and (4) yield a system of ODEs that approximates (1) within O(h 4 ): d φ dt ), = L φ + f(t), (5) for which we can use the method of lines to advance the solution for each time step. For example, an implicitexplicit (IMEX) scheme has the following steps: for s = 1, 2,, n s, n s φ (s) = φ n + k a [E] s,j (t f (j)) n s + k a [I] s,j (φ L (j), t (j)), j=1 j=1 (6a) n s ( φ n+1 = φ n + k b [E] s f t (s)) n s ( + k b [I] s L φ (s), t (s)), s=1 s=1 (6b) where the superscript (s) denotes an intermediate stage, t (s) = t n + c s k the time of that stage, n s the number of stages, and A, b, c the standard coefficients of the Butcher tableau. 3 Software Quality S1. Correctness: perform the tasks as defined by their specifications; S2. Ease of use S3. Reusability: serve for the construction of many different applications; S4. Extendibility: easily adapt to changes of specifications; S5. Robustness: react appropriately to abnormal conditions; S6. Efficiency: place as few demands as possible on hardware resources to achieve a certain metric; S7. Compatibility: easily to be combined with others; S8. Portability: easily to be transferred to various hardware and software environments; 4 An Example of OOP Below is some pseudo-code illustrating the paradigm of object-oriented programming (OOP). LevelData data; data.define(xo, ncells, h); ScalarFunction initfunc; initfunc.setdata(data); ScalarFunction bcfunc; bcfunc.define(...); BoundaryCondition bc; bc.define("dirichlet", bcfunc); DiscreteLaplacian<4> lapl; 1

2 Qinghai Zhang An Introduction to Software Engineering for Mathematicians 2014-SEP-30 lapl.define(xo, ncells, h); ScalarFunction forcingfunc; forcingfunc.define(...); TimeIntegrator ti; ti.define("erk-esdirk", lapl, forcingfunc); for (int i=0; i<ntimesteps; i++) { Real t = t0 + i*dt; ti.timestep(data, t); } ti.report(data); Some real C++ code are also included at the end of this document. TimeIntegrator.H: interface class for time integrators. ExplicitRungeKutta.H: an concrete class capturing explicit Runge-Kutta methods. ExplicitRungeKutta.cpp: the definition of various explicit Runge-Kutta methods. 5 Some OOP principles 5.1 Abstraction 5.2 Encapsulation 5.3 Inheritance: reusing the interface 5.4 Polymorphism: interchanging objects 6 Testing T1. unit tests; T2. acceptance test. 7 Debugging D1. a NP-complete problem; D2. use patterns to avoid cross-level bugs; D3. search by bisections. 2

3 File: /home/tsinghai/dao/src/timeintegrators/timeintegrator.h Page 1 of 1 1 #ifndef _TIMEINTEGRATOR_H_ 2 #define _TIMEINTEGRATOR_H_ /** 6 * Abstract base interface for time integrators. 7 * F is either FArrayBox or FluxBox 8 */ 9 template<class F> 10 class TimeIntegrator 11 { 12 public: virtual ~TimeIntegrator(){} virtual void updatetimestepsize(const Real& dt) = 0; /// 19 /// Advance one time step for the unknown. 20 /// 21 virtual void timestep(vector<leveldata<f>*>& U, Real time) = 0; }; #endif

4 File: /home/tsinghai/dao/src/timeintegrators/explicitrungekutta.h Page 1 of 3 1 #ifndef _EXPLICITRUNGEKUTTA_H_ 2 #define _EXPLICITRUNGEKUTTA_H_ 3 4 #include "BoundaryConditionFactory.H" 5 #include "HierarchyDataOps.H" 6 7 /// The list of implemented ERK methods. 8 enum ERK_Type 9 { 10 ForwardEuler=1, 11 ClassicRK4, 12 nerk_type 13 }; /// The compile time constants of orders-of-accuracy 16 template<erk_type Type> 17 struct ERK_Order; template<> 20 struct ERK_Order<ForwardEuler> 21 { 22 enum {val=1}; 23 }; template<> 26 struct ERK_Order<ClassicRK4> 27 { 28 enum {val=4}; 29 }; /// The compile time constants of numbers of stages 32 template<erk_type Type> 33 struct ERK_NumStages; template<> 36 struct ERK_NumStages<ForwardEuler> 37 { 38 enum {val=1}; 39 }; template<> 42 struct ERK_NumStages<ClassicRK4> 43 { 44 enum {val=4}; 45 }; /// The Butcher Tableau of ERK methods 49 template <ERK_Type Type> 50 struct ERK_ButcherTableau 51 { 52 static const int ns = ERK_NumStages<Type>::val; 53 // The first nstages numbers are the nominators 54 // while the last one their common denominator. 55 static const int a[ns][ns+1]; 56 static const int b[ns+1]; 57 static const int c[ns+1]; 58 }; /// default ERK methods for different orders-of-accuracy. 61 template<unsigned int Order> 62 struct ERK_DefaultMethods; template<> 65 struct ERK_DefaultMethods<1> 66 { 67 enum {val=forwardeuler}; 68 }; template<> 71 struct ERK_DefaultMethods<4> 72 { 73 enum {val=classicrk4}; 74 };

5 File: /home/tsinghai/dao/src/timeintegrators/explicitrungekutta.h Page 2 of /** 78 * This class encapsulates timestepping algorithms 79 * of an ERK (explicit Runge-Kutta) method. 80 * To implement a new ERK method, 81 * all one needs to do is to 82 * (1) add a new key to the enumerations in ERK_Type; 83 * (2) set its order with template specialization of ERK_Order; 84 * (3) set its # of stages with template specialization of ERK_NumStages; 85 * (4) specify its Butcher tableau in ExplicitRungeKutta.cpp. 86 * In other words, the following class stays the same 87 * if the ERK method can be expressed with a single Butcher tableau. 88 */ template<erk_type Type, /// The type of the ERK method 91 class F, /// FArrayBox or FluxBox? 92 class EOS> /// Equation Op strategies 93 class ExplicitRungeKutta 94 { 95 public: /// type acronyms 98 typedef BoundaryConditionBase BCB; 99 typedef RefCountedPtr<BCB> BCP; 100 typedef ERK_ButcherTableau<Type> ERC; 101 typedef HierarchyDataOps HOP; 102 typedef Vector<LevelData<F>*> VLF; 103 typedef Vector<Vector<LevelData<F>*> > VVL; static const int nstages = ERC::nS; 106 /// gamma is never used, just for interface uniformality 107 static const int gamma = 1; void define(const Real& dx, const Vector<int>& refv, const BCP phibc) 110 { 111 m_dx = dx; 112 m_refv = refv; 113 m_phibc = phibc; 114 // initialize the Butcher arrays from ERC 115 a.resize(nstages); 116 for (int i=0; i<a.size(); i++) 117 a[i].resize(nstages); 118 b.resize(nstages); 119 c.resize(nstages); 120 for (int i=0; i<a.size(); i++) 121 { 122 for (int j=0; j<a[i].size(); j++) 123 a[i][j] = static_cast<real>(erc::a[i][j])/erc::a[i][erc::ns]; 124 b[i] = static_cast<real>(erc::b[i])/erc::b[erc::ns]; 125 c[i] = static_cast<real>(erc::c[i])/erc::c[erc::ns]; 126 } 127 } /// 131 /// Advance one time step for the unknown. 132 /// The container imp here is intended for interface uniformity 133 /// and never used. 134 /// 135 void timestep(const Real& time, const Real& dt, 136 VLF& u, VVL& phi, VVL& exp, VVL& imp, EOS& eos) 137 { 138 for (int s=0; s<nstages; s++) 139 HOP::assign(phi[s], u); // Loop over all the stages 142 for (int ns=0; ns<nstages; ns++) 143 { 144 pout() << " ERK stage: " << ns+1 << endl; 145 for (int j=0; j<ns; j++) 146 { 147 HOP::incr(phi[ns], exp[j], a[ns][j]*dt); 148 }

6 File: /home/tsinghai/dao/src/timeintegrators/explicitrungekutta.h Page 3 of // The current intermediate time 151 const Real ts = time + c[ns]*dt; 152 m_phibc->settime(ts); 153 eos.computeoperators(phi[ns], exp[ns], imp[ns], ts); 154 // add results of implicit operators to explicit results 155 // since we are using explicit Runge-Kutta methods. 156 HOP::incr(exp[ns], imp[ns], 1.0); 157 eos.stagesteppostprocessing(phi[ns], ts); 158 } // calculate the results of the final stage 161 HOP::assign(u, phi[0]); 162 for (int s=0; s<nstages; s++) 163 HOP::incr(u, exp[s], b[s]*dt); 164 HOP::checkData(*u[0]); // set BC of u for other operators like vorticity. 167 m_phibc->fillghostcells(u, m_dx, m_refv, false); // false: homogeneous 168 } private: // The Butcher arrays from ERC 174 Vector<Vector<Real> > a; 175 Vector<Real> b; 176 Vector<Real> c; BCP m_phibc; 179 Real m_dx; 180 Vector<int> m_refv; 181 }; #endif

7 File: /home/tsinghai/dao/src/timein grators/explicitrungekutta.cpp Page 1 of 1 1 #include "ExplicitRungeKutta.H" 2 3 /// /// Butcher tableau of the forward Euler method 5 /// template<> 7 const int ERK_ButcherTableau<ForwardEuler>::a[][2] = 8 { 9 {0, 1} 10 }; template<> 13 const int ERK_ButcherTableau<ForwardEuler>::b[] = 14 { 15 1, 1 16 }; template<> 19 const int ERK_ButcherTableau<ForwardEuler>::c[] = 20 { 21 0, 1 22 }; /// /// Butcher tableau of the fourth-order Runge-Kutta method 27 /// template<> 29 const int ERK_ButcherTableau<ClassicRK4>::a[][5] = 30 { 31 {0, 0, 0, 0, 1}, 32 {1, 0, 0, 0, 2}, 33 {0, 1, 0, 0, 2}, 34 {0, 0, 1, 0, 1} 35 }; template<> 38 const int ERK_ButcherTableau<ClassicRK4>::b[] = 39 { 40 1, 2, 2, 1, 6 41 }; template<> 44 const int ERK_ButcherTableau<ClassicRK4>::c[] = 45 { 46 0, 1, 1, 2, 2 47 };

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane. Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane c Sateesh R. Mane 2018 16 Lecture 16 May 3, 2018 Numerical solution of systems

More information

Finite difference methods

Finite difference methods Finite difference methods Siltanen/Railo/Kaarnioja Spring 8 Applications of matrix computations Applications of matrix computations Finite difference methods Spring 8 / Introduction Finite difference methods

More information

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP OOP Object oriented programming Polymorphism Encapsulation Inheritance OOP Class concepts Classes can contain: Constants Delegates Events Fields Constructors Destructors Properties Methods Nested classes

More information

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming

More information

Parallel implicit ordinary differential equation solver for cuda. Tomasz M. Kardaś

Parallel implicit ordinary differential equation solver for cuda. Tomasz M. Kardaś Parallel implicit ordinary differential equation solver for cuda Tomasz M. Kardaś August 11, 2014 Chapter 1 Parallel Implicit Ordinary Differential Equations Solver A simplest definition of stiffness,

More information

Discontinuous Galerkin Sparse Grid method for Maxwell s equations

Discontinuous Galerkin Sparse Grid method for Maxwell s equations Discontinuous Galerkin Sparse Grid method for Maxwell s equations Student: Tianyang Wang Mentor: Dr. Lin Mu, Dr. David L.Green, Dr. Ed D Azevedo, Dr. Kwai Wong Motivation u We consider the Maxwell s equations,

More information

ForTrilinos Tutorial

ForTrilinos Tutorial ForTrilinos Tutorial Damian Rouson, Nicole Lemaster Sandia National Laboratories Karla Morris, Xiaofeng Xu City University of New York Salvatore Filippone University of Rome Jim Xia IBM Sponsors: DOE/OASCR,

More information

CME 345: MODEL REDUCTION

CME 345: MODEL REDUCTION CME 345: MODEL REDUCTION Parameterized Partial Differential Equations Charbel Farhat Stanford University cfarhat@stanford.edu 1 / 19 Outline 1 Initial Boundary Value Problems 2 Typical Parameters of Interest

More information

ambrosys The Taylor series method for ordinary differential equations Karsten Ahnert 1,2 Mario Mulansky 2 December, 8, 2011

ambrosys The Taylor series method for ordinary differential equations Karsten Ahnert 1,2 Mario Mulansky 2 December, 8, 2011 1 The Taylor series method for ordinary differential equations Karsten Ahnert 1,2 Mario Mulansky 2 1 Ambrosys GmbH, Potsdam 2 Institut für Physik und Astronomie, Universität Potsdam December, 8, 2011 ambrosys

More information

Computer Project 3. AA Computational Fluid Dyanmics University of Washington. Mishaal Aleem March 17, 2015

Computer Project 3. AA Computational Fluid Dyanmics University of Washington. Mishaal Aleem March 17, 2015 Computer Project 3 AA 543 - Computational Fluid Dyanmics University of Washington Mishaal Aleem March 17, 2015 Contents Introduction........................................... 1 3.1 Grid Generator.......................................

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

C++ & Object Oriented Programming Concepts The procedural programming is the standard approach used in many traditional computer languages such as BASIC, C, FORTRAN and PASCAL. The procedural programming

More information

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

Mathematics for chemical engineers

Mathematics for chemical engineers Mathematics for chemical engineers Drahoslava Janovská Department of mathematics Winter semester 2013-2014 Numerical solution of ordinary differential equations Initial value problem Outline 1 Introduction

More information

Today. Motivation. Motivation. Image gradient. Image gradient. Computational Photography

Today. Motivation. Motivation. Image gradient. Image gradient. Computational Photography Computational Photography Matthias Zwicker University of Bern Fall 009 Today Gradient domain image manipulation Introduction Gradient cut & paste Tone mapping Color-to-gray conversion Motivation Cut &

More information

CS Software Engineering for Scientific Computing. Lecture 5: More C++, more tools.

CS Software Engineering for Scientific Computing. Lecture 5: More C++, more tools. CS 294-73 Software Engineering for Scientific Computing Lecture 5: More C++, more tools. Let s go back to our build of mdarraymain.cpp clang++ -DDIM=2 -std=c++11 -g mdarraymain.cpp DBox.cpp -o mdarraytest.exe

More information

Explicit\Implicit time Integration in MPM\GIMP. Abilash Nair and Samit Roy University of Alabama, Tuscaloosa

Explicit\Implicit time Integration in MPM\GIMP. Abilash Nair and Samit Roy University of Alabama, Tuscaloosa Explicit\Implicit time Integration in MPM\GIMP Abilash Nair and Samit Roy University of Alabama, Tuscaloosa Objectives Develop a Implicit algorithm for GIMP based on Implicit MPM* Benchmark the algorithm

More information

Fast Multipole Method on the GPU

Fast Multipole Method on the GPU Fast Multipole Method on the GPU with application to the Adaptive Vortex Method University of Bristol, Bristol, United Kingdom. 1 Introduction Particle methods Highly parallel Computational intensive Numerical

More information

18. Inheritance and Polymorphism

18. Inheritance and Polymorphism (Expression) Trees -(3-(4-5))*(3+4*5)/6 18. Inheritance and Polymorphism fork fork / root 6 Expression Trees, Inheritance, Code-Reuse, Virtual Functions, Polymorphism, Concepts of Object Oriented Programming

More information

POLITECNICO DI MILANO. Introduction to C++ for CFD modeling

POLITECNICO DI MILANO. Introduction to C++ for CFD modeling Introduction to C++ for CFD modeling Tommaso Lucchini Department of Energy Politecnico di Milano Outline Overview of the main C++ capabilities applied to CFD practical examples: Classes to protect data

More information

NIA CFD Seminar, October 4, 2011 Hyperbolic Seminar, NASA Langley, October 17, 2011

NIA CFD Seminar, October 4, 2011 Hyperbolic Seminar, NASA Langley, October 17, 2011 NIA CFD Seminar, October 4, 2011 Hyperbolic Seminar, NASA Langley, October 17, 2011 First-Order Hyperbolic System Method If you have a CFD book for hyperbolic problems, you have a CFD book for all problems.

More information

Double Pendulum. Freddie Witherden. February 10, 2009

Double Pendulum. Freddie Witherden. February 10, 2009 Double Pendulum Freddie Witherden February 10, 2009 Abstract We report on the numerical modelling of a double pendulum using C++. The system was found to be very sensitive to both the initial starting

More information

Exam Issued: December 18, 2015, 09:00 Hand in: December 18, 2015, 12:00

Exam Issued: December 18, 2015, 09:00 Hand in: December 18, 2015, 12:00 P. Koumoutsakos, M. Troyer ETH Zentrum, CTL F 11 CH-8092 Zürich High Performance Computing for Science and Engineering I Exam Issued: December 18, 2015, 09:00 Hand in: December 18, 2015, 12:00 Fall semester

More information

OOD and C++ Section 5: Templates. Templates - Generic Programming

OOD and C++ Section 5: Templates. Templates - Generic Programming Templates - Generic Programming OOD and C++ Section 5: Templates Decide which algorithms you want: parameterize them so that they work for a wide-range of types & data structures Templates in C++ support

More information

Topic 7: Algebraic Data Types

Topic 7: Algebraic Data Types Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,

More information

CS205b/CME306. Lecture 9

CS205b/CME306. Lecture 9 CS205b/CME306 Lecture 9 1 Convection Supplementary Reading: Osher and Fedkiw, Sections 3.3 and 3.5; Leveque, Sections 6.7, 8.3, 10.2, 10.4. For a reference on Newton polynomial interpolation via divided

More information

Simulation in Computer Graphics. Particles. Matthias Teschner. Computer Science Department University of Freiburg

Simulation in Computer Graphics. Particles. Matthias Teschner. Computer Science Department University of Freiburg Simulation in Computer Graphics Particles Matthias Teschner Computer Science Department University of Freiburg Outline introduction particle motion finite differences system of first order ODEs second

More information

Modeling Cloth Using Mass Spring Systems

Modeling Cloth Using Mass Spring Systems Modeling Cloth Using Mass Spring Systems Corey O Connor Keith Stevens May 2, 2003 Abstract We set out to model cloth using a connected mesh of springs and point masses. After successfully implementing

More information

The Level Set Method. Lecture Notes, MIT J / 2.097J / 6.339J Numerical Methods for Partial Differential Equations

The Level Set Method. Lecture Notes, MIT J / 2.097J / 6.339J Numerical Methods for Partial Differential Equations The Level Set Method Lecture Notes, MIT 16.920J / 2.097J / 6.339J Numerical Methods for Partial Differential Equations Per-Olof Persson persson@mit.edu March 7, 2005 1 Evolving Curves and Surfaces Evolving

More information

Data Visualization. Fall 2017

Data Visualization. Fall 2017 Data Visualization Fall 2017 Vector Fields Vector field v: D R n D is typically 2D planar surface or 2D surface embedded in 3D n = 2 fields tangent to 2D surface n = 3 volumetric fields When visualizing

More information

Development of a Maxwell Equation Solver for Application to Two Fluid Plasma Models. C. Aberle, A. Hakim, and U. Shumlak

Development of a Maxwell Equation Solver for Application to Two Fluid Plasma Models. C. Aberle, A. Hakim, and U. Shumlak Development of a Maxwell Equation Solver for Application to Two Fluid Plasma Models C. Aberle, A. Hakim, and U. Shumlak Aerospace and Astronautics University of Washington, Seattle American Physical Society

More information

weighted minimal surface model for surface reconstruction from scattered points, curves, and/or pieces of surfaces.

weighted minimal surface model for surface reconstruction from scattered points, curves, and/or pieces of surfaces. weighted minimal surface model for surface reconstruction from scattered points, curves, and/or pieces of surfaces. joint work with (S. Osher, R. Fedkiw and M. Kang) Desired properties for surface reconstruction:

More information

CMPT 898 Final Report. Adam L. Preuss. Numerical Simulation Laboratory. Department of Computer Science. University of Saskatchewan

CMPT 898 Final Report. Adam L. Preuss. Numerical Simulation Laboratory. Department of Computer Science. University of Saskatchewan A GPU implementation of massively parallel direction splitting for the incompressible Navier Stokes equations CMPT 898 Final Report Adam L. Preuss Numerical Simulation Laboratory Department of Computer

More information

Object oriented programming Concepts

Object oriented programming Concepts Object oriented programming Concepts Naresh Proddaturi 09/10/2012 Naresh Proddaturi 1 Problems with Procedural language Data is accessible to all functions It views a program as a series of steps to be

More information

struct Properties C struct Types

struct Properties C struct Types struct Properties 1 The C struct mechanism is vaguely similar to the Java/C++ class mechanisms: - supports the creation of user-defined data types - struct types encapsulate data members struct Location

More information

Introduce C# as Object Oriented programming language. Explain, tokens,

Introduce C# as Object Oriented programming language. Explain, tokens, Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Non-Rigid Image Registration III

Non-Rigid Image Registration III Non-Rigid Image Registration III CS6240 Multimedia Analysis Leow Wee Kheng Department of Computer Science School of Computing National University of Singapore Leow Wee Kheng (CS6240) Non-Rigid Image Registration

More information

Wentworth Institute of Technology COMP201 Computer Science II Spring 2015 Derbinsky. C++ Kitchen Sink. Lecture 14.

Wentworth Institute of Technology COMP201 Computer Science II Spring 2015 Derbinsky. C++ Kitchen Sink. Lecture 14. Lecture 14 1 Exceptions Iterators Random numbers Casting Enumerations Pairs The Big Three Outline 2 Error Handling It is often easier to write a program by first assuming that nothing incorrect will happen

More information

Immersed Boundary Method in FOAM

Immersed Boundary Method in FOAM Immersed Boundary Method in FOAM Theory, Implementation and Use Hrvoje Jasak and Željko Tuković Chalmers University, Gothenburg Faculty of Mechanical Engineering and Naval Architecture, Zagreb Immersed

More information

I101/B100 Problem Solving with Computers

I101/B100 Problem Solving with Computers I101/B100 Problem Solving with Computers By: Dr. Hossein Hakimzadeh Computer Science and Informatics IU South Bend 1 What is Visual Basic.Net Visual Basic.Net is the latest reincarnation of Basic language.

More information

Questions. Numerical Methods for CSE Final Exam Prof. Rima Alaifari ETH Zürich, D-MATH. 22 January / 9

Questions. Numerical Methods for CSE Final Exam Prof. Rima Alaifari ETH Zürich, D-MATH. 22 January / 9 Questions Numerical Methods for CSE Final Exam Prof Rima Alaifari ETH Zürich, D-MATH 22 January 2018 1 / 9 1 Tridiagonal system solver (16pts) Important note: do not use built-in LSE solvers in this problem

More information

Block-Structured Adaptive Mesh Refinement Algorithms and Software Phillip Colella Lawrence Berkeley National Laboratory

Block-Structured Adaptive Mesh Refinement Algorithms and Software Phillip Colella Lawrence Berkeley National Laboratory Block-Structured Adaptive Mesh Refinement Algorithms and Software Phillip Colella Lawrence Berkeley National Laboratory Adaptive Mesh Refinement (AMR) Modified equation analysis: finite difference solutions

More information

Part I: Theoretical Background and Integration-Based Methods

Part I: Theoretical Background and Integration-Based Methods Large Vector Field Visualization: Theory and Practice Part I: Theoretical Background and Integration-Based Methods Christoph Garth Overview Foundations Time-Varying Vector Fields Numerical Integration

More information

CODE-GENERATION FOR DIFFERENTIAL EQUATION SOLVERS

CODE-GENERATION FOR DIFFERENTIAL EQUATION SOLVERS CODE-GENERATION FOR DIFFERENTIAL EQUATION SOLVERS Dániel Berényi Wigner RCP, GPU Laboratory, Budapest, Hungary Perspectives of GPU Computing in Physics and Astrophysics Rome 2014. INTRODUCTION The most

More information

On Robust Parallel Preconditioning for Incompressible Flow Problems

On Robust Parallel Preconditioning for Incompressible Flow Problems On Robust Parallel Preconditioning for Incompressible Flow Problems Timo Heister, Gert Lube, and Gerd Rapin Abstract We consider time-dependent flow problems discretized with higher order finite element

More information

Type systems. Static typing

Type systems. Static typing Type system A type is a set of values and operations on those values A language s type system specifies which operations are valid for a type The aim of type checking is to ensure that operations are used

More information

September 10,

September 10, September 10, 2013 1 Bjarne Stroustrup, AT&T Bell Labs, early 80s cfront original C++ to C translator Difficult to debug Potentially inefficient Many native compilers exist today C++ is mostly upward compatible

More information

PROFESSOR: DR.JALILI BY: MAHDI ESHAGHI

PROFESSOR: DR.JALILI BY: MAHDI ESHAGHI PROFESSOR: DR.JALILI BY: MAHDI ESHAGHI 1 2 Overview Distributed OZ Java RMI CORBA IDL IDL VS C++ CORBA VS RMI 3 Distributed OZ Oz Language Multi paradigm language, strong support for compositionality and

More information

boost::enable_if Deep Down Boostimagical Fun Christian Bay and Kasper A Andersen Department of Computer Science University of Copenhagen

boost::enable_if Deep Down Boostimagical Fun Christian Bay and Kasper A Andersen Department of Computer Science University of Copenhagen Deep Down Boostimagical Fun boost::enable_if Christian Bay and Kasper A Andersen Department of Computer Science University of Copenhagen C. Bay and K. A. Andersen, June 2, 2006 p. 1/12 SFINAE revisited

More information

20. Inheritance and Polymorphism

20. Inheritance and Polymorphism (Expression) Trees 20. Inheritance and Polymorphism Expression Trees, Inheritance, Code-Reuse, Virtual Functions, Polymorphism, Concepts of Object Oriented Programming bend fork 3 -(3-(4-5))*(3+4*5)/6

More information

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

More information

Template Metaprogramming in Finite Element Computations

Template Metaprogramming in Finite Element Computations Template Metaprogramming in Finite Element Computations Zuse Institute Berlin DFG Research Center Workshop on Data Structures for Finite Element and Finite Volume Computations, 2008 02 29, Berlin Contents

More information

OpenFOAM Programming the basic classes

OpenFOAM Programming the basic classes OpenFOAM Programming the basic classes Prof Gavin Tabor Friday 25th May 2018 Prof Gavin Tabor OpenFOAM Programming the basic classes Friday 25th May 2018 1 / 30 OpenFOAM : Overview Overview : programming

More information

Partial Differential Equations

Partial Differential Equations Simulation in Computer Graphics Partial Differential Equations Matthias Teschner Computer Science Department University of Freiburg Motivation various dynamic effects and physical processes are described

More information

Fast Expression Templates

Fast Expression Templates Fast Expression Templates Object-Oriented High Performance Computing Jochen Härdtlein, Alexander Linke, and Christoph Pflaum University of Erlangen, Department of Computer Science 10, System Simulation

More information

Semi-Conservative Schemes for Conservation Laws

Semi-Conservative Schemes for Conservation Laws Semi-Conservative Schemes for Conservation Laws Rosa Maria Pidatella 1 Gabriella Puppo, 2 Giovanni Russo, 1 Pietro Santagati 1 1 Università degli Studi di Catania, Catania, Italy 2 Università dell Insubria,

More information

Adarsh Krishnamurthy (cs184-bb) Bela Stepanova (cs184-bs)

Adarsh Krishnamurthy (cs184-bb) Bela Stepanova (cs184-bs) OBJECTIVE FLUID SIMULATIONS Adarsh Krishnamurthy (cs184-bb) Bela Stepanova (cs184-bs) The basic objective of the project is the implementation of the paper Stable Fluids (Jos Stam, SIGGRAPH 99). The final

More information

PROGRAMMING IN C++ COURSE CONTENT

PROGRAMMING IN C++ COURSE CONTENT PROGRAMMING IN C++ 1 COURSE CONTENT UNIT I PRINCIPLES OF OBJECT ORIENTED PROGRAMMING 2 1.1 Procedure oriented Programming 1.2 Object oriented programming paradigm 1.3 Basic concepts of Object Oriented

More information

A Semi-Lagrangian Discontinuous Galerkin (SLDG) Conservative Transport Scheme on the Cubed-Sphere

A Semi-Lagrangian Discontinuous Galerkin (SLDG) Conservative Transport Scheme on the Cubed-Sphere A Semi-Lagrangian Discontinuous Galerkin (SLDG) Conservative Transport Scheme on the Cubed-Sphere Ram Nair Computational and Information Systems Laboratory (CISL) National Center for Atmospheric Research

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Review: C++ Basic Concepts. Dr. Yingwu Zhu

Review: C++ Basic Concepts. Dr. Yingwu Zhu Review: C++ Basic Concepts Dr. Yingwu Zhu Outline C++ class declaration Constructor Overloading functions Overloading operators Destructor Redundant declaration A Real-World Example Question #1: How to

More information

A Toolbox of Level Set Methods

A Toolbox of Level Set Methods A Toolbox of Level Set Methods Ian Mitchell Department of Computer Science University of British Columbia http://www.cs.ubc.ca/~mitchell mitchell@cs.ubc.ca research supported by the Natural Science and

More information

over The idea is to construct an algorithm to solve the IVP ODE (8.1)

over The idea is to construct an algorithm to solve the IVP ODE (8.1) Runge- Ku(a Methods Review of Heun s Method (Deriva:on from Integra:on) The idea is to construct an algorithm to solve the IVP ODE (8.1) over To obtain the solution point we can use the fundamental theorem

More information

B16 Object Oriented Programming

B16 Object Oriented Programming B16 Object Oriented Programming Michael A. Osborne mosb@robots.ox.ac.uk http://www.robots.ox.ac.uk/~mosb/teaching.html#b16 Hilary 2013 This course will introduce object-oriented programming (OOP). It will

More information

The Mathemagix compiler. Joris van der Hoeven, Palaiseau

The Mathemagix compiler. Joris van der Hoeven, Palaiseau The Mathemagix compiler Joris van der Hoeven, Palaiseau 2011 http://www.texmacs.org 1 Motivation Existing computer algebra systems are slow for numerical algorithms we need a compiled language Low level

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Chapter 5 Object-Oriented Programming

Chapter 5 Object-Oriented Programming Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

GTC 2014 Session 4155

GTC 2014 Session 4155 GTC 2014 Session 4155 Portability and Performance: A Functional Language for Stencil Operations SFB/TR 7 gravitational wave astronomy Gerhard Zumbusch Institut für Angewandte Mathematik Results: Standard

More information

The Mathemagix compiler. Joris van der Hoeven, Palaiseau 2011

The Mathemagix compiler. Joris van der Hoeven, Palaiseau 2011 The Mathemagix compiler Joris van der Hoeven, Palaiseau 2011 http://www.texmacs.org Motivation Existing computer algebra systems are slow for numerical algorithms we need a compiled language Low level

More information

ODEs occur quite often in physics and astrophysics: Wave Equation in 1-D stellar structure equations hydrostatic equation in atmospheres orbits

ODEs occur quite often in physics and astrophysics: Wave Equation in 1-D stellar structure equations hydrostatic equation in atmospheres orbits Solving ODEs General Stuff ODEs occur quite often in physics and astrophysics: Wave Equation in 1-D stellar structure equations hydrostatic equation in atmospheres orbits need workhorse solvers to deal

More information

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017 OOP components For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Data Abstraction Information Hiding, ADTs Encapsulation Type Extensibility Operator Overloading

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Fundamentals of Type-Dependent Code Reuse in C++ Mark Isaacson

Fundamentals of Type-Dependent Code Reuse in C++ Mark Isaacson Fundamentals of Type-Dependent Code Reuse in C++ Mark Isaacson Roadmap Reusing an implementation Selecting between implementations Opt-in functions A Beginning assert(max(3, 5) == 5); assert(max("abc"s,

More information

4 Visualization and. Approximation

4 Visualization and. Approximation 4 Visualization and Approximation b A slope field for the differential equation y tan(x + y) tan(x) tan(y). It is not always possible to write down an explicit formula for the solution to a differential

More information

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli COMS W3101 Programming Language: C++ (Fall 2015) ramana@cs.columbia.edu Lecture-2 Overview of C continued C character arrays Functions Structures Pointers C++ string class C++ Design, difference with C

More information

Solving Partial Differential Equations Using The Chombo Framework for Block-Structured Adaptive Mesh Refinement Algorithms

Solving Partial Differential Equations Using The Chombo Framework for Block-Structured Adaptive Mesh Refinement Algorithms Solving Partial Differential Equations Using The Chombo Framework for Block-Structured Adaptive Mesh Refinement Algorithms Dan Martin Applied Numerical Algorithms Group (ANAG) Lawrence Berkeley National

More information

The University of Alabama in Huntsville Electrical and Computer Engineering CPE Example of Objective Test Questions for Test 4

The University of Alabama in Huntsville Electrical and Computer Engineering CPE Example of Objective Test Questions for Test 4 The University of Alabama in Huntsville Electrical and Computer Engineering CPE 112 02 Example of Objective Test Questions for Test 4 True or False Name: 1. The statement switch (n) case 8 : alpha++; case

More information

CIS 190: C/C++ Programming. Classes in C++

CIS 190: C/C++ Programming. Classes in C++ CIS 190: C/C++ Programming Classes in C++ Outline Header Protection Functions in C++ Procedural Programming vs OOP Classes Access Constructors Headers in C++ done same way as in C including user.h files:

More information

COMS W3101 Programming Language: C++ (Fall 2016) Ramana Isukapalli

COMS W3101 Programming Language: C++ (Fall 2016) Ramana Isukapalli COMS W3101 Programming Language: C++ (Fall 2016) ramana@cs.columbia.edu Lecture-2 Overview of C C++ Functions Structures Pointers Design, difference with C Concepts of Object oriented Programming Concept

More information

CONSERVATIVE AND NON-CONSERVATIVE METHODS BASED ON HERMITE WEIGHTED ESSENTIALLY-NON-OSCILLATORY RECONSTRUCTION FOR VLASOV EQUATIONS

CONSERVATIVE AND NON-CONSERVATIVE METHODS BASED ON HERMITE WEIGHTED ESSENTIALLY-NON-OSCILLATORY RECONSTRUCTION FOR VLASOV EQUATIONS CONSERVATIVE AND NON-CONSERVATIVE METHODS BASED ON HERMITE WEIGHTED ESSENTIALLY-NON-OSCILLATORY RECONSTRUCTION FOR VLASOV EQUATIONS CHANG YANG AND FRANCIS FILBET Abstract. We develop weighted essentially

More information

Object orientation. Programming classes. Programming classes

Object orientation. Programming classes. Programming classes Object orientation Computational Physics Lectures: Programming aspects, object orientation in C++ and Fortran Morten Hjorth-Jensen 1,2 Department of Physics, University of Oslo 1 Department of Physics

More information

Class and Functions. Reusable codes

Class and Functions. Reusable codes Class and Functions Reusable codes Object Oriented Design First concept of object oriented programming is emerged at 60 s. Smalltalk language which is introduced at 1972 was first object oriented programming

More information

III. Classes (Chap. 3)

III. Classes (Chap. 3) III. Classes III-1 III. Classes (Chap. 3) As we have seen, C++ data types can be classified as: Fundamental (or simple or scalar): A data object of one of these types is a single object. int, double, char,

More information

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright Instructors. What is a Data Type? A type is a collection of computational entities that share some common property Programming

More information

Object-Oriented Design (OOD) and C++

Object-Oriented Design (OOD) and C++ Chapter 2 Object-Oriented Design (OOD) and C++ At a Glance Instructor s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Questions Projects to Assign

More information

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli COMS W3101 Programming Language: C++ (Fall 2015) ramana@cs.columbia.edu Lecture-2 Overview of C continued C character arrays Functions Structures Pointers C++ string class C++ Design, difference with C

More information

No model may be available. Software Abstractions. Recap on Model Checking. Model Checking for SW Verif. More on the big picture. Abst -> MC -> Refine

No model may be available. Software Abstractions. Recap on Model Checking. Model Checking for SW Verif. More on the big picture. Abst -> MC -> Refine No model may be available Programmer Software Abstractions Tests Coverage Code Abhik Roychoudhury CS 5219 National University of Singapore Testing Debug Today s lecture Abstract model (Boolean pgm.) Desirable

More information

Section 2 0: The Rectangular Coordinate System. The Coordinate System

Section 2 0: The Rectangular Coordinate System. The Coordinate System Section 2 : The Rectangular Coordinate System The rectangular coordinate system is based on two number lines. A horizontal line called the x axis and a vertical line called the y axis. Each axis has marks

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information

1. Software Systems Complexity, OO Paradigm, UML

1. Software Systems Complexity, OO Paradigm, UML 1. Software Systems Complexity, OO Paradigm, UML Software Systems Complexity Inherent Arbitrary Complexity Problem Domain Complexity Expressing the Requirements Changing Requirements System Evolution -

More information

over The idea is to construct an algorithm to solve the IVP ODE (9.1)

over The idea is to construct an algorithm to solve the IVP ODE (9.1) Runge- Ku(a Methods Review of Heun s Method (Deriva:on from Integra:on) The idea is to construct an algorithm to solve the IVP ODE (9.1) over To obtain the solution point we can use the fundamental theorem

More information

cuibm A GPU Accelerated Immersed Boundary Method

cuibm A GPU Accelerated Immersed Boundary Method cuibm A GPU Accelerated Immersed Boundary Method S. K. Layton, A. Krishnan and L. A. Barba Corresponding author: labarba@bu.edu Department of Mechanical Engineering, Boston University, Boston, MA, 225,

More information

EL2310 Scientific Programming

EL2310 Scientific Programming (pronobis@kth.se) Overview Overview Wrap Up Introduction to Object Oriented Paradigm More on and Members Operator Overloading Last time Intro to C++ Differences between C and C++ Intro to OOP Today Object

More information

Efficient Tridiagonal Solvers for ADI methods and Fluid Simulation

Efficient Tridiagonal Solvers for ADI methods and Fluid Simulation Efficient Tridiagonal Solvers for ADI methods and Fluid Simulation Nikolai Sakharnykh - NVIDIA San Jose Convention Center, San Jose, CA September 21, 2010 Introduction Tridiagonal solvers very popular

More information

Review: Concrete syntax for Impcore

Review: Concrete syntax for Impcore Review: Concrete syntax for Impcore Definitions and expressions: def ::= (define f (x1... xn) exp) (val x exp) exp (use filename) (check-expect exp1 exp2) (check-error exp) exp ::= integer-literal ;; atomic

More information

Marching Squares. Rodrigo Morante

Marching Squares. Rodrigo Morante Marching Squares Rodrigo Morante 1/9 Objective Implicit functions Implement a method for polygonizing implicit functions that apply fromr 2 tor. 2/9 Implicit functions Implicit functions An implicit function

More information