1%%%%%%%%%%%%%%%%%%%
2% XLiFE++ is an extended library of finite elements written in C++
3%     Copyright (C) 2014  Lunéville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin
4%
5%     This program is free software: you can redistribute it and/or modify
6%     it under the terms of the GNU General Public License as published by
7%     the Free Software Foundation, either version 3 of the License, or
8%     (at your option) any later version.
9%     This program is distributed in the hope that it will be useful,
10%     but WITHOUT ANY WARRANTY; without even the implied warranty of
11%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12%     GNU General Public License for more details.
13%     You should have received a copy of the GNU General Public License
14%     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15%%%%%%%%%%%%%%%%%%%
16
17\section{About the {\tt init} function}
18
19Initialization is the aim of the {\lib init} library and more precisely the \emph{init.cpp} and \emph{init.hpp} files and the definition of the {\tt init} functions.
20
21Each user program needing \xlifepp has to begin with a call to the {\cmd init} routinewith up to 4 key/value arguments:
22\begin{description}
23\item[{\param \_lang}] enum to set the language for print and log messages. Possible values are $en$, $fr$, or $de$. Default value is $en$.
24\item[{\param \_verbose}] integer to set the verbose level. Default value is 1.
25\item[{\param \_trackingMode}] boolean to set if in the log file, you have a backtrace of every call to a \xlifepp routine. Default value is false.
26\item[{\param \_isLogged}] boolean to activate log. Default value is false.
27\end{description}
28
29Available languages are English, French and German, but \xlifepp is easily extendible for other languages.
30
31\begin{lstlisting}[]{}
32init(_lang=en)
33\end{lstlisting}
34
35What is the {\tt init} function doing ?
36
37\begin{enumerate}
38\item If the {\tt init} function was previously called, it stops, or does the following steps otherwise.
39\item It builds the global {\class Environment} object to initializes dictionary and paths to messages formats, according to the given language. \\ The path to the english dictionary file is {\tt XLIFEPP\_DIR/etc/Messages/en/dictionary.txt}, the path to the french messages file is {\tt XLIFEPP\_DIR/etc/Messages/fr/messages.txt}, \ldots
40\item It builds the global {\class Trace object} to initialize logs
41\item It prints the execution header (logo + execution date, host machine \ldots)
42\item It opens the print file and write the header in it.
43\item It builds the global {\class Messages} object to load messages formats
44\item It initializes RTI names for {\class Function} and {\class Value} objects.
45\end{enumerate}
46
47Global objects are declared in \emph{config.hpp} and defined in \emph{globalScopeData.hpp}. In the next section, we will see what is the content of these two files and of \emph{setup.hpp}
48
49\section{Global declarations and definitions}
50
51\subsection{\emph{setup.hpp}}
52
53This file is automatically generated when you execute \cmake.
54Its aim is to set compilation macros :
55
56\begin{itemize}
57\item {\bf OS\_IS\_UNIX}, {\bf OS\_IS\_WIN}, to set the OS. It is useful for instance to load specific source code for time management ({\em Timer.*pp})
58\item {\bf XLIFEPP\_WITH\_GMSH} and {\bf XLIFEPP\_WITHOUT\_GMSH}, to activate/deactivate compilation of \xlifepp routines using a system call to \gmsh
59\item {\bf XLIFEPP\_WITH\_PARAVIEW} and {\bf XLIFEPP\_WITHOUT\_PARAVIEW}, to activate/deactivate compilation of \xlifepp routines using a system call to \paraview
60\item {\bf XLIFEPP\_WITH\_ARPACKPP} and {\bf XLIFEPP\_WITHOUT\_ARPACKPP}, to activate/deactivate compilation of \xlifepp interface of \arpackpp library.
61\item {\bf XLIFEPP\_WITH\_UMFPACK} and {\bf XLIFEPP\_WITHOUT\_UMFPACK}, to activate/deactivate compilation of \xlifepp interface of \umfpack library.
62\item {\bf XLIFEPP\_WITH\_OMP} and {\bf XLIFEPP\_WITHOUT\_OMP}, to activate/deactivate compilation of \xlifepp using OpenMP library.
63\item {\bf INSTALL\_PATH}, to set the install path of \xlifepp and build paths for dictionary or messages formats.
64\item {\bf GMSH\_PATH}, to set the path of \gmsh.
65\item {\bf PARAVIEW\_PATH}, to set the path of \paraview.
66\item {\bf STD\_TYPES}, {\bf LONG\_TYPES}, {\bf LONGLONG\_TYPES} to set the precision of scalar non integer values. The default is {\bf LONG\_TYPES}
67\item {\bf STD\_STRING}, {\bf WIDE\_STRING}, to set the encoding of strings, by loading either the STL string classes, or . The default is {\bf STD\_STRING}.
68\item {\bf COMPILER\_IS\_32\_BITS}, {\bf COMPILER\_IS\_64\_BITS} to set the precision od integer values
69\end{itemize}
70
71The last five macros are used in \emph{config.hpp} to define some typedefs.
72
73\subsection{\emph{config.hpp}}
74
75This file defines some scalar types, objects and parameters, and also enums.
76
77\begin{itemize}
78\item {\bf Scalar types :} \xlifepp uses scalar types that depend on the precision given in \emph{setup.hpp} : {\class int\_t} , {\class real\_t}, {\class complex\_t} are typedefs for respectively {\tt int}, {\tt float}, {\tt complex<float>} and their families ({\tt long int}, {\tt double},\ldots) according to the corresponding macro.  Two additional typedefs are {\class number\_t} and {\class dimen\_t} respectively for {\tt size\_t} and {\tt short unsigned int}, independent on precision. These scalar types can be called by users. According to the \xlifepp code convention, they have user typedefs : {\class Int}, {\class Real}, {\class Complex}, {\class Number}, {\tt Dimen}. For the same reason, there is the {\class String} typedef for STL classes {\tt string} or {\tt wstring} according to the corresponding macro, and the {\class Strings} typedef for {\tt std::vector<\class String\tt >}
79\item {\bf Global parameters :} This is about output format parameters and extremal values :
80\begin{lstlisting}[deletekeywords={[3] size_t},morekeywords={size_t}]
81extern const number_t entriesPerRow;
82extern const number_t entryWidth;
83extern const number_t entryPrec;
84extern const number_t addrPerRow;
85extern const number_t addrWidth;
86extern const number_t numberPerRow;
87extern const number_t numberWidth;
88extern const number_t theNumberMax;
89extern const size_t theSizeMax;
90extern const dimen_t theDimMax;
91extern const real_t theRealMax;
92extern const real_t theEpsilon;
93extern const real_t theTolerance;
94extern const real_t theZeroThreshold;
95extern const number_t theLanguage;
96extern unsigned int theGlobalVerboseLevel;
97extern unsigned int theVerboseLevel;
98\end{lstlisting}
99There is also some mathematical constants :
100\begin{lstlisting}
101extern const real_t over3;
102extern const real_t over6;
103extern const real_t pi;
104extern const real_t overpi;
105extern const real_t over2pi;
106extern const real_t over4pi;
107extern const real_t sqrtOf2_;
108extern const real_t sqrtOf3_;
109extern const real_t logOf2_;
110extern const real_t theEulerConst;
111\end{lstlisting}
112\item {\bf Global objects :} Global Trace, Messages, Parameters and Environment are also declared here
113\item {\bf enums :} This is the list of enums defined here. For convenience, we give only their declaration :
114\begin{lstlisting}
115enum Language;
116enum ShapeType;
117enum ShapesType;
118enum StrucType;
119enum SymType;
120enum ValueType;
121enum FunctType;
122enum FuncFormType;
123enum SobolevType;
124enum SpaceType;
125enum DofType;
126enum SupportType;
127enum UnknownType;
128enum FEType;
129enum FESubType;
130enum PolynomType;
131enum QolynomType;
132enum LinearFormType;
133enum QuadRule
134
135//for matrix storages
136enum StorageType;
137enum AccessType;
138enum MatrixPart;
139
140// for solver purpose
141enum FactorizationType;
142enum PreconditionerType;
143enum EigenComputationalMode;
144enum EigenSolverMode;
145enum MsgEigenType;
146
147enum ComputationInfo;
148enum IOFormat;
149enum TestStatus;
150enum DataAccess;
151
152\end{lstlisting}
153Each enum has a dictionary counter-part for output.
154\end{itemize}
155
156\subsection{\emph{globalScopeData.hpp}}
157
158This file is the last file include by main programs. Its aim is to define the global parameters and objects declared in \emph{config.hpp}, and also the static class attributes :
159
160\begin{lstlisting}[deletekeywords={[3] map}]
161std::vector<Interpolation*> Interpolation::theInterpolations;
162std::vector<Space*>  Space::theSpaces;
163Number FeSpace::lastEltIndex = 0;
164std::vector<Unknown*> Unknown::theUnknowns;
165std::vector<DifferentialOperator*> DifferentialOperator::theDifferentialOperators;
166std::map<String, std::pair<ValueType, StrucType> > Function::returnTypes;
167std::map<String, std::pair<ValueType, StrucType> > Function::returnArgs;
168std::map<String, std::pair<ValueType, StrucType> > Value::theValueTypeRTInames;
169std::vector<const GeomDomain*> GeomDomain::theDomains;
170std::vector<GeomRefElement*> GeomRefElement::theGeomRefElements;
171std::vector<RefElement*> RefElement::theRefElements;
172std::vector<Quadrature*> Quadrature::theQuadratures;
173std::vector<Term*> Term::theTerms;
174std::vector<MatrixStorage*> MatrixStorage::theMatrixStorages;
175\end{lstlisting}
176
177You may read their function in the chapter dedicated to the corresponding classes.
178
179\section{About the {\tt finalize} function}
180
181The \texttt{finalize} function is defined in the {\lib finalize} library. Its aim is to clean every global static list defined in {\emph globalScopeData.hpp}. Why a library with a single external function ? For dependencies purpose. As the {\lib init} library and {\lib utils} library depend on each other through headers, the {\tt finalize function} depends on libraries concerned by those global static lists, namely {\lib finiteElements}, {\lib operator}, {\lib space}, {\lib geometry}, {\lib largeMatrix} and {\lib term}.
182To preserve independence of the {\lib utils} library, the {\tt finalize} function cannot be placed in the {\lib init} library.
183
184Here is the implementation of this function :
185
186\begin{lstlisting}
187void finalize()
188{
189  // clean all non user run-time lists
190  Interpolation::clearGlobalVector();
191  GeomRefElement::clearGlobalVector();
192  RefElement::clearGlobalVector();
193  DifferentialOperator::clearGlobalVector();
194  Domain::clearGlobalVector();
195  Space::clearGlobalVector();
196  Unknown::clearGlobalVector();
197  Quadrature::clearGlobalVector();
198  MatrixStorage::clearGlobalVector();
199  Term::clearGlobalVector();
200}
201\end{lstlisting}
202
203It is used to preserve independence of tests when running all tests.
204
205