TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Lire_Ideas.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 <Lire_Ideas.h>
17#include <Domaine.h>
18#include <EFichier.h>
19#include <Scatter.h>
20
21Implemente_instanciable(Lire_Ideas,"Lire_Ideas",Interprete_geometrique_base);
22// XD lire_ideas interprete lire_ideas INHERITS_BRACE Read a geom in a unv file. 3D tetra mesh elements only may be read
23// XD_CONT by TRUST.
24// XD attr nom_dom ref_domaine nom_dom REQ Name of domain.
25// XD attr file chaine file REQ Name of file.
26
28{
29 return s << que_suis_je() << finl;
30}
31
33{
34 return is;
35}
36
38{
39 Nom nom_fic;
41 is >> nom_fic;
42 Domaine& dom=domaine();
43 //
44 int NDIM=dimension;
45 int NNOEUDS=0;
46 int NELEM=0;
47 int NTETRA=0;
48 int NFACB=0;
49 int NSEG=0;
50 int NGROUPE=0;
51 int CAS=0;
52 //
53 Cerr << "First pass to determine the sizes of arrays" << finl;
54 //
55 char nom_fic2[81];
56 for (int ii=0; ii<80; ii++)
57 nom_fic2[ii]='\0';
58 strcpy(nom_fic2,nom_fic);
59 F77NAME(LIREPREM) (nom_fic2,
60 &NDIM,
61 &NNOEUDS,
62 &NELEM,
63 &NTETRA,
64 &NFACB,
65 &NSEG,
66 &NGROUPE,
67 &CAS);
68 //
69 Cerr << "Number of nodes : " << NNOEUDS << finl;
70 Cerr << "Number of elements : " << NELEM << finl;
71 Cerr << "Number of tetrahedra : " << NTETRA << finl;
72 Cerr << "Number of boundary faces : " << NFACB << finl;
73 Cerr << "Number of boundary segments : " << NSEG << finl;
74 Cerr << "Number of groups : " << NGROUPE << finl;
75 //
76 ArrOfInt NGELEM(NGROUPE);
77 ArrOfInt WORK(std::max(NTETRA,NFACB*4));
78 //
79 //Passage F77 a C++: les indices entre les deux langages sont inverses
80 // (methode de stockage differente)
81 //
82 IntTab TETRA(4,NTETRA);
83 IntTab FACB(3,NFACB);
84 IntTab GROUP(NFACB,NGROUPE);
85 //
86 ArrOfDouble X(NNOEUDS);
87 ArrOfDouble Y(NNOEUDS);
88 ArrOfDouble Z(NNOEUDS);
89 Cerr << "call of LIREIDEAS " << finl;
90 //
91 F77NAME(LIREIDEAS)(nom_fic2,
92 &NDIM,
93 X.addr(),
94 Y.addr(),
95 Z.addr(),
96 TETRA.addr(),
97 FACB.addr(),
98 GROUP.addr(),
99 &NNOEUDS,
100 &NELEM,
101 &NTETRA,
102 &NFACB,
103 &NGROUPE,
104 NGELEM.addr(),
105 WORK.addr(),
106 &CAS);
107 //
108 Cerr << " Reading completed " << finl;
109 //
110 DoubleTab& coord=dom.les_sommets();
111 dom.type_elem().typer("Tetraedre");
112 dom.type_elem()->associer_domaine(dom);
113
114 //
115 // On commence par transferer les coordonnees
116 //
117 coord.resize(NNOEUDS, dimension);
118 {
119 for(int i=0; i<NNOEUDS; i++)
120 {
121 coord(i,0) = (X[i]);
122 coord(i,1) = (Y[i]);
123 coord(i,2) = (Z[i]);
124 }
125 }
126 //
127 Cerr << " Completing the assignment of coordinates of nodes" << finl;
128 //
129 // On continue par les elements (connectivite element -> noeuds)
130 //
131 IntTab& les_elems=dom.les_elems();
132 les_elems.resize(NTETRA, dimension+1);
133 for(int i=0; i<NTETRA; i++)
134 {
135 for(int j=0; j<dimension+1; j++)
136 {
137 //
138 // ATTENTION : Inversion des indices entre le tableau Fortran et C++
139 //
140 les_elems(i,j)= TETRA(j,i)-1 ;
141 }
142 }
143 //
144 Cerr << " Completing the assignment of elements" << finl;
145 //
146 //
147 // Maintenant, on traite les faces de bords (tableau FACB, de dim (NFACB,3))
148 // qui se trouvent dans les differents groupes de faces de bords. Chaque
149 // groupe correspond a un bord bien defini du domaine (paroi, entree, sortie,
150 // symetrie, ...) et chaque groupe porte le nom de ce type de bord (GRNAME)
151 //
152 // En resume :
153 // GRNAME (NGROUPE) : Nom des differents bords
154 // GROUP (NNOEUDS,NGROUPE) : Groupe de faces de bord (Numero de la face)
155 // NGELEM (NGROUPE) : Nombre de faces de bords pour le groupe NGROUPE
156 // FACB (NFACB,3) : Connectivite des faces de bords (les 3 noeuds du triangle)
157 //
158 //
159 //
160 // On ouvre le fichier contenant les noms des groupes
161 //
162 Nom nom1="nom.groupe";
163 EFichier fic(nom1);
164 fic.set_check_types(1); // Remplace UFichier
165 Cerr << "Reading of the file : " << nom1 << finl;
166 // On definit les bords comme etant des faces de bords du domaine
167 // On fait Domaine --> les_bords
168 //
169 Bords& les_bords=dom.faces_bord();
170 //
171 // Ici, on associe les bords au domaine (on se refere a dom)
172 // On fait les_bords --> Domaine
173 //
174 les_bords.associer_domaine(dom);
175 //
176 Nom nom_bord="Bord";
177 //
178 // On affecte les bords :
179 //
180 for(int k=0; k<NGROUPE; k++)
181 {
182 fic >> nom_bord;
183 Bord& nouveau=les_bords.add(Bord());
184 //
185 nouveau.nommer(nom_bord);
186 nouveau.faces().typer(Type_Face::triangle_3D);
187 //
188 nouveau.faces().dimensionner(NGELEM[k]);
189 //
190 int num;
191 for (int j=0; j<NGELEM[k]; j++)
192 {
193 //
194 // ATTENTION : Inversion des indices entre le tableau Fortran et C++
195 //
196 // GF renumerotation dans lire_ideas.f maintenant...
197 //
198 //num=GROUP(j,k)-1-NTETRA;
199 num=GROUP(j,k)-1;
200 nouveau.faces().sommet(j,0)= FACB(0,num)-1;
201 nouveau.faces().sommet(j,1)= FACB(1,num)-1;
202 nouveau.faces().sommet(j,2)= FACB(2,num)-1;
203 }
204 nouveau.associer_domaine(dom);
205 }
206 //
207 Cerr << " Completing the assignment of the boundary faces" << finl;
208 //
209 Cerr << " Exit of Lire_Ideas " << finl;
210 //
212
214 return is;
215}
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 fixer_premieres_faces_frontiere()
Definition Domaine.cpp:1102
void typer(const Nom &)
Type les elements du domaine avec le nom passe en parametre.
Definition Domaine.h:457
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
virtual void set_check_types(bool flag)
indique si le stream doit verifier les types des objets lus (ints et nombres flottants).
Definition Entree.cpp:313
void typer(const Motcle &)
Type les faces.
Definition Faces.cpp:390
int_t dimensionner(int_t)
(Re-)dimensionne les faces On redimensionne les voisins en consequence.
Definition Faces.cpp:344
int_t sommet(int_t, int) const
Renvoie le numero du j-ieme sommet de la i-ieme face.
Definition Faces.h:130
void nommer(const Nom &) override
Donne un nom a la frontiere.
Definition Frontiere.cpp:74
void associer_domaine(const Domaine_t &)
Associe la frontiere au domaine dont elle depend.
Definition Frontiere.cpp:63
const Faces_t & faces() const
Definition Frontiere.h:54
Entree & interpreter_(Entree &) override
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:76
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
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 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:2742
Classe de base des flux de sortie.
Definition Sortie.h:52
_TYPE_ * addr()
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469