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{The {\classtitle ThreadData} class}
18
19The {\class ThreadData} class is a utility class that manages some FE computation data (normal vectors, current element, current dof, current domain) that may be get by user function or user kernel. When the computation is done on several threads, these data have multiple instances (one by thread), this a reason why a {\class ThreadData} object handles some vectors of data pointers:\\
20
21\begin{lstlisting}[]{}
22vector<Vector<real_t>*> theCurrentNxs;     // normal pointers or x-normal pointers
23vector<Vector<real_t>*> theCurrentNys;     // y-normal pointers
24vector<GeomElement*> theCurrentElements;   // element pointers
25vector<Dof*> theCurrentDofs;               // dof pointers
26GeomDomain* currentDomainx;                // domain pointer or domain_x pointer
27GeomDomain* currentDomainy;                // domain_y pointer
28\end{lstlisting}
29\vspace{2mm}
30It has only one a basic constructor and a resize function that is called when the number of threads changes:
31\vspace{1mm}
32\begin{lstlisting}[]{}
33ThreadData(number_t s=1);
34void resize(number_t);
35\end{lstlisting}
36\vspace{2mm}
37Besides, it offers various functions to set or get the data:
38\vspace{1mm}
39\begin{lstlisting}[]{}
40void setNx(Vector<real_t>*);
41void setNy(Vector<real_t>*);
42void setElement(GeomElement*);
43void setDomainx(GeomDomain*);
44void setDomainy(GeomDomain*);
45void setDof(Dof*);
46void setNx(Vector<real_t>*, number_t);
47void setNy(Vector<real_t>*, number_t);
48void setElement(GeomElement*, number_t);
49void setDof(Dof*, number_t);
50
51Vector<real_t>& getNx(number_t) const;
52Vector<real_t>& getNx() const;
53Vector<real_t>& getNy(number_t ) const;
54Vector<real_t>& getNy() const;
55GeomElement& getElement(number_t);
56GeomElement& getElement() const;
57GeomDomain& getDomainx() const;
58GeomDomain& getDomainy() const;
59Dof& getDof(number_t ) const;
60Dof& getDof() const;
61FeDof& getFeDof(number_t) const;
62FeDof& getFeDof() const;
63\end{lstlisting}
64\vspace{2mm}
65Print utility are also available
66\vspace{1mm}
67\begin{lstlisting}[]{}
68void print(std::ostream&) const;
69void print(PrintStream& os) const {print(os.currentStream());}
70\end{lstlisting}
71\vspace{2mm}
72When starting, \xlifepp create one instance of {\class ThreadData} : {\var theThreadData} (see {\em globalScopeData.hpp, config.hpp}). To avoid the user to deal explicitely with it, some extern functions (wrappers to member functions) are also proposed:
73\vspace{1mm}
74\begin{lstlisting}[]{}
75inline void setNx(Vector<real_t>* p, number_t t);
76inline void setNy(Vector<real_t>* p, number_t t);
77inline void setElement(GeomElement* p, number_t t);
78inline void setDof(Dof* p,number_t t);
79inline void setNx(Vector<real_t>* p);
80inline void setNy(Vector<real_t>* p);
81inline void setElement(GeomElement* p);
82inline void setDomain(GeomDomain* p);
83inline void setDomainx(GeomDomain* p);
84inline void setDomainy(GeomDomain* p);
85inline void setDof(Dof* p);
86inline Vector<real_t>& getN(number_t t);
87inline Vector<real_t>& getNx(number_t t);
88inline Vector<real_t>& getNy(number_t t ;
89inline GeomElement& getElement(number_t t);
90inline Dof& getDof(number_t t);
91inline FeDof& getFeDof(number_t t);
92inline Vector<real_t>& getN();
93inline Vector<real_t>& getNx();
94inline Vector<real_t>& getNy();
95inline GeomElement& getElement();
96inline GeomDomain& getDomain();
97inline GeomDomain& getDomainx();
98inline GeomDomain& getDomainy();
99inline Dof& getDof();
100inline FeDof& getFeDof();
101\end{lstlisting}
102\vspace{2mm}
103This machinery allows the user to simply deal with such computation data:
104\begin{lstlisting}[]{}
105Real fun(cons Point& x, Parameters& pars=theDefaultParameters)
106{...
107Vector<Real>& n = getN();      //get the normal vector
108GeomElement& elt=getElement(); //get element
109...}
110
111int main()
112{...
113 Function F(fun);     //link a C++ function fun to a Function object
114 F.require(_n);       //tell that function fun will use normal vector
115 F.require("element");//tell that function fun will use element
116...
117}
118\end{lstlisting}
119
120\displayInfos{library=utils, header=ThreadData.hpp, implementation=ThreadData.cpp, test=test\_ThreadData.cpp,
121	header dep={config.h, utils.h}}