Upload
vincent-nichols
View
213
Download
0
Embed Size (px)
Citation preview
MA/CS471Lecture 8
Fall 2003Prof. Tim [email protected]
Today
Today we are going to discuss implementation of the simplestpossible partial differential equations:
Example domain discretization (L-shape domain with 3 cells):
0a bt x y
a
b
Traveling Wave Solutions in 1D and 2D
This PDE is the two-dimensional analogue to the PDE we saw last time:
0a bt x y
2D
0at x
1D
Solutions:1
f t xa
2 2
ax byf t
a b
t=0:Later t:
2 2
1 a
ba b
In Words
• The initial condition is translated with velocity:•
• i.e. the density does not change shape – it simply translates with a constant velocity.
2 2
1 a
ba b
Conservation Law
• We first divide the full domain into quadrilateral cells. For each cell e the following conservation law holds:
• i.e. the total density change in a cell e is equal to the flux of density through the boundary of e
• -- or – the rate of change of material in the cell e is equal to the amount “translated” through the boundary.
4
, ,
1
, , , ,f
e f e fx y
fe e
dx y t dxdy an bn x y t ds
dt
Boundary Conditions
• Where do we need to apply boundary conditions:
• Hint – which way is the solution translating?
2 2
1 a
ba b
Boundary Conditions
• Where do we need to apply external boundary conditions ?:
• i.e. wherever where is the outwards facing normal for the cell e at the face f :
, , 0e f e fx yan bn
,
,
e fx
e fy
n
n
e,1
,1
ex
ey
n
n
,2
,2
ex
ey
n
n
,4
,4
ex
ey
n
n
,3
,3
ex
ey
n
n
2 2
1 a
ba b
Definition of Cell Average and Area
4, ,
1
4, ,
1
1Define : , , ,
:
Then , , , ,
, ,
f
f
e
e
e
e
e
e f e fx y
fe e
e f e fx ye
f e
t x y t dxdyA
A dxdy
dx y t dxdy an bn x y t ds
dt
dan bn x y t ds
dA
t
Use Upwinding At Boundary of e
e,f e,
4, ,
1
4, ,
1
e,f e,fx y
fx y
,
,
,
,, ,
1 if n n 0:
0 otherwise
Define
The
n
:
n
,
n 1
,f
f
f
e f e fe e x y
f e
e f e fx y e
f e
e
e
e f
e
e f
f
e f e f e f
dA an bn x y t ds
dt
an bn t d
S ds
a b
s
b Sa
4
1f
• The tau variable acts as a switch.• If tau=1 at a face then rho is approximated by the local cell average at the face • If tau=0 at a face then rho is approximated by the neighbor cell average.
Upwind Switch
• In this case so
• i.e. for the surface flux term we should use the cell average density from the neighbor cell.
rhoe,1+
rhoea
b
,1 ,1 0e ex yan bn
,1
,1
ex
ey
n
n
e,1 e,1x y
,1
1 if n n 0:
0 otherwise
0
e
a b
Euler Forward In Time
1
1 4e,f e
,,x y1
,,f
,
Define
Then
Hence the sc e
1
h me:
n n
ne
e f e f
e
n ne e
e e
n nn ne e
e fe e e ff
ndt
dA
dt dt
A a bdt
S
• For each cell we now have a discrete space in time and space which will compute approximations the cell average density at a given time level.• We do need to specify an initial value at each cell for the cell average density• We also need to specify boundary conditions at “inflow” edges.
Summary of Scheme
30
, ,1
41 e,f e,f
x y,
1, ,,
Set up the initial condition
10 , , 0
3
Iterate for neccessary time st
1
eps:
n n
e e e v e vv
n n n ne e e e f
fe f e
ef
e f
t x y t
dt a bA
S
4, ,
1
4, ,
1
4, ,
1
4
, , , ,
,, ,, ,
1
1
,
,
1
, , , ,
,
: 1
,
1
f
f
e f e fx y
fe e
e f e fx y
f e
e f e f
n ne
x yf
e f e f e e f e f
e fe f ee f
e fx y e f e
n ne e
e
e ff e
e
e f
dx y t dxdy an bn x y t ds
dt
dan bn x y t ds
dt
an bn
San bn
Adt
S
Sdt
A
,
4
, ,1
1 en n
e f e e ff e
fA
The time rate ofchange of total density in the cell e
The flux through the boundary of the four faces of cell e
Implementation
What do we need for the implementation:
(1) A list of vertex locations (x0,y0,x1,y1…)
(2) For each cell e a list of the four vertices
(3) A routine to calculate the area of each cell {Ae}
(4) A routine to calculate the length of each cell edge {Ae,f}
(5) A routine to calculate the outwards facing normal to each cell edge
(6) A routine to calculate the inflow switch tau for each cell edge.
(7) A routine to calculate the initial density profile.
(8) A routine to calculate dt in the following way
(9) A routine to figure out which cells connect to each cell.
30
, ,1
41 e,f e,f
x y ,, ,1
,
10 , , 0
1
3
Loop:
n n
e e e
e f
v e vv
n n n ne e e e fe
e
f e
ff
S
t x y t
dt a bA
, ,,e f e fx yn n
,e f
, , 0x y t
, ,,,
1 1min
4e
e f e fe fx y e f
Adt
an bn S
Details
1) Compute cell area by dividing each cell into two triangles, find their areas, and sum up.
2) Do not assume cells are right-angled quadrilaterals (can be deformed).
3) To compute normal to a face:
,1
,1
e
e
x
y
,2
,2
e
e
x
y
,1
,2 ,1
,1 2 2,2 ,1
,2 ,1 ,2 ,1
1e
e ex
ee ey
e e e e
y yn
x xn x x y y
16
Project 2: continued
• Create a serial version of the 2d finite volume scheme for the above one way wave equation.
• Make it parallel.
17