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