TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Tetraedriser_par_prisme.cpp
1/****************************************************************************
2* Copyright (c) 2023, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Tetraedriser_par_prisme.h>
17#include <Domaine.h>
18
19Implemente_instanciable(Tetraedriser_par_prisme, "Tetraedriser_par_prisme", Triangulation_base);
20// XD tetraedriser_par_prisme tetraedriser tetraedriser_par_prisme INHERITS_BRACE Tetraedriser_par_prisme generates 6
21// XD_CONT iso-volume tetrahedral element from primary hexahedral one (contrarily to the 5 elements ordinarily generated
22// XD_CONT by tetraedriser). This element is suitable for calculation of gradients at the summit (coincident with the
23// XD_CONT gravity centre of the jointed elements related with) and spectra (due to a better alignment of the points).
24// XD_CONT \includeimage{{tetraedriserparprisme.jpeg}} NL2 \includeimage{{tetraedriserparprisme2.jpeg}} NL2 Initial
25// XD_CONT block is divided in 6 prismes.
26
27
29
31
32/*! @brief Function outside class Cuts all faces of a Faces object
33 *
34 * whose faces have 4 vertices
35 * into 2 faces with 3 vertices.
36 *
37 * @param (Faces& faces) the set of faces to cut
38 */
39static void decoupe(Domaine& dom, Faces& faces)
40{
41 const DoubleTab& coord = dom.coord_sommets();
42
43 IntTab& sommets = faces.les_sommets();
44 int nb_faces = sommets.dimension(0);
45 assert(sommets.dimension(1) == 4);
46 IntTab nouveaux(2 * nb_faces, 3);
47 faces.voisins().resize(2 * nb_faces, 2);
48 faces.voisins() = -1;
49 for(int i=0; i<nb_faces; i++)
50 {
51 int i1 = sommets(i, 0);
52 int i2 = sommets(i, 1);
53 int i3 = sommets(i, 2);
54 int i4 = sommets(i, 3);
55
56 // This is a face with X constant
57 if ((coord(i1, 0) == coord(i2, 0)) && (coord(i1, 0) == coord(i3, 0)))
58 {
59 nouveaux(i, 0) = i1;
60 nouveaux(i, 1) = i2;
61 nouveaux(i, 2) = i3;
62 nouveaux(nb_faces + i, 0) = i2;
63 nouveaux(nb_faces + i, 1) = i3;
64 nouveaux(nb_faces + i, 2) = i4;
65 }
66
67 // This is a face with Z constant
68 if ((coord(i1, 2) == coord(i2, 2)) && (coord(i1, 2) == coord(i3, 2)))
69 {
70 nouveaux(i, 0) = i1;
71 nouveaux(i, 1) = i2;
72 nouveaux(i, 2) = i3;
73 nouveaux(nb_faces + i, 0) = i2;
74 nouveaux(nb_faces + i, 1) = i3;
75 nouveaux(nb_faces + i, 2) = i4;
76 }
77 // This is a face with Y constant
78 if ((coord(i1, 1) == coord(i2, 1)) && (coord(i1, 1) == coord(i3, 1)))
79 {
80 nouveaux(i, 0) = i1;
81 nouveaux(i, 1) = i2;
82 nouveaux(i, 2) = i4;
83 nouveaux(nb_faces + i, 0) = i1;
84 nouveaux(nb_faces + i, 1) = i3;
85 nouveaux(nb_faces + i, 2) = i4;
86 }
87
88 }
89 sommets.ref(nouveaux);
90}
91
92/*! @brief @brief Tetrahedralises all elements of a domain: transforms the geometric elements of the domain into IDENTICAL tetrahedra
93 *
94 * using the prism method.
95 * Currently only Hexaedre elements can be tetrahedralised
96 * (they are split into 2).
97 * All elements are tetrahedralised and all boundaries
98 * are typed as Triangle_3D.
99 *
100 * @param domaine The domain whose elements are to be tetrahedralised.
101 * @throws Cannot tetrahedralise by prism the geometric elements of this type.
102 */
104{
105 if (domaine.type_elem()->que_suis_je() == "Hexaedre")
106 {
107 domaine.typer("Tetraedre");
108 IntTab& les_elems = domaine.les_elems();
109 int oldsz = les_elems.dimension(0);
110 IntTab new_elems(6 * oldsz, 4);
111 for (int i = 0; i < oldsz; i++)
112 {
113 int i0 = les_elems(i, 0);
114 int i1 = les_elems(i, 1);
115 int i2 = les_elems(i, 2);
116 int i3 = les_elems(i, 3);
117 int i4 = les_elems(i, 4);
118 int i5 = les_elems(i, 5);
119 int i6 = les_elems(i, 6);
120 int i7 = les_elems(i, 7);
121 {
122 new_elems(i, 0) = i0;
123 new_elems(i, 1) = i1;
124 new_elems(i, 2) = i2;
125 new_elems(i, 3) = i5;
126
127 new_elems(i + oldsz, 0) = i0;
128 new_elems(i + oldsz, 1) = i2;
129 new_elems(i + oldsz, 2) = i4;
130 new_elems(i + oldsz, 3) = i5;
131 mettre_a_jour_sous_domaine(domaine, i, i + oldsz, 1);
132
133 new_elems(i + 2 * oldsz, 0) = i1;
134 new_elems(i + 2 * oldsz, 1) = i2;
135 new_elems(i + 2 * oldsz, 2) = i3;
136 new_elems(i + 2 * oldsz, 3) = i5;
137 mettre_a_jour_sous_domaine(domaine, i, i + 2 * oldsz, 1);
138
139 new_elems(i + 3 * oldsz, 0) = i2;
140 new_elems(i + 3 * oldsz, 1) = i3;
141 new_elems(i + 3 * oldsz, 2) = i5;
142 new_elems(i + 3 * oldsz, 3) = i7;
143 mettre_a_jour_sous_domaine(domaine, i, i + 3 * oldsz, 1);
144
145 new_elems(i + 4 * oldsz, 0) = i2;
146 new_elems(i + 4 * oldsz, 1) = i4;
147 new_elems(i + 4 * oldsz, 2) = i5;
148 new_elems(i + 4 * oldsz, 3) = i6;
149 mettre_a_jour_sous_domaine(domaine, i, i + 4 * oldsz, 1);
150
151 new_elems(i + 5 * oldsz, 0) = i2;
152 new_elems(i + 5 * oldsz, 1) = i5;
153 new_elems(i + 5 * oldsz, 2) = i6;
154 new_elems(i + 5 * oldsz, 3) = i7;
155 mettre_a_jour_sous_domaine(domaine, i, i + 5 * oldsz, 1);
156 }
157 }
158 les_elems.ref(new_elems);
159 }
160 else
161 Cerr << "We do not yet know how to Tetraedriser_par_prisme the " << domaine.type_elem()->que_suis_je() << "s" << finl;
162
163 for (auto &itr : domaine.faces_bord())
164 {
165 Faces& les_faces = itr.faces();
166 les_faces.typer(Type_Face::triangle_3D);
167 decoupe(domaine, les_faces);
168 }
169
170 for (auto &itr : domaine.faces_raccord())
171 {
172 Faces& les_faces = itr->faces();
173 les_faces.typer(Type_Face::triangle_3D);
174 decoupe(domaine, les_faces);
175 }
176
177 for (auto &itr : domaine.bords_int())
178 {
179 Faces& les_faces = itr.faces();
180 les_faces.typer(Type_Face::triangle_3D);
181 decoupe(domaine, les_faces);
182 }
183
184 for (auto &itr : domaine.groupes_faces())
185 {
186 Faces& les_faces = itr.faces();
187 les_faces.typer(Type_Face::triangle_3D);
188 decoupe(domaine, les_faces);
189 }
190}
191
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void typer(const Motcle &)
Sets the type of the faces.
Definition Faces.cpp:382
IntTab_t & voisins()
Returns the array of neighbors (of the faces).
Definition Faces.h:89
const IntTab_t & les_sommets() const
Returns the array of vertices of all faces.
Definition Faces.h:74
void mettre_a_jour_sous_domaine(Domaine_t &domaine, int_t &elem, int_t num_premier_elem, int_t nb_elem) const
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for output streams.
Definition Sortie.h:52
virtual void ref(const TRUSTTab &)
Definition TRUSTTab.tpp:308
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
Class Tetra_par_prisme This class is an interpreter that serves to read and execute.
void trianguler(Domaine &) const override
Tetrahedralises all elements of a domain: transforms the geometric elements of the domain into IDENTI...
Triangulation_base Base class intended to factor out the triangulation action of interpreters.