2009-10-27 12:00:08 -05:00
\newcommand { \nextline } { \par \phantom { a} \vspace * { 0.1\textwidth } }
\chapter { The flow of things in \Dumux }
2012-02-03 10:15:12 -06:00
\label { flow}
2009-10-27 12:00:08 -05:00
2010-11-10 04:15:37 -06:00
This chapter is supposed to show how things are ``handed around'' in \Dumux . This is not a comprehenisve guide through the modeling framework of \Dumux , but hopefully it will help getting to grips with it.
2009-10-27 12:00:08 -05:00
In Section \ref { content} the structure of \Dumux is shown from a \emph { content} point of view.
Section \ref { implementation} is written from the point of view of the \emph { implementation} . These two approaches are linked by the circled numbers (like \textbf { \textcircled { \ref { init} } } ) in the flowchart of Section \ref { implementation} corresponding to the enumeration of the list of Section \ref { content} . This is supposed to demonstrate at which point of the program-flow you are content- and implementation-wise.
Section \ref { implementation} is structured by \fbox { boxes} and $ \overrightarrow { \textnormal { arrows } } $ . Boxes stand for more or less important points in the programm. They may may be reckoned ``step stones''. Likewise, the arrows connect the boxes. If important things happen in between, it is written under the arrows.
2010-12-10 09:05:12 -06:00
\fbox { Plain boxes} stand for generic parts of the program. \fbox { \fbox { double} } $ \lbrace \lbrace $ boundings$ \rbrace \rbrace $ stand for the implementatin specific part of the program, like \verb +2p, 2p2c...+. This will be the most important part for most users. \uwave { snakelike lines} tell you that this part is specific to the components considered.
2009-10-27 12:00:08 -05:00
For keeping things simple, the program flow of a \verb +2p+ model is shown.
There are extensive comments regarding the formating in the tex file: so feel free, to enhance this description.
\section { Structure -- by content}
\label { content}
% by means of this enumerated list, the connection between algorithm and content can be achieved by references to the labels of this list.
2010-12-10 09:05:12 -06:00
This list shows the algorithmic outline of a typical \Dumux run employing a fully coupled model. Each item stands for a characteristic step within the modeling framework.
2009-10-27 12:00:08 -05:00
\clearpage
\begin { tabbing}
\textbf { \numberThis { main} { init} } \hspace { 0.01\textwidth } \=
\textbf { \numberThis { time step} { prep} } \hspace { 0.01\textwidth } \=
2012-02-24 05:16:37 -06:00
\textbf { \numberThis { Newton step} { elem} } \hspace { 0.01\textwidth } \=
2009-10-27 12:00:08 -05:00
\textbf { \numberThis { Element} { calc} } \hspace { 0.01\textwidth } \\
\\
initialize \\
2010-12-14 06:31:21 -06:00
\textbf { for each} time step\\
2009-10-27 12:00:08 -05:00
2010-12-14 06:31:21 -06:00
\> pre-process solution\\
\> \textbf { for each} \textsc { Newton} iteration \\
2009-10-27 12:00:08 -05:00
2010-12-14 06:31:21 -06:00
\> \> \textbf { for each} element \\
2009-10-27 12:00:08 -05:00
2010-12-14 06:31:21 -06:00
\> \> \> calculate element's local residual \\
2012-02-06 07:24:07 -06:00
\> \> \> calculate element's \textsc { Jacobian} of local residual \\
\> \> \> add local residual to global residual vector \\
2010-12-14 06:31:21 -06:00
\> \> \> add local \textsc { Jacobian} to global \textsc { Jacobian} matrix \\
2009-10-27 12:00:08 -05:00
2010-12-14 06:31:21 -06:00
\> \> \textbf { end for} \\
2009-10-27 12:00:08 -05:00
2010-12-14 06:31:21 -06:00
\> \> solve linear system of equations\\
\> \> update current iterative solution\\
\> \> \textbf { if} converged \\
\> \> \qquad stop \textsc { Newton} iteration\\
\> \> \textbf { end if} \\
2009-10-27 12:00:08 -05:00
\> \textbf { endfor} \\
2010-12-14 06:31:21 -06:00
\> \textbf { if} converged \\
\> \qquad post-process solution\\
\> \qquad write result\\
\> \qquad adapt timestep size \\
\> \textbf { else if} not converged \\
\> \qquad retry with half time step size\\
\> \textbf { end if} \\
\textbf { end for} \\
2009-10-27 12:00:08 -05:00
finalize\\
\end { tabbing}
2009-10-29 04:01:43 -05:00
%% this is tructured by a table propably the new structure (\numberThis{}{} defined in the main document)is intuetivly easier to get
2009-10-27 12:00:08 -05:00
% \begin{enumerate}[1]
% \item\label{init} initialize \\
% \textbf{foreach} timestep
% \item\label{prep}
% \hspace*{0.05\textwidth} prepare update\\
% \hspace*{0.05\textwidth} \textbf{foreach} \textsc{Newton} step
% \item\label{elem}
% \hspace*{0.1\textwidth} \textbf{foreach} element
% \item\label{calc}
% \hspace*{0.15\textwidth} calculate element \textit{Jacobian}\\
% \hspace*{0.15\textwidth} assemble into global \textit{Jacobian} matrix \\
%
% \hspace*{0.10\textwidth} \textbf{foreach} element calculate element residual \\
% \hspace*{0.10\textwidth} assemble into global defect\\
%
% \hspace*{0.05\textwidth} solve linear system\\
% \hspace*{0.05\textwidth} update solution\\
% \hspace*{0.05\textwidth} check for \textsc{Newton} convergence\\
% \hspace*{0.05\textwidth} adapt timestep, possibly redo with smaller stepsize\\
% \hspace*{0.05\textwidth} write result\\
% \end{enumerate}
\subsection { Levels}
\textcircled { \ref { init} } main\\
\textcircled { \ref { prep} } time step\\
\textcircled { \ref { elem} } \textsc { Newton} step\\
2012-02-24 05:16:37 -06:00
\textcircled { \ref { calc} } Element-wise assembly
2009-10-27 12:00:08 -05:00
\section { Structure -- by implementation}
\label { implementation}
2010-12-10 09:05:12 -06:00
This section is supposed to help you in getting an idea how things are handled in \Dumux and in which files things are written down.
This is not intuitivly clear, therefore it is mentioned for each \fbox { step-stone} . \textbf { called by} tells you from which file a function is
accessed. \textbf { implemented in} tells you in which file the function is written down. The name of the function is set in \verb +typewriter+.
Being a function is indicated by round brackets \verb +()+ but only the function name is given and not the full signature (arguments...) .
Comments regarding the events within one step-stone are set \scriptsize { smaller} .
2009-10-27 12:00:08 -05:00
\begin { landscape}
2010-12-10 09:05:12 -06:00
%switch off headings and footer in order to get more space for the flowchart
\pagestyle { empty}
2009-10-27 12:00:08 -05:00
{ \small
2010-12-10 09:05:12 -06:00
\setlength { \voffset } { 4.2cm}
2009-10-27 12:00:08 -05:00
%%README!!! it is important NOT to leave any blank lines, as multiple boxes are supposed to be in one line
2012-02-06 07:24:07 -06:00
%% Unfortunately, blank lines need to be inserted manually if one box is lapping over the page border
2009-10-27 12:00:08 -05:00
%% by means of \newline, a new line plus some extra space can be inserted, which has unfortunately to be done after each line
2012-02-06 07:24:07 -06:00
%% \newline is defined at the beginning of this file
2009-10-27 12:00:08 -05:00
%% sometimes \texttt{} is used (in stead of \verb), as it is not possible to have ANY environment within \verb.
%% If multiple lines are supposed to be under one arrow, I used an align environment and switched back to \textnormal for each line
%% a blank template for one step-stone is at the end of the file
%%SAMPLE:
% \begin{tabular}{|l|} % each box is a single table, left jusified and bars to the right and left
% \hline % this makes the top bar of the box
2009-10-29 04:01:43 -05:00
% \textbf{\textcircled{\ref{calc}}}\verb+ctl.newtonEnd()+ \\ % this is the line for showing code. also in this line the circled numbers are printed, that show the connection to the content wise structure. The numbers are realized as references to the enumerated list. bold!
% \begin{scriptsize}\end{scriptsize}\\
2009-10-27 12:00:08 -05:00
% \textbf{called by}:\\ %one line in the box/ table: ``called by'' is set in bold face
% \textbf{implemented in}: \\ %another line in the box / table
2009-10-29 04:01:43 -05:00
% \hline % this line is smaller textsize for writing comments \hline makesthe bottom bar of the box
2009-10-27 12:00:08 -05:00
% \end{tabular}
% $\overrightarrow{\scriptsize % this is the arrow connecting two boxes. In can carry text.
% \begin{array}{l} % if the arrow is supposed to carry multiple lines, an array is inserted.
% \textnormal{timemanager.hh}\\ % formating within an array is tiring. Each line needs its own set of size and textnormal
% \textbf{\textcircled{\ref{prep}}} \rightarrow \textbf{\textcircled{\ref{init}}}
% \end{array}
% }$
2009-10-29 04:01:43 -05:00
\begin { tabular} { |l|} \hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { init} } } \verb +timeManager.init()+ \\
\begin { scriptsize} initialization\end { scriptsize} \\
2009-10-27 12:00:08 -05:00
\textbf { called by} : main() \\
2010-12-10 09:05:12 -06:00
\textbf { implemented in} : timemanager.hh \\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
$ \overrightarrow { } $
\begin { tabular} { |l|} \hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { init} } } \verb +timeManager.run()+\\
2009-10-29 04:01:43 -05:00
\begin { scriptsize} \end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : { main()} \\
2009-10-27 12:00:08 -05:00
\textbf { implemented in} : { timemanager.hh} \\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
{ \scriptsize
$ \overrightarrow { %an arrow under which things may be written
\begin { array} { l} % in order to be able to write multiple lines under the arrow
\textnormal { \texttt { while(!finished)} loop} \\
\textbf { \textbf { \textcircled { \ref { init} } } } \rightarrow \textbf { \textcircled { \ref { prep} } }
\end { array}
} $ }
\begin { tabular} { |l|}
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { prep} } } \verb +problem->timeIntegration()+ \\
\begin { scriptsize} execute time integration scheme \end { scriptsize} \\
2009-10-27 12:00:08 -05:00
\textbf { called by} : timemanager.hh\\
\textbf { implemented in} : boxproblem.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
\nextline
{ \scriptsize $ \overrightarrow {
\begin { array} { l}
2012-02-06 07:24:07 -06:00
\textnormal { define number of allowed \textsc { Newton} fails} \\
2010-12-10 09:05:12 -06:00
\textnormal { (each halving dt)}
2009-10-27 12:00:08 -05:00
\end { array}
} $ }
\begin { tabular} { |l|}
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { prep} } } \verb +model->update()+ \\
2009-10-29 04:01:43 -05:00
\begin { scriptsize} sth like numerical model\end { scriptsize} \\
2009-10-27 12:00:08 -05:00
\textbf { called by} : boxproblem.hh\\
\textbf { implemented in} : boxscheme.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow { } $ }
% % $\overrightarrow{}$
% % \begin{tabular}{|l|}
% % \hline
% % \textbf{\textcircled{\ref{prep}}}\verb+asImp_().updatebegin()+ \\
% % \begin{scriptsize}\textbf{applies Dirichlets}\end{scriptsize}\\
% % \begin{scriptsize}\textbf{not applied here any mroe}\end{scriptsize}\\
% % \textbf{called by}: boxscheme.hh\\
% % \textbf{implemented in}: boxscheme.hh\\
% % \hline
% % \end{tabular}
% %
% % {\scriptsize$\overrightarrow{
% %\begin{array}{l}
% % \textnormal{\texttt{while(true)}loop} \\
% % \rightarrow \textnormal{until converged}
% % \end{array} } $}
% %
2009-10-27 12:00:08 -05:00
\begin { tabular} { |l|}
\hline
2009-10-29 04:01:43 -05:00
\textbf { \textcircled { \ref { prep} } } \verb +solver.execute()+ \\
\begin { scriptsize} $ \begin { array } { l }
2010-12-10 09:05:12 -06:00
\textnormal { not only solving in there: applying \textsc { Newton} method} \\
\rightsquigarrow \textnormal { solver keeps track of things} \\
\textnormal { catching errors}
2009-10-29 04:01:43 -05:00
\end { array} $ \end { scriptsize } \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : boxmodel.hh\\
2012-02-06 07:24:07 -06:00
\textbf { implemented in} : newtonmethod.hh : $ \texttt { execute \_ ( ) } $ \\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
\nextline
2012-02-06 07:24:07 -06:00
$ \overrightarrow { \begin { array } { l }
2009-10-27 12:00:08 -05:00
\textbf { \textcircled { \ref { prep} } } \rightarrow \textbf { \textcircled { \ref { elem} } } \\
\texttt { while(ctl.newtonProceed())} \\
2012-02-06 07:24:07 -06:00
\textnormal { uLastIter = uCurrentIter(model.uCur())}
2009-10-27 12:00:08 -05:00
\end { array}
2010-12-10 09:05:12 -06:00
} $
2009-10-27 12:00:08 -05:00
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
\textbf { \textcircled { \ref { elem} } } \verb +jacobianAsm.assemble()+ \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} linearize the problem: \end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} add all element contributions to global \textsc { Jacobian} and global residual\end { scriptsize} \\
2009-10-27 12:00:08 -05:00
\textbf { called by} : newtonmethod.hh\\
2010-12-14 06:31:21 -06:00
\textbf { implemented in} : boxassembler.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
\nextline
2009-10-27 12:00:08 -05:00
$ \overrightarrow {
} $
2010-12-10 09:05:12 -06:00
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { elem} } } \verb +resetSystem_ ()+ \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} set r.h.s. (i.e. residual) and\end { scriptsize} \\
\begin { scriptsize} set \textsc { Jacobian} to zero \end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\textbf { called by} : boxassembler.hh\\
\textbf { implemented in} : boxassembler.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
{ \scriptsize $ \overrightarrow { \begin { array } { l }
\textbf { \textcircled { \ref { elem} } } \rightarrow \textbf { \textcircled { \ref { calc} } } \\
2010-12-10 09:05:12 -06:00
\texttt { loop all elements}
2009-10-27 12:00:08 -05:00
\end { array}
} $ }
\begin { tabular} { |l|}
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { calc} } } \verb +assembleElement_ ()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} call local \textsc { Jacobian} and residual assembly\end { scriptsize} \\
\textbf { called by} : boxassembler.hh\\
\textbf { implemented in} : boxassembler.hh\\
2009-10-29 04:01:43 -05:00
\hline
\end { tabular}
2009-10-27 12:00:08 -05:00
\nextline
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow {
2012-02-06 07:24:07 -06:00
} $ }
2009-10-27 12:00:08 -05:00
\begin { tabular} { |l|}
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { calc} } } \verb +model_ ().localJacobian().assemble()+ \\
\begin { scriptsize} set curr. element, update element's fin.vol.geom.\end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} reset local \textsc { Jacobian} to 0\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} update types of boundaries on this element\end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\textbf { called by} : boxassembler.hh\\
2012-02-06 07:24:07 -06:00
\textbf { implemented in} : boxlocaljacobian.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
$ \overrightarrow {
} $
\begin { tabular} { |l|}
\hline
2012-02-06 07:24:07 -06:00
\textbf { \textcircled { \ref { calc} } } \verb +prevVolVars_ .update()+, \textbf { \textcircled { \ref { calc} } } \verb +curVolVars_ .update()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} call model specific update of quantities defined for the volume:\end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} variables for the \emph { current and previous timestep...!!} \end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : boxlocaljacobian.hh\\
\textbf { implemented in} : boxelementvolumevariables.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
\nextline
$ \overrightarrow {
} $
\begin { tabular} { ||l||}
\hline \hline
\textbf { \textcircled { \ref { calc} } } \verb +update()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} calculate all two-phase specific quantites defined in the volume\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : boxelementvolumevariables.hh\\
\textbf { implemented in} : 2pvolumevariables.hh\\
\hline \hline
\end { tabular}
$ \overrightarrow {
} $
\begin { tabular} { ||l||}
\hline \hline
2012-02-06 07:24:07 -06:00
\textbf { \textcircled { \ref { calc} } } \verb +completeFluidState()_ .update()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} calculate all required fluid properties from the primary variables\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : 2pvolumevariables.hh\\
2012-02-06 07:24:07 -06:00
\textbf { implemented in} : 2pvolumevariables.hh\\
2010-12-10 09:05:12 -06:00
\hline \hline
\end { tabular}
\nextline
$ \overrightarrow {
} $
\begin { tabular} { ||l||}
\uwave { \mbox { \phantom { \textbf { \textcircled { \ref { calc} } } + e.g: density\_ = Fluidsystem::phaseDensity()+ bissl} } }
\\
2012-02-06 07:24:07 -06:00
\textbf { \textcircled { \ref { calc} } } \verb + e.g: rho = Fluidsystem::density()+ \\
\verb + fluidState.setDensity(phaseIdx,rho)+ \\
\begin { scriptsize} The fluid system does the real work: \end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} calculates densities, diffusivities ... \end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} The fluidstate save and provides them. \end { scriptsize} \\
\textbf { called by} : 2pvolumevariables.hh\\
\textbf { implemented in} : 2pvolumevariables.hh\\
2010-12-10 09:05:12 -06:00
\uwave { \mbox { \phantom { \textbf { \textcircled { \ref { calc} } } + e.g: density\_ = Fluidsystem::phaseDensity()+ bissl} } }
\\
\end { tabular}
$ \overrightarrow {
} $
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { calc} } } \verb +localResidual().eval()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} the element's local residual is calculated:\end { scriptsize} \\
\begin { scriptsize} see the next two stepstones\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : boxlocaljacobian.hh\\
\textbf { implemented in} : boxlocalresidual.hh\\
\hline
\end { tabular}
$ \overrightarrow {
} $
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { calc} } } \verb +asImp_ ().evalFluxes_ ()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} evaluate the fluxes going into each finite volume\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} how this is done is \fbox { \fbox { model specific} } (see below)\end { scriptsize} \\
\textbf { called by} : boxlocalresidual.hh\\
\textbf { implemented in} : boxlocalresidual.hh\\
\hline
\end { tabular}
2012-02-06 07:24:07 -06:00
\nextline
2010-12-14 06:31:21 -06:00
{ \scriptsize $ \overrightarrow {
2012-02-06 07:24:07 -06:00
\begin { array} { l}
\textnormal { calculating the fluxes} \\
\textnormal { takes two more steps} \\
\end { array}
2010-12-14 06:31:21 -06:00
} $ }
\begin { tabular} { ||l||}
\hline \hline
\textbf { \textcircled { \ref { calc} } } \verb +FluxVariables vars()+ \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} this is a call to a constructor: \end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} calculate the gradients and average the K\end { scriptsize} \\
\textbf { called by} : 2plocalresidual.hh\\
\textbf { implemented in} : 2pfluxvariables.hh\\
\hline \hline
\end { tabular}
$ \overrightarrow {
} $
\begin { tabular} { ||l||}
\hline \hline
\textbf { \textcircled { \ref { calc} } } \verb +computeAdvectiveFlux()+ (other models: also diffusive)\\
2012-02-06 07:24:07 -06:00
\scriptsize { for 2p-model: calculation of phase velocities} \\
2010-12-14 06:31:21 -06:00
\textbf { called by} : 2plocalresidual.hh\\
\textbf { implemented in} : 2plocalresidual.hh\\
\hline \hline
\end { tabular}
2012-02-06 07:24:07 -06:00
\nextline
2010-12-10 09:05:12 -06:00
$ \overrightarrow {
} $
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { calc} } } \verb +asImp_ ().evalVolumeTerms_ ()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} evaluate the storage and source terms for each finite volume\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} how this is done is \fbox { \fbox { model specific} } (see below)\end { scriptsize} \\
\textbf { called by} : boxlocalresidual.hh\\
\textbf { implemented in} : boxlocalresidual.hh\\
\hline
\end { tabular}
$ \overrightarrow {
} $
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { calc} } } \verb +asImp_ ().evalBoundary_ ()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} deal with the boundary conditions\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} may be \fbox { \fbox { model specific} } \end { scriptsize} \\
\textbf { called by} : boxlocalresidual.hh\\
\textbf { implemented in} : boxlocalresidual.hh (or modelspecific)\\
\hline
\end { tabular}
2009-10-27 12:00:08 -05:00
$ \overrightarrow {
} $
\begin { tabular} { |l|}
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { calc} } } \verb +asImp_ ().evalPartialDerivative()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} actually calculate the element's (local) \textsc { Jacobian} matrix\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} a property chooses backward/central/foward differences\end { scriptsize} \\
\begin { scriptsize} here: central differences\end { scriptsize} \\
\textbf { called by} : boxlocaljacobian.hh\\
\textbf { implemented in} : boxlocaljacobian.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
\nextline
$ \overrightarrow {
} $
2010-12-14 06:31:21 -06:00
\begin { minipage} { 0.50\textwidth }
\begin { scriptsize} \textnormal { approximation of partial derivatives: numerical differentiation} \end { scriptsize} \\
\begin { scriptsize} \textnormal { add $ \pm \epsilon $ solution, divide difference of residual by $ 2 \epsilon $ } \end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} \textnormal { all partial derivatives for the element from the local \textsc { Jacobian} matrix} \end { scriptsize} \\
2009-10-27 12:00:08 -05:00
$ \left \lbrace
\begin { tabular} { l} %these question marks are for the \verb, not meant as ``unclear''
2010-12-10 09:05:12 -06:00
\verb ?priVars[pvIdx]+=eps?\\
2009-10-27 12:00:08 -05:00
\begin { scriptsize} \textnormal { this is adding eps to the current solution} \end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\verb ?curVolVars_ [scvIdx].update(+eps)?\\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} \textnormal { recalculate volume variables, having $ \epsilon $ added} \end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\verb ?localResidual().eval(+eps)?\\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} \textnormal { calculate local residual for modified solution as before: involves} \end { scriptsize} \\
{ \scriptsize $ \begin { array } { l }
2010-12-10 09:05:12 -06:00
\textnormal { - \textbf { computeFlux} } \\
\textnormal { - \textbf { computeStorage} } \\
\textnormal { - \textbf { computeSource} } \\
2010-12-14 06:31:21 -06:00
\end { array} $ } \\
2010-12-10 09:05:12 -06:00
\verb ?store the residual()?\\
2010-12-14 06:31:21 -06:00
\verb ?repeat for priVars[pvIdx]-=eps?\\
\verb ?derivative is (residual(+eps) - residual(-eps))/2eps?\\
2009-10-27 12:00:08 -05:00
\end { tabular}
\right .
2012-02-24 05:16:37 -06:00
$
2009-10-27 12:00:08 -05:00
\end { minipage}
2012-02-06 07:24:07 -06:00
\hspace { .25\textwidth }
2010-12-14 06:31:21 -06:00
{ \scriptsize $ \overrightarrow { } $ }
2010-12-10 09:05:12 -06:00
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { calc} } } \verb +assembleElement_ ()+ \\
2012-02-06 07:24:07 -06:00
\verb +model_ ().localJacobian().assemble()+ \\
\begin { scriptsize} Residual of the current solution is now\end { scriptsize} \\
\begin { scriptsize} ``numerically differentiated'', for the element i.e.\end { scriptsize} \\
\begin { scriptsize} the local \textsc { Jacobian} matrix is calculated. \end { scriptsize} \\
\textbf { called by} : boxassembler.hh \\
2010-12-14 06:31:21 -06:00
\textbf { implemented in} : boxassembler.hh\\
2010-12-10 09:05:12 -06:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2012-02-06 07:24:07 -06:00
{ \scriptsize $ \overrightarrow { } $ }
$ \left |
\begin { array} { l}
\textnormal { The contribution of a single element is done.} \\
\textnormal { Now, it needs to be added to the global quantities:} \\
\textnormal { Add to global residual and global \textsc { Jacobian} .}
\end { array}
\right |$
{ \scriptsize $ \overrightarrow { } $ }
2010-12-10 09:05:12 -06:00
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { calc} } } \verb ?resdidual_ [globI]+=? \\
\verb ? model_ ().globalJacobian().resdidual(i)? \\
\begin { scriptsize} Add to global residual.\end { scriptsize} \\
\textbf { called by} : continuing in the function. \\
2010-12-14 06:31:21 -06:00
\textbf { implemented in} : boxassembler.hh\\
2010-12-10 09:05:12 -06:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
\nextline
{ \scriptsize $ \overrightarrow {
\begin { array} { l}
\textnormal { loop vertices} \\
\textnormal { of an element}
\end { array} } $ }
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { calc} } } \verb ?(*matrix_ )[globI][globJ] +=? \\
\verb ? model_ ().localJacobian().mat(i,j)? \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} Add to global \textsc { Jacobian} .\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : continuing in the function. \\
2010-12-14 06:31:21 -06:00
\textbf { implemented in} : boxassembler.hh\\
2010-12-10 09:05:12 -06:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
{ \scriptsize $ \overrightarrow {
2010-12-10 09:05:12 -06:00
\begin { array} { l}
\textbf { \textcircled { \ref { calc} } } \rightarrow \textbf { \textcircled { \ref { elem} } } \\
\end { array}
2009-10-27 12:00:08 -05:00
} $ }
2010-12-10 09:05:12 -06:00
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { elem} } } \verb ?assemble()? \\
\begin { scriptsize} Assembling of elements to global quantities is done.\end { scriptsize} \\
2010-12-14 06:31:21 -06:00
%\begin{scriptsize}In case: print partial assembling stuff\end{scriptsize}\\
2010-12-10 09:05:12 -06:00
\textbf { called by} : continuing in the function. \\
2010-12-14 06:31:21 -06:00
\textbf { implemented in} : boxassembler.hh\\
2010-12-10 09:05:12 -06:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
\nextline
2010-12-10 09:05:12 -06:00
{ $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2012-02-06 07:24:07 -06:00
\textbf { \textcircled { \ref { elem} } } \verb ?while newtonProceed() ?\\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} Print information.\end { scriptsize} \\
\begin { scriptsize} start/ stop timer.\end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\textbf { called by} : continuing in the function, $ \texttt { execute \_ ( ) } $ \\
2010-12-10 09:05:12 -06:00
\textbf { implemented in} : newtonmethod.hh\\
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow
{ \begin { array} { l}
\textnormal { set delta Vector to zero} \\
\textnormal { (this is what is} \\
\textnormal { solved for later)} \\
\end { array} }
$ }
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2012-02-06 07:24:07 -06:00
\textbf { \textcircled { \ref { elem} } } \verb ?newtonSolveLinear() ?\\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} Ask the linear solver to solve the system.\end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} i.e. : give \textsc { Jacobian} (matrix), delta(x), r.h.s.(residual) to linear solver\end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} $ \nabla r ( x ^ k ) \cdot \Delta x ^ k = r ( x ^ k ) $ \end { scriptsize} \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} tricky: each \textsc { Newton} step solves a linear system of equations. \end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\textbf { called by} : continuing in the function, $ \texttt { execute \_ ( ) } $ . \\
2010-12-10 09:05:12 -06:00
\textbf { implemented in} : newtonmethod.hh\\
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
\nextline
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { elem} } } \verb +newtonSolveLinear()+\\
\begin { scriptsize} Catching errors.\end { scriptsize} \\
\textbf { called by} : newtonmethod.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { elem} } } \verb +solveLinear_ ()+\\
\verb +typedef Dune::PDELab::ISTLBackend_ SEQ_ BCGS_ SSOR Solver;+\\
\begin { scriptsize} Selecting Solver (BiCGStab) and preconditioner (SSOR)\end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} Instantiate linear solver (set max number of iterations, verbosity)\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : newtoncontroller.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
2009-10-29 04:01:43 -05:00
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
\nextline
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { elem} } } \verb +solver.apply(A, x, bTmp, residReduction)+\\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} Finally handing matrix, unknowns and r.h.s. to the solver backend.\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} Preconditioning and solving the system. \end { scriptsize} \\
\textbf { called by} : newtoncontroller.hh\\
\textbf { implemented in} : istlsolverbackend.hh\\
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { elem} } } \verb +solveLinear_ ()+\\
\begin { scriptsize} dealing with errors, infs, nans \end { scriptsize} \\
\textbf { called by} : continuing in function\\
\textbf { implemented in} : newtoncontroller.hh\\
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
\nextline
{ \scriptsize $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { elem} } } \verb +newtonupdateRelError()+\\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} calculate the \emph { relative error} between two iterations\end { scriptsize} \\
\begin { scriptsize} \quad find the prim. var. that changed most between \end { scriptsize} \\
\begin { scriptsize} \quad last(\verb +uLastIter+) and current (\verb +uCurrentIter+) \end { scriptsize} \\
\begin { scriptsize} \quad \textsc { Newton} iteration.\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : newtoncontroller.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
2009-10-29 04:01:43 -05:00
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { elem} } } \verb +ctl.newtonUpdate()+\\
\begin { scriptsize} We solved for the change in solution, but need the solution:\end { scriptsize} \\
\begin { scriptsize} Calculate current (this iteration) solution\end { scriptsize} \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} \quad from last (iteration) solution and current (iteration) change in solution:\end { scriptsize} \\
\begin { scriptsize} $ x ^ { k + 1 } = x ^ k - \Delta x ^ k $ where $ \Delta x ^ k = ( \nabla r ( x ^ k ) ) ^ { - 1 } \cdot r ( x ^ k ) $ \end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : newtonmethod.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
\hline
2009-10-27 12:00:08 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
\nextline
{ \scriptsize $ \overrightarrow { }
$ }
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { elem} } } \verb +ctl.newtonEndStep()+\\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} Increase counter for number of \textsc { Newton} steps. \end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} Print info. \end { scriptsize} \\
\textbf { called by} : newtonmethod.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
\hline
\end { tabular}
{ \scriptsize $ \overrightarrow
{ \begin { array} { l}
2012-02-06 07:24:07 -06:00
\textnormal { check whether to do another \textsc { Newton} iteration:} \\
2010-12-14 06:31:21 -06:00
\textnormal { that is: check if the error is below tolerance or} \\
\textnormal { maximum number of iterations was reached.} \\
2010-12-10 09:05:12 -06:00
\end { array} }
$ }
{ \scriptsize $ \overrightarrow { \begin { array } { l }
\textbf { \textcircled { \ref { elem} } } \rightarrow \textbf { \textcircled { \ref { prep} } } \\
\textnormal { \textsc { Newton} done.} \\
2010-12-14 06:31:21 -06:00
\textnormal { if failed $ \rightsquigarrow $ halve timestep size, restart loop}
2010-12-10 09:05:12 -06:00
\end { array}
2009-10-27 12:00:08 -05:00
} $ }
2010-12-10 09:05:12 -06:00
\nextline
2009-10-27 12:00:08 -05:00
\begin { tabular} { |l|}
\hline
2010-12-10 09:05:12 -06:00
\textbf { \textcircled { \ref { prep} } } \verb +ctl.newtonEnd()+ \\
\begin { scriptsize} Tell the controller we are done\end { scriptsize} \\
\textbf { called by} : newtonmethod.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
2012-02-06 07:24:07 -06:00
\hline
2009-10-29 04:01:43 -05:00
\end { tabular}
2010-12-10 09:05:12 -06:00
{ \scriptsize $ \overrightarrow { } $ }
\begin { tabular} { |l|}
\hline
2012-02-06 07:24:07 -06:00
\textbf { \textcircled { \ref { prep} } } \verb +ctl.updateSuccessful()+ \\
2010-12-10 09:05:12 -06:00
\begin { scriptsize} Can be filled by the \fbox { \fbox { model} } .\end { scriptsize} \\
\textbf { called by} : boxmodel.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
\hline
\end { tabular}
{ \scriptsize $ \overrightarrow
{ \begin { array} { l}
\textnormal { in while(!finished)} \\
\end { array} }
$ }
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { prep} } } \verb +postTimeStep()+ \\
2010-12-14 06:31:21 -06:00
\begin { scriptsize} Give the \fbox { \fbox { problem} } the chance to\end { scriptsize} \\
\begin { scriptsize} post-process the solution.\end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : boxmodel.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
\hline
\end { tabular}
\nextline
{ \scriptsize $ \overrightarrow { } $ }
\begin { tabular} { |l|}
\hline
\textbf { \textcircled { \ref { prep} } } \verb +suggestTimestepSize()+ \\
2012-02-06 07:24:07 -06:00
\begin { scriptsize} Determine new time step size from number of \textsc { Newton} steps. \end { scriptsize} \\
2010-12-10 09:05:12 -06:00
\textbf { called by} : timemanager.hh, boxproblem.hh\\
\textbf { implemented in} : newtoncontroller.hh\\
\hline
\end { tabular}
{ \scriptsize $ \overrightarrow
{ \begin { array} { l}
\textnormal { write output} \\
2012-02-06 07:24:07 -06:00
\textnormal { uPrev $ \leftarrow $ uCur} \\
2010-12-10 09:05:12 -06:00
\textnormal { time += dt, timestepIdx++} \\
\textnormal { deal with restart and episodes } \\
\end { array} }
$ }
2009-10-27 12:00:08 -05:00
{ \scriptsize $ \overrightarrow {
\begin { array} { l}
\textnormal { timemanager.hh} \\
\textbf { \textcircled { \ref { prep} } } \rightarrow \textbf { \textcircled { \ref { init} } }
\end { array}
} $ }
% \begin{tabular}{|l|}
% \hline
2009-10-29 04:01:43 -05:00
% \textbf{\textcircled{\ref{calc}}}\verb++ \\
% \begin{scriptsize}\end{scriptsize}\\
2009-10-27 12:00:08 -05:00
% \textbf{called by}:\\
% \textbf{implemented in}: \\
2009-10-29 04:01:43 -05:00
% \hline
% \end{tabular}
2009-10-27 12:00:08 -05:00
% $\overrightarrow{\scriptsize
% }$
}
2010-12-10 09:05:12 -06:00
\end { landscape}
2010-11-10 04:15:37 -06:00
\normalsize
2010-12-10 09:05:12 -06:00
\newpage
% Original pagestyle (headings and footer) were switched off, in order to get mroe space for the flowchart.
\pagestyle { scrheadings}
2010-12-14 06:31:21 -06:00
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "dumux-handbook"
%%% End: