Commit 77f566fe authored by Hélène Ruffieux's avatar Hélène Ruffieux Committed by Simone Deparis
Browse files

update of the tutorial

parent 23a0f806
This diff is collapsed.
......@@ -10,11 +10,11 @@ software library \thelibrary (life 5).
The major objectives of this document are:
\begin{enumerate}
\item To compile the software library.
\item To provide examples of its use.
\item to compile the software library,
\item to provide examples of its use.
\end{enumerate}
\section{Language and nomenclature convection}
For a more detailed overview of \lifev's main features (management of boundary conditions, time and space discretization, algebraic solvers and preconditioners, etc), see the doxygen webpage: \url{http://cmcsforge.epfl.ch/www/lifev/doxygen-release-2.2.0/lifev/}.
\section{Language and nomenclature convention}
\label{sec:lang-nomencl-conv}
\texttt{typesetting font style} is used to indicate parts of
......@@ -25,20 +25,18 @@ computer code, configure shell scripts, command-prompt instructions and webpages
The software source, its documentation and all related documents (this
one included) are kept in a repository under revision control
using \verb!git!\ixns{git}{versioning}\footnote{git is the fast version control system}. Its goal
using \verb!git!\ixns{git}{versioning}\footnote{git is the fast version control system.}. Its goal
is to provide tools to manage software development in a concurrent environment.
See \url{http://git-scm.com/documentation}
for a tutorial.
A web site {\it\`a la} Sourceforge
\footnote{\url{http://www.sourceforge.net}}
As mentioned above, a website {\it\`a la} Sourceforge\footnote{\url{http://www.sourceforge.net}}
\url{http://cmcsforge.epfl.ch} has been set up
to host the source code and help the software management.
It requires that you open an account
\footnote{\url{https://cmcsforge.epfl.ch/account/register.php}}
It requires that you open an account\footnote{\url{https://cmcsforge.epfl.ch/account/register.php}}
there and ask to join the project \lifev using the link at the
bottom of the developers' list.
Once you'd become a member, you'll gain access to all the facilities:
Once you would become a member, you will gain access to all the facilities:
tracker, task manager, git repository, forums, document manager and a few other
tools which are very useful if not absolutely essential to such a project.
......@@ -56,9 +54,15 @@ where one can get in touch with other users and developers.
\label{compile-lifev}
There are a few compilation tools and libraries we need to build and install before
compiling \lifev.
compiling \lifev, here is a short presentation. Note that, in addition to the following description, the complete installation steps are available on the following webpages:
\begin{enumerate}
\item \url{http://www.lifev.org/documentation/installation-tutorial}\,,
\item \url{http://www.lifev.org/documentation/lifev-on-macosx}\,.
\end{enumerate}
In computer science a library is a set of subroutines or classes used to develop software.
In computer science, a library is a set of subroutines or classes used to develop software.
Usually they are downloaded as a so called ``tarball" file
compressed using the \verb!tar! command. There are different ways to compress
libraries but the most common is to use the command \verb!tar -cvf! and further compress
......@@ -86,21 +90,19 @@ and linked with the compiler flag \verb!-l! followed by its name.
\label{sec:comp-envir}
\lifev depends on a number of tools at compilation time that are part
of the \ix{autotools} from the GNU project \footnote{\url{http://www.gnu.org}}
of the \ix{autotools} from the GNU project\footnote{\url{http://www.gnu.org}}
available in most Linux OS:
\begin{itemize}
\item \verb!libtool 1.5!\ixns{libtool}{autotools} or newer (currently $2.2.6$)
\item \verb!automake 1.7!\ixns{automake}{autotools} or newer (currently $1.9.6$)
\item \verb!autoconf 2.52!\ixns{autoconf}{autotools} or newer (currently $2.65$)
\item \verb!g++-4.0!\ixns{g++}{compilers} or newer (currently $4.4.4$)
\item \verb!CMake 2.8! or newer
\item \verb!libtool 1.5!\ixns{libtool}{autotools} or newer (currently $2.4.2$)%$2.2.6$)
\item \verb!automake 1.7!\ixns{automake}{autotools} or newer (currently $1.12.2$)%$1.9.6$)
\item \verb!autoconf 2.52!\ixns{autoconf}{autotools} or newer (currently $2.69$)%$2.65$)
\item \verb!g++-4.0!\ixns{g++}{compilers} or newer (currently $4.5.4$)%$4.4.4$)
\item \verb!CMake 2.8! or newer.
\end{itemize}
In Mac OS X you get the autotools in Xcode and cmake can be
installed using MacPorts \verb!sudo port install cmake!.
You can check the version of a command typing the command followed by \verb!--help!,
installed using MacPorts \verb!sudo port install cmake!. You can check the version of a command typing the command followed by \verb!--help!,
for example type \verb!cmake --help!.
\lifev depends on several optimized libraries, you can check if you have them installed
......@@ -119,7 +121,7 @@ The message passing interface for C and Fortran compilers. For example \url{http
Once installed you can check the necessary flags for its use by typing
\verb!mpicc --show!.
In Mac OS X using MacPorts install a fortran compiler typing
\verb!sudo port install gcc46! and openmpi with \verb!sudo port install openmpi!.
\verb!sudo port install gcc46! and openmpi with \verb!sudo port install openmpi!. Note however that MPI should be natively installed if you installed XCode.
\item \verb!BOOST!.
Libraries to extend the functionality of C$++$. Check if they exist on your computer, they are many
......@@ -157,7 +159,7 @@ Copy \verb!make.inc.example! to \verb!make.inc! and edit the path to the blas li
and type \verb!make!.
\item \verb!PARMETIS!.
Download from \url{http://glaros.dtc.umn.edu/gkhome/metis/parmetis/download}. Set \verb!CC=mpicc!
You can download it from \url{http://glaros.dtc.umn.edu/gkhome/metis/parmetis/download}. Set \verb!CC=mpicc!
in \verb!Makefile.in!. and type \verb!make!. In Mac OS X you need the include path flags
\verb!-I/usr/include! and \verb!-I/usr/include/malloc!.
......@@ -251,7 +253,7 @@ After the configuration is done, just type
\begin{verbatim}
make
\end{verbatim}
that will compile the static files using 4 processors and further
that will compile the static files and further
\begin{verbatim}
make install
\end{verbatim}
......@@ -267,12 +269,11 @@ The trilinos library is now installed in the build directory you created.
You need first to have an account on \url{http://cmcsforge.epfl.ch} and
be part of the \lifev project, see~\ref{sec:software-management}.
\noindent First, you need to checkout \lifev. \verb!git! has
First, you need to checkout \lifev. \verb!git! has
been configured to use \ixv{ssh} and your \verb!ssh! keys to
access the repository via \verb!ssh! without entering your password.
When your ssh agent is properly configure, log into your cmcsforge account and
access the repository via \verb!ssh! without entering your password. When your ssh agent is properly configure, log into your cmcsforge account and
go to the \verb!Account Maintenance! tab. At the bottom of the page, in the
\verb!Shell Account Information!, you will see \verb!Edit Keys!. click on that link,
\verb!Shell Account Information!, you will see \verb!Edit Keys!. Click on that link,
input your public key, then click on \verb!update!. The server will take up to one
hour to update your ssh account information, then you will be able to access the
repositories without password.\\
......@@ -289,65 +290,110 @@ cd lifev
\end{verbatim}
and type
\begin{verbatim}
git clone developername@cmcsforge.epfl.ch:/gitroot/lifev/admin
git clone developername@cmcsforge.epfl.ch:/gitroot/lifev/cmake
\end{verbatim}
\noindent Second, you have to generate the compilation environment by typing
\begin{verbatim}
make -f Makefile.git
\end{verbatim}
%\begin{verbatim}
%git clone developername@cmcsforge.epfl.ch:/gitroot/lifev/admin
%\end{verbatim}
%\noindent Second, you have to generate the compilation environment by typing
%\begin{verbatim}
%make -f Makefile.git
%\end{verbatim}
\noindent Third, you must make a build directory apart from the
Second, you must make a build directory apart from the
lifev sources directory, for example in your home you can have a
\verb!lib! directory with a \verb!lifev! subdirectory and further
an optimized version subdirectory \verb!opt! or the debugging mode
subdirectory \verb!debug!, or something similar according to your own taste.
subdirectory \verb!debug!, or something similar according to your own taste.
Third, you have to execute the
\verb+do-configure+ shell script in the \verb!opt! directory.
It will automatically check the availability of the needed components
for \lifev compilation :
\noindent Fourth, you have to execute the script
\ixvs{configure}{autotools}
it will automatically check the availability of the needed components
for \lifev compilation. Type
\begin{verbatim}
./configure \
--with-trilinos-lib=/your_trilinos_library_path/ \
--with-trilinos-include=/your_trilinos_include_path/ \
--enable-opt \
--with-mpi=/usr/lib/openmpi \
--with-mpi-lib=/usr/lib/openmpi/lib \
--with-mpi-include=/usr/include/openmpi \
--with-parmetis-include=/your_parmetis_include_path/ \
--with-parmetis-lib=/your_parmetis_library_path/ \
--with-umfpack-include=/your_umfpack_include_path/ \
--with-umfpack-lib=/your_umfpack_library_path/ \
--with-amd-include=/your_amd_include_path/ \
--with-amd-lib=/your_amd_library_path/ \
--with-hdf5=/usr \
--prefix=/your_lifeV_library_install_path/
CXXFLAGS ="-O2"
cmake \
-D CMAKE_BUILD_TYPE:STRING=RELEASE \
\
-D TPL_ENABLE_MPI:BOOL=ON \
\
-D ParMETIS_INCLUDE_DIRS:PATH=/parmetis_include_path/ \
-D ParMETIS_LIBRARY_DIRS:PATH=/parmetis_library_path/ \
\
-D TPL_ENABLE_UMFPACK:BOOL=ON \
\
-D TPL_ENABLE_BLAS:BOOL=ON \
-D BLAS_LIBRARY_DIRS:PATH=/blas_library_path/ \
-D BLAS_LIBRARY_NAMES:STRING="blas_library_name" \
-D TPL_ENABLE_LAPACK:BOOL=ON \
-D LAPACK_LIBRARY_DIRS:PATH=/lapack_library_path/ \
-D LAPACK_LIBRARY_NAMES:STRING="lapack_library_name" \
-D TPL_ENABLE_Boost:BOOL=ON \
-D TPL_Boost_INCLUDE_DIRS:STRING=/boost_include_path/ \
\
-D TPL_ENABLE_Trilinos:STRING=ON \
-D Trilinos_INCLUDE_DIRS:PATH=/trilinos_include_path/ \
-D Trilinos_LIBRARY_DIRS:PATH=/trilinos_library_path/ \
\
-D LifeV_VERBOSE_CONFIGURE:BOOL=OFF \
-D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \
\
-D LifeV_ENABLE_STRONG_CXX_COMPILE_WARNINGS:BOOL=OFF \
\
-D LifeV_ENABLE_ALL_PACKAGES:BOOL=ON \
-D LifeV_ENABLE_TESTS:BOOL=ON \
-D LifeV_ENABLE_EXAMPLES:BOOL=ON \
-D CMAKE_INSTALL_PREFIX:PATH=$MY_LIB_DIR \
$* \
$BASE_DIR/lifev
\end{verbatim}
to configure with optimized libraries, or change the line \verb!--enable-opt! to
\verb!--enable-debug! and \verb!CXXFLAGS="-g2 -O0"! to build the libraries
in debugging mode.
Remember to specify the
path to your build directory (external to the sources directory) with the flag \verb!--prefix!.
Change the path and name of mpi, mpi library and include if yours is different.
You can check for additional flags for mpi typing \verb!mpicc -show!.
Do the same in the \verb!debug! directory, replacing the first line by \begin{verbatim} -D CMAKE_BUILD_TYPE:STRING=DEBUG\ \end{verbatim}
%\begin{verbatim}
%./configure \
% --with-trilinos-lib=/your_trilinos_library_path/ \
% --with-trilinos-include=/your_trilinos_include_path/ \
% --enable-opt \
% --with-mpi=/usr/lib/openmpi \
% --with-mpi-lib=/usr/lib/openmpi/lib \
% --with-mpi-include=/usr/include/openmpi \
% --with-parmetis-include=/your_parmetis_include_path/ \
% --with-parmetis-lib=/your_parmetis_library_path/ \
% --with-umfpack-include=/your_umfpack_include_path/ \
% --with-umfpack-lib=/your_umfpack_library_path/ \
% --with-amd-include=/your_amd_include_path/ \
% --with-amd-lib=/your_amd_library_path/ \
% --with-hdf5=/usr \
% --prefix=/your_lifeV_library_install_path/
% CXXFLAGS ="-O2"
%\end{verbatim}
%\noindent to configure with optimized libraries, or change the line \verb!--enable-opt! to
%\verb!--enable-debug! and \verb!CXXFLAGS="-g2 -O0"! to build the libraries
%in debugging mode.
%
%Remember to specify the
%path to your build directory (external to the sources directory) with the flag \verb!--prefix!.
%
%Change the path and name of mpi, mpi library and include if yours is different.
%You can check for additional flags for mpi typing \verb!mpicc -show!.
\noindent Finally, you just have to use \ixv{make} to compile \lifev libraries and documentation.
Enter
\begin{verbatim}
make -j4
make -j 4
make install
\end{verbatim}
\noindent Be careful because \verb!configure! will fail if you have already compiled
\lifev in the source directory. Therefore is not a good idea to build in the sources.
\noindent Be careful because \verb!do-configure! will fail if you have already compiled
\lifev in the source directory. Therefore is not a good idea to build in the sources.
\subsection{Compilation from Official Distribution}
\label{sec:comp-from-offic}
......@@ -367,50 +413,58 @@ tar -xzf lifev-x.y.z.tar.gz
\item configure it following the instructions of the previous section,
\item compile and install it
\begin{verbatim}
make -j4
make -j 4
make install
\end{verbatim}
\end{enumerate}
\subsection{Compiling Testsuite}
\noindent \lifev comes with a testsuite covering a lot of features. It is located in the directory \verb+testsuite+
\subsection{Compiling Testsuites}
\noindent \lifev comes with testsuites covering a lot of features. They are located in different directories, mainly depending on the physical or technical aspects they are concerned with. For example, you can find a number of tests in the \verb+core+
directory (\verb+lifev/lifev/core/testsuite+) but \verb+darcy, fsi, navier_stokes, structure+ are other directories where you can find tests.%It is located in the directory \verb+testsuite+
%\begin{verbatim}
%|-- data
%|-- test_bdf
%|-- test_darcy
%|-- test_essentialbc
%|-- test_fe
%|-- test_fsi_newton
%|-- test_fsi_picard
%|-- test_linearelasticity
%|-- test_matrix
%|-- test_mesh
%|-- test_robin
%|-- test_naturalbc
%|-- test_ns_bdf
%|-- test_ns_cyl
%|-- test_ns_sstress
%|-- test_p2
%|-- test_postproc
%`-- test_q1
%\end{verbatim}
All these tests are automatically compiled once you have installed \lifev. To run them just type
\begin{verbatim}
|-- data
|-- test_bdf
|-- test_darcy
|-- test_essentialbc
|-- test_fe
|-- test_fsi_newton
|-- test_fsi_picard
|-- test_linearelasticity
|-- test_matrix
|-- test_mesh
|-- test_robin
|-- test_naturalbc
|-- test_ns_bdf
|-- test_ns_cyl
|-- test_ns_sstress
|-- test_p2
|-- test_postproc
`-- test_q1
make test
\end{verbatim}
\noindent In order to compile the testsuite, you need the following steps
\begin{verbatim}
cd lifev-directory/testsuite
make check
\end{verbatim}
where the lifev-directory is the directory where you unpacked \lifev.
\noindent If you just want to compile a specific test, say \verb+test_darcy+
\begin{verbatim}
cd lifev-directory/testsuite/data
make check
cd lifev-directory/testsuite/test_darcy
make test_darcy OR make check
\end{verbatim}
%\noindent In order to compile a testsuite, you need the following steps
%\begin{verbatim}
%cd <lifev-directory>/testsuite
%make check
%\end{verbatim}
%where the lifev-directory is the directory where you unpacked \lifev.
%
%\noindent If you just want to compile a specific test, say \verb+test_darcy+
%\begin{verbatim}
%cd lifev-directory/testsuite/data
%make check
%cd lifev-directory/testsuite/test_darcy
%make test_darcy OR make check
%\end{verbatim}
%
%%%%%%%%%%%%% Some Settings for emacs and auc-TeX
......
\documentclass[a4paper, 12pt, report]{lifestyle}
\usepackage{rcs}
\usepackage[top=3.6cm,bottom=3.6cm,right=3.2cm,left=3.5cm]{geometry}
\usepackage{bm}
\RCS $Revision: 1.7 $
\RCS $date: 2010-10-08 13:00:00 $
\RCS $Revision: 1.8 $
\RCS $Date: 2012-08-16 17:00:00$
\RCS $State: Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -108,6 +110,7 @@
\newcommand{\invNN}{{S'}_\mf^{-1}(\lambda^k) + S'_\ms^{-1}(\lambda^k)}
\title{\lifetitle{LifeV User Manual}
{G. Fourestey, S. Deparis}
}
......@@ -119,14 +122,16 @@
%%\includeonly{lifev-dev_generalities,lifev-dev_howto}
\begin{document}
\maketitle
\phantom{dummy text}
\vfill
This manual is for LifeV (version 1.3.1, October 2010), a library for scientific computing
This manual is for LifeV (version 2.2.1, March 2012), %1.3.1, October 2010),
a library for scientific computing
using finite elements, specially aimed at fluid-structure interaction and blood flow simulation.
Copyright (C) 2001-2010 EPFL, INRIA, Polytechnico Di Milano.
Copyright (C) 2001- 2012 EPFL, INRIA, Polytechnico Di Milano.
\tableofcontents
......
......@@ -8,78 +8,79 @@
% E-MAIL: foureste@iacspc.epfl.ch
%
% ORIG-DATE: 4-Feb-09 at 14:11:50
% LAST-MOD: 5-Feb-09 at 18:11:24 by Gilles Fourestey
% LAST-MOD: 16-Aug-12 at 17:00:00 by Hélène Ruffieux
%
% DESCRIPTION:
% DESCRIP-END.
Now that we have decribed a simple stationary problem, let's have a look at the evolutionary
Now that we have described a simple stationary problem, let's have a look at the evolutionary
case. In this example, we will consider the same domain, but this time we will solve the
Navier-Stokes problem \ixn{Navier-Stokes Problem}. Starting from the Oseen problem (\ref{eqn-oseen})
\begin{equation*}
\left\{
\begin{array}{rl}
\displaystyle \alpha u + \beta \cdot \nabla u - \nu \Delta u+
\nabla p & = f \\
\displaystyle \nabla \cdot u & = 0
\begin{array}{rll}
\displaystyle \alpha \bm{u} + \bm{\beta} \cdot \nabla \bm{u} - \nu \Delta \bm{u}+
\nabla p & = \bm{f}& \mbox{ in } \Omega\\
\displaystyle \nabla \cdot \bm{u} & = 0& \mbox{ in } \Omega
\end{array}
\right.
\end{equation*}
plus boundary conditions.
We want to solve the non-stationary Navier-Stokes problem
\begin{equation*} \label{eqn-navierstokes}
\left\{
\begin{array}{rl}
\displaystyle \frac{\partial u}{\partial t} + u \cdot \nabla u - \nu \Delta u+
\nabla p & = f \\
\displaystyle \nabla \cdot u & = 0
\begin{array}{rll}
\displaystyle \frac{\partial \bm{u}}{\partial t} + \bm{u} \cdot \nabla \bm{u} - \nu \Delta \bm{u}+
\nabla p & = \bm{f} & \mbox{ in } \Omega\\
\displaystyle \nabla \cdot \bm{u} & = 0& \mbox{ in } \Omega
\end{array}
\right.
\end{equation*}
which can be written, using a semi-discretization of the time partial derivative as
\noindent which can be written, using a semi-discretization of the time partial derivative as
\begin{equation*} \label{eqn-nsnl}
\left\{
\begin{array}{rl}
\displaystyle \alpha u^{n+1} + u^{n+1} \cdot \nabla u^{n+1} - \nu \Delta u^{n+1}+
\nabla p^{n+1} & = f^n \\
\displaystyle \nabla \cdot u & = 0 \\
\begin{array}{rll}
\displaystyle \alpha \bm{u}^{n+1} + \bm{u}^{n+1} \cdot \nabla \bm{u}^{n+1} - \nu \Delta \bm{u}^{n+1}+
\nabla p^{n+1} & = \bm{f}^n& \mbox{ in }\Omega \\
\displaystyle \nabla \cdot \bm{u} & = 0 & \mbox{ in } \Omega\,. \\
\end{array}
\right.
\end{equation*}
Where $\alpha$ is a constant which depends on the time discretization order,
$\Delta t$ is the time step, $u^{n+1}$ and $p^{n+1}$
Here $\alpha$ is a constant which depends on the time discretization order,
$\Delta t$ is the time step, $\bm{u}^{n}$ and $p^{n}$
are the velocity and the pressure at the time $t^n = n\Delta t$.
Note that $f^n$ now contains terms resulting from the time discretization.
Using a linearization $\beta^n$ of (\ref{eqn-nsnl}) around $u^{n+1}$,
Note that $\bm{f}^n$ now contains terms resulting from the time discretization.
Using a linearization $\bm{\beta}^n$ of (\ref{eqn-nsnl}) around $\bm{u}^{n+1}$,
we get the full semi-discrete linearized Navier-Stokes
equations
\begin{equation*} \label{eqn-ns}
\left\{
\begin{array}{rl}
\displaystyle \alpha u^{n+1} + \beta^n \cdot \nabla u^{n+1} - \nu \Delta u^{n+1}+
\nabla p^{n+1} & = f^n \\
\displaystyle \nabla \cdot u & = 0 \\
\begin{array}{rll}
\displaystyle \alpha \bm{u}^{n+1} + \bm{\beta}^n \cdot \nabla \bm{u}^{n+1} - \nu \Delta \bm{u}^{n+1}+
\nabla p^{n+1} & = \bm{f}^n& \mbox{ in } \Omega \\
\displaystyle \nabla \cdot \bm{u} & = 0& \mbox{ in } \Omega\,. \\
\end{array}
\right.
\end{equation*}
Solving (\ref{eqn-ns}) using the framework we used for the stationary driven cavity is not difficult.
Instead of setting $\alpha$, $\beta$ and $f^n$ to zero, we give them their proper values. For instance,
Solving (\ref{eqn-ns}) using the framework that we introduced for the stationary driven cavity is not difficult.
Instead of setting $\alpha$, $\bm{\beta}$ and $\bm{f}^n$ to zero, we give them their proper values. For instance,
consider the first order discretization in time
\begin{equation*} \label{eqn-nso1}
\left\{
\begin{array}{rl}
\displaystyle \frac {u^{n+1}}{\Delta t} + u^n \cdot \nabla u^{n+1} - \nu \Delta u^{n+1}+
\nabla p^{n+1} & = \displaystyle \frac{u^n}{\Delta t} \\
\displaystyle \nabla \cdot u & = 0. \\
\begin{array}{rll}
\displaystyle \frac {\bm{u}^{n+1}}{\Delta t} + \bm{u}^n \cdot \nabla \bm{u}^{n+1} - \nu \Delta \bm{u}^{n+1}+
\nabla p^{n+1} & = \displaystyle \frac{\bm{u}^n}{\Delta t} & \mbox{ in } \Omega \\
\displaystyle \nabla \cdot \bm{u} & = 0 & \mbox{ in } \Omega\,. \\
\end{array}
\right.
\end{equation*}
......@@ -88,98 +89,191 @@ Or the second order discretization
\begin{equation*} \label{eqn-nso2}
\left\{
\begin{array}{rl}
\displaystyle \frac {3u^{n+1}}{2\Delta t} + u^n \cdot \nabla u^{n+1} - \nu \Delta u^{n+1}+
\nabla p^{n+1} & = \displaystyle \frac{2u^n}{\Delta t} - \frac{u^{n-1}}{2\Delta t} \\
\displaystyle \nabla \cdot u & = 0. \\
\begin{array}{rll}
\displaystyle \frac {3\bm{u}^{n+1}}{2\Delta t} + \bm{u}^n \cdot \nabla \bm{u}^{n+1} - \nu \Delta \bm{u}^{n+1}+
\nabla p^{n+1} & = \displaystyle \frac{2\bm{u}^n}{\Delta t} - \frac{\bm{u}^{n-1}}{2\Delta t} & \mbox{ in } \Omega \\
\displaystyle \nabla \cdot \bm{u} & = 0& \mbox{ in } \Omega\,. \\
\end{array}
\right.
\end{equation*}
Let's have a look at the code in \verb!testsuite/test_cavity/main.cpp!.
Until the first \verb!fluid.iterate()!, the code is the same as the one used to compute the Stokes problem.
Now, we want to use this Stokes solution to initialize our non-stationary Navier-Stokes problem, and be able
to store a history of previous solutions in order to compute the time derivative.
This can be done by using the following object
\begin{verbatim}
// bdf initialization with the stokes problem solution
BdfTNS<vector_type> bdf(oseenData.getBDF_order());
\end{verbatim}
The backward differentiation formula, class \verb!BdfTNS! \ixn{Backward Differentiation Formula},
stores the previous solution $u^n$, $u^{n-1}$ ...
All we need to do is to construct this class
with the correct time discretization order given in the data file (variable \verb!fluid/discretization/bdf_order!)
so that the stored vector will be resized correctly, and intialize it with our previously computed Stokes problem solution
Let's have a look at the code in $$ \verb+<lifev directory>/lifev/navier_stokes/examples/cavity_ns.cpp+.$$ Apart from the fact that we included another header file that allows to deal with the time discretization :
\begin{verbatim}
bdf.bdf_u().initialize_unk( fluid.solution() );
#include <lifev/core/fem/TimeAdvanceBDFNavierStokes.hpp>
\end{verbatim}
We are now ready to enter the time loop
\begin{verbatim}
Real dt = oseenData.getTimeStep();
Real t0 = oseenData.getInitialTime();
Real tFinal = oseenData.getEndTime ();
\noindent the code is the same as the one used to compute the Stokes problem until the definition of the communication Epetra \verb+fullMap+. %the first \verb!fluid.iterate()!,
int iter = 1;
Now, we want to use this Stokes solution to initialize our non-stationary Navier-Stokes problem, and be able
to store a history of previous solutions in order to compute the time derivative :
for ( Real time = t0 + dt ; time <= tFinal + dt/2.; time += dt, iter++)
\begin{verbatim}
if (verbose) std::cout<< std::endl << "[Initialization of the simulation]"
<< std::endl;
Real dt = oseenData->dataTime()->timeStep();
Real t0 = oseenData->dataTime()->initialTime();
Real tFinal = oseenData->dataTime()->endTime ();
TimeAdvanceBDFNavierStokes<vector_Type> bdf;
bdf.setup(oseenData->dataTime()->orderBDF());
t0 -= dt * bdf.bdfVelocity().order();
(...)
oseenData->dataTime()->setTime(t0);
(...)
// We get the initial solution using a steady Stokes problem
bdf.bdfVelocity().setInitialCondition( *fluid.solution() );
Real time = t0 + dt;
for ( ; time <= oseenData->dataTime()->initialTime() + dt/2.; time += dt)
{
// inside the time loop, it's really like the initialization procedure,
// exept that we now have an advection velocity, rhs and the mass matrix
oseenData.setTime(time);
if (verbose)
{
std::cout << std::endl;
std::cout << "We are now at time " << oseenData.time()
<< " s. " << std::endl;
std::cout << std::endl;
}
chrono.start();
oseenData->dataTime()->setTime(time);
// alpha coefficient for the mass matrix
double alpha = bdf.bdf_u().coeff_der( 0 ) / oseenData.timestep();
fluid.updateSystem(alpha,beta,rhs);
fluid.iterate(bcH);
bdf.bdfVelocity().shiftRight( *fluid.solution() );
}
// extrapolation of the advection term
beta = bdf.bdf_u().extrap();