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{Geometric element}\label{sec_GeomElement}
18
19The atomic object of a mesh is a geometric element, that is a segment, a polygon or a polyhedron
20of physical space with flat or curved faces or edges. A general way to describe it, consists
21in giving a polynomial interpolation and a reference geometric element in reference space.
22Thus, a geometric element is the image by the map of a reference geometric element. This map
23is defined from the polynomial interpolation and some nodes of the geometric element: vertices
24and extra points regarding the order of the polynomial interpolation.
25\begin{center}
26\includePict[trim = 0mm 6cm 0mm 0mm, width=9cm]{P1map.pdf}
27\end{center}
28\begin{center}
29\includePict[trim = 0mm 9cm 0mm 0mm, clip,  width=9cm]{P2map.pdf}
30\end{center}
31Geometric elements are the geometric supports of finite element. In other words, a finite element
32is defined from a geometric element and an interpolation (different from interpolation used
33in geometric element!), see {\class Element} class in {\lib space} library.\\
34
35As some finite elements may be required on a boundary of domain, geometric element can be a
36side of geometric element and even a side of side. It is the reason why a geometric element
37can possibly manage side informations (parent and side number).
38
39\subsection{The {\classtitle GeomElement} class}
40
41The {\class GeomElement} class has only four protected members:
42\vspace{.1cm}
43\begin{lstlisting}
44class GeomElement
45{protected :
46   const Mesh* mesh_p;                     //pointer to the mesh
47   Number number_;                         //unique id number
48   MeshElement* meshElement_p;             //pointer to a MeshElement
49   std::vector<GeoNumPair> parentSides_;   //if a side element
50   ...
51\end{lstlisting}
52\vspace{.1cm}
53The most important member \verb?meshElement_p? is a pointer to a {\class MeshElement} object
54collecting real geometric informations (nodes, numbering, reference element, map data, ...).
55This class is detailed in the next section. \\
56
57Besides, it manage some additional informations :
58\vspace{.1cm}
59\begin{lstlisting}[deletekeywords={[3] phi}]
60Number materialId;    // material id (default= 0)
61Number domainId;      // domain id (default=0)
62Real theta, phi;      // angles to describe local curvature (default 0,0)
63\end{lstlisting}
64\vspace{.1cm}
65
66\verb?GeoNumPair? is an alias for storing a pair of parent geometric element and a side number:
67 \vspace{.1cm}
68\begin{lstlisting}[]
69typedef std::pair<GeomElement*,Number> GeoNumPair;
70\end{lstlisting}
71\vspace{.1cm}
72When the geometric element is a side of a geometric element, \verb?parentSides_? is not empty
73and by default, the \verb?meshElement_p? is null. Note that it is possible to build it. Of
74course, when geometric element is not a side element (say plain element), \verb?parentSides_?
75is empty.\\
76
77This class provides few public constructors, an assignment operator and a destructor:
78\vspace{.1cm}
79\begin{lstlisting}[]
80GeomElement(const Mesh* m=0, Number n = 0);
81GeomElement(const Mesh*, const RefElement*, Dimen, Number);  //for plain element
82GeomElement(GeomElement*, Number, Number);                   //for side element
83GeomElement(const GeomElement&);
84GeomElement& operator =(const GeomElement&);
85\end{lstlisting}
86\vspace{.2cm}
87some simple accessors:
88\vspace{.1cm}
89\begin{lstlisting}[]
90Number number() const;
91Number& number();
92bool hasMeshElement() const;
93bool isSideElement() const;
94\end{lstlisting}
95\vspace{.2cm}
96and complex accessors working for plain or side elements, even if \verb?meshElement_p? is null
97:
98\vspace{.1cm}
99\begin{lstlisting}[]
100const MeshElement* meshElement() const;
101MeshElement* meshElement();
102const GeomElement* parent(Number i=0) const;
103const GeoNumPair parentSide(Number i) const;
104std::vector<GeoNumPair>& parentSides();
105Dimen elementDim() const;
106const RefElement* refElement(Number s = 0) const;
107const GeomRefElement* geomRefElement(Number s = 0) const;
108Number numberOfVertices() const;
109Number numberOfSides() const;
110Number numberOfSideOfSides() const;
111ShapeType shapeType(Number s = 0) const;
112Number vertexNumber(Number i) const;
113Number nodeNumber(Number i) const;
114std::vector<Number> vertexNumbers(Number s = 0) const;
115std::vector<Number> nodeNumbers(Number s = 0) const;
116\end{lstlisting}
117\vspace{.1cm}
118\verb?s? means a side number of element and when it is null, function applies to element itself.
119Most of these member functions are recursive. It allows to get data for plain, side and side
120of side elements (side of side of side is not managed). Be cautious, these member functions
121does not check the integrity of data. For instance, the function {\cmd meshElement()} may return
122a null pointer (case of a side element). \\
123
124For a side element, it is possible to construct, if really necessary, its {\class MeshElement}
125structure using the member function:
126\vspace{.1cm}
127\begin{lstlisting}[]
128void buildSideMeshElement();
129void deleteMeshElement();        // destroy meshElement information
130\end{lstlisting}
131\vspace{.2cm}
132There is an encoding function which constructs a string key with global numbers of vertices
133of the geometric element (\verb?s=0?) or its side (\verb?s?). This function is used to build
134global lists of sides (edge in 2D or face in 3D), of side of sides (edge in 3D) and vertices
135(see the {\class Mesh} class).
136\vspace{.1cm}
137\begin{lstlisting}[]
138String encodeElement(Number s=0) const;
139\end{lstlisting}
140\vspace{.2cm}
141Related to these global lists, the following functions return temporary lists of adjacent elements
142by side, by side of side or by vertex:
143\vspace{.1cm}
144\begin{lstlisting}[]
145GeoNumPair elementsSharingSide(Number s) const;
146std::vector<GeoNumPair> elementsSharingVertex(Number v,bool o=false) const;
147std::vector<GeoNumPair> elementsSharingSideOfSide(Number s, bool o=false) const;
148\end{lstlisting}
149\vspace{.2cm}
150When the boolean argument \verb?o? is true, it means that elements in lists are adjacent \textbf{only}
151by side of side or only by vertex. When it is false, all elements are listed. Obviously, these
152functions work only if the global lists of sides, of side of sides and vertices have been constructed
153before. By default, they are not (see the {\class Mesh} class).\\
154
155The class provides a function to test if a point belongs to element:
156\vspace{.1cm}
157\begin{lstlisting}[]
158bool contains(const std::vector<Real>& p);
159\end{lstlisting}
160\vspace{.2cm}
161It is possible to compare {\class GeomElement} objects by their indices (\verb?number_?) using
162the operators:
163\vspace{.1cm}
164\begin{lstlisting}[]
165bool operator== (const GeomElement&, const GeomElement&);
166bool operator<  (const GeomElement&, const GeomElement&);
167\end{lstlisting}
168\vspace{.2cm}
169For output purpose, you can split a GeomElement in first order elements, either simplices or of same shape  :
170\vspace{.1cm}
171\begin{lstlisting}[]
172std::vector<GeomElement*> splitP1() const;
173std::vector<GeomElement*> splitO1() const;
174\end{lstlisting}
175\vspace{.2cm}
176Finally, the {\class GeomElement} class provides usual printing facilities:
177\vspace{.1cm}
178\begin{lstlisting}[]
179void print(std::ostream&) const ;
180friend std::ostream& operator<< (std::ostream&, const GeomElement&);
181\end{lstlisting}
182\vspace{.2cm}
183
184\subsection{The {\classtitle MeshElement} class}
185
186{\class MeshElement} is the real class storing geometric element data:
187\vspace{.1cm}
188\begin{lstlisting}[deletekeywords={[3] nodes, vertexNumbers, nodeNumbers}]
189class MeshElement
190{public:
191  std::vector<Point*> nodes;              //nodes of element
192  std::vector<Number> nodeNumbers;        //global numbers of node
193  std::vector<Number> vertexNumbers;      //global numbers of vertices
194  std::vector<Number> sideNumbers;        //global numbers of sides
195  std::vector<Number> sideOfSideNumbers;  //global numbers of side of sides
196  short int orientation;                  //element orientation
197  std::vector<Real> measures;             //measure of element and its sides
198  GeomMapData* geomMapData_p;             //useful data for geometric map
199 private:
200  Number index_;                          //element index
201  const Dimen spaceDim_;                  //space dimension
202  const RefElement* refElt_p;       //pointer to associated Reference Element
203  ...
204\end{lstlisting}
205\vspace{.1cm}
206The vector \verb?nodes? gives a direct access to the node coordinates of the element (it is
207redundant).  The numbering vectors \verb?nodeNumbers?, \verb?vertexNumbers?, \verb?sideNumbers?
208and \verb?sideOfSideNumbers? are related to global vectors defined in {\class Mesh} ; \verb?nodes?,
209\verb?vertices_?, \verb?sides_? and \verb?sideOfSide_?. Note that the  \verb?sideNumbers? and
210\verb?sideOfSideNumbers? vectors are not built by default (see the \verb?buildSides? and \verb?buildSideOfSides?
211member functions of {\class Mesh} class). The \verb?nodeNumbers? and \verb?vertexNumbers? vectors
212are the same for one order polynomial geometric interpolation. \\
213
214The orientation of an element is defined by default as the sign of the determinant of the jacobian of the geometric map from reference element to geometric element; this map being well defined through the {\class RefElement} pointer \verb?refElt_p? and the geometric element nodes. But, this orientation may be changed by the function {\cmd setOrientationForManifold} which set the orientation in order the normal computed from jacobian be always the outward normal.\\
215
216Besides, the {\class MeshElement} class manages
217a pointer to a {\class GeomMapData} object storing computational data related to the geometric
218map: jacobian matrix, its inverse, its determinant, ... see the next section. \\
219
220\begin{remark}
221As it refers to some {\class Mesh} class members, {\class MeshElement} object should not be
222instanciated independantly of a mesh.
223\end{remark}
224
225The class has only one basic constructor initializing the {\class RefElement} pointer, the
226space dimension and the element index:
227\vspace{.1cm}
228\begin{lstlisting}[]
229MeshElement();
230MeshElement(const RefElement*, Dimen, Number);
231~MeshElement();
232\end{lstlisting}
233\vspace{.1cm}
234It means that numbering informations has to be given outside the constructor. Generally, this
235is done by meshing tools.\\
236
237There are some useful accessors, most of them providing same information as those defined in
238the {\class GeomElement} interface class:
239\vspace{.1cm}
240\begin{lstlisting}[]
241Number index() const;
242Dimen spaceDim() const;
243Number order() const;
244Real measure(const Number s = 0) const;
245const RefElement* refElement(Number s = 0) const;
246const GeomRefElement* geomRefElement(Number i = 0) const;
247Dimen elementDim() const;
248ShapeType shapeType(Number s = 0) const;
249Number vertexNumber(Number i) const;
250Number nodeNumber(Number i) const;
251std::vector<Number> verticesNumbers(Number s=0) const;
252Number numberOfNodes() const;
253Number numberOfVertices() const;
254Number numberOfSides() const;
255Number numberOfSideOfSides() const;
256\end{lstlisting}
257\vspace{.2cm}
258
259Besides, there are some computation functions related to geometric element:
260\vspace{.1cm}
261\begin{lstlisting}[]
262void computeMeasures();
263void computeMeasure();
264void computeMeasureOfSides();
265void computeOrientation();
266bool contains(const std::vector<Real>&);
267void clearGeomMapData();
268\end{lstlisting}
269\vspace{.1cm}
270The functions related to jacobian computations are defined in the {\class GeomMapData} class.
271The \verb?geomMapData_p? pointer may be used to store map data and the function \verb?clearGeomMapData()?
272deletes the {\class GeomMapData} object.\\
273
274Finally, {\class MeshElement} informations are displayed with:
275\vspace{.1cm}
276\begin{lstlisting}[]
277void print(std::ostream&) const;
278friend std::ostream& operator<< (std::ostream&, const MeshElement&);
279\end{lstlisting}
280\vspace{.1cm}
281
282\displayInfos{library=geometry, header=GeomElement.hpp, implementation=GeomElement.cpp, test=test\_GeomElement.cpp,
283header dep={config.h, utils.h}}
284
285