TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Decouper_Bord_coincident.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Decouper_Bord_coincident.h>
17#include <EFichier.h>
18#include <ArrOfBit.h>
19#include <Scatter.h>
20
21Implemente_instanciable(Decouper_Bord_coincident,"Decouper_Bord_coincident",Interprete_geometrique_base);
22// XD decouper_bord_coincident interprete decouper_bord_coincident INHERITS_BRACE In case of non-coincident meshes and a
23// XD_CONT paroi_contact condition, run is stopped and two external files are automatically generated in VEF
24// XD_CONT (connectivity_failed_boundary_name and connectivity_failed_pb_name.med). In 2D, the keyword
25// XD_CONT Decouper_bord_coincident associated to the connectivity_failed_boundary_name file allows to generate a new
26// XD_CONT coincident mesh.
27// XD attr domain_name ref_domaine domain_name REQ Name of domain.
28// XD attr bord chaine bord REQ connectivity_failed_boundary_name
29
30
32
34
36{
37 if(dimension==3)
38 {
39 Cerr << "We do not know how to split in 3D" << finl;
40 exit();
41 }
43 is >> nom_bord;
44
46
47 Cerr << "Decouper_Bord_coincident... OK" << finl;
48 return is;
49}
50
51
53{
54 if (domaine.type_elem()->que_suis_je() == "Triangle")
55 // ||(domaine.type_elem()->que_suis_je() == "Tetraedre"))
56 {
57 Nom fichier="connectivity_failed_";
58 fichier+=nom_bord;
59 EFichier fic(fichier);
60
61 if(!fic.good())
62 {
63 Cerr << "The file " << fichier << " was not found !!! " << finl;
64 exit();
65 }
66
67 const DoubleTab& xs = domaine.coord_sommets();
68 IntTab& les_elems = domaine.les_elems();
69 int oldsz = les_elems.dimension(0);
70 int oldnbsom = domaine.nb_som();
71
72 IntTab new_elems(3*oldsz, dimension+1); // over-dimensioned array
73
74 // Build the Octree on the base VEF grid
75 domaine.construit_octree();
76
77 //First dimension the vertex array
78 //then resize it at the end to the exact size
80
81 DoubleTab& sommets_dom = domaine.les_sommets();
82 //int dim_som_old=sommets_domaine.dimension(0); // dim_som_old = oldnbsom
83 sommets_dom.resize(2*oldnbsom,dimension);
84
85 // Initialize new_elem based on the unsplit mesh:
86
87 for(int elem=0; elem<oldsz; elem++)
88 {
89 for(int k=0; k<dimension+1; k++)
90 new_elems(elem, k) = les_elems(elem,k);
92 }
93
94
95 int face_oldsz, face_newsz, fac, indice;
96
97 fic >> face_oldsz;
98 fic >> face_newsz;
99
100 IntTab new_faces_racc(face_newsz, dimension);
101 // IntTab new_faces_int(3*face_oldsz, dimension); // over-dimensioned array
102
103 int j,elem;
104 int j0=0,j1=0,j2=0;
105 int som1=0,som2=0;
106
107
108 // compteurs
109
110 int indice_new_som = oldnbsom;
111 int i=0;
112 // int ii=0;
113
114 fic >> indice ;
115
116 while (indice!=-1)
117 {
118 if (!fic.good())
119 {
120 Cerr<<"Pb with "<<fichier <<" in Decouper_Bord_coincident::interpreter_"<<finl;
121 Cerr<<" eof ???"<<finl;
122 exit();
123 }
124
125 fic >> fac >> elem >> j ;
126
127 if(j==0)
128 {
129 j0=0;
130 j1=1;
131 j2=2;
132 }
133 else if(j==1)
134 {
135 j0=1;
136 j1=0;
137 j2=2;
138 }
139 else if(j==2)
140 {
141 j0=2;
142 j1=0;
143 j2=1;
144 }
145 else
146 {
147 Cerr << " problem with the index j " << finl;
148 exit();
149 }
150
151 if(indice==1) // boundary face not to be split
152 {
153 new_faces_racc(fac,0) = les_elems(elem,j1);
154 new_faces_racc(fac,1) = les_elems(elem,j2);
155 }
156 else if(indice==2) // boundary face to be split
157 {
158 som1=les_elems(elem,j1);
159 som2=les_elems(elem,j2);
160
161 sommets_dom(indice_new_som,0) = 0.5*(xs(som1,0)+xs(som2,0));
162 sommets_dom(indice_new_som,1) = 0.5*(xs(som1,1)+xs(som2,1));
163
164 //////////////////////////////////////////////////
165
166 new_elems(elem, 0) = les_elems(elem,j0);
167 new_elems(elem, 1) = les_elems(elem,j1);
168 new_elems(elem, 2) = indice_new_som;
169
170 new_faces_racc(fac,0) = les_elems(elem,j1);
171 new_faces_racc(fac,1) = indice_new_som;
172
173 //////////////////////////////////////////////////
174
175 new_elems(i+oldsz, 0) = les_elems(elem,j0);
176 new_elems(i+oldsz, 1) = les_elems(elem,j2);
177 new_elems(i+oldsz, 2) = indice_new_som;
178
179 new_faces_racc(i+face_oldsz,0) = les_elems(elem,2);
180 new_faces_racc(i+face_oldsz,1) = indice_new_som;
181
182 indice_new_som++;
183 i++;
184
185 //////////////////////////////////////////////////
186
187 // new_faces_int(ii,0) = les_elems(elem,j0);
188 // new_faces_int(ii,1) = indice_new_som;
189 //
190 // ii++;
191 }
192 else
193 {
194 Cerr << "problem with the partition of the element to realize" << finl;
195 Cerr << "We do not know how to split in " << indice << finl;
196 exit();
197 }
198
199 fic >> indice ;
200
201 }//while
202
203
204 Cerr << " Number of boundary face (generated) " << i+face_oldsz << finl;
205 Cerr << " Number of boundary face (planned) " << face_newsz << finl;
206
207 if( (i+face_oldsz) != face_newsz)
208 {
209 Cerr << " Concern in the reconstruction " << finl;
210 exit();
211 }
212
213
214 sommets_dom.resize(indice_new_som,dimension);
215 new_elems.resize(i+oldsz,dimension+1);
216 les_elems.ref(new_elems);
217 // new_faces_int.resize(ii,dimension);
218
219 // Rebuild the octree
220 Cerr << "Splitting performs ..." << finl;
221 domaine.invalide_octree();
222 if(dimension==2)
223 domaine.typer("Triangle");
224 else
225 domaine.typer("Tetraedre");
226 Cerr << " Reconstruction of the Octree" << finl;
227 domaine.construit_octree();
228 Cerr << " Octree rebuilt" << finl;
229
230 {
231 // Connections
232 Cerr << "Splitting of connections" << finl;
233 for (auto &itr : domaine.faces_raccord())
234 {
235 if (itr->le_nom() == nom_bord)
236 {
237 Faces& les_faces = itr->faces();
238 if (dimension == 2)
239 les_faces.typer(Type_Face::segment_2D);
240 else
241 les_faces.typer(Type_Face::triangle_3D);
242
243 IntTab& sommets = les_faces.les_sommets();
244 assert(sommets.dimension(1) == dimension);
245 sommets.ref(new_faces_racc);
246 les_faces.voisins().resize(face_newsz, 2);
247 les_faces.voisins() = -1;
248 }
249 }
250 }
252 Cerr<<"END of Decouper_Bord_coincident..."<<finl;
253 Cerr<<" 1 NbElem="<<domaine.les_elems().dimension(0)<<" NbSom="<<domaine.nb_som()<<finl;
254 }
255 else
256 {
257 Cerr << "We do not yet know how to Decouper_Bord_coincident the "
258 << domaine.type_elem()->que_suis_je() <<"s"<<finl;
259 }
260}
class Decouper_Bord_coincident Generates a mesh by splitting each triangle into 4 new triangles,
Entree & interpreter_(Entree &) override
File for reading. This class is to the C++ ifstream class what the Entree class is to the.
Definition EFichier.h:29
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
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
static int dimension
Definition Objet_U.h:94
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
static void init_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
Create parallel descriptors for the vertex and element arrays of the domain (necessary because Scatte...
Definition Scatter.cpp:2739
static void uninit_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
Method used by interpreters that modify the domain (sequential), destroys the descriptors of vertices...
Definition Scatter.cpp:2754
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