TrioCFD 1.9.9_beta
TrioCFD documentation
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// Method to be moved to a base class above all lire_... classes,
26// or to be placed in the EFichier constructor with optional deletion
27// of the decompressed file in the EFichier destructor.
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// Converts a hex-format string (e.g. "00aad22") to an integer value
59int htoi(const char * szChaine)
60{
61 int lResult = 0;
62 int iLength = 0;
63 // Null pointer: return -1
64 if (szChaine == nullptr)
65 return -1;
66 // Compute the string length
67 iLength = (int)strlen(szChaine);
68
69 // Convert the string to uppercase in a new string (allocated by strdup)
70 char * szHexaString = strdup(szChaine);
71 // For each character, compute its integer value
72 for (int i = iLength - 1; i >= 0; i--)
73 {
74 char cCharacter = szHexaString[i];
75 int iValue = 0;
76 // It's a digit, convert it to integer
77 if (isdigit(cCharacter))
78 {
79 //iValue = atoi(&cCharacter);
80 // atoi seems badly buggy!
81 // Using a correct chartoint implementation:
82 iValue = chartoint(cCharacter);
83 if (iValue>9)
84 {
85 Cerr << "iValue is worth " << iValue << " ! " << finl;
87 }
88 }
89 // It's a letter, assign it an integer value
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; // Invalid hex character.
120 }
121 }
122 // Neither a letter nor a digit.
123 else
124 return -4; // Invalid character.
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 // Free the allocated string
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 Main function of the Lire_Tgrid interpreter. Reads a Tgrid mesh file.
191 *
192 * With 2 arguments nom1 and nom2, reads the object from file nom2 into object nom1.
193 * With a single argument nom1, interprets the file named nom1.
194 *
195 * @param is An input stream.
196 * @return The modified input stream.
197 */
199{
200 Cerr << "Reading a mesh which comes from Tgrid" << finl;
202 Domaine& dom=domaine();
203 DoubleTab& coord_sommets=dom.les_sommets();
204 // Variable declarations
205 int dim = -1;
206 int nb_som = 0;
207 int nb_elem = 0;
208 int nb_face = 0;
209 int nb_som_elem = 0;
210 int type_elements = 0;
211 int compteur = 0;
212 // Work array
213 ArrOfInt nb_som_lu_elem;
214 Motcle motlu;
215 // File management
216 Nom nom_fichier;
217 is >> nom_fichier;
218 decompression(nom_fichier);
219 Cerr << "Reading of the file " << nom_fichier << " ..." << finl;
220 EFichier lecture(nom_fichier);
221 // Check immediately that the file exists, because if it does not,
222 // execution hangs in eof();
223 if (!lecture.good())
224 {
225 Cerr << "Problem to open the file " << nom_fichier << finl;
226 Cerr << "There is maybe an error in the filename." << finl;
227 exit();
228 }
229
230 // First pass through the .msh file
231 // to find the number of elements, as it is sometimes placed at the end of the file!
232 while (!lecture.eof())
233 {
234 lecture >> motlu;
235 if (motlu=="(12")
236 {
237 lecture >> motlu;
238 if (motlu=="(0")
239 {
240 lecture >> motlu; // Index of the first element
241 lecture >> motlu; // Number of elements
242 nb_elem=htoi(motlu);
243 Cerr << "The total number of elements to read is " << nb_elem << finl;
244 lecture >> motlu; // Domain type (0=dead; 1=active; 32=inactive) or "0))"
245 if (motlu!="0))") lecture >> motlu; // Skip the type if it exists
246 }
247 else if (motlu=="(id") lecture >> motlu; // skip reading the description of the (12 tag
248 else
249 {
250 lecture >> motlu; // Index of the first element
251 lecture >> motlu; // Number of elements
252 lecture >> motlu; // Domain type (1:fluid or 0x11:solid)
253 lecture >> motlu; // Element type
254 if (motlu=="1))")
255 {
256 // Reading triangles
257 type_elements=1;
258 Cerr << "2D elements of type Triangle" << finl;
259 }
260 else if (motlu=="3))")
261 {
262 // Reading quadrangles
263 type_elements=3;
264 Cerr << "2D elements of type Quadrangle" << finl;
265 }
266 else if (motlu=="2))")
267 {
268 // Reading tetrahedra
269 type_elements=2;
270 Cerr << "3D elements of type Tetrahedron" << finl;
271 }
272 else if (motlu=="4))")
273 {
274 // Reading hexahedra
275 type_elements=4;
276 Cerr << "3D elements of type Hexahedron" << finl;
277 }
278 else
279 {
280 // Unknown element type
281 Cerr << "Elements unknown !" << finl;
282 Cerr << "It should probably crashed !!!!!" << finl;
283 }
284 lecture.close();
285 }
286 }
287 }
288 // Second pass through the .msh file
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; // Index of the first vertex
327 fic >> motlu; // Number of vertices
328 nb_som=htoi(motlu);
329 Cerr << "The total number of nodes to read is " << nb_som << finl;
330 // Resize the vertex array
331 coord_sommets.resize(nb_som,dim);
332 // Format-dependent
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; // Start index
342 int ideb=htoi(motlu);
343 fic >> motlu; // End index
344 int ifin=htoi(motlu);
345 Cerr << ifin-ideb+1 << " nodes are read in the area " << idomaine << finl;
346 // Format-dependent: advance to the opening parenthesis
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 // Information already obtained in the first pass
368 fic >> motlu; // Index of the first element
369 fic >> motlu; // Number of elements
370 fic >> motlu; // Domain type (0=dead; 1=active; 32=inactive) or "0))"
371 if (motlu!="0))") fic >> motlu; // Skip the type if it exists
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 // Reading tetrahedra
387 dom.type_elem().typer("Tetraedre");
388 }
389 else if (motlu=="4))")
390 {
391 // Reading hexahedra
392 dom.type_elem().typer("Hexaedre_VEF");
393 }
394 else if (motlu=="1))")
395 {
396 // Reading triangles
397 dom.type_elem().typer("Triangle");
398 }
399 else if (motlu=="3))")
400 {
401 // Reading 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; // Index of the first face
423 fic >> motlu; // Number of faces
424 nb_face=htoi(motlu);
425 Cerr << "The total number of faces to read is " << nb_face << finl;
426 fic >> motlu; // Face type or "0))"
427 if (motlu != "0))") fic >> motlu; // Skip the type if it exists
428 }
429 else
430 {
431 int idomaine=htoi(motlu.suffix("("));
432 fic >> motlu; // Start index
433 int ideb=htoi(motlu);
434 fic >> motlu; // End index
435 int ifin=htoi(motlu);
436 fic >> motlu; // Type (2: interior, >2: boundary condition): this does not seem accurate (see page C-8)!
437 int type=htoi(motlu);
438 fic >> motlu; // Face type (0:mixed, 2:linear, 3:triangular, 4:quadrilateral)
439 // Format-dependent:
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; // We will read mixed elements, hoping they are all of the same type
450 fic >> motlu; // Read the first line
451 nb_som_face=htoi(motlu);
452 }
453 if (nb_som_face==3)
454 nb_som_elem=4; // Reading triangles: elements are tetrahedra (4 vertices)
455 else if (nb_som_face==4)
456 nb_som_elem=8; // Reading quadrangles: elements are hexahedra (8 vertices)
457 else if (nb_som_face==2 && type_elements==1)
458 nb_som_elem=3; // Reading segments: elements are triangles (3 vertices)
459 else if (nb_som_face==2 && type_elements==3)
460 nb_som_elem=4; // Reading segments: elements are quadrangles (4 vertices)
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) // No longer necessary since we can now read
466 // Cerr << "It seems we are trying to read a segment..." << finl; // 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 // Work arrays
474 IntTab& les_elems=dom.les_elems();
475 if (les_elems.size()==0)
476 {
477 // If les_elems is not yet dimensioned (first face reading)
478 les_elems.resize(nb_elem,nb_som_elem);
479 // Initialise to -1 to identify undefined vertices
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 // Read the face vertices and the 2 elements adjacent to the 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 // For hexahedra due to TRUST numbering, swap vertices 2 and 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; // first element neighboring the face (zero if boundary)
513 elem[0]=htoi(motlu)-1;
514 fic >> motlu; // second element neighboring the face (zero if boundary)
515 // Start addition by 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; // This counter prevents reading the next "motlu"
522 }
523 else
524 {
525 if (tmp2!=motlu.prefix(")"))
526 {
527 tmp2=motlu.prefix(")");
528 elem[1]=htoi(motlu)-1;
529 compteur=-1; // This counter triggers reading the next "motlu"
530 }
531 else
532 {
533 elem[1]=htoi(motlu)-1;
534 compteur=0; // This counter triggers reading the next "motlu"
535 }
536 }
537
538 // elem(1)=htoi(motlu)-1;
539 // End addition by Cyril MALOD : 15-06-2006
540 // First pass: verify that we are reading a boundary
541 if (i==0)
542 {
543 if (elem[0]<0 || elem[1]<0)
544 {
545 // Confirmed as a boundary: allocate the necessary structures
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 // Internal faces are read but not stored; boundary faces are stored
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 // Build the les_elems array from the faces read
575 for (int i2=0; i2<2; i2++)
576 {
577 if (elem[i2]>=0) // Skip elements with index -1 (neighbors of boundary faces)
578 {
579 // First fill of 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 // Add the vertex if it is not already in 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 // Only complete for tetrahedra or 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 // Fill the opposite face of the hexahedron or 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; // ) or ))
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; // Domain number
639 // Note: the domain number is in decimal!
640 //int idomaine=htoi(motlu.suffix("("));
641 int idomaine=atoi(motlu.suffix("("));
642 fic >> motlu; // Domain type
643 Nom Nomdomaine;
644 fic >> Nomdomaine; // Domain name)())
645 Nom nom_domaine=Nomdomaine;
646 nom_domaine.prefix(")())");
647 if (nom_domaine==Nomdomaine)
648 if (1)
649 {
650 // line break?
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 // Iterate through boundaries to rename them
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 // Verify that the les_elems array has been fully filled
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 // Reorder the domain (useful especially for hexahedra)
706 dom.type_elem()->reordonner();
707
708 // Clean the domain to remove unused nodes
709 // A method should be added to Domaine::nettoie
710 // Note: the following lines are not compatible with TRUST < v1.4.6
711
714
715 return is;
716}
void associer_domaine(const Domaine_t &)
Associates a domain to all boundaries in the list.
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 &)
Sets the element type of the domain using the name passed as parameter.
Definition Domaine.h:457
void reordonner()
Definition Domaine.h:104
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
class Lire_Fichier Reads a file.
Definition Lire_Tgrid.h:27
Entree & interpreter_(Entree &) override
Main function of the Lire_Tgrid interpreter. Reads a Tgrid mesh file.
A character string (Nom) in uppercase.
Definition Motcle.h:26
static void nettoie(Domaine_t &)
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const char * getChar() const
Definition Nom.h:91
Nom & prefix(const char *const)
Definition Nom.cpp:324
friend class Entree
Definition Objet_U.h:71
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 Sortie & Journal(int message_level=0)
Returns a static Sortie object used as an event journal.
Definition Process.cpp:592
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static bool is_sequential()
Definition Process.cpp:113
Base class for output streams.
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