TrioCFD 1.9.8
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 Fonction hors classe Decoupe toutes les faces d'un objet Faces
33 *
34 * dont les faces ont 4 sommets
35 * en 2 faces a 3 sommets.
36 *
37 * @param (Faces& faces) l'ensemble des faces a decouper
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 // C'est une face a 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 // C'est une face a 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 // C'est une face a 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 Tetraedrise tous les elements d'un domaine : transforme les elements goemetriques du domaine en tetraedres IDENTIQUES
93 *
94 * par la methode des prismes.
95 * Pour l'instant on ne sait tetraedriser que des Hexaedre.
96 * (on les coupe en 2).
97 * Les elements sont tetraedrises et tous les bords
98 * sont types en Triangle_3D.
99 *
100 * @param (Domaine& domaine) le domaine dont on veut tetraedriser les elements
101 * @throws on ne sait pas Tetraedriser par prisme les elements
102 * geometriques de ce type
103 */
105{
106 if (domaine.type_elem()->que_suis_je() == "Hexaedre")
107 {
108 domaine.typer("Tetraedre");
109 IntTab& les_elems = domaine.les_elems();
110 int oldsz = les_elems.dimension(0);
111 IntTab new_elems(6 * oldsz, 4);
112 for (int i = 0; i < oldsz; i++)
113 {
114 int i0 = les_elems(i, 0);
115 int i1 = les_elems(i, 1);
116 int i2 = les_elems(i, 2);
117 int i3 = les_elems(i, 3);
118 int i4 = les_elems(i, 4);
119 int i5 = les_elems(i, 5);
120 int i6 = les_elems(i, 6);
121 int i7 = les_elems(i, 7);
122 {
123 new_elems(i, 0) = i0;
124 new_elems(i, 1) = i1;
125 new_elems(i, 2) = i2;
126 new_elems(i, 3) = i5;
127
128 new_elems(i + oldsz, 0) = i0;
129 new_elems(i + oldsz, 1) = i2;
130 new_elems(i + oldsz, 2) = i4;
131 new_elems(i + oldsz, 3) = i5;
132 mettre_a_jour_sous_domaine(domaine, i, i + oldsz, 1);
133
134 new_elems(i + 2 * oldsz, 0) = i1;
135 new_elems(i + 2 * oldsz, 1) = i2;
136 new_elems(i + 2 * oldsz, 2) = i3;
137 new_elems(i + 2 * oldsz, 3) = i5;
138 mettre_a_jour_sous_domaine(domaine, i, i + 2 * oldsz, 1);
139
140 new_elems(i + 3 * oldsz, 0) = i2;
141 new_elems(i + 3 * oldsz, 1) = i3;
142 new_elems(i + 3 * oldsz, 2) = i5;
143 new_elems(i + 3 * oldsz, 3) = i7;
144 mettre_a_jour_sous_domaine(domaine, i, i + 3 * oldsz, 1);
145
146 new_elems(i + 4 * oldsz, 0) = i2;
147 new_elems(i + 4 * oldsz, 1) = i4;
148 new_elems(i + 4 * oldsz, 2) = i5;
149 new_elems(i + 4 * oldsz, 3) = i6;
150 mettre_a_jour_sous_domaine(domaine, i, i + 4 * oldsz, 1);
151
152 new_elems(i + 5 * oldsz, 0) = i2;
153 new_elems(i + 5 * oldsz, 1) = i5;
154 new_elems(i + 5 * oldsz, 2) = i6;
155 new_elems(i + 5 * oldsz, 3) = i7;
156 mettre_a_jour_sous_domaine(domaine, i, i + 5 * oldsz, 1);
157 }
158 }
159 les_elems.ref(new_elems);
160 }
161 else
162 Cerr << "We do not yet know how to Tetraedriser_par_prisme the " << domaine.type_elem()->que_suis_je() << "s" << finl;
163
164 for (auto &itr : domaine.faces_bord())
165 {
166 Faces& les_faces = itr.faces();
167 les_faces.typer(Type_Face::triangle_3D);
168 decoupe(domaine, les_faces);
169 }
170
171 for (auto &itr : domaine.faces_raccord())
172 {
173 Faces& les_faces = itr->faces();
174 les_faces.typer(Type_Face::triangle_3D);
175 decoupe(domaine, les_faces);
176 }
177
178 for (auto &itr : domaine.bords_int())
179 {
180 Faces& les_faces = itr.faces();
181 les_faces.typer(Type_Face::triangle_3D);
182 decoupe(domaine, les_faces);
183 }
184
185 for (auto &itr : domaine.groupes_faces())
186 {
187 Faces& les_faces = itr.faces();
188 les_faces.typer(Type_Face::triangle_3D);
189 decoupe(domaine, les_faces);
190 }
191}
192
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 &)
Type les faces.
Definition Faces.cpp:390
IntTab_t & voisins()
Renvoie le tableau des voisins (des faces).
Definition Faces.h:89
const IntTab_t & les_sommets() const
Renvoie le tableau des sommets de toutes les 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 &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Classe de base des flux de sortie.
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
Classe Tetra_par_prisme Cette classe est un interprete qui sert a lire et executer.
void trianguler(Domaine &) const override
Tetraedrise tous les elements d'un domaine : transforme les elements goemetriques du domaine en tetra...
Triangulation_base Classe destinee a factoriser l'action de triangulation des interpretes.