Академический Документы
Профессиональный Документы
Культура Документы
Lecture 1
(3)
Lecture 1
(1)
What is object-orientation?
Organisation of software as a collection of discrete objects that incorporate both data structure and behaviour. Some key concepts: Identity data quantized into distinguashable entities (objects). Abstraction separate external aspects of an object from internal (functionality from implementation) Inheritance build new abstractions out of existing ones Polymorphism ability to provide the same interface to objects with dierent implementations. Objects are similar to C structures but have associated functions. There are no widely accepted denitions of OO requirements.
Marco Kupiainen marcok@nada.kth.se
NADA NADA
NADA
Lecture 1
(2)
Familiarity with basic C can help, see e.g. http://www.nada.kth.se/kurser/master/intro/ lectures 24 (apart from input/output).
Prerequisites
Goals
Lecture 1 (4)
Lecture 1
(5)
Lecture 1
(6)
Literature Examination
Written exam (2 credits): rst exam by end of May or beginning of June 2002 at least three times per year Computer laborations (2 credits): 1. Algebraic grid generation (due 15/2) 2. Distributed parallel arrays (due 22/3) 3. A parallel PDE solver (due 17/5) The laborations can be done individually or in groups of two students. The course literature will consist of handouts, lecture notes written by Bjrn Sjgren o o brief notes on topics not in lecture notes copies of transparencies Additional online references can be found on the course homepage. Good C++ books ( $50 each): The C++ Programming Language, Bjarne Stroustrup C++ Primer, Lippman & Lajoie It will not be assumed that you buy any C++ books for the course. There are many other C++ books (e.g. at the KTH library). Ask me if youd like a second opinion on a book.
Marco Kupiainen marcok@nada.kth.se
NADA NADA
Lecture 1
(7)
Lecture 1
(8)
(Preliminary) schedule
Lectures Monday Friday Monday Friday Monday Friday Monday Friday Wednesday Wednesday Wednesday Wednesday 21/1 25/1 28/1 1/2 4/2 8/2 11/2 15/2 20/2 27/2 13/3 20/3 13.15 15.00 13.15 15.00 13.15 15.00 13.15 15.00 13.15 15.00 13.15 15.00 13.15 15.00 13.15 15.00 10.15 12.00 10.15 12.00 10.15 12.00 10.15 12.00 4523 4523 4523 4523 4523 4523 4523 4523 4523 4523 4523 4523
(Preliminary) schedule
Computer exercises Period 3 Period 4 Weeks 5, 7, 9 Weeks 12, 17, 19
Tuesday or Thursday mornings? Afternoons? You will probably have to work more than this to complete the laborations. Outside of scheduled classes any questions should be directed to the teaching assistants Kyoung-Sook Moon (moon@nada.kth.se) Sandy Se (sandy@nada.kth.se) They can be reached by email, and also answer questions in person (subject to oce hours).
Lecture 1
(9) (10)
Subdivision of domain into small cells or a nite set of points intended for approximating PDEs by algebraic equations.
Boundary representation
Numerical approximation
Given a geometry a partial dierential equation initial & boundary conditions we need to 1. Discretize the domain (generate a grid) 2. Approximate the PDE on the grid by e.g. nite dierences or nite elements 3. Find a tool for solving the discretized PDE, or 4. Implement a solver in e.g. C++
Today
Overview of computational grids Basic C/C++ constructs
Boundary-tted
Unstructured
Cartesian
Unstructured grids
Structured grids
Structure
Boundary-tted
Cartesian
Structured
Lecture 1
Lecture 1
Lecture 1
Unstructured grids
0.5
1.5
A structured grid
0.5
+ Generality Handles complex geometries Straightforward generation & renement Ineciency Indirect addressing inecient cache usage & many dereferences Parallelization dicult double x[n],y[n]; // Node coordinates int tri[m,3]; // Nodes in triangle Coordinates for rst node in triangle i: x[tri[i,0]], y[tri[i,0]].
NADA
1.5
0.5
1.5
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0.1
0.2
= [radius , angle]
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Lecture 1
(13)
Lecture 1
(14)
Structured grids
Cartesian grids
Mapping from unit square to geometry, x(). + Eciency Memory usage (regular connectivity) Numerical methods (structured matrices) + Simple to use How to do local renement? Diculties with complex geometries (x()) may have to divide domain into smaller blocks before grid generation. Block subdivision may be good for parallel computations (c.f. domain decomposition)
Marco Kupiainen marcok@nada.kth.se
NADA NADA
Rectangular grid with objects carved out. + works for any geometry (simple) accuracy in boundary conditions numerical stability It is possible but cumbersome to get accurate boundary conditions (immersed boundary method ). Can be useful for inexact domains, e.g. a lake shore.