Вы находитесь на странице: 1из 4

2D1263 : Scientic Computing

Lecture 1

(3)

2D1263 : Scientic Computing

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

Object Oriented Program Construction for Scientic Computing 2D1263


http://www.nada.kth.se/kurser/kth/2D1263/ Marco Kupiainen marcok@nada.kth.se http://www.nada.kth.se/ marcok

NADA

Marco Kupiainen marcok@nada.kth.se

2D1263 : Scientic Computing 2D1263 : Scientic Computing


NADA

Lecture 1

(2)

What is scientic computing?


Golub and Ortega: Scientic computing is the collection of tools, techniques and theories required to solve on a computer mathematical models of problems in science and engineering. Or a more narrow denition: Development and use of numerical methods and mathematical models to solve real-world problems eciently on computers. Interdisciplinary eld requiring: knowledge about the underlying (physical) problem, ability to formulate a mathematical model, stable & accurate numerical schemes, ecient implementation on high performance computers.
Marco Kupiainen marcok@nada.kth.se
NADA

Familiarity with basic C can help, see e.g. http://www.nada.kth.se/kurser/master/intro/ lectures 24 (apart from input/output).

To give students knowledge of

previous programming experience (preferably but not necessarily C)

a second course in numerical analysis, e.g. Applied Numerical Methods (2D1250)

parallel programming for distributed memory architectures (SPMD)

object-oriented implementation in C++,

their numerical approximation on non-trivial grids using nite dierences,

formulation of PDEs from uid dynamics,

Prerequisites

Goals

Marco Kupiainen marcok@nada.kth.se

Lecture 1 (4)

2D1263 : Scientic Computing

Lecture 1

(5)

2D1263 : Scientic Computing

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

Marco Kupiainen marcok@nada.kth.se

2D1263 : Scientic Computing

Lecture 1

(7)

2D1263 : Scientic Computing

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).

Marco Kupiainen marcok@nada.kth.se


NADA NADA

Marco Kupiainen marcok@nada.kth.se

2D1263 : Scientic Computing

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++

2D1263 : Scientic Computing

Today
Overview of computational grids Basic C/C++ constructs

This course focuses mainly on structured boundary-tted grids.

Boundary-tted

Unstructured

Dierent types of grids

Cartesian

Unstructured grids

Structured grids

Structure

Boundary-tted

Cartesian

Structured

Marco Kupiainen marcok@nada.kth.se (12)


NADA

Marco Kupiainen marcok@nada.kth.se


NADA

Lecture 1

2D1263 : Scientic Computing (11)

Lecture 1

Marco Kupiainen marcok@nada.kth.se

Lecture 1

Unstructured grids

0.5

1.5

Structured grids are indexed along coordinate directions:

x = [(1/2 + 1 ) cos(2 ), (1/2 + 1 ) sin(2 )]

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

2D1263 : Scientic Computing

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

Marco Kupiainen marcok@nada.kth.se


NADA

2D1263 : Scientic Computing

Lecture 1

(13)

2D1263 : Scientic Computing

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

(only cells intersecting domain shown)

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.

Marco Kupiainen marcok@nada.kth.se

Вам также может понравиться