TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Lire_Tgrid.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 <NettoieNoeuds.h>
17#include <Lire_Tgrid.h>
18#include <Frontiere.h>
19#include <TRUST_Ref.h>
20#include <EFichier.h>
21#include <Domaine.h>
22#include <ctype.h>
23#include <math.h>
24
25// Methode a remonter dans une classe au dessus de toutes les classes lire_...
26// Ou a placer dans le constructeur d'EFichier avec eventuellement un
27// effacement du fichier decompresse dans le desctructeur d'EFichier
28inline void decompression(Nom& nom_fichier)
29{
30 Nom tmp(nom_fichier);
31 if (tmp.prefix(".gz")!=nom_fichier)
32 {
33 Cerr << "Unzipping file " << nom_fichier << " ..." << finl;
34 Nom cmd="gunzip -c ";
35 cmd+=nom_fichier+" > "+tmp;
36 Cerr << (int)system(cmd) << finl;
37 nom_fichier=tmp;
38 }
39}
40Implemente_instanciable(Lire_Tgrid,"Lire_Tgrid",Interprete_geometrique_base);
41// XD read_tgrid interprete lire_tgrid INHERITS_BRACE Keyword to reaf Tgrid/Gambit mesh files. 2D (triangles or
42// XD_CONT quadrangles) and 3D (tetra or hexa elements) meshes, may be read by TRUST.
43// XD attr dom ref_domaine dom REQ Name of domaine.
44// XD attr filename chaine filename REQ Name of file containing the mesh.
45
46Sortie& Lire_Tgrid::printOn(Sortie& os) const { return Interprete::printOn(os); }
47
49
50int chartoint(char c)
51{
52 if( (0>(c-'0')) || ((c-'0')>9) )
53 return -1;
54 else
55 return (c-'0');
56}
57
58// Convertit une chaine au format hexa (00aad22) en une valeur entiere
59int htoi(const char * szChaine)
60{
61 int lResult = 0;
62 int iLength = 0;
63 // Pointeur null, on renvoi -1
64 if (szChaine == nullptr)
65 return -1;
66 // On calcule la longueur de la chaine
67 iLength = (int)strlen(szChaine);
68
69 // On met la chaine en majuscule dans une nouvelle chaine (allouee par strdup)
70 char * szHexaString = strdup(szChaine);
71 // Pour chaque caractere on calcule sa valeur
72 for (int i = iLength - 1; i >= 0; i--)
73 {
74 char cCharacter = szHexaString[i];
75 int iValue = 0;
76 // C'est un digit, on le convertit en entier
77 if (isdigit(cCharacter))
78 {
79 //iValue = atoi(&cCharacter);
80 // atoi a l'air mechamment bugge !
81 // Je code un chartoint correct !
82 iValue = chartoint(cCharacter);
83 if (iValue>9)
84 {
85 Cerr << "iValue is worth " << iValue << " ! " << finl;
87 }
88 }
89 // C'est un caractere, on lui associe une valeur entiere
90 else if (isalpha(cCharacter))
91 {
92 switch(cCharacter)
93 {
94 case 'A' :
95 case 'a' :
96 iValue = 10;
97 break;
98 case 'B' :
99 case 'b' :
100 iValue = 11;
101 break;
102 case 'C' :
103 case 'c' :
104 iValue = 12;
105 break;
106 case 'D' :
107 case 'd' :
108 iValue = 13;
109 break;
110 case 'E' :
111 case 'e' :
112 iValue = 14;
113 break;
114 case 'F' :
115 case 'f' :
116 iValue = 15;
117 break;
118 default :
119 return -3; // Caractere invalide en Hexa.
120 }
121 }
122 // Ce n'est ni un caractere ni un digit.
123 else
124 return -4; // Caractere non valide.
125 //lResult += iValue * pow(16, iLength - i - 1);
126 for (int puissance=0; puissance<iLength - i - 1; puissance++)
127 iValue *= 16;
128 lResult += iValue;
129 }
130 // Liberation de la chaine allouee
131 free (szHexaString);
132 //Cerr << lResult << finl;
133 return lResult;
134}
135
136inline void va_a_la_parenthese_fermante(EFichier& fic)
137{
138 int parenthese_ouverte=1;
139 Nom lu;
140 while ((parenthese_ouverte!=0)&&(fic.good()))
141 {
142 fic >> lu;
143 const char* chaine = lu.getChar();
144 Process::Journal()<<"|"<<chaine<<"|"<<finl;
145 size_t iLength = strlen(chaine);
146 for (size_t i=0; i<iLength; i++)
147 {
148 char c = chaine[i];
149 switch(c)
150 {
151 case 40 :
152 parenthese_ouverte++;
153 break;
154 case 41 :
155 parenthese_ouverte--;
156 break;
157 }
158 }
159 }
160
161 if (parenthese_ouverte!=0)
162 {
163 Cerr<< "Error in file"<<finl;
165 }
166
167}
168inline void va_a_la_parenthese_ouvrante(EFichier& fic)
169{
170 int ok=0;
171 Nom lu;
172 while (ok!=1)
173 {
174 fic >> lu;
175 const char* chaine = lu.getChar();
176 size_t iLength = strlen(chaine);
177 for (size_t i=0; i<iLength; i++)
178 {
179 char c = chaine[i];
180 switch(c)
181 {
182 case 40 :
183 ok=1;
184 break;
185 }
186 }
187 }
188}
189
190/*! @brief Lecture d'un fichier Avec 2 arguments nom1 et nom2 , lit l'objet du fichier nom2 dans l'objet nom1
191 *
192 * Avec un seul argument nom1, interprete le fichier de nom nom1
193 *
194 * @param (Entree& is)
195 * @return (Entree&)
196 */
198{
199 Cerr << "Reading a mesh which comes from Tgrid" << finl;
201 Domaine& dom=domaine();
202 DoubleTab& coord_sommets=dom.les_sommets();
203 // Declaration des variables
204 int dim = -1;
205 int nb_som = 0;
206 int nb_elem = 0;
207 int nb_face = 0;
208 int nb_som_elem = 0;
209 int type_elements = 0;
210 int compteur = 0;
211 // Tableau de travail
212 ArrOfInt nb_som_lu_elem;
213 Motcle motlu;
214 // Gestion fichier
215 Nom nom_fichier;
216 is >> nom_fichier;
217 decompression(nom_fichier);
218 Cerr << "Reading of the file " << nom_fichier << " ..." << finl;
219 EFichier lecture(nom_fichier);
220 // On teste tout de suite l'existence du fichier car s'il
221 // n'existe pas, cela bloque dans le eof();
222 if (!lecture.good())
223 {
224 Cerr << "Problem to open the file " << nom_fichier << finl;
225 Cerr << "There is maybe an error in the filename." << finl;
226 exit();
227 }
228
229 // Premiere lecture du fichier .msh
230 //pour trouver le nombre d'element car
231 // il est parfois place en fin de fichier !
232 while (!lecture.eof())
233 {
234 lecture >> motlu;
235 if (motlu=="(12")
236 {
237 lecture >> motlu;
238 if (motlu=="(0")
239 {
240 lecture >> motlu; // Numero premier element
241 lecture >> motlu; // Nombre d'element
242 nb_elem=htoi(motlu);
243 Cerr << "The total number of elements to read is " << nb_elem << finl;
244 lecture >> motlu; // Type du domaine (0=dead domaine; 1=active domaine; 32=inactive domaine) ou 0))
245 if (motlu!="0))") lecture >> motlu; // On saut le type s'il existe
246 }
247 else if (motlu=="(id") lecture >> motlu; // evite de lire la description de la balise (12
248 else
249 {
250 lecture >> motlu; // Numero premier element
251 lecture >> motlu; // Nombre d'element
252 lecture >> motlu; // Type de domaine (1:fluid ou 0x11:solid)
253 lecture >> motlu; // Type des elements
254 if (motlu=="1))")
255 {
256 // On lit des triangles
257 type_elements=1;
258 Cerr << "2D elements of type Triangle" << finl;
259 }
260 else if (motlu=="3))")
261 {
262 // On lit des quadrangles
263 type_elements=3;
264 Cerr << "2D elements of type Quadrangle" << finl;
265 }
266 else if (motlu=="2))")
267 {
268 // On lit des tetraedres
269 type_elements=2;
270 Cerr << "3D elements of type Tetrahedron" << finl;
271 }
272 else if (motlu=="4))")
273 {
274 // On lit des hexaedres
275 type_elements=4;
276 Cerr << "3D elements of type Hexahedron" << finl;
277 }
278 else
279 {
280 // On ne sait pas ce qu'on lit
281 Cerr << "Elements unknown !" << finl;
282 Cerr << "It should probably crashed !!!!!" << finl;
283 }
284 lecture.close();
285 }
286 }
287 }
288 // Deuxieme lecture du fichier .msh
289 EFichier fic(nom_fichier);
290 while (!fic.eof())
291 {
292 fic >> motlu;
293 if (motlu=="(0")
294 {
295 Cerr << "Reading a comment:" << finl;
296 Cerr << motlu;
297 va_a_la_parenthese_fermante(fic);
298 Cerr << finl << finl;
299 }
300 else if (motlu=="(1")
301 {
302 Cerr << "Reading a header:" << finl;
303 Cerr << motlu;
304 va_a_la_parenthese_fermante(fic);
305 Cerr << finl << finl;
306 }
307 else if (motlu=="(2")
308 {
309 Cerr << "Reading of the dimension of the case:" << finl;
310 fic >> motlu;
311 dim=atoi(motlu.prefix(")"));
312 if (dim==3) Cerr << "Dimension 3." << finl;
313 else if (dim==2) Cerr << "Dimension 2." << finl;
314 else
315 {
316 Cerr << "Dimension " << dim << " of the mesh not provided." << finl;
317 exit();
318 }
319 Cerr << finl;
320 }
321 else if (motlu=="(10")
322 {
323 fic >> motlu;
324 if (motlu=="(0")
325 {
326 fic >> motlu; // Numero du premier sommet
327 fic >> motlu; // Nombre de sommets
328 nb_som=htoi(motlu);
329 Cerr << "The total number of nodes to read is " << nb_som << finl;
330 // On dimensionne le tableau des sommets
331 coord_sommets.resize(nb_som,dim);
332 // Depend du format
333 fic >> motlu;
334 Nom tmp=motlu;
335 if (tmp==motlu.prefix("))"))
336 fic >> motlu;
337 }
338 else
339 {
340 int idomaine=htoi(motlu.suffix("("));
341 fic >> motlu; // Debut
342 int ideb=htoi(motlu);
343 fic >> motlu; // Fin
344 int ifin=htoi(motlu);
345 Cerr << ifin-ideb+1 << " nodes are read in the area " << idomaine << finl;
346 // Depend du format, on va donc a la paranthese ouvrante
347 va_a_la_parenthese_ouvrante(fic);
348 /*
349 fic >> motlu; // Type (0: virtual, 1:any, 2:boundary)
350 if (motlu.prefix(")"))
351 fic >> motlu; // Dimension
352 assert(htoi(motlu.prefix(")"))==dim);
353 fic >> motlu; // ( */
354
355 for (int i=ideb-1; i<ifin; i++)
356 for (int j=0; j<dim; j++)
357 fic >> coord_sommets(i,j);
358 fic >> motlu; // ))
359 }
360 Cerr << finl;
361 }
362 else if (motlu=="(12")
363 {
364 fic >> motlu;
365 if (motlu=="(0")
366 {
367 // Informations obtenues lors de la premiere lecture
368 fic >> motlu; // Numero premier element
369 fic >> motlu; // Nombre d'element
370 fic >> motlu; // Type du domaine (0=dead domaine; 1=active domaine; 32=inactive domaine) ou 0))
371 if (motlu!="0))") fic >> motlu; // On saut le type s'il existe
372 }
373 else
374 {
375 int idomaine=htoi(motlu.suffix("("));
376 fic >> motlu; // Debut
377 //int ideb=htoi(motlu);
378 fic >> motlu; // Fin
379 //int ifin=htoi(motlu);
380 fic >> motlu; // Type (1:fluid, Ox11:solid)
381 int type=htoi(motlu);
382 Cerr << "The type of area " << idomaine << " is " << type << " (1:fluid, 17:solid)" << finl;
383 fic >> motlu; // Type cell (0:mixed,1:tri,2:tetra,3:quad,4:hexa,5:pyramid,6:wedge)
384 if (motlu=="2))")
385 {
386 // On lit bien des tetraedres
387 dom.type_elem().typer("Tetraedre");
388 }
389 else if (motlu=="4))")
390 {
391 // On lit bien des hexaedres
392 dom.type_elem().typer("Hexaedre_VEF");
393 }
394 else if (motlu=="1))")
395 {
396 // On lit bien des triangles
397 dom.type_elem().typer("Triangle");
398 }
399 else if (motlu=="3))")
400 {
401 // On lit bien des quadrangles
402 dom.type_elem().typer("Quadrangle");
403 }
404 else
405 {
406 Cerr << "Reading the elements is not provided in this interpreter." << finl;
407 Cerr << "Indeed, we read faces to reconstruct the elements." << finl;
408 Cerr << "Contact TRUST support." << finl;
409 exit();
410 }
411 dom.type_elem()->associer_domaine(dom);
412 }
413 Cerr << finl;
414 }
415 else if (motlu.debute_par("(13"))
416 {
417 motlu.suffix("(13");
418 if (motlu=="")
419 fic >> motlu;
420 if (motlu=="(0")
421 {
422 fic >> motlu; // Numero de la premiere face
423 fic >> motlu; // Nombre de faces
424 nb_face=htoi(motlu);
425 Cerr << "The total number of faces to read is " << nb_face << finl;
426 fic >> motlu; // Type de face ou 0))
427 if (motlu != "0))") fic >> motlu; // On saut le type s'il existe
428 }
429 else
430 {
431 int idomaine=htoi(motlu.suffix("("));
432 fic >> motlu; // Debut
433 int ideb=htoi(motlu);
434 fic >> motlu; // Fin
435 int ifin=htoi(motlu);
436 fic >> motlu; // Type (2: interior, >2: boundary condition): ne semble pas vrai (voir page C-8)!
437 int type=htoi(motlu);
438 fic >> motlu; // Type face (0:mixed, 2:linear, 3:triangular, 4:quadrilateral)
439 // Depend du format:
440 Nom tmp=motlu;
441 int nb_som_face,mixte=0;
442 if (tmp!=motlu.prefix(")"))
443 fic >> tmp; // (
444 else
445 motlu.prefix(")(");
446 nb_som_face=htoi(motlu);
447 if (nb_som_face==0)
448 {
449 mixte=1; // On va lire des elements mixtes en esperant qu'ils sont de meme type
450 fic >> motlu; // On lit la premiere ligne
451 nb_som_face=htoi(motlu);
452 }
453 if (nb_som_face==3)
454 nb_som_elem=4; // On va lire des triangles donc les elements sont des tetras (4 sommets)
455 else if (nb_som_face==4)
456 nb_som_elem=8; // On va lire des quadrangles donc les elements sont des hexas (8 sommets)
457 else if (nb_som_face==2 && type_elements==1)
458 nb_som_elem=3; // On va lire des segments dont les elements sont des triangles (3 sommets)
459 else if (nb_som_face==2 && type_elements==3)
460 nb_som_elem=4; // On va lire des segments dont les elements sont des quadrangles (4 sommets)
461 else
462 {
463 if (nb_som_face==0)
464 Cerr << "It seems that we try to read faces with different types..." << finl;
465 // if (nb_som_face==2) // N'est plus necessaire, vu qu'on sait lire
466 // Cerr << "Il semble que l'on essaie de lire un segment..." << finl; // maintenant des segments
467 Cerr << "The case of faces that are not triangles or quadrangles" << finl;
468 Cerr << "or a mixture of several types of faces" << finl;
469 Cerr << "is not yet provided. Your mesh is not only composed" << finl;
470 Cerr << "of tetrahedra, hexahedra, triangles or quadrangles." << finl;
471 exit();
472 }
473 // Tableaux de travail
474 IntTab& les_elems=dom.les_elems();
475 if (les_elems.size()==0)
476 {
477 // Si les_elems n'est pas dimensionne (1ere lecture de faces)
478 les_elems.resize(nb_elem,nb_som_elem);
479 // On initialise a -1 pour voir les sommets non definis
480 les_elems=-1;
481 nb_som_lu_elem.resize_array(nb_elem);
482 nb_som_lu_elem=0;
483 }
484 ArrOfInt elem(2),som(nb_som_face);
485 int nb_face_lu=ifin-ideb+1;
486 OBS_PTR(Frontiere) nouveau_bord;
487 // On lit les sommets de la face et les 2 elements au contact de la face
488 for (int i=0; i<nb_face_lu; i++)
489 {
490 if (mixte && i>0)
491 {
492 fic >> motlu;
493 if (htoi(motlu)!=nb_som_face)
494 {
495 Cerr << "We read an element to " << htoi(motlu) << " faces." << finl;
496 Cerr << "So it was planned to read elements to " << nb_som_face << " faces."<< finl;
497 exit();
498 }
499 }
500 for (int j=0; j<nb_som_face; j++)
501 {
502 fic >> motlu;
503 som[j]=htoi(motlu)-1;
504 }
505 // Pour les hexaedres a cause de la numerotation TRUST, on inverse les sommets 2 et 3
506 if (nb_som_face==4)
507 {
508 int tmp2=som[2];
509 som[2]=som[3];
510 som[3]=tmp2;
511 }
512 fic >> motlu; // premier element voisin de la face (nul si frontiere)
513 elem[0]=htoi(motlu)-1;
514 fic >> motlu; // deuxieme element voisin de la face (nul si frontiere)
515 // Debut Rajout Cyril MALOD : 15-06-2006
516 Nom tmp2=motlu;
517 if (tmp2!=motlu.prefix("))"))
518 {
519 tmp2=motlu.prefix("))");
520 elem[1]=htoi(tmp2)-1;
521 compteur=1; // Ce compteur sert a ne pas lire le "motlu" suivant
522 }
523 else
524 {
525 if (tmp2!=motlu.prefix(")"))
526 {
527 tmp2=motlu.prefix(")");
528 elem[1]=htoi(motlu)-1;
529 compteur=-1; // Ce compteur sert a lire le "motlu" suivant
530 }
531 else
532 {
533 elem[1]=htoi(motlu)-1;
534 compteur=0; // Ce compteur sert a lire le "motlu" suivant
535 }
536 }
537
538 // elem(1)=htoi(motlu)-1;
539 // Fin Rajout Cyril MALOD : 15-06-2006
540 // Premier passage, on verifie bien qu'on lit une frontiere
541 if (i==0)
542 {
543 if (elem[0]<0 || elem[1]<0)
544 {
545 // C'est bien une frontiere donc on dimensionne le necessaire
546 type=3;
547 Cerr << nb_face_lu << " faces are read from the boundary number " << idomaine << finl;
548 nouveau_bord=dom.faces_bord().add(Bord());
549 nouveau_bord->nommer((Nom)idomaine);
550 if (nb_som_face==3)
551 nouveau_bord->faces().typer(Type_Face::triangle_3D);
552 else if (nb_som_face==4)
553 nouveau_bord->faces().typer(Type_Face::quadrangle_3D);
554 else if (nb_som_face==2)
555 nouveau_bord->faces().typer(Type_Face::segment_2D);
556 else
557 {
558 Cerr << "Type of boundary face not provided for nb_som_face=" << nb_som_face << finl;
559 exit();
560 }
561 nouveau_bord->faces().dimensionner(nb_face_lu);
562 }
563 else
564 {
565 type=2;
566 Cerr << nb_face_lu << " internal faces are read in the area " << idomaine << finl;
567 }
568 }
569 // Les faces internes sont lues mais pas stockees, les faces frontieres sont stockees
570 if (type!=2)
571 for (int j=0; j<nb_som_face; j++)
572 nouveau_bord->faces().sommet(i,j)=som[j];
573
574 // On construit le tableau les_elems a partir des faces lues
575 for (int i2=0; i2<2; i2++)
576 {
577 if (elem[i2]>=0) // On ne traite pas les elements -1 voisins des faces frontieres
578 {
579 // Premier remplissage de elem(i)
580 if (nb_som_lu_elem[elem[i2]]==0)
581 {
582 for (int j=0; j<nb_som_face; j++)
583 les_elems(elem[i2],nb_som_lu_elem[elem[i2]]++)=som[j];
584 }
585 else
586 {
587 int face_opposee=1;
588 for (int j=0; j<nb_som_face; j++)
589 {
590 // On ajoute le sommet s'il n'est pas deja dans les_elems
591 int k=0,trouve=0;
592 while (k<nb_som_lu_elem[elem[i2]] && trouve==0)
593 {
594 if (les_elems(elem[i2],k)==som[j])
595 {
596 face_opposee=0;
597 trouve=1;
598 }
599 else
600 k++;
601 }
602 // On ne complete que pour les tetraedres ou les triangles
603 if ((trouve==0 && nb_som_face==3) || (trouve==0 && nb_som_face==2 && type_elements==1))
604 les_elems(elem[i2],nb_som_lu_elem[elem[i2]]++)=som[j];
605
606 assert(elem[i2]<nb_elem);
607 if (nb_som_lu_elem[elem[i2]]>nb_som_elem)
608 {
609 Cerr << "Problem on reading the element " << elem[i2] << finl;
610 Cerr << "There is more than " << nb_som_elem << " nodes !" << finl;
611 Cerr << "Check that the read file contains only tetrahedra or triangles" << finl;
612 Cerr << "or contact TRUST support." << finl;
613 exit();
614 }
615 }
616 // On complete la face opposee de l'hexaedre ou du quadrangle
617 if ((nb_som_face==4 && face_opposee==1) || (nb_som_face==2 && face_opposee==1 && type_elements==3))
618 {
619 for (int j=0; j<nb_som_face; j++)
620 les_elems(elem[i2],nb_som_lu_elem[elem[i2]]++)=som[j];
621 }
622 }
623 }
624 }
625 }
626 if (compteur==0 || compteur==-1)
627 {
628 fic >> motlu; // ) ou ))
629 if (motlu==")" && compteur==0)
630 fic >> motlu; // )
631 }
632 }
633 Cerr << finl;
634 }
635 else if ((motlu=="(45") || (motlu=="(39"))
636 {
637 Cerr << "Reading of a name:" << finl;
638 fic >> motlu; // Numero du domaine
639 // Attention le numero du domaine est en decimal !
640 //int idomaine=htoi(motlu.suffix("("));
641 int idomaine=atoi(motlu.suffix("("));
642 fic >> motlu; // Type du domaine
643 Nom Nomdomaine;
644 fic >> Nomdomaine; // Nom du domaine)())
645 Nom nom_domaine=Nomdomaine;
646 nom_domaine.prefix(")())");
647 if (nom_domaine==Nomdomaine)
648 if (1)
649 {
650 // retour a la ligne ?
651 Nom app;
652 fic >> app;
653 Nomdomaine+=app;
654 nom_domaine=Nomdomaine;
655 nom_domaine.prefix(")())");
656
657 }
658 Cerr << "The area " << idomaine << " is called " << nom_domaine << finl;
659 // On parcourt les bords pour renommer
660 Bords& les_bords=dom.faces_bord();
661 les_bords.associer_domaine(dom);
662 if (les_bords.est_vide())
663 {
664 Cerr << "Reading a name before reading the boundaries..." << finl;
665 Cerr << "Case not provided, contact TRUST support." << finl;
666 exit();
667 }
668
669 for (auto& itr : les_bords)
670 if (itr.le_nom()==(Nom)idomaine) itr.nommer(nom_domaine);
671
672 Cerr << finl;
673 }
674 else
675 {
676 if (motlu.debute_par("("))
677 {
678 Cerr << "Reading a tag:" << finl;
679 Cerr << motlu;
680 va_a_la_parenthese_fermante(fic);
681 Cerr << finl << finl;
682 }
683 else if ( (motlu==" ") || (motlu=="") )
684 {
685 Cerr << "End of file ?" << finl;
686 }
687 else if (motlu!="??")
688 {
689 Cerr << "Tag " << motlu << " unrecognized." << finl;
690 exit();
691 }
692 }
693 }
694 // Verification si le tableau les_elems a ete rempli completement
695 IntTab& les_elems=dom.les_elems();
696 for (int i=0; i<nb_elem; i++)
697 for (int j=0; j<nb_som_elem; j++)
698 if (les_elems(i,j)==-1)
699 {
700 Cerr << "The array of connectivity elements-nodes is wrong filled in Lire_Tgrid::interpreter." << finl;
701 Cerr << "Contact TRUST support." << finl;
702 exit();
703 }
704
705 // On reordonne le domaine (utile surtout pour les hexaedres)
706 dom.type_elem()->reordonner();
707
708 // Nettoie le domaine pour enlever les noeuds inutiles
709 // Mettre une methode a Domaine::nettoie
710 // Attention: les lignes suivantes pas compatibles avec TRUST < v1.4.6
711
714
715 return is;
716}
void associer_domaine(const Domaine_t &)
Associe un domaine a tous les bords de la liste.
Definition Bords.cpp:32
DoubleTab_t & les_sommets()
Definition Domaine.h:113
Bords_t & faces_bord()
Definition Domaine.h:198
IntTab_t & les_elems()
Definition Domaine.h:129
void typer(const Nom &)
Type les elements du domaine avec le nom passe en parametre.
Definition Domaine.h:457
void reordonner()
Definition Domaine.h:104
Fichier en lecture Cette classe est a la classe C++ ifstream ce que la classe Entree est a la.
Definition EFichier.h:29
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Lire_Fichier Lecture d'un fichier
Definition Lire_Tgrid.h:27
Entree & interpreter_(Entree &) override
Lecture d'un fichier Avec 2 arguments nom1 et nom2 , lit l'objet du fichier nom2 dans l'objet nom1.
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
static void nettoie(Domaine_t &)
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const char * getChar() const
Definition Nom.h:91
Nom & prefix(const char *const)
Definition Nom.cpp:329
friend class Entree
Definition Objet_U.h:76
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 Sortie & Journal(int message_level=0)
Renvoie un objet statique de type Sortie qui sert de journal d'evenements.
Definition Process.cpp:588
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static bool is_sequential()
Definition Process.cpp:115
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ size() const
Definition TRUSTVect.tpp:45