TrioCFD 1.9.9_beta
TrioCFD documentation
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 //Switching F77 to C++: indices between the two languages are reversed
80 // (different storage convention)
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 // First, transfer the coordinates
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 // Then, process the elements (element -> node connectivity)
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 // NOTE: Index inversion between Fortran and C++ arrays
139 //
140 les_elems(i,j)= TETRA(j,i)-1 ;
141 }
142 }
143 //
144 Cerr << " Completing the assignment of elements" << finl;
145 //
146 //
147 // Now process the boundary faces (array FACB, of dimension (NFACB,3))
148 // located in the different boundary face groups. Each
149 // group corresponds to a well-defined boundary of the domain (wall, inlet, outlet,
150 // symmetry, ...) and each group bears the name of that boundary type (GRNAME)
151 //
152 // Summary:
153 // GRNAME (NGROUPE) : Names of the different boundaries
154 // GROUP (NNOEUDS,NGROUPE) : Group of boundary faces (face number)
155 // NGELEM (NGROUPE) : Number of boundary faces for group NGROUPE
156 // FACB (NFACB,3) : Connectivity of boundary faces (the 3 nodes of the triangle)
157 //
158 //
159 //
160 // Open the file containing the group names
161 //
162 Nom nom1="nom.groupe";
163 EFichier fic(nom1);
164 fic.set_check_types(1); // Replaces UFichier
165 Cerr << "Reading of the file : " << nom1 << finl;
166 // Define the boundaries as boundary faces of the domain
167 // Domaine --> les_bords
168 //
169 Bords& les_bords=dom.faces_bord();
170 //
171 // Associate the boundaries with the domain (reference to dom)
172 // les_bords --> Domaine
173 //
174 les_bords.associer_domaine(dom);
175 //
176 Nom nom_bord="Bord";
177 //
178 // Assign the boundaries:
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 // NOTE: Index inversion between Fortran and C++ arrays
195 //
196 // GF renumbering in lire_ideas.f now...
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 &)
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 fixer_premieres_faces_frontiere()
Definition Domaine.cpp:1101
void typer(const Nom &)
Sets the element type of the domain using the name passed as parameter.
Definition Domaine.h:457
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
virtual void set_check_types(bool flag)
Indicates whether the stream should verify the types of read objects (ints and floating-point numbers...
Definition Entree.cpp:313
void typer(const Motcle &)
Sets the type of the faces.
Definition Faces.cpp:382
int_t dimensionner(int_t)
(Re-)sizes the faces. The neighbors are resized accordingly.
Definition Faces.cpp:336
int_t sommet(int_t, int) const
Returns the number of the j-th vertex of the i-th face.
Definition Faces.h:130
void nommer(const Nom &) override
Gives a name to the boundary.
Definition Frontiere.cpp:74
void associer_domaine(const Domaine_t &)
Associates the boundary to the domain it belongs to.
Definition Frontiere.cpp:63
const Faces_t & faces() const
Definition Frontiere.h:54
Entree & interpreter_(Entree &) override
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
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
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 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
Base class for output streams.
Definition Sortie.h:52
_TYPE_ * addr()
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469