TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Quadri_EF.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Quadri_EF.h>
17#include <Domaine.h>
18
19Implemente_instanciable_sans_constructeur(Quadri_EF,"Quadri_EF",Elem_EF_base);
20
21// printOn and readOn
22
24{
25 return s << que_suis_je() << finl;
26}
27
29{
30 return s ;
31}
32
33/*! @brief KEL_(0,fa7), KEL_(1,fa7) are the local indices of the 2 faces surrounding facet with local index fa7.
34 *
35 * @brief The local index of fa7 is that of the vertex that carries it.
36 *
37 */
41
42/*! @brief Fills the face_normales array in the Domaine_EF.
43 *
44 * @param num_Face Local face index.
45 * @param Face_normales Array of face normals to fill.
46 * @param Face_sommets Face-to-vertex connectivity table.
47 * @param Face_voisins Face neighbour element table.
48 * @param elem_faces Element-to-face connectivity table.
49 * @param domaine_geom Geometric domain.
50 */
51void Quadri_EF::normale(int num_Face,DoubleTab& Face_normales,
52 const IntTab& Face_sommets,
53 const IntTab& Face_voisins,
54 const IntTab& elem_faces,
55 const Domaine& domaine_geom) const
56{
57 const DoubleTab& les_coords = domaine_geom.coord_sommets();
58 double x1,y1;
59 double nx,ny;
60 double x1g=0,y1g=0;
61 double x2g=0,y2g=0;
62 double grx,gry,psc;
63 int sign=1,i;
64 int n0 = Face_sommets(num_Face,0);
65 int n1 = Face_sommets(num_Face,1);
66 x1 = les_coords(n0,0)-les_coords(n1,0);
67 y1 = les_coords(n0,1)-les_coords(n1,1);
68 nx = -y1;
69 ny = x1;
70 int elem1=Face_voisins(num_Face,0);
71 int elem2=Face_voisins(num_Face,1);
72
73 // Orient the normal toward the element with the highest index.
74 // First check whether we are on a boundary.
75 if (elem2!=-1)
76 {
77 // orient from the centre of gravity
78 // compute the centre of gravity of each element
79 for(i=0; i<4; i++)
80 {
81 x1g+=les_coords(Face_sommets(elem_faces(elem1,i),0),0);
82 x1g+=les_coords(Face_sommets(elem_faces(elem1,i),1),0);
83 y1g+=les_coords(Face_sommets(elem_faces(elem1,i),0),1);
84 y1g+=les_coords(Face_sommets(elem_faces(elem1,i),1),1);
85 x2g+=les_coords(Face_sommets(elem_faces(elem2,i),0),0);
86 x2g+=les_coords(Face_sommets(elem_faces(elem2,i),1),0);
87 y2g+=les_coords(Face_sommets(elem_faces(elem2,i),0),1);
88 y2g+=les_coords(Face_sommets(elem_faces(elem2,i),1),1);
89 }
90
91 grx=(x2g-x1g)*0.125;
92 gry=(y2g-y1g)*0.125;
93
94 // check the sign of the dot product
95 psc=grx*nx+gry*ny;
96 if(psc<0)
97 {
98 if(elem1<elem2)
99 sign=-1;
100 }
101 else if(elem2<elem1)
102 sign=-1;
103 }
104 else
105 {
106 // orient from the centre of gravity and the midpoint of the
107 // current face
108
109 for(i=0; i<4; i++)
110 {
111 x1g+=les_coords(Face_sommets(elem_faces(elem1,i),0),0);
112 x1g+=les_coords(Face_sommets(elem_faces(elem1,i),1),0);
113 y1g+=les_coords(Face_sommets(elem_faces(elem1,i),0),1);
114 y1g+=les_coords(Face_sommets(elem_faces(elem1,i),1),1);
115 }
116 // Cerr << "xg et yg de Face_normales: " << x1g << " " << y1g << finl;
117
118 x2g = les_coords(n0,0)+les_coords(n1,0);
119 y2g = les_coords(n0,1)+les_coords(n1,1);
120 grx=x2g*0.5-x1g*0.125;
121 gry=y2g*0.5-y1g*0.125;
122
123 // Cerr << "grx et gry : " << grx << " " << gry << finl;
124 // check the sign of the dot product
125 psc=grx*nx+gry*ny;
126 if(psc<0)
127 sign=-1;
128 }
129 double scale = 1.0;
130 if (bidim_axi)
131 {
132 const double r0 = les_coords(n0, 0);
133 const double r1 = les_coords(n1, 0);
134 const double r_bar = 0.5 * (r0 + r1);
135 scale = 2.0 * M_PI * ((r_bar <=1e-10) ? x1g / 8.0 : r_bar);
136 }
137 Face_normales(num_Face, 0) = sign * nx * scale;
138 Face_normales(num_Face, 1) = sign * ny * scale;
139}
140
141/*! @brief
142 *
143 */
144void Quadri_EF::calcul_vc(const ArrOfInt& Face,ArrOfDouble& vc,
145 const ArrOfDouble& vs,const DoubleTab& vsom,
146 const Champ_Inc_base& vitesse,int type_cl) const
147{
148 //Cerr << " DANS Quadri_EF::calcul_vc , type_cl = " << type_cl << finl;
149 //Cerr << "vs " << vs << " et vsom " << vsom << " et vitesse " << vitesse << finl;
150
151// switch(type_cl) {
152// case 0: // no Dirichlet face
153// {
154 vc[0] = vs[0]*0.25;
155 vc[1] = vs[1]*0.25;
156// break;
157// }
158
159// case 1: // one Dirichlet face: Face 3
160// {
161// vc[0] = vitesse.valeurs()(Face[3],0);
162// vc[1] = vitesse.valeurs()(Face[3],1);
163// break;
164// }
165
166// case 3: // one Dirichlet face: Face 2
167// {
168// vc[0] = vitesse.valeurs()(Face[2],0);
169// vc[1] = vitesse.valeurs()(Face[2],1);
170// break;
171// }
172
173// case 9: // one Dirichlet face: Face 1
174// {
175// vc[0] = vitesse.valeurs()(Face[1],0);
176// vc[1] = vitesse.valeurs()(Face[1],1);
177// break;
178// }
179
180// case 27: // one Dirichlet face: Face 0
181// {
182// vc[0] = vitesse.valeurs()(Face[0],0);
183// vc[1] = vitesse.valeurs()(Face[0],1);
184// break;
185// }
186
187// case 4: // two Dirichlet faces: Faces 2,3
188// {
189// vc[0]= vsom(3,0);
190// vc[1]= vsom(3,1);
191// break;
192// }
193
194// case 28: // two Dirichlet faces: Faces 0,3
195// {
196// vc[0]= vsom(2,0);
197// vc[1]= vsom(2,1);
198// break;
199// }
200
201// case 12: // two Dirichlet faces: Faces 1,2
202// {
203// vc[0]= vsom(1,0);
204// vc[1]= vsom(1,1);
205// break;
206// }
207
208// case 36: // two Dirichlet faces: Faces 0,1
209// {
210// vc[0]= vsom(0,0);
211// vc[1]= vsom(0,1);
212// break;
213// }
214
215
216// case 10: // two Dirichlet faces: Faces 1,3
217// {
218// vc[0] = vs[0]*0.25;
219// vc[1] = vs[1]*0.25;
220// break;
221// }
222
223// case 30: // two Dirichlet faces: Faces 0,2
224// {
225// vc[0] = vs[0]*0.25;
226// vc[1] = vs[1]*0.25;
227// break;
228// }
229
230// case 13: //three Dirichlet faces: Faces 3,2,1
231// {
232// vc[0]= vitesse.valeurs()(Face[2],0);
233// vc[1]= vitesse.valeurs()(Face[2],1);
234// break;
235// }
236
237// case 31: //three Dirichlet faces: Faces 0,3,2
238// {
239// vc[0]= vitesse.valeurs()(Face[3],0);
240// vc[1]= vitesse.valeurs()(Face[3],1);
241// break;
242// }
243
244// case 37: //three Dirichlet faces: Faces 1,0,3
245// {
246// vc[0]= vitesse.valeurs()(Face[0],0);
247// vc[1]= vitesse.valeurs()(Face[0],1);
248// break;
249// }
250
251// case 39: //three Dirichlet faces: Faces 2,1,0
252// {
253// vc[0]= vitesse.valeurs()(Face[1],0);
254// vc[1]= vitesse.valeurs()(Face[1],1);
255// break;
256// }
257
258// default :
259// {
260// Cerr << "\n type inconnu : " << type_cl ;
261// exit();
262// }
263
264// } // end of switch
265
266}
267
268/*! @brief Computes the coordinates xg of the centre of a non-standard element.
269 *
270 * @brief Also computes idirichlet = number of Dirichlet faces of the element.
271 * If idirichlet=2, n1 is the index of the vertex coinciding with G.
272 * @param xg Output centre coordinates.
273 * @param x Vertex coordinate table for the element.
274 * @param type_elem_Cl Element boundary condition type.
275 * @param idirichlet Output number of Dirichlet faces.
276 * @param n1 Output index of the vertex coinciding with G (when idirichlet=2).
277 */
278void Quadri_EF::calcul_xg(DoubleVect& xg, const DoubleTab& x,
279 const int type_elem_Cl,int& idirichlet,int& n1,int& ,int& ) const
280{
281 int j,dim=xg.size();
282// switch(type_elem_Cl) {
283
284// case 0: // no Dirichlet face: it has 4 facets
285// // point G is the barycenter of the element vertices
286// {
287 for (j=0; j<dim; j++)
288 xg[j]=(x(0,j)+x(1,j)+x(2,j)+x(3,j))*0.25;
289 idirichlet=0;
290// break;
291// }
292
293// case 1: // one Dirichlet face: Face 3
294// // point G is the center of face 3
295// {
296// for (j=0; j<dim; j++)
297// xg[j]=(x(2,j)+x(3,j))*0.5;
298// idirichlet=1;
299// break;
300// }
301
302// case 3: // one Dirichlet face: Face 2
303// // point G is the center of face 2
304// {
305// for (j=0; j<dim; j++)
306// xg[j]=(x(1,j)+x(3,j))*0.5;
307// idirichlet=1;
308// break;
309// }
310
311// case 9: // one Dirichlet face: Face 1
312// // point G is the center of face 1
313// {
314// for (j=0; j<dim; j++)
315// xg[j]=(x(0,j)+x(1,j))*0.5;
316// idirichlet=1;
317// break;
318// }
319
320// case 27: // one Dirichlet face: Face 0
321// // point G is the center of face 0
322// {
323// for (j=0; j<dim; j++)
324// xg[j]=(x(0,j)+x(2,j))*0.5;
325// idirichlet=1;
326// break;
327// }
328
329// case 4: // two Dirichlet faces: Faces 2,3
330// // point G is the vertex common to the two Dirichlet faces
331// {
332// for (j=0; j<dim; j++)
333// xg[j]=x(3,j);
334// idirichlet=2;
335// break;
336// }
337
338// case 28: // two Dirichlet faces: Faces 0,3
339// // point G is the vertex common to the two Dirichlet faces
340// {
341// for (j=0; j<dim; j++)
342// xg[j]=x(2,j);
343// idirichlet=2;
344// break;
345// }
346
347// case 12: // two Dirichlet faces: Faces 1,2
348// // point G is the vertex common to the two Dirichlet faces
349// {
350// for (j=0; j<dim; j++)
351// xg[j]=x(1,j);
352// idirichlet=2;
353// break;
354// }
355
356// case 36: // two Dirichlet faces: Faces 0,1
357// // point G is the vertex common to the two Dirichlet faces
358// {
359// for (j=0; j<dim; j++)
360// xg[j]=x(0,j);
361// idirichlet=2;
362// break;
363// }
364
365// case 10: // two Dirichlet faces: Faces 1,3
366// // keep the same control volumes as for internal faces
367// {
368// for (j=0; j<dim; j++)
369// xg[j]=(x(0,j)+x(1,j)+x(2,j)+x(3,j))*0.25;
370// idirichlet=0;
371// break;
372// }
373
374// case 30: // two Dirichlet faces: Faces 0,2
375// // keep the same control volumes as for internal faces
376// {
377// for (j=0; j<dim; j++)
378// xg[j]=(x(0,j)+x(1,j)+x(2,j)+x(3,j))*0.25;
379// idirichlet=0;
380// break;
381// }
382
383// case 13: //three Dirichlet faces: Faces 3,2,1
384// // point G is the center of the Dirichlet face opposite to the non-Dirichlet face
385// {
386// for (j=0; j<dim; j++)
387// xg[j]=(x(1,j)+x(3,j))*0.5;
388// idirichlet=3;
389// break;
390// }
391
392// case 31: //three Dirichlet faces: Faces 0,3,2
393// // point G is the center of the Dirichlet face opposite to the non-Dirichlet face
394// {
395// for (j=0; j<dim; j++)
396// xg[j]=(x(2,j)+x(3,j))*0.5;
397// idirichlet=3;
398// break;
399// }
400
401// case 37: //three Dirichlet faces: Faces 1,0,3
402// // point G is the center of the Dirichlet face opposite to the non-Dirichlet face
403// {
404// for (j=0; j<dim; j++)
405// xg[j]=(x(0,j)+x(2,j))*0.5;
406// idirichlet=3;
407// break;
408// }
409
410// case 39: //three Dirichlet faces: Faces 2,1,0
411// // point G is the center of the Dirichlet face opposite to the non-Dirichlet face
412// {
413// for (j=0; j<dim; j++)
414// xg[j]=(x(0,j)+x(1,j))*0.5;
415// idirichlet=3;
416// break;
417// }
418
419// } // end of switch
420
421}
Class Champ_Inc_base.
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
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
static int bidim_axi
Definition Objet_U.h:97
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
void normale(int, DoubleTab &, const IntTab &, const IntTab &, const IntTab &, const Domaine &) const override
Fills the face_normales array in the Domaine_EF.
Definition Quadri_EF.cpp:51
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.
void calcul_vc(const ArrOfInt &, ArrOfDouble &, const ArrOfDouble &, const DoubleTab &, const Champ_Inc_base &, int) const override
Quadri_EF()
KEL_(0,fa7), KEL_(1,fa7) are the local indices of the 2 faces surrounding facet with local index fa7.
Definition Quadri_EF.cpp:38
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45