 # Diff of /trunk/doc/user/Models.tex

revision 1966 by jfenwick, Wed Nov 5 04:59:22 2008 UTC revision 2432 by gross, Wed May 20 06:06:20 2009 UTC
# Line 13  Line 13
13
14
15  \chapter{Models}  \chapter{Models}
16    \label{MODELS CHAPTER}
17
18  The following sections give a breif overview of the model classes and their corresponding methods.  The following sections give a breif overview of the model classes and their corresponding methods.
19
20  \section{Stokes Problem}  \section{Stokes Problem}
21  The velocity field $v$ and pressure $p$ of an incompressible fluid is given as the solution of their  The velocity \index{velocity} field $v$ and pressure $p$ of an incompressible fluid \index{incompressible fluid} is given as the solution of the Stokes problem\index{Stokes problem}
Stokes problem
22  \begin{equation}\label{Stokes 1}  \begin{equation}\label{Stokes 1}
23  -\left(\eta(v\hackscore{i,j}+ v\hackscore{i,j})\right)\hackscore{,j}+p\hackscore{,i}=F\hackscore{i}  -\left(\eta(v\hackscore{i,j}+ v\hackscore{i,j})\right)\hackscore{,j}+p\hackscore{,i}=f\hackscore{i}-\sigma\hackscore{ij,j}
24  \end{equation}  \end{equation}
25  where $\eta$ is the viscosity and $F_i$ defines an internal force. We assume an incompressible media:  where $\eta$ is the viscosity, $F\hackscore{i}$ defines an internal force \index{force, internal} and $\sigma\hackscore{ij}$ is an intial stress \index{stress, initial}. We assume an incompressible media:
26  \begin{equation}\label{Stokes 2}  \begin{equation}\label{Stokes 2}
27  -v\hackscore{i,i}=0  -v\hackscore{i,i}=0
28  \end{equation}  \end{equation}
29  Natural boundary conditions are taken in the form  Natural boundary conditions are taken in the form
30  \begin{equation}\label{Stokes Boundary}  \begin{equation}\label{Stokes Boundary}
31  \left(\eta(v\hackscore{i,j}+ v\hackscore{i,j})\right)n\hackscore{j}-n\hackscore{i}p=f  \left(\eta(v\hackscore{i,j}+ v\hackscore{i,j})\right)n\hackscore{j}-n\hackscore{i}p=s\hackscore{i}+\sigma\hackscore{ij} n\hackscore{i}
32  \end{equation}  \end{equation}
33  which can be overwritten by a constraint  which can be overwritten by constraints of the form
34  \begin{equation}\label{Stokes Boundary0}  \begin{equation}\label{Stokes Boundary0}
35  v\hackscore{i}(x)=0  v\hackscore{i}(x)=v^D\hackscore{i}(x)
36  \end{equation}  \end{equation}
37  where the index $i$ may depend on the location $x$ on the bondary.  at some locations $x$ at the boundary of the domain. The index $i$ may depend on the location $x$ on the boundary.
38    $v^D$ is a given function on the domain.
39
40  \subsection{Solution Method \label{STOKES SOLVE}}  \subsection{Solution Method \label{STOKES SOLVE}}
41  In block form equation equations~\ref{Stokes 1} and~\ref{Stokes 2} takes the form of a saddle point problem  In block form equation equations~\ref{Stokes 1} and~\ref{Stokes 2} takes the form of a saddle point problem
43  \begin{equation}  \begin{equation}
44  \left[ \begin{array}{cc}  \left[ \begin{array}{cc}
45  A     & B^{*} \\  A     & B^{*} \\
46  B & 0 \\  B & 0 \\
47  \end{array} \right]  \end{array} \right]
48  \left[ \begin{array}{c}  \left[ \begin{array}{c}
49  u \\  v \\
50  p \\  p \\
51  \end{array} \right]  \end{array} \right]
52  =\left[ \begin{array}{c}  =\left[ \begin{array}{c}
53  F \\  G \\
54  0 \\  0 \\
55  \end{array} \right]  \end{array} \right]
57  \end{equation}  \end{equation}
58  where $A$ is coercive, self-adjoint linear operator in $V$, $B$ is a divergence operator and $B^{*}$ is it adjoint operator (=gradient operator)). For more details on the mathematics see references \cite{AAMIRBERKYAN2008,MBENZI2005}.  where $A$ is coercive, self-adjoint linear operator in a suitable Hilbert space, $B$ is the $(-1) \cdot$ divergence operator and $B^{*}$ is it adjoint operator (=gradient operator). For more details on the mathematics see references \cite{AAMIRBERKYAN2008,MBENZI2005}.
59  We apply the preconditioner matrix  We use iterative techniques to solve this problem. To make sure that the incomressibilty condition holds
60    with sufficient accuracy we check for
61  \begin{equation}  \begin{equation}
62  \left[ \begin{array}{cc}  \|v\hackscore{k,k}\| \hackscore \le  \epsilon
63  A^{-1}     & 0 \\  \|\sqrt{v\hackscore{j,k}v\hackscore{j,k}}\|
64  S^{-1} B A^{-1}  & -S^{-1} \\  \label{STOKES STOP}
\end{array} \right]
65  \end{equation}  \end{equation}
66  with the Schur complement $S=BA^{-1}B^{*}$ to solve the problem iteratively. The updates $dv$ and $dp$ for  where $\epsilon$ is the desired relative accuracy and
given velocity $v$ and pressure $p$ is given as
67  \begin{equation}  \begin{equation}
68  \begin{array}{rcl}  \|p\|^2= \int\hackscore{\Omega} p^2 \; dx
69  A dv & = & F-Av-B^{*}p \\  \label{PRESSURE NORM}
S dp & = & B(v+dv) \\
\end{array}
70  \end{equation}  \end{equation}
71  This scheme is called the Uzawa scheme.  defines the $L^2$-norm. We use the Uzawa scheme \index{Uzawa scheme} to solve the problem.
72
73  In the case of the Stokes problem it can be shown that $S$ can be approximated by $\frac{1}{\eta}$. With this the iteration scheme can be implemented as  In fact the first equation in~\ref{SADDLEPOINT} gives for a known pressure
74  \begin{equation}  \begin{equation}
75  \begin{array}{rcl}  v=A^{-1}(G-B^{*}p)
76  -\left(\eta(dv\hackscore{i,j}+ dv\hackscore{i,j})\right)\hackscore{,j} & = & F\hackscore{i}+\left(\eta(v\hackscore{i,j}+ v\hackscore{i,j})\right)\hackscore{,j}-p\hackscore{,i} \\  \label{V CALC}
77  \frac{1}{\eta} dp & = & - \left(v\hackscore{,i}+dv\hackscore{,i} \right)\hackscore{,i} \\  \end{equation}
78  \end{array}  which is inserted into the second equation leading to
80    S p =  B A^{-1} G
81  \end{equation}  \end{equation}
82  To accelerate the convergence we are using the restarted $GMRES$ method using the norm  with the Schur complement \index{Schur complement} $S=BA^{-1}B^{*}$. This problem can be solved iteratively
83    with the preconditioner $\hat{S}$ defined as $q=\hat{S}^{-1}p$ by solving
84  \begin{equation}  \begin{equation}
85  \|(v,p)\|^2= \int\hackscore{\Omega} \eta^2 v\hackscore{i,j}^2 + p^2 \; dx  \frac{1}{\eta}q = p
86  \end{equation}  \end{equation}
87  or alternatively the $PCG$ method on the pressure only using the norm  see~\cite{ELMAN} for more details. Note that the residual for the current approximation $p$ is given as
88  \begin{equation}  \begin{equation}
89  \|p\|^2= \int\hackscore{\Omega} \frac{1}{\eta^2} p^2 \; dx  r=B A^{-1} (G - B^* p) = Bv
90  \end{equation}  \end{equation}
91    where $v$ is given by~\ref{V CALC}.
92
93    If one uses the generalized minimal residual method (GMRES) \index{generalized minimal residual method!GMRES}
94    the method is directly applied to the preconditioned system

\begin{classdesc}{StokesProblemCartesian}{domain,debug}
opens the stokes equations on the \Domain domain. Setting debug=True switches the debug mode to on.
\end{classdesc}

example usage:

solution=StokesProblemCartesian(mesh) \\
solution.setTolerance(TOL) \\
velocity,pressure=solution.solve(velocity,pressure,max\_iter=max\_iter,solver=solver) \\

% \subsection{Benchmark Problem}
%
% Convection problem

\section{Temperature Cartesian}

95  \begin{equation}  \begin{equation}
96  \rho c\hackscore{p} \left (\frac{\partial T}{\partial t} + \vec{v} \cdot \nabla T \right ) = k \nabla^{2}T  \hat{S}^{-1} S p =  \hat{S}^{-1} B A^{-1} G
\label{HEAT EQUATION}
97  \end{equation}  \end{equation}
98    We use the norm
99    \begin{equation}
100    \|p\|\hackscore{GMRES} = \|\hat{S} p \|
101    \end{equation}
102    Notice that for the residual $\hat{r}=\hat{S}^{-1} r$ one has
103    \begin{equation}
104    \
105    \end{equation}
106    If $p^{0}$ provides an initial guess for the pressure we use~\ref{V CALC} to get a first initial guess for the
107    velocity $v^{0}$ which we use to set an absolute tolerance $ATOL =\epsilon \|\sqrt{v^{0}\hackscore{j,k}v^{0}\hackscore{j,k}}\|$.
108    The GMRES is terminated when
109    \begin{equation}
110    \|\hat{r}\|\hackscore{GMRES} \le ATOL
111    \end{equation}
112    Notice that $\|\hat{r}\|\hackscore{GMRES}= \|r \| = \|Bv\| = \|v\hackscore{k,k}\|$ so we we can expect that
113    the target stopping criterion~\ref{STOKES STOP} is fullfilled. However, if $v$ is very different from the
114    initial choice of $v^{0}$ the value of $ATOL$ is corrected and GMRES is restarted with a new tolerance. For time dependend problems this apprach works well as value for $p$ form a previous time step provides a good initial guess.
115
116    Alternatively, as $S$ is symmetric and positive definite one can apply the preconditioned conjugate gradient method (PCG) \index{preconditioned conjugate gradient method!PCG}. PCG use the norm
117    \begin{equation}
118    \|r\|\hackscore{PCG}^2 = \int\hackscore{\Omega} r \hat{S}^{-1}r \; dx = \int\hackscore{\Omega}  \eta r^2 \; dx
119    \end{equation}
120    To take the extra factor $\eta$ into consideration when checking the stopping criterion we use the following
121    definition for $ATOL$:
122    \begin{equation}
123    ATOL = \epsilon \frac{\|\sqrt{v^{0}\hackscore{j,k}v^{0}\hackscore{j,k}}\|  }{\|v^{0}\hackscore{k,k}\|}
124    \|v^{0}\hackscore{k,k}\|\hackscore{PCG}
125    \end{equation}
126
where $\vec{v}$ is the velocity vector, $T$ is the temperature, $\rho$ is the density, $\eta$ is the viscosity, $c\hackscore{p}$ is the specific heat at constant pressure and $k$ is the thermal conductivity.
127
\subsection{Description}
128
129  \subsection{Method}  \subsection{Functions}
130
131  \begin{classdesc}{TemperatureCartesian}{dom,theta=THETA,useSUPG=SUPG}  \begin{classdesc}{StokesProblemCartesian}{domain}
132    opens the Stokes problem\index{Stokes problem} on the \Domain domain. The approximation
133    order needs to be two.
134  \end{classdesc}  \end{classdesc}
135
136  \subsection{Benchmark Problem}  \begin{methoddesc}[StokesProblemCartesian]{initialize}{\optional{f=Data(), \optional{fixed_u_mask=Data(), \optional{eta=1, \optional{surface_stress=Data(), \optional{stress=Data()}}}}}}
137    assigns values to the model parameters. In any call all values must be set.
138    \var{f} defines the external force $f$, \var{eta} the viscosity $\eta$,
139    \var{surface_stress} the surface stress $s$ and \var{stress} the initial stress $\sigma$.
140    The locations and compontents where the velocity is fixed are set by
141    the values of \var{fixed_u_mask}. The method will try to cast the given values to appropriate
142    \Data class objects.
143    \end{methoddesc}
144
145    \begin{methoddesc}[StokesProblemCartesian]{solve}{v,p,
146    \optional{max_iter=20, \optional{verbose=False, \optional{usePCG=True}}}}
147    solves the problem and return approximations for velocity and pressure.
148    The arguments \var{v} and \var{p} define initial guess. The values of \var{v} marked
150    If \var{usePCG} is set to \True
151    reconditioned conjugate gradient method (PCG) \index{preconditioned conjugate gradient method!PCG}  scheme is used. Otherwise the problem is solved generalized minimal residual method (GMRES) \index{generalized minimal residual method!GMRES}. In most cases
152    the PCG scheme is more efficient.
153    \var{max_iter} defines the maximum number of iteration steps.
154    If \var{verbose} is set to \True informations on the progress of of the solver are printed.
155    \end{methoddesc}
156
\section{Level Set Method}
157
158  \subsection{Description}  \begin{methoddesc}[StokesProblemCartesian]{setTolerance}{\optional{tolerance=1.e-4}}
159    sets the tolerance in an appropriate norm relative to the right hand side. The tolerance must be non-negative and less than 1.
160    \end{methoddesc}
161    \begin{methoddesc}[StokesProblemCartesian]{getTolerance}{}
162    returns the current relative tolerance.
163    \end{methoddesc}
164    \begin{methoddesc}[StokesProblemCartesian]{setAbsoluteTolerance}{\optional{tolerance=0.}}
165    sets the absolute tolerance for the error in the relevant norm. The tolerance must be non-negative. Typically the
166    absolute talerance is set to 0.
167    \end{methoddesc}
168    \begin{methoddesc}[StokesProblemCartesian]{getAbsoluteTolerance}{}
169    sreturns the current absolute tolerance.
170    \end{methoddesc}
171    \begin{methoddesc}[StokesProblemCartesian]{setSubProblemTolerance}{\optional{rtol=None}}
172    sets the tolerance to solve the involved PDEs. The subtolerance \var{rtol} should not be choosen to large
173    in order to avoid feed back of errors in the subproblem solution into the outer iteration.
174    On the otherhand is choosen to small compute time is wasted.
175    If \var{rtol} is set to \var{None} the sub-tolerance is set automatically depending on the
176    tolerance choosen for the oter iteration.
177    \end{methoddesc}
178    \begin{methoddesc}[StokesProblemCartesian]{getSubProblemTolerance}{}
179    return the tolerance for the involved PDEs.
180    \end{methoddesc}
181
182  \subsection{Method}  \subsection{Example: Lit Driven Cavity}
183     The following script \file{lit\hackscore driven\hackscore cavity.py}
184    \index{scripts!\file{helmholtz.py}} which is available in the \ExampleDirectory
185    illustrates the usage of the \class{StokesProblemCartesian} class to solve
186    the lit driven cavity problem:
187    \begin{python}
188    from esys.escript import *
189    from esys.finley import Rectangle
190    from esys.escript.models import StokesProblemCartesian
191    NE=25
192    dom = Rectangle(NE,NE,order=2)
193    x = dom.getX()
194    sc=StokesProblemCartesian(dom)
196          (whereZero(x)*[0.,1.]+whereZero(x-1))*[1.,1]
198    v=Vector(0.,Solution(dom))
199    v+=whereZero(x-1.)
200    p=Scalar(0.,ReducedSolution(dom))
201    v,p=sc.solve(v,p, verbose=True)
202    saveVTK("u.xml",velocity=v,pressure=p)
203    \end{python}
204
205    \section{Darcy Flux}
206    We want to calculate the velocity $u$ and pressure $p$ on a domain $\Omega$ solving
207    the Darcy flux problem \index{Darcy flux}\index{Darcy flow}
208    \begin{equation}\label{DARCY PROBLEM}
209    \begin{array}{rcl}
210    u\hackscore{i} + \kappa\hackscore{ij} p\hackscore{,j} & = & g\hackscore{i} \\
211    u\hackscore{k,k} & = & f
212    \end{array}
213    \end{equation}
214    with the boundary conditions
215    \begin{equation}\label{DARCY BOUNDARY}
216    \begin{array}{rcl}
217    u\hackscore{i} \; n\hackscore{i}  = u^{N}\hackscore{i}  \; n\hackscore{i} & \mbox{ on } & \Gamma\hackscore{N} \\
218    p = p^{D} &  \mbox{ on } & \Gamma\hackscore{D} \\
219    \end{array}
220    \end{equation}
221    where $\Gamma\hackscore{N}$ and $\Gamma\hackscore{D}$ are a partition of the boundary of $\Omega$ with $\Gamma\hackscore{D}$ non empty, $n\hackscore{i}$ is the outer normal field of the boundary of $\Omega$, $u^{N}\hackscore{i}$ and $p^{D}$ are given functions on $\Omega$, $g\hackscore{i}$ and $f$ are given source terms and $\kappa\hackscore{ij}$ is the given permability. We assume that $\kappa\hackscore{ij}$ is symmetric (which is not really required) and positive definite, i.e there are positive constants $\alpha\hackscore{0}$ and $\alpha\hackscore{1}$ wich are independent from the location in $\Omega$ such that
222    \begin{equation}
223    \alpha\hackscore{0} \; x\hackscore{i} x\hackscore{i} \le \kappa\hackscore{ij} x\hackscore{i} x\hackscore{j} \le \alpha\hackscore{1} \; x\hackscore{i} x\hackscore{i}
224    \end{equation}
225    for all $x\hackscore{i}$.
226
227
228  \begin{classdesc}{LevelSet}{mesh, func\_new, reinit\_max, reinit\_each, tolerance, smooth}  \subsection{Solution Method \label{DARCY SOLVE}}
229    In practical applications it is an advantage to calculate the pressure $p$ as a correction of a 'static' pressure $p^{ref}$ which is the solution of
230    \begin{equation}
231    -(\kappa\hackscore{ki}\kappa\hackscore{kj} p\hackscore{,j}^{ref})\hackscore{,i} =  - (\kappa\hackscore{ki} (g\hackscore{k}- u^{N}\hackscore{k}))\hackscore{,i}
232    \mbox{ with }
233    p^{ref} = p^{D} \mbox{ on } \Gamma\hackscore{D}
234    \end{equation}
235    With setting $u \leftarrow u-u^{N}$ and $p \leftarrow p-p^{ref}$ and
236    \begin{equation}
237    \begin{array}{rcl}
238    g\hackscore{i} & \leftarrow & g\hackscore{i} - u^{N}\hackscore{i} -  \kappa\hackscore{ij} p^{ref}\hackscore{,j }\\
239    f & \leftarrow & f - u^{N}\hackscore{k,k}
240    \end{array}
241    \end{equation}
242    we can assume that $u^{N}\hackscore{i} \; n\hackscore{i}=0$ and
243    $p^{D}=0$.
244    We set
245    \begin{equation}
246    V = \{ q \in H^{1}(\Omega) : q=0 \mbox{ on } \Gamma\hackscore{D} \}
247    \end{equation}
248    and
249    \begin{equation}
250    W = \{ v \in (L^2(\Omega))^{d} : v\hackscore{k,k} \in L^2(\Omega) \mbox{ and } u\hackscore{i} \; n\hackscore{i} =0  \mbox{ on } \Gamma\hackscore{N} \}
251    \end{equation}
252    and define the operator $Q: V \rightarrow (L^2(\Omega))^{d}$ defined by
253    \begin{equation}
254    (Qp)\hackscore{i} = \kappa\hackscore{ij} p\hackscore{,j}
255    \end{equation}
256    and the operator $D: W \rightarrow L^2(\Omega)$ defined by
257    \begin{equation}
258    Dv = v\hackscore{k,k}
259    \end{equation}
260    In operator notation the Darcy problem~\ref{DARCY PROBLEM} is written in the form
261    \begin{equation}
262    \begin{array}{rcl}
263    u + Qp & = & g \\
264    Du & = & f
265    \end{array}
266    \end{equation}
267    We solve this equation by minimising the functional
268    \begin{equation}
269    J(u,p):=\|u + Qp - g\|^2\hackscore{0} + \|Du-f\|\hackscore{0}^2
270    \end{equation}
271    over $W \times V$ where $\|.\|\hackscore{0}$ denotes the norm in $L^2(\Omega)$. A simple calculation shows that
272    one has to solve
273    \begin{equation}
274    ( v + Qq , u + Qp - g) + (Dv,Du-f) =0
275    \end{equation}
276    for all $v\in W$ and $q \in V$.which translates back into operator notation
277    \begin{equation}
278    \begin{array}{rcl}
279    (I+D^*D)u + Qp & = & D^*f + g \\
280    Q^*u  + Q^*Q p & = & Q^*g \\
281    \end{array}
282    \end{equation}
283    where $D^*$ and $Q^*$ denote the adjoint operators.
284    In~\cite{LEASTSQUARESFEM1994} it has been shown that this problem is continuous and coercive in $W \times V$ and therefore has a unique solution. Also standart FEM methods can be used for discretization. It is also possible
285    to solve the problem is coupled form, however this approach leads in some cases to a very ill-conditioned stiffness matrix in particular in the case of a very small or large permability ($\alpha\hackscore{1} \ll 1$ or $\alpha\hackscore{0} \gg 1$)
286
287    The approach we are taking is to eliminate the velocity $u$ from the problem. Assuming that $p$ is known we have
288    \begin{equation}\label{DARCY V FORM}
289    v= (I+D^*D)^{-1} (D^*f + g - Qp)
290    \end{equation}
291    (notice that $(I+D^*D)$ is coercive in $W$) which is inserted into the second equation
292    \begin{equation}
293    Q^* (I+D^*D)^{-1} (D^*f + g - Qp) + Q^* Q p = Q^*g
294    \end{equation}
295    which is
296    \begin{equation}
297    Q^* ( I - (I+D^*D)^{-1} ) Q p = Q^* (g-(I+D^*D)^{-1} (D^*f + g) )
298    \end{equation}
299    We use the PCG \index{linear solver!PCG}\index{PCG} method to solve this. The residual $r$ ($\in V^*$) is given as
300    \begin{equation}
301    \begin{array}{rcl}
302    r & = & Q^*  \left( g -(I+D^*D)^{-1} (D^*f + g) - Qp + (I+D^*D)^{-1}Q p \right)\\
303    & =&  Q^* \left( g- Qp - (I+D^*D)^{-1} (D^*f + g - Qp) \right) \\
304    & =&  Q^* \left( g - Qp - v \right)
305    \end{array}
306    \end{equation}
307    So in a partical implementation we use $\hat{r}=g-Qp-v$ to represent the residual.
308    The evaluation of the iteration operator for a given $p$ is then
309    returning $Qp+v$ where $v$ is the solution of
310    \begin{equation}\label{UPDATE W}
311    (I+D^*D)v = Qp
312    \end{equation}
313    We use $(Q^*Q)^{-1}$ as a preconditioner for the iteration operator $Q^* ( I - (I+D^*D)^{-1} ) Q$. So the application of the preconditioner to $\hat{r}$ representing the residual is given by solving
314    implemented by solving
315    \begin{equation}\label{UPDATE P}
316    Q^*Q q  = Q^*\hat{r}
317    \end{equation}
318    The residual norm used in the PCG is given as
319    \begin{equation}\label{DARCY R NORM}
320    \|r\|\hackscore{PCG}^2 = \int r \cdot (Q^*Q)^{-1} r \; dx =\int \hat{r} \cdot Q (Q^*Q)^{-1} Q^* \hat{r} \; dx \approx
321    \|\hat{r}\|\hackscore{0}^2
322    \end{equation}
323    The iteration is terminated if
324    \begin{equation}\label{DARCY STOP}
325    \|r\|\hackscore{PCG} \le \mbox{ATOL}
326    \end{equation}
327    where we set
328    \begin{equation}\label{DARCY ATOL DEF}
329    \mbox{ATOL} = \mbox{atol} + \mbox{rtol} \cdot \left(\frac{1}{\|v\|\hackscore{0}} + \frac{1}{\|Qp\|\hackscore{0}} \right)^{-1}
330    \end{equation}
331    where rtol is a given relative tolerance and $\mbox{atol}$ is a given absolute tolerance (typically $=0$).
332    Notice that if $Qp$ and $v$ both are zero, the pair $(0,p)$ is a solution.
333    The problem is that ATOL is depending on the solution $p$ (and $v$ calculated form~\ref{DARCY V FORM}). In partcice one use the initial guess for $p$
334    to get a first value for ATOL. If the stopping crierion is met in the PCG iteration, a new $v$ is calculated from the current pressure approximation and ATOL is recalculated. If \ref{DARCY STOP} is still fullfilled the calculation is terminated and $(v,p)$ is returned. Otherwise PCG is restarted with a new ATOL.
335
336    \subsection{Functions}
337    \begin{classdesc}{DarcyFlow}{domain}
338    opens the Darcy flux problem\index{Darcy flux} on the \Domain domain.
339  \end{classdesc}  \end{classdesc}
340    \begin{methoddesc}[DarcyFlow]{setValue}{\optional{f=None, \optional{g=None, \optional{location_of_fixed_pressure=None, \optional{location_of_fixed_flux=None, \optional{permeability=None}}}}}}
341    assigns values to the model parameters. Values can be assigned using various calls - in particular
342    in a time dependend problem only values that change over time needs to be reset. The permability can be defined as scalar (isotropic), a vector (orthotropic) or a matrix (anisotropic).
343    \var{f} and \var{g} are the corresponding parameters in~\ref{DARCY PROBLEM}.
344    The locations and compontents where the flux is prescribed are set by positive values in
345    \var{location_of_fixed_flux}.
346    The locations where the pressure is prescribed are set by
347    by positive values of \var{location_of_fixed_pressure}.
348    The values of the pressure and flux are defined by the initial guess.
349    Notice that at any point on the boundary of the domain the pressure or the normal component of
350    the flux must be defined. There must be at least one point where the pressure is prescribed.
351    The method will try to cast the given values to appropriate
352    \Data class objects.
353    \end{methoddesc}
354
355  %example usage:  \begin{methoddesc}[DarcyFlow]{setTolerance}{\optional{rtol=1e-4}}
356    sets the relative tolerance \mbox{rtol} in \ref{DARCY ATOL DEF}.
357    \end{methoddesc}
358
359  %levelset = LevelSet(mesh, func\_new, reinit\_max, reinit\_each, tolerance, smooth)  \begin{methoddesc}[DarcyFlow]{setAbsoluteTolerance}{\optional{atol=0.}}
360    sets the absolute tolerance \mbox{atol} in \ref{DARCY ATOL DEF}.
361    \end{methoddesc}
362
363  \begin{methoddesc}[LevelSet]{update\_parameter}{parameter}  \begin{methoddesc}[DarcyFlow]{setSubProblemTolerance}{\optional{rtol=None}}
364  Update the parameter.  sets the relative tolerance used to solve the involved PDEs. If no argument is given,
365    the square of the current relative tolerance is used. The sub-problem tolerance should be choosen as large as possible to minimize the compute time. However, a too large value for the sub-problem tolerance may lead to slow convergence or even dibergence in the outer iteration.
366  \end{methoddesc}  \end{methoddesc}
367
368  \begin{methoddesc}[LevelSet]{update\_phi}{paramter}{velocity}{dt}{t\_step}  \begin{methoddesc}[DarcyFlow]{solve}{u0,p0, \optional{max_iter=100, \optional{verbose=False \optional{sub_rtol=1.e-8}}}}
369  Update level set function; advection and reinitialization  solves the problem. and returns approximations for the flux $v$ and the pressure $p$.
370    \var{u0} and \var{p0} define initial guess for flux and pressure. Values marked
371    by positive values \var{location_of_fixed_flux} and \var{location_of_fixed_pressure}, respectively, are kept unchanged.
372  \end{methoddesc}  \end{methoddesc}
373
\subsection{Benchmark Problem}
374
375  Rayleigh-Taylor instability problem  \subsection{Example: Gravity Flow}
376    later
377
378    %\input{levelsetmodel}
379
380
% \section{Drucker Prager Model}
381
382  \section{Isotropic Kelvin Material \label{IKM}}  \section{Isotropic Kelvin Material \label{IKM}}
383  As proposed by Kelvin~\ref{KELVN} material strain $D\hackscore{ij}=v\hackscore{i,j}+v\hackscore{j,i}$ can be decomposed into  As proposed by Kelvin~\cite{Muhlhaus2005} material strain $D\hackscore{ij}=\frac{1}{2}(v\hackscore{i,j}+v\hackscore{j,i})$ can be decomposed into
384  an elastic part $D\hackscore{ij}^{el}$ and visco-plastic part $D\hackscore{ij}^{vp}$:  an elastic part $D\hackscore{ij}^{el}$ and visco-plastic part $D\hackscore{ij}^{vp}$:
385  \begin{equation}\label{IKM-EQU-2}  \begin{equation}\label{IKM-EQU-2}
386  D\hackscore{ij}=D\hackscore{ij}^{el}+D\hackscore{ij}^{vp}  D\hackscore{ij}=D\hackscore{ij}^{el}+D\hackscore{ij}^{vp}
387  \end{equation}  \end{equation}
388  with the elastic strain given as  with the elastic strain given as
389  \begin{equation}\label{IKM-EQU-3}  \begin{equation}\label{IKM-EQU-3}
390  D\hackscore{ij}'^{el}=\frac{1}{2 \mu} \dot{\sigma}\hackscore{ij}'  D\hackscore{ij}^{el'}=\frac{1}{2 \mu} \dot{\sigma}\hackscore{ij}'
391  \end{equation}  \end{equation}
392  where $\sigma'\hackscore{ij}$ is the deviatoric stress (Notice that $\sigma'\hackscore{ii}=0$).  where $\sigma'\hackscore{ij}$ is the deviatoric stress (Notice that $\sigma'\hackscore{ii}=0$).
393  If the material is composed by materials $q$ the visco-plastic strain can be decomposed as  If the material is composed by materials $q$ the visco-plastic strain can be decomposed as
394  \begin{equation}\label{IKM-EQU-4}  \begin{equation}\label{IKM-EQU-4}
395  D\hackscore{ij}'^{vp}=\sum\hackscore{q} D\hackscore{ij}'^{q}  D\hackscore{ij}^{vp'}=\sum\hackscore{q} D\hackscore{ij}^{q'}
396  \end{equation}  \end{equation}
397  where $D\hackscore{ij}^{q}$ is the strain in material $q$ given as  where $D\hackscore{ij}^{q}$ is the strain in material $q$ given as
398  \begin{equation}\label{IKM-EQU-5}  \begin{equation}\label{IKM-EQU-5}
399  D\hackscore{ij}'^{q}=\frac{1}{2 \eta^{q}} \sigma'\hackscore{ij}  D\hackscore{ij}^{q'}=\frac{1}{2 \eta^{q}} \sigma'\hackscore{ij}
400  \end{equation}  \end{equation}
401  where $\eta^{q}$ is the viscosity of material $q$. We assume the following  where $\eta^{q}$ is the viscosity of material $q$. We assume the following
402  betwee the the strain in material $q$  betwee the the strain in material $q$
# Line 187  betwee the the strain in material $q$ Line 404  betwee the the strain in material $q$
404  \eta^{q}=\eta^{q}\hackscore{N} \left(\frac{\tau}{\tau\hackscore{t}^q}\right)^{\frac{1}{n^{q}}-1}  \eta^{q}=\eta^{q}\hackscore{N} \left(\frac{\tau}{\tau\hackscore{t}^q}\right)^{\frac{1}{n^{q}}-1}
405  \mbox{ with } \tau=\sqrt{\frac{1}{2}\sigma'\hackscore{ij} \sigma'\hackscore{ij}}  \mbox{ with } \tau=\sqrt{\frac{1}{2}\sigma'\hackscore{ij} \sigma'\hackscore{ij}}
406  \end{equation}  \end{equation}
407  for a given power law coefficients $n^{q}$ and transition stresses $\tau\hackscore{t}^q$, see~\ref{POERLAW}.  for a given power law coefficients $n^{q}\ge1$ and transition stresses $\tau\hackscore{t}^q$, see~\cite{Muhlhaus2005}.
408  Notice that $n^{q}=1$ gives a constant viscosity.  Notice that $n^{q}=1$ gives a constant viscosity.
409  After inserting equation~\ref{IKM-EQU-5} into equation \ref{IKM-EQU-4} one gets:  After inserting equation~\ref{IKM-EQU-5} into equation \ref{IKM-EQU-4} one gets:
410  \begin{equation}\label{IKM-EQU-6}  \begin{equation}\label{IKM-EQU-6}
411  D\hackscore{ij}'^{vp}=\frac{1}{2 \eta^{vp}} \sigma'\hackscore{ij} \mbox{ with } \frac{1}{\eta^{vp}} \sum\hackscore{q} \frac{1}{\eta^{q}} \;.  D\hackscore{ij}'^{vp}=\frac{1}{2 \eta^{vp}} \sigma'\hackscore{ij} \mbox{ with } \frac{1}{\eta^{vp}} = \sum\hackscore{q} \frac{1}{\eta^{q}} \;.
412  \end{equation}  \end{equation}
413  With  and finally with~\ref{IKM-EQU-2}
414  \begin{equation}\label{IKM-EQU-8}  \begin{equation}\label{IKM-EQU-2bb}
415  \dot{\gamma}=\sqrt{2 D\hackscore{ij} D\hackscore{ij}}  D\hackscore{ij}'=\frac{1}{2 \eta^{vp}} \sigma'\hackscore{ij}+\frac{1}{2 \mu} \dot{\sigma}\hackscore{ij}'
416  \end{equation}  \end{equation}
417  one gets  The total stress $\tau$ needs to fullfill the yield condition \index{yield condition}
\begin{equation}\label{IKM-EQU-8b}
\tau = \eta^{vp} \dot{\gamma}^{vp} \;.
\end{equation}
With the Drucker-Prager cohesion factor $\tau\hackscore{Y}$, Drucker-Prager friction $\beta$ and total pressure $p$ we want to achieve
418  \begin{equation}\label{IKM-EQU-8c}  \begin{equation}\label{IKM-EQU-8c}
419  \tau \le \tau\hackscore{Y} + \beta \; p  \tau \le \tau\hackscore{Y} + \beta \; p
420  \end{equation}  \end{equation}
421  which leads to the condition  with the Drucker-Prager \index{Druck-Prager} cohesion factor \index{cohesion factor} $\tau\hackscore{Y}$, Drucker-Prager friction $\beta$ and total pressure $p$.
\begin{equation}\label{IKM-EQU-8d}
\eta^{vp} \le \frac{\tau\hackscore{Y} + \beta \; p}{ \dot{\gamma}^{vp}} \; .
\end{equation}
Therefore we modify the definition of $\eta^{vp}$ to the form
\begin{equation}\label{IKM-EQU-6b}
\frac{1}{\eta^{vp}}=\max(\sum\hackscore{q} \frac{1}{\eta^{q}}, \frac{\dot{\gamma}^{vp}} {\tau\hackscore{Y} + \beta \; p})
\end{equation}
422  The deviatoric stress needs to fullfill the equilibrion equation  The deviatoric stress needs to fullfill the equilibrion equation
423  \begin{equation}\label{IKM-EQU-1}  \begin{equation}\label{IKM-EQU-1}
424  -\sigma'\hackscore{ij,j}+p\hackscore{,i}=F\hackscore{i}  -\sigma'\hackscore{ij,j}+p\hackscore{,i}=F\hackscore{i}
425  \end{equation}  \end{equation}
426  where $F\hackscore{j}$ is a given external fource. We assume an incompressible media:  where $F\hackscore{j}$ is a given external fource. We assume an incompressible media:
427  \begin{equation}\label{IKM-EQU-2}  \begin{equation}\label{IKM-EQU-2bbb}
428  -v\hackscore{i,i}=0  -v\hackscore{i,i}=0
429  \end{equation}  \end{equation}
430  Natural boundary conditions are taken in the form  Natural boundary conditions are taken in the form
# Line 234  where the index $i$ may depend on the lo Line 440  where the index $i$ may depend on the lo
440  \subsection{Solution Method \label{IKM-SOLVE}}  \subsection{Solution Method \label{IKM-SOLVE}}
441  By using a first order finite difference approximation wit step size $dt>0$~\ref{IKM-EQU-3} get the form  By using a first order finite difference approximation wit step size $dt>0$~\ref{IKM-EQU-3} get the form
442  \begin{equation}\label{IKM-EQU-3b}  \begin{equation}\label{IKM-EQU-3b}
443  D\hackscore{ij}'^{el}=\frac{1}{2 \mu dt } \left( \sigma\hackscore{ij}' - \sigma\hackscore{ij}^{'-} \right)  \dot{\sigma}\hackscore{ij}=\frac{1}{dt } \left( \sigma\hackscore{ij} - \sigma\hackscore{ij}^{-} \right)
444    \end{equation}
445    and
446    \begin{equation}\label{IKM-EQU-2b}
447    D\hackscore{ij}'=\left(\frac{1}{2 \eta^{vp}} + \frac{1}{2 \mu dt}\right) \sigma\hackscore{ij}'-\frac{1}{2 \mu dt } \sigma\hackscore{ij}^{-'}
448    \end{equation}
449    where $\sigma\hackscore{ij}^{-}$ is the stress at the precious time step. With
450    \begin{equation}\label{IKM-EQU-2c}
451    \dot{\gamma} = \sqrt{ 2 \left( D\hackscore{ij}' +
452    \frac{1}{  2 \mu \; dt} \sigma\hackscore{ij}^{-'}\right)^2}
453    \end{equation}
454    we have
455    \begin{equation}
456    \tau = \eta\hackscore{eff} \cdot \dot{\gamma}
457    \end{equation}
458    where
459    \begin{equation}
460    \eta\hackscore{eff}= min( \left(\frac{1}{\mu \; dt}+\frac{1}{\eta^{vp}}\right)^{-1}
461    , \eta\hackscore{max}) \mbox{ with }
462    \eta\hackscore{max} = \left\{
463    \begin{array}{rcl}
464    \frac{\tau\hackscore{Y} + \beta \; p}{\dot{\gamma}} & & \dot{\gamma}>0 \\
465    &\mbox{ if } \\
466    \infty & & \mbox{otherwise}
467    \end{array}
468    \right.
469  \end{equation}  \end{equation}
470  where $\sigma\hackscore{ij}^{'-}$ is the deviatoric stress at the precious time step.  The upper bound $\eta\hackscore{max}$ makes sure that yield condtion~\ref{IKM-EQU-8c} holds. With this setting the eqaution \ref{IKM-EQU-2b} takes the form
Now we can combine equations~\ref{IKM-EQU-2}, \ref{IKM-EQU-3b} and~\ref{IKM-EQU-6b} to get
471  \begin{equation}\label{IKM-EQU-10}  \begin{equation}\label{IKM-EQU-10}
472  \sigma\hackscore{ij}' =  2 \eta\hackscore{eff} D\hackscore{ij}' +  \sigma\hackscore{ij}' =  2 \eta\hackscore{eff}  \left( D\hackscore{ij}' +
473  \frac{\eta\hackscore{eff}}{\mu \; dt}  \frac{1}{  2 \mu \; dt} \sigma\hackscore{ij}^{'-}\right)
\sigma\hackscore{ij}^{'-} \mbox{ with }
\frac{1}{\eta\hackscore{eff}}=\frac{1}{\mu \; dt}+\frac{1}{\eta^{vp}}
474  \end{equation}  \end{equation}
Notice that $\eta\hackscore{eff}$ is a function of stress.
475  After inserting~\ref{IKM-EQU-10} into~\ref{IKM-EQU-1} we get  After inserting~\ref{IKM-EQU-10} into~\ref{IKM-EQU-1} we get
476  \begin{equation}\label{IKM-EQU-1ib}  \begin{equation}\label{IKM-EQU-1ib}
477  -\left(\eta\hackscore{eff} (v\hackscore{i,j}+ v\hackscore{i,j})\right)\hackscore{,j}+p\hackscore{,i}=F\hackscore{i}+  -\left(\eta\hackscore{eff} (v\hackscore{i,j}+ v\hackscore{i,j})
478  \frac{\eta\hackscore{eff}}{\mu dt } \sigma\hackscore{ij,j}^{'-}  \right)\hackscore{,j}+p\hackscore{,i}=F\hackscore{i}+
479     \left(\frac{\eta\hackscore{eff}}{\mu dt } \sigma\hackscore{ij}^{'-} \right)\hackscore{,j}
480    \end{equation}
481    Combining this with the incomressibilty condition~\ref{IKM-EQU-2} we need to solve a
482    Stokes problem as discussed in section~\ref{STOKES SOLVE} in each time step.
483
484    If we set
485    \begin{equation}\label{IKM-EQU-44}
486    \frac{1}{\eta(\tau)}= \frac{1}{\mu \; dt}+\frac{1}{\eta^{vp}}
487  \end{equation}  \end{equation}
488  Together with the incomressibilty condition~\ref{IKM-EQU-2} we need to solve a problem with a form almost identical  we need to solve the nonlinear problem
to the Stokes problem discussed in section~\ref{STOKES SOLVE} but with the difference that $\eta\hackscore{eff}$ is depending on the solution. Analog to the iteration scheme~\ref{SADDLEPOINT iteration 2} we can run
489  \begin{equation}  \begin{equation}
490  \begin{array}{rcl}  \eta\hackscore{eff} -  min(\eta( \dot{\gamma} \cdot \eta\hackscore{eff})
491  -\left(\eta\hackscore{eff}(dv\hackscore{i,j}+ dv\hackscore{i,j})\right)\hackscore{,j} & = & F\hackscore{i}+ \sigma\hackscore{ij,j}' \\  , \eta\hackscore{max}) =0
\frac{1}{\eta\hackscore{eff}} dp & = & - v\hackscore{i,i}^+ \\
d\sigma\hackscore{ij}' & = & 2 \eta\hackscore{eff} D\hackscore{ij}^{+'} + \frac{\eta\hackscore{eff}}{\mu \; dt} \sigma\hackscore{ij}' -  \sigma\hackscore{ij}\\
\end{array}
\label{IKM iteration 2}
492  \end{equation}  \end{equation}
493  where $v^+=v+dv$. As this problem is non-linear the Jacobi-free Newton-GMRES method is used with the norm  We use the Newton-Raphson Scheme \index{Newton-Raphson scheme} to solve this problem
494    \begin{equation}\label{IKM-EQU-45}
495    \eta\hackscore{eff}^{(n+1)} = \min(\eta\hackscore{max},
496    \eta\hackscore{eff}^{(n)} -
497    \frac{\eta\hackscore{eff}^{(n)} - \eta( \tau^{(n)}) }
498    {1-\dot{\gamma} \cdot \eta'( \tau^{(n)} )} )
499    =\min(\eta\hackscore{max},
500    \frac{\eta( \tau^{(n)}) -\tau^{(n)} \cdot  \eta'( \tau^{(n)} )  }
501    {1-\dot{\gamma} \cdot \eta'( \tau^{(n)} )} )
502    \end{equation}
503    where $\eta'$ denotes the derivative of $\eta$ with respect of $\tau$
504    and $\tau^{(n)} = \dot{\gamma} \cdot \eta\hackscore{eff}^{(n)}$.
505
506    Looking at the evaluation of $\eta$ in~\ref{IKM-EQU-44} it makes sense formulate
507    the iteration~\ref{IKM-EQU-45} using $\Theta=\eta^{-1}$.
508    In fact we have
509  \begin{equation}  \begin{equation}
510  \|(\sigma, p)\|^2= \int\hackscore{\Omega} \sigma\hackscore{i,j}^2 + p^2 \; dx  \eta' = - \frac{\Theta'}{\Theta^2}
511  \label{IKM iteration 3}  \mbox{ with }
512  \end{equation}  \Theta' = \sum\hackscore{q} \left(\frac{1}{\eta^{q}} \right)'
513    \label{IKM iteration 7}
514    \end{equation}
515    As
516    \begin{equation}\label{IKM-EQU-47}
517    \left(\frac{1}{\eta^{q}} \right)'
518    = \frac{1-\frac{1}{n^{q}}}{\eta^{q}\hackscore{N}} \frac{\tau^{-\frac{1}{n^{q}}}}{(\tau\hackscore{t}^q)^{1-\frac{1}{n^{q}}}}
519    = \frac{1-\frac{1}{n^{q}}}{\eta^{q}}\frac{1}{\tau}
520    \end{equation}
521    we have
522    \begin{equation}\label{IKM-EQU-48}
523    \Theta' = \frac{1}{\tau} \omega \mbox{ with } \omega = \sum\hackscore{q}\frac{1-\frac{1}{n^{q}}}{\eta^{q}}
524    \end{equation}
526    \begin{equation}\label{IKM-EQU-49}
527    \eta\hackscore{eff}^{(n+1)} = \min(\eta\hackscore{max},
528    \eta\hackscore{eff}^{(n)}
529    \frac{\Theta^{(n)}  + \omega^{(n)}  }
530    {\eta\hackscore{eff}^{(n)} \Theta^{(n)^2}+\omega^{(n)} })
531    \end{equation}
532
533
534    \subsection{Functions}
535
536    #=============================================================================
537    \begin{classdesc}{IncompressibleIsotropicFlowCartesian}{
538    domain
539    \optional{, stress=0
540    \optional{, v=0
541    \optional{, p=0
542    \optional{, t=0
543    \optional{, numMaterials=1
544    \optional{, verbose=True}}}}}}}
545    opens an incompressible, isotropic flow problem in Cartesian cooridninates.
546    \var{stress},
547    \var{v},
548    \var{p}, and
549    \var{t} set the initial deviatoric stress, velocity, pressure and time.
550    \var{numMaterials} specifies the number of materials used in the power law
551    model. Some progress information are printed if \var{verbose} is set to
552    \True.
553    \end{classdesc}
554
555     setExternals(self, F=None, f=None, fixed_v_mask=None, v_boundary=None):
557    assigns values to external forces and boundary conditions. Between two calls only variables with a new values need to be set.
558
559    In any call all values must be set.
560    \var{f} defines the external force $f$, \var{eta} the viscosity $\eta$,
561    \var{surface_stress} the surface stress $s$ and \var{stress} the initial stress $\sigma$.
562    The locations and compontents where the velocity is fixed are set by
563    the values of \var{fixed_u_mask}. The method will try to cast the given values to appropriate
564    \Data class objects.
565    \end{methoddesc}
566
567    \begin{methoddesc}[StokesProblemCartesian]{solve}{v,p,
568    \optional{max_iter=20, \optional{verbose=False, \optional{usePCG=True}}}}
569    solves the problem and return approximations for velocity and pressure.
570    The arguments \var{v} and \var{p} define initial guess. The values of \var{v} marked
572    If \var{usePCG} is set to \True
573    reconditioned conjugate gradient method (PCG) \index{preconditioned conjugate gradient method!PCG}  scheme is used. Otherwise the problem is solved generalized minimal residual method (GMRES) \index{generalized minimal residual method!GMRES}. In most cases
574    the PCG scheme is more efficient.
575    \var{max_iter} defines the maximum number of iteration steps.
576    If \var{verbose} is set to \True informations on the progress of of the solver are printed.
577    \end{methoddesc}
578
579
580    \begin{methoddesc}[StokesProblemCartesian]{setTolerance}{\optional{tolerance=1.e-4}}
581    sets the tolerance in an appropriate norm relative to the right hand side. The tolerance must be non-negative and less than 1.
582    \end{methoddesc}
583    \begin{methoddesc}[StokesProblemCartesian]{getTolerance}{}
584    returns the current relative tolerance.
585    \end{methoddesc}
586    \begin{methoddesc}[StokesProblemCartesian]{setAbsoluteTolerance}{\optional{tolerance=0.}}
587    sets the absolute tolerance for the error in the relevant norm. The tolerance must be non-negative. Typically the
588    absolute talerance is set to 0.
589    \end{methoddesc}
590    \begin{methoddesc}[StokesProblemCartesian]{getAbsoluteTolerance}{}
591    sreturns the current absolute tolerance.
592    \end{methoddesc}
593    \begin{methoddesc}[StokesProblemCartesian]{setSubProblemTolerance}{\optional{rtol=None}}
594    sets the tolerance to solve the involved PDEs. The subtolerance \var{rtol} should not be choosen to large
595    in order to avoid feed back of errors in the subproblem solution into the outer iteration.
596    On the otherhand is choosen to small compute time is wasted.
597    If \var{rtol} is set to \var{None} the sub-tolerance is set automatically depending on the
598    tolerance choosen for the oter iteration.
599    \end{methoddesc}
600    \begin{methoddesc}[StokesProblemCartesian]{getSubProblemTolerance}{}
601    return the tolerance for the involved PDEs.
602    \end{methoddesc}
603
604
605    % \section{Drucker Prager Model}

Legend:
 Removed from v.1966 changed lines Added in v.2432