Lecture 13 18.086

advertisement
Lecture 13
18.086
Multi-phase flow
Lattice-Boltzmann simulation of two-phase flow
https://www.youtube.com/watch?v=1tasbL39xds A. I. Kupershtokh, 2013
Modeling of moving
Evolving Curves and Surfaces
interfaces
• Will talk
aboutfunction
Levelset
te curve according
to speed
v =and
F n Fast
nds on space,
time, and
curveofitself
• Based
onthe
notes
Per-Olof
marching method
Persson (see download link on course website)
in three dimensions
•
Problem statement: Moving interfaces
Evolving Curves and Surface
F
• Propagate curve according to speed function v = F n
• F depends on space, time, and the curve itself
• Surfaces in three dimensions
F
Two different approaches
Geometry Representations
Explicit Geometry
• Parameterized boundaries
Implicit Geometry
• Boundaries given by zero level set
φ(x, y) = 0
φ(x, y) < 0
(x, y) = (x(s), y(s))
φ(x, y) > 0
Explicit geometry modeling
Explicit
Techniques
Simple approach:
Model geometry explicitly by parametrized curves c(s) or
Explicit
Techniques
•
surfaces Ω(s1,s2)
(i)
(i)
eoach:
approach:
Represent
curve
explicitly
by
nodes
x
and(in
lines
(i)
• Discretized as a set of nodes x , connected by edges
3D: “triangulated
Represent
curve explicitly by nodes x and lines
surface”)
gate
curve
by solving
ODEs
urve by
solving
ODEs
• Move nodes according to ODEs:
(i)
(i)
(i) (i)
dx dx =
(i)v(x(i) , t),
(i)
(0)
=
x
,
0
=dtv(x , t), x (0)x= x
,
0
dt
(i) •
Geometric properties (normal vector, curvature etc.) obtained by finite
al
curvature,
etc
by
difference
approximations,
e.g.:
or,vector,
curvature,
etc
by
difference
approximations,
e.g.:
differences, e.g.
AB
mo Demo
(i)
(i)(i+1) (i+1)
dx
x (i−1)
−
x
dx
x
−x
≈
≈
ds ds
2∆s 2∆s
(i−1)
Explicit Techniques - Drawbacks
Disadvantages
of explicit
geometry modeling
• Node redistribution required, introduces errors
deformation
leads
to distortion
=>
need to redistribute
• •NoShape
entropy
solution, sharp
corners
handled
incorrectly
nodes to accurately represent geometry!
• Need special treatment for topology changes
• Incorrect behavior at corners
• Stability constraints for curvature dependent speed functions
• Difficult to deal with topology changes!
Node distribution
Sharp corners
Topology changes
Implicit geometry modeling
•
Sethian & Osher (1988)
•
Represent curve by the zero level set of a function, ɸ(x)=ɸ(x,y,…)=0
•
Level set of a function f(x): Values x along which f has constant
value
Circle of radius r is in the level
set of the function f(x)=x2+y2
Topological changes easy to
model!
Implicit
geometry
modeling
Discretized
Implicit Geometries
Discretize implicit function φ on background grid
• •Discretization
(idea): Discretize implicit function
ɸ(x) on background
•grid
Obtain φ(x) for general x by interpolation
•
To find curve of zero level set ɸ(x)=0, interpolate for general x.
Cartesian
Quadtree/Octree
Implicit Geometries
Implicit
geometry
modeling
•
φ(x) = 0
Represent curve by zero level set of a function,
• ASpecial
case:
distance
function:
special but
verySigned
important
choice for
ɸ(x) is the signed distance function. Then:
•
–
|∇φ| = 1
–
|φ(x)| gives (shortest) distance from x to curve
φ>0
φ<0
Geometric Variables
Implicit
geometry
modeling
Geometric Variables
ctor n (without assuming distance function):
Geometric
Variables
• When the curve is evolving, it’s often necessary to know its geometric
∇φ
=
properties.
Forn
instance,
a distance
forest firefunction):
only moves normal to its current front
Normal vector
n (without
assuming
|∇φ|
thout assuming distance function):
•
Normal vector n (for general∇φ
𝜙)
(in two dimensions):
∇φ
n=
|∇φ|
n=
|∇φ|
2
2
φ
φ
−
2φ
φ
φ
+
φ
φ
xx y
y x xy
yy x
Curvature (in ∇φ
two dimensions):
• ·
Curvature=
(for 2D curve):
.
κ
=
∇
mensions): |∇φ|
2 + φ2 )3/2
(φ
φ φx2 − 2φy φ φ + φ φ2
∇φ
xx y
y x xy
yy x
2 ·
2
=
.
κ
=φ∇
φxx
−
2φ
φ
φ
+
φ
φ
∇φ
y
x
xy
yy
2
2
3/2
y
x +φ )
|∇φ|
(φ
x.
y
=
rial parameters,
etc,2 in terms
of
φ
:
3/2
|∇φ| • Material parameters
(φx + φ2y )(e.g.
density inside vs. outside):
Write material
parameters, etc, in terms of φ:
= of
ρ1φ+
meters, etc,
ρ(x)
in terms
: (ρ2 − ρ1 )θ(φ(x))
ρ(x)
=
ρ
+
(ρ
−
ρ
)θ(φ(x))
1
2
1
where θ is the Heaviside step function (smoothened in the discretized
ρ(x) = ρfunction
−over
ρ1 )θ(φ(x))
eaviside
a few grid cells.
1 + (ρ2 θ
case)
Smooth Heaviside function θ over a few grid cells.
The Level Set Equation
The Level Set Equation
Level
set
equation
nvection equation to propagate φ = 0 by velocities v
The Level Set Equation
quation
to propagate
φ=
0 by
velocities
v the advection equation
• Propagate
𝜙 (not only
its zero
level
set!) by solving
vel
Set equation
Equation
nvection
to propagate
φ=
velocities
φt +
v0·by∇φ
= 0.v
φt + v · ∇φ = 0.
• Since
part F=v ·n of velocity changes shape of curve, we can
o propagate
φ = 0only
by velocities
φnormal
t + v ·v∇φ = 0.
simply assume v=Fn. Then, we obtain, using
2
2
F
n
,
use
n
=
∇φ/|∇φ|
and
∇φ
·
∇φ
=
|∇φ|
to
obtain
the
n
=
∇φ/|∇φ|
and
∇φ
·
∇φ
=
|∇φ|
to
obtain
the
φ + v · ∇φ = 0.
t
F n, use n = ∇φ/|∇φ| and ∇φ · ∇φ = |∇φ|2 to obtain the
tφ/|∇φ|
Equation
and ∇φ · ∇φ = |∇φ|2 to obtain the
t Equation
φt + Fφ|∇φ|
=+
0.=F0.|∇φ|
|∇φ|
level
set
equation
t + Fφ
=
0.
t
φt + F |∇φ| = 0.
• Since
r, hyperbolic
equation
(Hamilton-Jacobi).
F can depend
on shape of curve, this is a nonlinear (hyperbolic) equation.
on
lic(Hamilton-Jacobi).
equation (Hamilton-Jacobi).
• Shape ofequation
curve is obtained
by finding the zero level set
r, hyperbolic
(Hamilton-Jacobi).
Discretization
•
Discretize 𝜙 using upwind finite differences (schemes from conservation
laws!)
•
See online notes for details of discretization (change upwind direction
depending on sign of F).
•
Matlab demo
φt + v · ∇φ = 0.
Reinitialization
• For Reinitialization
v = F n, use n = ∇φ/|∇φ| and ∇φ · ∇φ = |∇φ|2 to obt
Level Set Equation
variations in ∇φ for general speed functions F
• Consider the level set equation φt + F |∇φ| =
ccuracy• and
need
smaller
timesteps
Afterperformance,
few timesteps, ∇𝜙
varies
from point
to point. for stability
0.
• Nonlinear,
hyperbolic
(Hamilton-Jacobi).
=>
requires
timestep
for
stable
time
integration!
alize by•finding
new φ small
with
same
zeroequation
level
set but
|∇φ|
=1
•
=> Re-initialize by finding a new 𝜙 with the same zero level set, but with | ∇𝜙|=1
nt approaches:
Two different approaches:
grate the reinitialization equation for a few time steps
•
•
Stop advection, instead integrate the reinitialization equation for a few timesteps:
φt + sign(φ)(|∇φ| − 1) = 0
• Find a completely new 𝜙 with | ∇𝜙|=1 : Signed distance function!
mpute distances
from φ = 0 explicitly for nodes close to boundary,
Fast
=> Need to find signed distance of each mesh point from current curve, i.e. from 𝜙=0 (e.g.
Marching
Method
for remaining
using the
fast marching
method) nodes
Fast marching
method
φ>0
φ<0
•
Problem statement: Find
distance of grid points
from curve 𝜙=0.
•
Equivalent problem: Let the curve propagate in normal direction with uniform
speed F>0 (outward), or F<0 (inward), and find the arrival time of the front for
each grid point.
First arrivals and shortest geodesic
•
Arrival time calculation is a very generic problem:
The Boundary Value Formulation
> 0, formulate evolution by an arrival function T
Fast marching method
gives time to reach x from initial Γ
rate = distance gives the Eikonal equation:
l case:
•
Problem statement: Find|∇T
distance
|F = of
1, grid
T points
= 0 onfrom
Γ. curve 𝜙=0 <=> arrival time T(x) for front
propagating with speed F>0
F = 1 gives distance functions
•
T(x) is the time needed to reach x from initial curve 𝛤
The Boundary Value
T(x,y)Formulation
for 𝛤 a circle
T(x,y)
• For F > 0, formulate evolution by an arrival function T
• T (x) gives time to reach x from initial Γ
x
•
y
• time * rate = distance gives the Eikonal equation:
Note: Since time * velocity = distance, we obtain the Eikonal equation
|∇T |F = 1, T = 0 on Γ.
This is now an boundary value problem, not an initial value problem! In other words,
Special
case:method
F = 1actually
gives distance
the•fast
marching
solves anfunctions
Eikonal equation…
•
To obtain the distance function, we are interested in constant F=1
The Fast Marching algorithm
Fast marching method
!
•
Loop
{
Rough sketch of method: First, identify curve and fixed values. Mark nearest
neighbors
candidates
andthe
everything
asNarrow
far-distance.
Then: Value
Boundary
Formul
1. as
Let
Trial be
pointelse
inThe
band
with smallest
}
Let Trial be
the candidate
point with smallest
T. to Alive
1. Move
2.
Trial
from Narrow
band
• For F > 0, formulate evolution by an arrival function
2. Move
Mark Trialall
as aneighbors
fixed value (meaning
T is known)
3.
of Trial
to Narrow band
• T (x) gives time to reach x from initial Γ
Move all far-distance
neighbors
of Trial as Candidates
3. Recompute
4.
u for
all neighbors
of Trial
• time * rate = distance
gives
theby
Eikonal
this
is done
solvingequation:
the Eikonal
4. Compute T for all neighbors of Trial
5. Repeat 1-4 until all grid points are fixed
equation using a FD scheme
|∇T |F = 1, T = 0 on Γ.
•Alive
Special case: F = 1 gives distance functions
fixed
Narrow
band
candidates
far-distance points
Far
T(x,y)
Applications of Fast
Marching Method
Visibility around obstacles
Visibility of
obstacles
•
Travel time
(modified fast
marching)
Examples (in combination
with levelsets)
Examples
https://www.youtube.com/watch?v=J0hYFvkSfJk
Matrices in FD and Matlab
•
In discretized problems, we often end up solving
Ku=f
•
Need fast algorithms to invert K
•
Require some knowledge about K (symmetry,
Eigenvalues, etc.)
Gauss elimination
•
•
Consider Ax=b (with A invertible). Rewrite as
Bring A of Ax=b into upper triangular form by adding/subtracting multiples of lines with each other:
This is an upper triangular matrix U. One can write
A=LU
with L a lower triangular matrix: LU
decomposition
•
Solution is
Pivots
•
Pivots of Gauss elimination: diagonal elements of U.
•
Note that very small Pivots are potentially dangerous:
•
Cases:
•
A=LU (without permutations) and all pivots non-zero: A is invertible
•
PA=LU (with permutation matrix P), and all pivots non-zero: A invertible
•
There is always one or more zero Pivots: A not invertible
Symmetric A, Cholesky
factorization
•
What if A is symmetric?
•
What if A is symmetric and positive definite?
Performance
•
If A is tridiagonal n x n matrix, U and L are bi-diagonal and
LU-factorization requires O(n) operations
•
If A is a full matrix:
•
•
A symmetric: O(1/3 n3) operations
•
general A: O(2/3 n3) operations
Band matrices: A has bandwidth w if it’s “farthest” nonzero
diagonal has offset w from the diagonal.
•
Takes O(w2n) operations
Download