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