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
17When the {\bf subdivision algorithm} is chosen (mg = {\tt\_subdiv}), one can create a mesh of any order based on
18the following volumetric geometries:
19\begin{itemize}
20\item the sphere meshed by tetrahedra,
21\item the cube meshed by tetrahedra or hexahedra,
22\item the cone or truncated cone, which may be a cylinder, meshed by tetrahedra or hexahedra.
23\end{itemize}
24The following surface geometries are also handled:
25\begin{itemize}
26\item the boundary of the sphere meshed by triangles,
27\item the boundary of the cube meshed by quadrangles,
28\item the boundary of the cone or truncated cone meshed by triangles or quadrangles,
29\item the disk meshed by triangles or quadrangles,
30\item mesh built from an initial set of triangles or quadrangles in 2D or 3D.
31\end{itemize}
32The principle is to start from an initial mesh, a kind of ``seed" mesh, consisting of a set of elements, and build the
33mesh by subdividing each of them by cutting each edge in the middle until a prescribed so-called ``subdivision level"
34is reached. A subdivision level equal to 0 gives a mesh reduced to the initial mesh. A triangle and a quadrangle is
35subdivided into 4 pieces ; a tetrahedron and a hexahedron is subdivided into 8 pieces. Thus, at each subdivision,
36the number of elements of the mesh is multiplied by 4 for a surface mesh, by 8 for a volumetric one, and the characteristic
37dimension of the elements is halved.
38
39One has to declare an object of type {\class Geometry}, more precisely of type {\class Sphere}, {\class Ball},
40{\class Cube}, {\class RevTrunk}, {\class RevCone}, {\class RevCylinder}, {\class Disk} or {\class SetOfElems}
41using one of the available constructors, e.g.:
42
43\medskip
44
45\begin{lstlisting}[deletekeywords={[3]bounds}]
46SetOfElems(const std::vector<Point>& pts, const std::vector<std::vector<number_t> >& elems, const std::vector<std::vector<number_t> >& bounds, const ShapeType esh, const number_t nbsubdiv=1);
47\end{lstlisting}
48
49\subsubsection{Mesh of a ball (or sphere) with tetrahedra}
50
51The seed of the mesh consists of a unique tetrahedron inside each octant of the cartesian axes.
52We can choose the number of octants to be taken into account, from 1 to 8, to mesh different portions of the sphere.
53The figure \ref{volSphere_meshes} shows this in the case of  a subdivision level equal to 2. Each figure corresponds to
54the result of the following code, using the unit sphere and $nboctants$ varying from 1 to 8:
55\medskip
56\begin{lstlisting}[deletekeywords={[3]order}]
57order = 1, nbpts=5, meshType = 1;
58Ball sph(_center=Point(0.,0.,0.), _radius=1., _nboctants=nboctants, _nnodes=nbpts, _type=meshType);
59Mesh m(sph, _tetrahedron, order, _subdiv);
60\end{lstlisting}
61
62\begin{remark}
63The class {\class Sphere} could have been used instead of {\class Ball}, leading to the same result.
64\end{remark}
65
66\medskip
67
68Each color corresponds to a different boundary domain.
69The default value of the argument meshType is 1; setting it to 0 leads to a so-called flat mesh, where the points created
70during the algorithm are not projected onto the sphere, thus keeping the shape of the initial mesh. We can see the effect
71of this choice on figure \ref{sphereTetFlat_meshes}.
72
73\begin{figure}[H]
74 \begin{center}
75  \includePict[scale=0.9]{P1VolMeshTetSphere1.pdf}
76  \includePict[scale=0.9]{P1VolMeshTetSphere2.pdf}
77  \includePict[scale=0.9]{P1VolMeshTetSphere3.pdf}
78  \includePict[scale=0.9]{P1VolMeshTetSphere4.pdf}
79 \end{center}
80 \begin{center}
81  \includePict[scale=0.9]{P1VolMeshTetSphere5.pdf}
82  \includePict[scale=0.9]{P1VolMeshTetSphere6.pdf}
83  \includePict[scale=0.9]{P1VolMeshTetSphere7.pdf}
84  \includePict[scale=0.9]{P1VolMeshTetSphere8.pdf}
85 \end{center}
86 \caption{Volumic meshes of the different portions of the ball according to the number of octants.}
87 \label{volSphere_meshes}
88\end{figure}
89
90\begin{figure}[H]
91 \begin{center}
92  \includePict{P1VolMeshTetSphereFlat1.pdf}
93  \includePict{P1VolMeshTetSphereFlat2.pdf}
94  \includePict{P1VolMeshTetSphereFlat3.pdf}
95  \includePict{P1VolMeshTetSphereFlat4.pdf}
96 \end{center}
97 \begin{center}
98  \includePict{P1VolMeshTetSphereFlat5.pdf}
99  \includePict{P1VolMeshTetSphereFlat6.pdf}
100  \includePict{P1VolMeshTetSphereFlat7.pdf}
101  \includePict{P1VolMeshTetSphereFlat8.pdf}
102 \end{center}
103 \caption{Volumic meshes of the different portions of the ``flat ball" according to the number of octants.}
104 \label{sphereTetFlat_meshes}
105\end{figure}
106
107If we specifically want the mesh inside the whole sphere, it can be usefull to start from an icosahedron because
108of its geometric properties, which lead to a more isotropic mesh than the one based on the 8 octants
109of the space. On the other hand, there will be no interface planes defined.
110\par
111In order to activate this option, the argument nboctants should simply be set to 0. The following code
112gives the figure \ref{sphereTetIcosa_meshes}, which shows both the round and flat results of the algorithm:
113
114\begin{lstlisting}[deletekeywords={[3]order}]
115nboctants = 0, nbpts=5; meshType = 1;
116Ball sph(_center=Point(0.,0.,0.), _radius=1., _nboctants=nboctants, _nnodes=nbpts, _type=meshType);
117order = 1;
118Mesh m(sph, _tetrahedron, order, _subdiv);
119
120meshType = 0;
121Ball sph2(_center=Point(0.,0.,0.), _radius=1., _nboctants=nboctants, _nnodes=nbpts, _type=meshType);
122Mesh m2(sph2, _tetrahedron, order, _subdiv);
123\end{lstlisting}
124
125\begin{figure}[H]
126\begin{center}
127\includePict{P1VolMeshTetSphere0.pdf}\hskip2cm
128\includePict{P1VolMeshTetSphereFlat0.pdf}
129\end{center}
130\caption{Volumic meshes starting from an icosahedron.}
131\label{sphereTetIcosa_meshes}
132\end{figure}
133
134\subsubsection{Mesh of a cube with tetrahedra or hexahedra}
135
136The selection of the octants is also used in the case of the cube as shown on the figure \ref{vol_cube_meshes},
137which is the result of the following code, with no subdivision and $nboctants$ varying from 1 to 8:
138\medskip
139\begin{lstlisting}[deletekeywords={[3]order,cube}]
140order = 1, nbpts=2;
141Cube cube(_center=Point(0.,0.,0.), _length=2., _nboctants=nboctants, _nnodes=nbpts);
142Mesh m(cube, _hexahedron, order, _subdiv);
143\end{lstlisting}
144Notice that the edge length of the total cube is 2, so that the cube in the first octant is the so-called unit cube.
145Apart the choice of the mesh element (tetrahedron or hexahedron), the main interest of this case is the easy
146creation of a L-shape domain (3 octants) and the Fichera corner (7 octants), classical benchmark problem in
147the analysis of corner and edge singularities. It is shown on figure \ref{vol_cube_meshes} in an unsual position;
148in order to put the missing cube in the first octant, one must apply a rotation, which is done by the following
149code:
150\medskip
151\begin{lstlisting}[deletekeywords={[3]order,cube}]
152order = 1, nboctants=7, nbpts=2;
153Cube cube(_center=Point(0.,0.,0.), _length=2., _nboctants=nboctants, _nnodes=nbpts); cube.rotate3d(Point(0.,0.,0.), 1.,0.,0., pi);
154Mesh m(cube, _hexahedron, order, _subdiv);
155\end{lstlisting}
156The two additional arguments define the rotation of angle 180 degrees around the first axis (X-axis); the result
157is shown on figure \ref{vol_cube_meshes}, at the last position (bottom right). If necessary, one can specify one or
158two more rotations in the form (angle, naxis). The angle is to be given in degrees and naxis defines the rotation
159axis: it is the number of the absolute axis, thus 1, 2 or 3.
160\begin{figure}[H]
161 \begin{center}
162  \includePict[scale=0.8]{P1VolMeshHexCube1.pdf}
163  \includePict[scale=0.8]{P1VolMeshHexCube2.pdf}
164  \includePict[scale=0.8]{P1VolMeshHexCube3.pdf}
165  \includePict[scale=0.8]{P1VolMeshHexCube4.pdf}
166 \end{center}
167 \begin{center}
168  \includePict[scale=0.8]{P1VolMeshHexCube5.pdf}
169  \includePict[scale=0.8]{P1VolMeshHexCube6.pdf}
170  \includePict[scale=0.8]{P1VolMeshHexCube7.pdf}
171  \includePict[scale=0.8]{P1VolMeshHexCube8.pdf}\hskip2cm
172  \includePict[scale=0.8]{P1VolMeshHexCubeFich.pdf}
173 \end{center}
174 \caption{Volumic meshes of the different portions of the cube according to the number of octants.}
175 \label{vol_cube_meshes}
176\end{figure}
177
178\subsubsection{Mesh of a cylinder with tetrahedra or hexahedra}
179The subdivision algorithm can handle the case of a cylinder of revolution, whose axis is defined by two
180points P1 and P2, and delimited by the two planes containing the two points and orthogonal to the axis.
181As an example, we consider the ``unit" cylinder of radius 1 and height 1. The following code produces
182the first two meshes shown on figure \ref{cyl_meshes}:
183\medskip
184\begin{lstlisting}[deletekeywords={[3]order}]
185radius=1.;
186nbpts=3;
187Point P1(0.,0.,0.), P2(0.,0.,1.);
188RevCylinder cyl1(_center1=P1, _center2=P2, _radius=radius, _nnodes=nbpts);
189order=1;
190Mesh mT(cyl, _tetrahedron, order, _subdiv);
191Mesh mH(cyl, _hexahedron,  order, _subdiv);
192\end{lstlisting}
193
194\begin{figure}[H]
195 \begin{center}
196 \includePict{P1VolMeshTetCyl1.pdf}\hskip1cm
197 \includePict{P1VolMeshHexCyl1.pdf}\hskip2cm
198 \includePict{P1VolMeshTetCylE1.pdf}
199 \end{center}
200 \caption{Volumic meshes of the ``unit" cylinder with tetrahedra and hexahedra.}
201 \label{cyl_meshes}
202\end{figure}
203
204Obviously, this is a poor approximation of the cylinder. To get a more accurate description, the user can
205then increase the number of elements (greater value of nbsubdiv) or increase the approximation order (or both).
206
207\medskip
208In the case of a tetrahedron mesh, each end-plane may be covered by a ``hat", that is to say a solid whose
209shape may be a cone or an ellipsoid. The last drawing of figure \ref{cyl_meshes} shows such a configuration,
210with an ellipsoid on the side of P1 (keyword \_gesEllipsoid) whose apex is at radius/2 from the basis of the
211cylinder, and a cone on the side of P2 (keyword \_gesCone) whose apex is at radius from the other basis of
212the cylinder. It is obtained by the following code:
213
214\begin{lstlisting}[deletekeywords={[3]order}]
215radius=1.;
216nbpts=5;
217RevCylinder cyl2e(_center1=Point(0.,0.,0.), _center2=Point(0.,0.,1.), _radius=radius, _end1_shape=_gesEllipsoid, _end1_distance=radius/2, _end2_shape=_gesCone, _end2_distance=radius, _nnodes=nbpts);
218order=1;
219Mesh P1VolMeshTetCylE(cyl2e, _tetrahedron, order, _subdiv);
220\end{lstlisting}
221Two other keywords exist: \_gesNone and \_gesFlat. They have an equivalent meaning in the case of a solid body.
222They are the default value and indicate that no ``hat" should be added at the corresponding end.
223
224\subsubsection{Mesh of a cone or a truncated cone with tetrahedra or hexahedra}
225A truncated cone of revolution is defined by an axis, given by two points P1 and P2, delimited by the
226two planes containing the two points and orthogonal to the axis. The two circular sections are defined
227by two radii. The following code produces the first two meshes shown on figure \ref{vol_cone_meshes}:
228\medskip
229\begin{lstlisting}[deletekeywords={[3]order}]
230nbpts=5;
231radius1=0., radius2=1.;
232Point P1(-1.,-1.,0.), P2(0.,0.,2.);
233RevCone cone(_center=P2, _radius=radius2, _apex=P1, _nnodes=nbpts);
234order=1;
235Mesh mT(cone, _tetrahedron, order, _subdiv);
236
237radius1=0.5;
238RevTrunk cone2(_center1=P1, _radius1=radius1, _center2=P2, _radius2=radius2, _nnodes=nbpts);
239Mesh mH(cone2, _hexahedron, order, _subdiv);
240\end{lstlisting}
241
242The number of slices is 0, which means that a suitable default value is automatically computed from
243the length of the axis and the radii. The first object is a "true" cone since one radius is 0 ; it can
244be meshed exactly with tetrahedra. Using hexahedra for this geometry is not advised since the elements
245will be degenerated at the apex of the cone. Moreover, the radius cannot be 0, it should be at least 1.e-15,
246leading to a "near true" cone, but with highly degenerated hexahedra close to the apex. Hexahedra are more suitable
247to build a trucated cone ; an example is shown on the middle drawing of the figure \ref{vol_cone_meshes}.
248\begin{figure}[H]
249 \begin{center}
250 \includePict[scale=0.8]{P1VolMeshTetCone0.pdf}\hskip1cm
251 \includePict[scale=0.8]{P1VolMeshHexCone0.pdf}\hskip2cm
252 \includePict[scale=0.8]{P1VolMeshTetConeE0.pdf}
253 \end{center}
254 \caption{Volumic meshes of the cone and truncated cone with tetrahedra and hexahedra.}
255 \label{vol_cone_meshes}
256\end{figure}
257The following code produces the last mesh shown on figure \ref{vol_cone_meshes}:
258\begin{lstlisting}[deletekeywords={[3]order}]
259nbpts=5;
260radius1=0.6, radius2=1.;
261RevTrunk cone1(_center1=Point(-1.,-1.,0.), _radius1=radius1, _center2=Point(0.,0.,2.), _radius2=radius2, _end1_shape=_gesCone, _end1_distance=1.5, _end2_Shape=_gesEllipsoid, _end2_distance=0.7, _nnodes=nbpts);
262order=1;
263Mesh mTE(cone1, _tetrahedron, order, _subdiv);
264\end{lstlisting}
265In the same way as for the cylinder, the truncated cone can be ``covered" with a solid. This is only available for
266a mesh made of tetrahedra. We show a cone and an ellipsoid put at each end of a truncated cone, respectively
267on the side of P1 and on the side of P2.
268
269\subsubsection{Mesh of a sphere with triangles}
270The same logic described previously for a mesh of tetrahedra apply here for a mesh of triangles. The following
271code leads to meshes of the boundary of the unit sphere, and the result is shown on figure \ref{surfSphere_meshes}:
272\begin{lstlisting}[deletekeywords={[3]order}]
273    order = 1, nbpts=5;
274    Ball sph(_center=Point(0.,0.,0.), _radius=1., _nboctants=nboctants, _nnodes=nbpts);
275    Mesh m(sph, _triangle, order, _subdiv);
276\end{lstlisting}
277
278\begin{figure}[H]
279 \begin{center}
280  \includePict[scale=0.9]{P1SurfMeshTriSphere1.pdf}\hskip1cm
281  \includePict[scale=0.9]{P1SurfMeshTriSphere2.pdf}\hskip1cm
282  \includePict[scale=0.9]{P1SurfMeshTriSphere3.pdf}\hskip1cm
283  \includePict[scale=0.9]{P1SurfMeshTriSphere4.pdf}
284 \end{center}
285 \begin{center}
286  \includePict[scale=0.9]{P1SurfMeshTriSphere5.pdf}
287  \includePict[scale=0.9]{P1SurfMeshTriSphere6.pdf}
288  \includePict[scale=0.9]{P1SurfMeshTriSphere7.pdf}
289  \includePict[scale=0.9]{P1SurfMeshTriSphere8.pdf}
290 \end{center}
291 \caption{Surfacic meshes of the different portions of the boundary of the sphere according to the number of octants.}
292 \label{surfSphere_meshes}
293\end{figure}
294Again, if the argument meshType is set to 0, we get the ``flat" version of the meshes, i.e. the
295meshes obtained from the subdivision of the nboctants initial triangles (see figure \ref{sphereTriFlat_meshes}).
296
297\begin{figure}[H]
298 \begin{center}
299  \includePict{P1SurfMeshTriSphereFlat1.pdf}
300  \includePict{P1SurfMeshTriSphereFlat2.pdf}
301  \includePict{P1SurfMeshTriSphereFlat3.pdf}
302  \includePict{P1SurfMeshTriSphereFlat4.pdf}
303 \end{center}
304 \begin{center}
305  \includePict{P1SurfMeshTriSphereFlat5.pdf}
306  \includePict{P1SurfMeshTriSphereFlat6.pdf}
307  \includePict{P1SurfMeshTriSphereFlat7.pdf}
308  \includePict{P1SurfMeshTriSphereFlat8.pdf}
309 \end{center}
310 \caption{Surfacic meshes of the different portions of the ``flat sphere" according to the number of octants.}
311 \label{sphereTriFlat_meshes}
312\end{figure}
313
314If we specifically want the mesh of the whole sphere, it can be usefull to start from an icosahedron because
315of its geometric properties, which lead to a more isotropic mesh than the one based on the 8 octants
316of the space. On the other hand, there will be no interface planes defined.
317\par
318In order to activate this option, the argument nboctants should simply be set to 0. The following code
319gives the figure \ref{sphereTriIcosa_meshes}, which shows both the round and flat results of the algorithm:
320
321\begin{lstlisting}[deletekeywords={[3]order}]
322nboctants = 0, nbpts=5; meshType = 1;
323Ball sph(_center=Point(0.,0.,0.), _radius=1., _nboctants=nboctants, _nnodes=nbpts, _type=meshType);
324order = 1;
325Mesh m(sph, _triangle, order, _subdiv);
326
327meshType = 0;
328Ball sph2(_center=Point(0.,0.,0.), _radius=1., _nboctants=nboctants, _nnodes=nbpts, _type=meshType);
329Mesh m2(sph2, _triangle, order, _subdiv);
330\end{lstlisting}
331
332\begin{figure}[H]
333 \begin{center}
334  \includePict{P1SurfMeshTriSphere0.pdf}\hskip2cm
335  \includePict{P1SurfMeshTriSphereFlat0.pdf}
336 \end{center}
337 \caption{Surfacic meshes starting from an icosahedron.}
338 \label{sphereTriIcosa_meshes}
339\end{figure}
340
341\subsubsection{Mesh of a cube with quadrangles}
342We can obtain the mesh of the surface of a cube, or part of it, with quadrangles, by using the same
343logic described just above for the sphere. Consider the following code:
344\begin{lstlisting}[deletekeywords={[3]order,cube}]
345    order = 1, nbpts=2;
346    Cube cube(_center=Point(0.,0.,0.), _length=2., _nboctants=nboctants, _nnodes=nbpts);
347    Mesh m(cube, _quadrangle, order, _subdiv);
348\end{lstlisting}
349Letting nboctants vary from 1 to 8, then 0, lead to the objects shown on figure \ref{surf_cube_meshes}
350below.
351\begin{figure}[H]
352 \begin{center}
353  \includePict[scale=0.8]{P1SurfMeshQuaCube1.pdf}
354  \includePict[scale=0.8]{P1SurfMeshQuaCube2.pdf}
355  \includePict[scale=0.8]{P1SurfMeshQuaCube3.pdf}
356  \includePict[scale=0.8]{P1SurfMeshQuaCube4.pdf}
357 \end{center}
358 \begin{center}
359  \includePict[scale=0.8]{P1SurfMeshQuaCube5.pdf}
360  \includePict[scale=0.8]{P1SurfMeshQuaCube6.pdf}
361  \includePict[scale=0.8]{P1SurfMeshQuaCube7.pdf}
362  \includePict[scale=0.8]{P1SurfMeshQuaCube8.pdf}\hskip2cm
363  \includePict[scale=0.8]{P1SurfMeshQuaCube0.pdf}
364 \end{center}
365 \caption{Surfacic meshes of the different portions of the cube according to the number of octants.}
366 \label{surf_cube_meshes}
367\end{figure}
368The last object (nboctants = 0) is the simplest mesh of a cube made of 6 quadrangles (squares here).
369By subdividing it once, we get the previous yellow object (nboctants = 8) made of 24 quadrangles.
370
371\subsubsection{Mesh of a cone or a truncated cone with triangles}
372We can build a mesh of the surface of a truncated cone with triangles. The following code produces
373the first two drawings of the figure \ref{tri_cyl_meshes}:
374\begin{lstlisting}[deletekeywords={[3]order}]
375radius=1.;
376nbslices=1, nbpts=3;
377Point P1(0.,0.,0.), P2(0.,0.,1.);
378RevCylinder cyl1(_center1=P1, _center2=P2, _radius=radius, _nnodes=nbpts);
379order=1;
380Mesh mT(cyl, _triangle, order, _subdiv, fname);
381
382nbpts=5;
383RevCylinder cylE(_center1=P1, _center2=P2, _radius=radius, _end1_shape=_gesFlat, _end1_distance=0., _end2_shape=_gesNone, _end2_distance=0., _nnodes=nbpts);
384Mesh mTE(cylE, _triangle, order, _subdiv);
385\end{lstlisting}
386
387\begin{figure}[H]
388 \begin{center}
389  \includePict{P1SurfMeshTriCyl1.pdf}\hskip2cm
390  \includePict{P1SurfMeshTriCylE1.pdf}
391 \end{center}
392 \caption{Surfacic meshes of a cylinder.}
393 \label{tri_cyl_meshes}
394\end{figure}
395
396\begin{lstlisting}[deletekeywords={[3]order}]
397nbpts=5;
398radius1=0.5, radius2=1.;
399Point P1(-1.,-1.,0.), P2(0.,0.,2.);
400RevTrunk cone3(_center1=P1, _radius1=radius1, _center2=P2, _radius2=radius2, _end1_shape=_gesNone, _end1_distance=0., _end2_shape=_gesFlat, _end2_distance=0., _nnodes=nbpts);
401order=1;
402Mesh mT(cone3, _triangle, order, _subdiv);
403
404RevTrunk cone1(_center1=P1, _radius1=radius1, _center2=P2, _radius2=radius2, _end1_shape=_gesCone, _end1_distance=1.5, _end2_shape=_gesEllipsoid, _end2_distance=0.7, _nnodes=nbpts);
405Mesh mTE(cone1, _triangle, order, _subdiv);
406\end{lstlisting}
407
408\begin{figure}[H]
409 \begin{center}
410  \includePict[scale=0.8]{P1SurfMeshTriCone0.pdf}\hskip2cm
411  \includePict[scale=0.8]{P1SurfMeshTriConeE0.pdf}
412 \end{center}
413 \caption{Surfacic meshes of a truncated cone.}
414 \label{tri_cone_meshes}
415\end{figure}
416
417\subsubsection{Mesh of a cone or a truncated cone with quadrangles}
418We can build a mesh of the surface of a truncated cone with quadrangles. The following code produces
419the first two drawings of the figure \ref{qua_cone_meshes}:
420\begin{lstlisting}[deletekeywords={[3]order}]
421nbpts=5;
422radius1=0.5, radius2=1.;
423Point P1(-1.,-1.,0.), P2(0.,0.,2.);
424RevTrunk cone2(_center1=P1, _radius1=radius1, _center2=P2, _radius2=radius2, _nnodes=nbpts);
425order=1;
426Mesh mQ(cone2, _quadrangle, order, _subdiv);
427
428RevTrunk cone3(_center1=P1, _radius1=radius1, _center2=P2, _radius2=radius2, _end1_shape=_gesNone, _end1_distance=0., _end2_shape=_gesFlat, _end2_distance=0., _nnodes=nbpts);
429Mesh mQF(cone3, _quadrangle, order, _subdiv, "mQF");
430mQF.printInfo();
431\end{lstlisting}
432The left truncated cone is opened at both ends (this is the default) ; thus it has two boundaries
433shown in green (bottom) and orange (top). The object cone2 is the same as the one used previously
434to make the mesh of hexahedra (see figure \ref{vol_cone_meshes}).
435\par
436The second drawing shows the same object bearing a ``lid" on its top (on the side of P2). Indeed, such
437a truncated cone may be closed at one or both ends by a plane ``lid". This is obtained by specifying
438the geometric end shape to be used at each end: \_gesNone means that the cone is left opened, which
439is the default behaviour, and \_gesFlat means that a plane ``lid" is requested.
440The objet proposed in this example has thus one boundary at its other end (on the side of P1),
441shown as an orange line.
442\par\smallskip
443In both cases, the requested number of slices is 0 ; thus, the algorithm decided to create two slices
444displayed in magenta and yellow. The result of the instruction mQF.printInfo(); is the following :
445\par
446{\scriptsize
447\begin{verbatim}
448Mesh'mQF' (cone - Quadrangle mesh)
449  space dimension : 3, element dimension : 2
450  Geometry   of shape type revolution volume based on cone of dimension 3,
451  BoundingBox [-1.45412,0.908248]x[-1.45412,0.908248]x[-0.288675,2.57735], names of variable : x, y, z
452  number of elements : 208, number of vertices : 217, number of nodes : 217, number of domains : 5
453    domain number 0: Omega (whole domain)
454    domain number 1: Sigma_1 (End subdomain on the side of end point 2)
455    domain number 2: Sigma_2 (Slice 1)
456    domain number 3: Sigma_3 (Slice 2)
457    domain number 4: Kappa_1 (Boundary: End curve on the side of end point 1)
458\end{verbatim}}
459
460\begin{figure}[H]
461 \begin{center}
462  \includePict[scale=0.8]{P1SurfMeshQuaCone0.pdf}
463  \includePict[scale=0.8]{P1SurfMeshQuaConeE0.pdf}\hskip1cm
464  \includePict{P1SurfMeshQuaCyl1.pdf}
465 \end{center}
466 \caption{Surfacic meshes of a cone and a cylinder.}
467 \label{qua_cone_meshes}
468\end{figure}
469The last drawing shows the surfacic mesh of a cylinder, since it is a particular kind of cone.
470The cylinder is the same as the one shown on figure \ref{cyl_meshes}. The code that produces
471this mesh is:
472\begin{lstlisting}[deletekeywords={[3]order}]
473radius=1.;
474nbpts=3;
475Point P1(0.,0.,0.), P2(0.,0.,1.);
476RevCylinder cyl(_center1=P1, _center2=P2, _radius=radius, _nnodes=nbpts);
477order=1;
478Mesh mQCyl(cyl, _quadrangle, order, _subdiv);
479\end{lstlisting}
480The cylinder is opened at both ends and thus has two boundaries shown as a green line and
481an orange line.
482
483\subsubsection{Mesh of a disk or a part of a disk}
484We can build the mesh of a disk or a portion of a disk, with triangles or quadrangles.
485Using the following code, we get the result shown on figure \ref{disk_meshes}.
486\begin{lstlisting}[deletekeywords={[3]order}]
487  radius=2.;
488  nbpts=5, order=1;
489  Disk pdisk(_center=Point(0.,1.), _radius=radius, _angle1=10., _angle2=300., _nnodes=nbpts);
490  Mesh meshTriDisk(pdisk, _triangle, order, _subdiv);
491  Mesh meshQuaDisk(pdisk, _quadrangle, order, _subdiv);
492\end{lstlisting}
493
494\begin{figure}[H]
495 \begin{center}
496  \includePict[scale=0.5]{P1SurfMeshTriDisk.pdf}
497  \includePict[scale=0.5]{P1SurfMeshQuaDisk.pdf}
498 \end{center}
499 \caption{Meshes of a portion of disk with triangles and quadrangles.}
500 \label{disk_meshes}
501\end{figure}
502
503\subsubsection{Mesh from a set of triangles or quadrangles}
504This possibility is designed to build a mesh starting from an elementary set of elements. Generally, this initial
505mesh is build ``manually". This gives a flexible mean to create a mesh which cannot be obtained with another
506constructor, but without having to resort to the help of a more complicated solution (like an external mesh
507generator in particular).
508
509Such meshes can be made in 2D or in 3D with triangles or quadrangles. Figure \ref{setofel_meshes} shows
510two examples, in 3D with triangles, in 2D with quadrangles on a domain with a hole.
511\begin{figure}[H]
512 \begin{center}
513  \includePict[scale=0.7]{P1SurfMeshTriSet.pdf}\hskip3cm
514  \includePict[scale=0.7]{P1SurfMeshQuaSet.pdf}
515 \end{center}
516 \caption{Meshes from initial set of triangles and quadrangles.}
517 \label{setofel_meshes}
518\end{figure}
519
520The program that produces it looks like the following:
521
522\medskip
523\begin{lstlisting}[deletekeywords={[3]order}]
524  order = 1, nbsubdiv = 1;
525  SetOfElems sot(tpts, telems, tbounds, _triangle, nbsubdiv);
526  Mesh mT(sot, _triangle, order, _subdiv);
527  SetOfElems soq(qpts, qelems, qbounds, _quadrangle, nbsubdiv);
528  Mesh mQ(soq, _quadrangle, order, _subdiv);
529\end{lstlisting}
530
531The mesh of triangle is based on an initial set of 2 triangles \{1,2,3\} and \{1,4,2\}, stored in the vector elems.
532The 4 points are Point(0.,0.,0.), Point(1.,0.,0.), Point(0.,1.,0.3), Point(0.,-1.,0.3) stored in the vector tpts.
533Four boundaries are defined. A boundary is simply defined by the list of point numbers lying on it, in any order.
534Thus, here, the four boundaries are \{1,4\}, \{4,2\}, \{2,3\} and \{1,3\}; they are stored in the vector tbounds.
535The same apply for the set of quadrangles.
536