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 data of a reference element} 18 19\subsection{The {\classtitle GeomRefElement} class} 20 21The {\class GeomRefElement} object carries geometric data of a reference element: type, dimension, 22number of vertices, sides and side of sides, measure, and coordinates of vertices. Furthermore, 23to help finding geometric data on sides, it also carries type, vertex numbers of each side 24on the first hand, and vertex numbers and relative number to parent side of each side of side 25on the second hand. 26 27\begin{lstlisting} 28class GeomRefElement 29{ 30protected: 31 ShapeType shapeType_; //element shape 32 const Dimen dim_; //element dimension 33 const Number nbVertices_, nbSides_, nbSideOfSides_; //number of vertices, ... 34 const Real measure_; //length or area or volume 35 vector<Real> centroid_; //coordinates of centroid 36 vector<Real> vertices_; //coordinates of vertices 37 vector<ShapeType> sideShapeTypes_; //shape type of each side 38 vector<vector<Number> > sideVertexNumbers_; 39 vector<vector<Number> > sideOfSideVertexNumbers_; 40 vector<vector<Number> > sideOfSideNumbers_; 41 42public: 43 static vector<GeomRefElement*> theGeomRefElements; //vector carrying all run time GeomReferenceElements 44}; 45\end{lstlisting} 46\vspace{0.2cm} 47It offers: 48 49\begin{itemize} 50\item few constructors (the default one, a general one with dimension, measure, centroid, and 51number of vertices, edges and faces and one more specific for each dimension): 52\vspace{.1cm} 53\begin{lstlisting}[]{} 54GeomRefElement(); //!< default constructor 55GeomRefElement(ShapeType, const Dimen d, const Real m, const Real c, 56 const Number v, const Number e, const Number f); general 57GeomRefElement(ShapeType, const Real m = 1.0, const Real c = 0.5); // 1D 58GeomRefElement(ShapeType, const Real m, const Real c, const Number v); // 2D 59GeomRefElement(ShapeType, const Real m, const Real c, const Number v, 60 const Number e); // 3D 61\end{lstlisting} 62\vspace{.2cm} 63\item a private copy constructor and a private assign operator, 64\item some public access functions to data: 65\begin{lstlisting}[deletekeywords={[3] begin}] 66Dimen dim() const { return dim_; } 67Number nbSides() const { return nbSides_; } 68Number nbSideOfSides() const { return nbSideOfSides_; } 69Real measure() const { return measure_; } 70std::vector<Real>::const_iterator centroid() const { return centroid_.begin(); } 71std::vector<Real>::const_iterator vertices() const { return vertices_.begin(); } 72std::vector<ShapeType> sideShapeTypes() {return sideShapeTypes_; } 73const std::vector<std::vector<Number> >& sideVertexNumbers() const 74 { return sideVertexNumbers_; } 75const std::vector<std::vector<Number> >& sideOfSideVertexNumbers() const 76 { return sideOfSideVertexNumbers_; } 77 78\end{lstlisting} 79\vspace{.2cm} 80\item some public methods to get data on sides and side of sides: 81\vspace{.1cm} 82\begin{lstlisting}[deletekeywords={[3] id, dim}] 83String shape(const Number sideNum = 0) const; // returns element (side) shape as a string 84ShapeType shapeType(const Number sideNum = 0) const; //returns element (side) shape as a ShapeType 85bool isSimplex() const; //true if a simplex 86Number nbVertices(const Number sideNum = 0) const; // returns number of element (side) vertices 87Number sideVertex(const Number id, const Number sideNum = 0) const;// returns vertex number of element (side) 88std::vector<Real>::const_iterator vertex(const Number vNum) const; // returns coordinates of n-th vertex 89Number sideVertexNumber(const Number vNum, const Number sideNum) const; 90Number sideOfSideVertexNumber(const Number vNum, const Number sideOfSideNum) const; 91Number sideOfSideNumber(const Number i, const Number sideNum) const; // returns local number of i-th edge ( i = 1,2, ...) 92void rotateVertices(const number_t newFirst, std::vector<number_t>&) const; // circular permutation of vertices 93std::vector<real_t> sideToElt(number_t, std::vector<real_t>::const_iterator) const; 94virtual Real measure(const Dimen dim, const Number sideNum = 0) const = 0; 95virtual std::vector<real_t> projection(const std::vector<real_t>&, real_t&) const; // projection of a point onto ref element 96virtual bool contains(std::vector<real_t>& p, real_t tol= theTolerance) const; // test if a point belongs to current element 97 98 \end{lstlisting} 99\vspace{.2cm} 100\item some protected append methods for vertices: 101\vspace{.1cm} 102\begin{lstlisting}[]{} 103//! build vertex 1d coordinates 104void vertex(std::vector<Real>::iterator& it, const Real x1); 105void vertex(std::vector<Real>::iterator& it, const Real x1, const Real x2); 106void vertex(std::vector<Real>::iterator& it, const Real x1, const Real x2, const Real x3); 107 \end{lstlisting} 108\vspace{.2cm} 109\item some public error handlers: 110\vspace{.1cm} 111\begin{lstlisting}[]{} 112void noSuchSideOfSide(const Number) const; 113void noSuchSide(const Number) const; 114void noSuchSide(const Number, const Number, const Number = 0, const Number = 0) const; 115void noSuchFunction(const String& s) const; 116\end{lstlisting} 117\vspace{.2cm} 118\item an external search function in the static run-time list of {\class GeomRefElement}: 119\vspace{.1cm} 120\begin{lstlisting}[]{} 121GeomRefElement* findGeomRefElement(ShapeType); 122\end{lstlisting} 123\end{itemize} 124 125\displayInfos{library=finiteElements, header=GeomRefElement.hpp, implementation=GeomRefElement.cpp, 126test={test\_segment.cpp, test\_triangle.cpp, test\_quadrangle.cpp, test\_tetrahedron.cpp, test\_hexahedron.cpp, test\_prism.cpp}, 127header dep={config.h, GeomRefSegment.hpp, GeomRefTriangle.hpp, GeomRefQuadrangle.hpp, 128GeomRefTetrahedron.hpp, GeomRefHexahedron.hpp, GeomRefPrism.hpp}} 129 130\subsection{Child classes of {\classtitle GeomRefElement}} 131 132The child classes of {\class GeomRefElement} are {\class GeomRefSegment} in 1D, {\class GeomRefTriangle} 133and {\class GeomRefQuadrangle} in 2D and {\class GeomRefHexahedron}, {\class GeomRefTetrahedron}, {\class GeomRefPrism} and {\class GeomRefPyramid} in 3D. 134 135Except implementation of virtual functions, these child classes provide 2 new member functions 136used in class constructors: 137 138\begin{lstlisting} 139void sideNumbering(); // local numbers of vertices on sides 140void sideOfSideNumbering(); // local numbers of vertices on side of sides 141\end{lstlisting} 142\vspace{0.2cm} 143 144The last one is not defined for {\class GeomRefSegment}. 145 146\displayInfos{library=finiteElements, header=GeomRefSegment.hpp, implementation=GeomRefSegment.cpp, 147test=test\_segment.cpp, header dep={config.h, GeomRefElement.hpp }} 148 149\displayInfos{library=finiteElements, header=GeomRefTriangle.hpp, implementation=GeomRefTriangle.cpp, 150test=test\_triangle.cpp, header dep={config.h, GeomRefElement.hpp }} 151 152\displayInfos{library=finiteElements, header=GeomRefQuadrangle.hpp, implementation=GeomRefQuadrangle.cpp, 153test=test\_quadrangle.cpp, header dep={config.h, GeomRefElement.hpp }} 154 155\displayInfos{library=finiteElements, header=GeomRefTetrahedron.hpp, implementation=GeomRefTetrahedron.cpp, 156test=test\_tetrahedron.cpp, header dep={config.h, GeomRefElement.hpp }} 157 158\displayInfos{library=finiteElements, header=GeomRefHexahedron.hpp, implementation=GeomRefHexahedron.cpp, 159test=test\_hexahedron.cpp, header dep={config.h, GeomRefElement.hpp }} 160 161\displayInfos{library=finiteElements, header=GeomRefPrism.hpp, implementation=GeomRefPrism.cpp, 162test=test\_prism.cpp, header dep={config.h, GeomRefElement.hpp }} 163 164\displayInfos{library=finiteElements, header=GeomRefPyramid.hpp, implementation=GeomRefPyramid.cpp, 165test=test\_pyramid.cpp, header dep={config.h, GeomRefElement.hpp }} 166 167