TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Tetra_poly.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Domaine_Poly_base.h>
17#include <Equation_base.h>
18#include <Milieu_base.h>
19#include <Tetra_poly.h>
20#include <Domaine.h>
21
22Implemente_instanciable_sans_constructeur(Tetra_poly,"Tetra_poly",Elem_poly_base);
23
24// printOn and readOn
25
26
28{
29 return s << que_suis_je() << finl;
30}
31
33{
34 return s ;
35}
36/*! @brief Returns for facet fa7: for j=0, j=1: the local indices of the 2 faces surrounding fa7;
37 *
38 * for j=2, j=3: the local indices of the tetrahedron vertices belonging to fa7.
39 *
40 */
44
45void Tetra_poly::normale(int num_Face,DoubleTab& Face_normales,
46 const IntTab& Face_sommets,
47 const IntTab& Face_voisins,
48 const IntTab& elem_faces,
49 const Domaine& domaine_geom) const
50{
51
52 //Cerr << " num_Face " << num_Face << finl;
53 const DoubleTab& les_coords = domaine_geom.coord_sommets();
54
55 // Cerr << "les face sommet " << Face_sommets << finl;
56 double x1,y1,z1,x2,y2,z2;
57 double nx,ny,nz;
58 int f0,no4;
59
60 int n0 = Face_sommets(num_Face,0);
61 int n1 = Face_sommets(num_Face,1);
62 int n2 = Face_sommets(num_Face,2);
63
64
65 x1 = les_coords(n0,0) - les_coords(n1,0);
66 y1 = les_coords(n0,1) - les_coords(n1,1);
67 z1 = les_coords(n0,2) - les_coords(n1,2);
68
69 x2 = les_coords(n2,0) - les_coords(n1,0);
70 y2 = les_coords(n2,1) - les_coords(n1,1);
71 z2 = les_coords(n2,2) - les_coords(n1,2);
72
73 nx = (y1*z2 - y2*z1)/2;
74 ny = (-x1*z2 + x2*z1)/2;
75 nz = (x1*y2 - x2*y1)/2;
76 // Cerr << "nx " << nx << " ny " << ny << " nz " << nz << finl;
77
78 // Orient the normal from elem1 to elem2
79 // by searching for the vertex of elem1 that is not on the Face
80 int elem1 = Face_voisins(num_Face,0);
81 if ( (f0 = elem_faces(elem1,0)) == num_Face )
82 f0 = elem_faces(elem1,1);
83
84 if ( (no4 = Face_sommets(f0,0)) != n0 && no4 != n1
85 && no4 != n2)
86 { /* Do nothing */}
87 else if ( (no4 = Face_sommets(f0,1)) != n0 && no4 != n1
88 && no4 != n2 )
89 { /* Do nothing */}
90 else
91 no4 = Face_sommets(f0,2);
92
93 x1 = les_coords(no4,0) - les_coords(n0,0);
94 y1 = les_coords(no4,1) - les_coords(n0,1);
95 z1 = les_coords(no4,2) - les_coords(n0,2);
96
97 if ( (nx*x1+ny*y1+nz*z1) > 0 )
98 {
99 Face_normales(num_Face,0) = - nx;
100 Face_normales(num_Face,1) = - ny;
101 Face_normales(num_Face,2) = - nz;
102 }
103 else
104 {
105 Face_normales(num_Face,0) = nx;
106 Face_normales(num_Face,1) = ny;
107 Face_normales(num_Face,2) = nz;
108 }
109
110 // Cerr << "Face_normales " << Face_normales << finl;
111
112}
113
114void Tetra_poly::calcul_vc(const ArrOfInt& Face,ArrOfDouble& vc,
115 const ArrOfDouble& vs,const DoubleTab& vsom,
116 const Champ_Inc_base& vitesse,int type_cl) const
117{
118 int comp;
119 const DoubleVect& porosite_face = vitesse.equation().milieu().porosite_face();
120 switch(type_cl)
121 {
122
123 case 0: // the tetrahedron has no Dirichlet face
124 {
125 for (comp=0; comp<3; comp++)
126 vc[comp] = 0.25*vs[comp];
127 break;
128 }
129
130 case 1: // the tetrahedron has one Dirichlet face: KEL3
131 {
132 for (comp=0; comp<3; comp++)
133 vc[comp] = vitesse.valeurs()(Face[3],comp)*porosite_face[Face[3]];
134 break;
135 }
136
137 case 2: // the tetrahedron has one Dirichlet face: KEL2
138 {
139 for (comp=0; comp<3; comp++)
140 vc[comp] = vitesse.valeurs()(Face[2],comp)*porosite_face[Face[2]];
141 break;
142 }
143
144 case 4: // the tetrahedron has one Dirichlet face: KEL1
145 {
146 for (comp=0; comp<3; comp++)
147 vc[comp] = vitesse.valeurs()(Face[1],comp)*porosite_face[Face[1]];
148 break;
149 }
150
151 case 8: // the tetrahedron has one Dirichlet face: KEL0
152 {
153 for (comp=0; comp<3; comp++)
154 vc[comp] = vitesse.valeurs()(Face[0],comp)*porosite_face[Face[0]];
155 break;
156 }
157
158 case 3: // the tetrahedron has two Dirichlet faces: KEL3 and KEL2
159 {
160 for (comp=0; comp<3; comp++)
161 vc[comp] = 0.5* (vsom(0,comp) + vsom(1,comp));
162 break;
163 }
164
165 case 5: // the tetrahedron has two Dirichlet faces: KEL3 and KEL1
166 {
167 for (comp=0; comp<3; comp++)
168 vc[comp] = 0.5* (vsom(0,comp) + vsom(2,comp));
169 break;
170 }
171
172 case 6: // the tetrahedron has two Dirichlet faces: KEL1 and KEL2
173 {
174 for (comp=0; comp<3; comp++)
175 vc[comp] = 0.5* (vsom(0,comp) + vsom(3,comp));
176 break;
177 }
178
179 case 9: // the tetrahedron has two Dirichlet faces: KEL0 and KEL3
180 {
181 for (comp=0; comp<3; comp++)
182 vc[comp] = 0.5* (vsom(1,comp) + vsom(2,comp));
183 break;
184 }
185
186 case 10: // the tetrahedron has two Dirichlet faces: KEL0 and KEL2
187 {
188 for (comp=0; comp<3; comp++)
189 vc[comp] = 0.5* (vsom(1,comp) + vsom(3,comp));
190 break;
191 }
192
193 case 12: // the tetrahedron has two Dirichlet faces: KEL0 and KEL1
194 {
195 for (comp=0; comp<3; comp++)
196 vc[comp] = 0.5*(vsom(2,comp) + vsom(3,comp));
197 break;
198 }
199
200 case 7: // the tetrahedron has three Dirichlet faces: KEL1, KEL2 and KEL3
201 {
202 for (comp=0; comp<3; comp++)
203 vc[comp] = vsom(0,comp);
204 break;
205 }
206
207 case 11: // the tetrahedron has three Dirichlet faces: KEL0, KEL2 and KEL3
208 {
209 for (comp=0; comp<3; comp++)
210 vc[comp] = vsom(1,comp);
211 break;
212 }
213
214 case 13: // the tetrahedron has three Dirichlet faces: KEL0, KEL1 and KEL3
215 {
216 for (comp=0; comp<3; comp++)
217 vc[comp] = vsom(2,comp);
218 break;
219 }
220
221 case 14: // the tetrahedron has three Dirichlet faces: KEL0, KEL1 and KEL2
222 {
223 for (comp=0; comp<3; comp++)
224 vc[comp] = vsom(3,comp);
225 break;
226 }
227
228 } // end switch
229}
230
231/*! @brief Computes the coordinates xg of the centre of a non-standard element;
232 * also computes idirichlet = number of Dirichlet faces of the element.
233 *
234 */
235void Tetra_poly::calcul_xg(DoubleVect& xg,const DoubleTab& x, const int type_elem_Cl,
236 int& idirichlet,int& n1,int& n2,int& n3) const
237{
238 int j,dim=xg.size();
239
240 switch(type_elem_Cl)
241 {
242
243 case 0: // the tetrahedron has no Dirichlet face. It has 6 facets.
244 {
245 for (j=0; j<dim; j++)
246 xg[j]=0.25*(x(0,j)+x(1,j)+x(2,j)+x(3,j));
247
248 idirichlet=0;
249 break;
250 }
251
252 case 1: // the tetrahedron has one Dirichlet face. The 'centre'
253 // of the tetrahedron is at the midpoint of face 3, with vertices 0, 1, 2.
254 // It has 3 real facets: 0 at nodes 2 3 xg
255 // 1 at nodes 1 3 xg
256 // 3 at nodes 3 0 xg
257 // the 3 other facets lie on face 3
258
259 {
260 for (j=0; j<dim; j++)
261 xg[j]=(x(0,j)+x(1,j)+x(2,j))/3.;
262
263 idirichlet=1;
264 break;
265
266 }
267
268 case 2: // the tetrahedron has one Dirichlet face. The 'centre'
269 // of the tetrahedron is at the midpoint of face 2, with vertices 0, 1, 3.
270 // It has 3 real facets: 0 at nodes 2 3 xg
271 // 2 at nodes 1 2 xg
272 // 4 at nodes 2 0 xg
273
274 {
275 for (j=0; j<dim; j++)
276 xg[j]=(x(0,j)+x(1,j)+x(3,j))/3.;
277
278 idirichlet=1;
279 break;
280 }
281
282 case 4: // the tetrahedron has one Dirichlet face. The 'centre'
283 // of the tetrahedron is at the midpoint of face 1, with vertices 0, 2, 3.
284 // It has 3 real facets: 1 at nodes 1 3 xg
285 // 2 at nodes 1 2 xg
286 // 5 at nodes 1 0 xg
287
288 {
289 for (j=0; j<dim; j++)
290 xg[j]=(x(0,j)+x(2,j)+x(3,j))/3.;
291
292 idirichlet=1;
293 break;
294 }
295
296 case 8: // the tetrahedron has one Dirichlet face. The 'centre'
297 // of the tetrahedron is at the midpoint of face 0, with vertices 1, 2, 3.
298 // It has 3 real facets: 3 at nodes 3 0 xg
299 // 4 at nodes 2 0 xg
300 // 5 at nodes 1 0 xg
301
302 {
303 for (j=0; j<dim; j++)
304 xg[j]=(x(1,j)+x(2,j)+x(3,j))/3.;
305
306 idirichlet=1;
307 break;
308 }
309
310 case 3: // the tetrahedron has two Dirichlet faces 2 and 3. The 'centre'
311 // of the tetrahedron is at the midpoint of the edge with endpoints 0, 1.
312 // It has 1 zero facet: 5
313
314 {
315 for (j=0; j<dim; j++)
316 xg[j]= 0.5*(x(0,j)+x(1,j));
317
318 n1=5;
319 idirichlet=2;
320 break;
321 }
322
323
324 case 5: // the tetrahedron has two Dirichlet faces 3 and 1. The 'centre'
325 // of the tetrahedron is at the midpoint of the edge with endpoints 0, 2.
326 // It has 1 zero facet: 4
327
328 {
329 for (j=0; j<dim; j++)
330 xg[j]= 0.5*(x(0,j)+x(2,j));
331
332 n1=4;
333 idirichlet=2;
334 break;
335 }
336
337 case 6: // the tetrahedron has two Dirichlet faces 1 and 2. The 'centre'
338 // of the tetrahedron is at the midpoint of the edge with endpoints 0, 3.
339 // It has 1 zero facet: 3
340
341 {
342 for (j=0; j<dim; j++)
343 xg[j]= 0.5*(x(0,j)+x(3,j));
344
345 n1=3;
346 idirichlet=2;
347 break;
348 }
349
350 case 9: // the tetrahedron has two Dirichlet faces 0 and 3. The 'centre'
351 // of the tetrahedron is at the midpoint of the edge with endpoints 1, 2.
352 // It has 1 zero facet: 2
353
354 {
355 for (j=0; j<dim; j++)
356 xg[j]= 0.5*(x(1,j)+x(2,j));
357
358 n1=2;
359 idirichlet=2;
360 break;
361 }
362
363 case 10: // the tetrahedron has two Dirichlet faces 0 and 2. The 'centre'
364 // of the tetrahedron is at the midpoint of the edge with endpoints 1, 3.
365 // It has 1 zero facet: 1
366
367 {
368 for (j=0; j<dim; j++)
369 xg[j]= 0.5*(x(1,j)+x(3,j));
370
371 n1=1;
372 idirichlet=2;
373 break;
374 }
375
376
377 case 12: // the tetrahedron has two Dirichlet faces 0 and 1. The 'centre'
378 // of the tetrahedron is at the midpoint of the edge with vertices 2, 3.
379 // It has 1 zero facet
380
381 {
382 for (j=0; j<dim; j++)
383 xg[j]= 0.5*(x(2,j)+x(3,j));
384
385 n1=0;
386 idirichlet=2;
387 break;
388 }
389
390 case 7: // three Dirichlet faces: 1, 2, 3. The centre is at vertex 0.
391 // There are 3 zero facets: 3, 4, 5
392
393 {
394 for (j=0; j<dim; j++)
395 xg[j]= x(0,j);
396
397 n1=3;
398 n2=4;
399 n3=5;
400 idirichlet=3;
401 break;
402
403 }
404
405 case 11: // three Dirichlet faces: 0, 2, 3. The centre is at vertex 1.
406 // There are 3 zero facets: 1, 2, 5
407
408 {
409 for (j=0; j<dim; j++)
410 xg[j]= x(1,j);
411
412 n1=1;
413 n2=2;
414 n3=5;
415 idirichlet=3;
416 break;
417
418 }
419
420 case 13: // three Dirichlet faces: 0, 1, 3. The centre is at vertex 2.
421 // There are 3 zero facets: 0, 2, 4
422
423 {
424 for (j=0; j<dim; j++)
425 xg[j]= x(2,j);
426
427 n1=0;
428 n2=2;
429 n3=4;
430 idirichlet=3;
431 break;
432
433 }
434 case 14: // three Dirichlet faces: 0, 1, 2. The centre is at vertex 3.
435 // There are 3 zero facets: 0, 1, 3
436
437 {
438 for (j=0; j<dim; j++)
439 xg[j]= x(3,j);
440
441 n1=0;
442 n2=1;
443 n3=3;
444 idirichlet=3;
445 break;
446
447 }
448 }
449}
450
Class Champ_Inc_base.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45
Tetra_poly()
Returns for facet fa7: for j=0, j=1: the local indices of the 2 faces surrounding fa7;.
void normale(int, DoubleTab &, const IntTab &, const IntTab &, const IntTab &, const Domaine &) const override
void calcul_vc(const ArrOfInt &, ArrOfDouble &, const ArrOfDouble &, const DoubleTab &, const Champ_Inc_base &, int) const
void calcul_xg(DoubleVect &, const DoubleTab &, const int, int &, int &, int &, int &) const
Computes the coordinates xg of the centre of a non-standard element; also computes idirichlet = numbe...