TRUST 1.9.8
HPC thermohydraulic platform
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 Fonction hors classe Decoupe toutes les faces d'un objet Faces
30 *
31 * dont les faces on 4 sommets
32 * en 2 faces a 3 sommets.
33 *
34 * @param (Faces& faces) l'ensemble des faces a decouper
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 Tetraedrise tous les elements d'un domaine: transforme les elements goemetriques du domaine en tetraedres.
61 *
62 * Pour l'instant on ne sait tetraedriser que des Hexaedre.
63 * (on les coupe en 2).
64 * Les elements sont tetraedrises et tous les bords
65 * sont types en Triangle_3D.
66 *
67 * @param (Domaine& domaine) le domaine dont on veut tetraedriser les elements
68 * @throws on ne sait pas tetraedriser les elements
69 * geometriques de ce 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 &)
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
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
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 Tetraedriser 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 tetrae...
Triangulation_base Classe destinee a factoriser l'action de triangulation des interpretes.