TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Tetraedriser.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.h>
17
18Implemente_instanciable(Tetraedriser, "Tetraedriser", Triangulation_base);
19// XD tetraedriser interprete tetraedriser INHERITS_BRACE To achieve a tetrahedral mesh based on a mesh comprising
20// XD_CONT blocks, the Tetraedriser (Tetrahedralise) interpretor is used in VEF discretization. Initial block is divided
21// XD_CONT in 6 tetrahedra: \includeimage{{tetraedriser.jpeg}}
22// XD attr domain_name ref_domaine domain_name REQ Name of domain.
23
24
26
28
29/*! @brief Function outside class Cuts all faces of a Faces object
30 *
31 * whose faces have 4 vertices
32 * into 2 faces with 3 vertices.
33 *
34 * @param (Faces& faces) the set of faces to cut
35 */
36static void decoupe(Faces& faces)
37{
38 IntTab& sommets = faces.les_sommets();
39 int nb_faces = sommets.dimension(0);
40 assert(sommets.dimension(1) == 4);
41 IntTab nouveaux(2 * nb_faces, 3);
42 faces.voisins().resize(2 * nb_faces, 2);
43 faces.voisins() = -1;
44 for (int i = 0; i < nb_faces; i++)
45 {
46 int i1 = sommets(i, 0);
47 int i2 = sommets(i, 1);
48 int i3 = sommets(i, 2);
49 int i4 = sommets(i, 3);
50 nouveaux(i, 0) = i1;
51 nouveaux(i, 1) = i2;
52 nouveaux(i, 2) = i3;
53 nouveaux(nb_faces + i, 0) = i2;
54 nouveaux(nb_faces + i, 1) = i3;
55 nouveaux(nb_faces + i, 2) = i4;
56 }
57 sommets.ref(nouveaux);
58}
59
60/*! @brief Tetrahedralizes all elements of a domain: transforms the geometric elements of the domain into tetrahedra.
61 *
62 * For now we can only tetrahedralize Hexahedra.
63 * (we cut them into 2).
64 * The elements are tetrahedralized and all boundaries
65 * are typed as Triangle_3D.
66 *
67 * @param (Domaine& domaine) the domain whose elements we want to tetrahedralize
68 * @throws we do not know how to tetrahedralize elements
69 * of this geometric type
70 */
72{
73 if (domaine.type_elem()->que_suis_je() == "Hexaedre")
74 {
75 domaine.typer("Tetraedre");
76 IntTab& les_elems = domaine.les_elems();
77 int oldsz = les_elems.dimension(0);
78 IntTab new_elems(6 * oldsz, 4);
79 for (int i = 0; i < oldsz; i++)
80 {
81 int i0 = les_elems(i, 0);
82 int i1 = les_elems(i, 1);
83 int i2 = les_elems(i, 2);
84 int i3 = les_elems(i, 3);
85 int i4 = les_elems(i, 4);
86 int i5 = les_elems(i, 5);
87 int i6 = les_elems(i, 6);
88 int i7 = les_elems(i, 7);
89 {
90 new_elems(i, 0) = i0;
91 new_elems(i, 1) = i1;
92 new_elems(i, 2) = i2;
93 new_elems(i, 3) = i4;
94
95 new_elems(i + oldsz, 0) = i1;
96 new_elems(i + oldsz, 1) = i2;
97 new_elems(i + oldsz, 2) = i3;
98 new_elems(i + oldsz, 3) = i6;
99 mettre_a_jour_sous_domaine(domaine, i, i + oldsz, 1);
100
101 new_elems(i + 2 * oldsz, 0) = i1;
102 new_elems(i + 2 * oldsz, 1) = i2;
103 new_elems(i + 2 * oldsz, 2) = i4;
104 new_elems(i + 2 * oldsz, 3) = i6;
105 mettre_a_jour_sous_domaine(domaine, i, i + 2 * oldsz, 1);
106
107 new_elems(i + 3 * oldsz, 0) = i3;
108 new_elems(i + 3 * oldsz, 1) = i5;
109 new_elems(i + 3 * oldsz, 2) = i6;
110 new_elems(i + 3 * oldsz, 3) = i7;
111 mettre_a_jour_sous_domaine(domaine, i, i + 3 * oldsz, 1);
112
113 new_elems(i + 4 * oldsz, 0) = i1;
114 new_elems(i + 4 * oldsz, 1) = i4;
115 new_elems(i + 4 * oldsz, 2) = i5;
116 new_elems(i + 4 * oldsz, 3) = i6;
117 mettre_a_jour_sous_domaine(domaine, i, i + 4 * oldsz, 1);
118
119 new_elems(i + 5 * oldsz, 0) = i1;
120 new_elems(i + 5 * oldsz, 1) = i3;
121 new_elems(i + 5 * oldsz, 2) = i5;
122 new_elems(i + 5 * oldsz, 3) = i6;
123 mettre_a_jour_sous_domaine(domaine, i, i + 5 * oldsz, 1);
124 }
125 }
126 les_elems.ref(new_elems);
127 }
128 else
129 {
130 Cerr << "We do not yet know how to Tetraedriser the " << domaine.type_elem()->que_suis_je() << "s" << finl;
131 Cerr << "Try to use Tetraedriser_homogene_compact instead." << finl;
133 }
134
135 for (auto &itr : domaine.faces_bord())
136 {
137 Faces& les_faces = itr.faces();
138 les_faces.typer(Type_Face::triangle_3D);
139 decoupe(les_faces);
140 }
141
142 for (auto &itr : domaine.faces_raccord())
143 {
144 Faces& les_faces = itr->faces();
145 les_faces.typer(Type_Face::triangle_3D);
146 decoupe(les_faces);
147 }
148
149 for (auto &itr : domaine.bords_int())
150 {
151 Faces& les_faces = itr.faces();
152 les_faces.typer(Type_Face::triangle_3D);
153 decoupe(les_faces);
154 }
155
156 for (auto &itr : domaine.groupes_faces())
157 {
158 Faces& les_faces = itr.faces();
159 les_faces.typer(Type_Face::triangle_3D);
160 decoupe(les_faces);
161 }
162}
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
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 Tetraedriser This class is an interpreter used to read and execute.
void trianguler(Domaine &) const override
Tetrahedralizes all elements of a domain: transforms the geometric elements of the domain into tetrah...
Triangulation_base Base class intended to factor out the triangulation action of interpreters.