TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Point_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 <Point_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// Triangle type to test champ_P1...
23Implemente_instanciable(Point_EF,"Point_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
38
39/*! @brief Fills the face_normales array in the Domaine_EF.
40 *
41 * @param num_Face Local face index.
42 * @param Face_normales Array of face normals to fill.
43 * @param Face_sommets Face-to-vertex connectivity table.
44 * @param Face_voisins Face neighbour element table.
45 * @param elem_faces Element-to-face connectivity table.
46 * @param domaine_geom Geometric domain.
47 */
48void Point_EF::normale(int num_Face,DoubleTab& Face_normales,
49 const IntTab& Face_sommets,
50 const IntTab& Face_voisins,
51 const IntTab& elem_faces,
52 const Domaine& domaine_geom) const
53{
54 abort();
55 // no simple meaning for a normal here
56 Face_normales(num_Face,0) = 1;
57
58 {
59
60 //int n0 = Face_sommets(num_Face,0);
61
62 int elem1 = Face_voisins(num_Face,0);
63 // int elem2 = Face_voisins(num_Face,1);
64
65 int n2=elem_faces(elem1,0);
66 if (n2==num_Face) Face_normales(num_Face,0) = -1;
67 /*
68 const DoubleTab& les_coords = domaine_geom.domaine().coord_sommets();
69 // const IntTab& elem = domaine_geom.elems();
70
71 {
72 int n2=elem_faces(elem1,0);
73 if ( n2 == num_Face )
74 n2 = elem_faces(elem1,1);
75 n2=Face_sommets(n2,0);
76 for (int i=0;i<dim;i++)
77 d(i) =les_coords(n0,i)- les_coords(n2,i);
78 d/=d.norm();
79
80 Face_normales(num_Face,0) = -1;
81
82 }
83
84 //int n1 = Face_sommets(num_Face,1);
85
86 // Orient the normal from elem1 toward elem2
87 // by searching for the vertex of elem1 that is not on the Face
88 int f0,no3;
89 int elem1 = Face_voisins(num_Face,0);
90 Cerr<<num_Face<<" iii "<<elem1<< " "<<Face_voisins(num_Face,1)<<" "<<(Face_voisins(num_Face,0)==elem1) <<finl;
91 if ( (f0 = elem_faces(elem1,0)) == num_Face )
92 f0 = elem_faces(elem1,1);
93 if ( (no3 = Face_sommets(f0,0)) != n0 )
94 Cerr<<"oo "<<finl;
95 else
96 {
97 Cerr<<"ii"<<finl;
98 no3 = Face_sommets(f0,1);
99 }
100 Cerr<<n0 << " "<<finl;
101 */
102 }
103 return;
104 /*
105
106
107 double x1,y1;
108 double nx,ny;
109 int no3; int f0;
110 int n0 = Face_sommets(num_Face,0);
111 int n1 = Face_sommets(num_Face,1);
112 x1 = les_coords(n0,0)-les_coords(n1,0);
113 y1 = les_coords(n0,1)-les_coords(n1,1);
114 nx = -y1;
115 ny = x1;
116
117 // Orient the normal from elem1 toward elem2
118 // by searching for the vertex of elem1 that is not on the Face
119 int elem1 = Face_voisins(num_Face,0);
120 if ( (f0 = elem_faces(elem1,0)) == num_Face )
121 f0 = elem_faces(elem1,1);
122 if ( (no3 = Face_sommets(f0,0)) != n0 && no3 != n1 )
123 ;
124 else
125 no3 = Face_sommets(f0,1);
126
127 x1 = les_coords(no3,0) - les_coords(n0,0);
128 y1 = les_coords(no3,1) - les_coords(n0,1);
129
130 if ( (nx*x1+ny*y1) > 0 ) {
131 Face_normales(num_Face,0) = - nx;
132 Face_normales(num_Face,1) = - ny;
133 }
134 else {
135 Face_normales(num_Face,0) = nx;
136 Face_normales(num_Face,1) = ny;
137 }
138 */
139}
140
141/*! @brief
142 *
143 */
144void Point_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 abort();
149 const DoubleVect& porosite_face = vitesse.equation().milieu().porosite_face();
150 //Cerr << " type_cl " << type_cl << finl;
151 switch(type_cl)
152 {
153 case 0: // the element has no Dirichlet face
154 {
155 vc[0] = vs[0]/3;
156 vc[1] = vs[1]/3;
157 break;
158 }
159
160 case 1: // the element has one Dirichlet face: face 2
161 {
162 vc[0]= vitesse.valeurs()(Face[2],0)*porosite_face[Face[2]];
163 vc[1]= vitesse.valeurs()(Face[2],1)*porosite_face[Face[2]];
164 //vc[0]= vitesse.valeurs()(Face[2],0);
165 //vc[1]= vitesse.valeurs()(Face[2],1);
166 break;
167 }
168
169 case 2: // the element has one Dirichlet face: face 1
170 {
171 vc[0]= vitesse.valeurs()(Face[1],0)*porosite_face[Face[1]];
172 vc[1]= vitesse.valeurs()(Face[1],1)*porosite_face[Face[1]];
173 //vc[0]= vitesse.valeurs()(Face[1],0);
174 //vc[1]= vitesse.valeurs()(Face[1],1);
175 break;
176 }
177
178 case 4: // the element has one Dirichlet face: face 0
179 {
180 vc[0]= vitesse.valeurs()(Face[0],0)*porosite_face[Face[0]];
181 vc[1]= vitesse.valeurs()(Face[0],1)*porosite_face[Face[0]];
182 // vc[0]= vitesse.valeurs()(Face[0],0);
183 //vc[1]= vitesse.valeurs()(Face[0],1);
184 break;
185 }
186
187 case 3: // the element has two Dirichlet faces: faces 1 and 2
188 {
189 vc[0]= vsom(0,0);
190 vc[1]= vsom(0,1);
191 break;
192 }
193
194 case 5: // the element has two Dirichlet faces: faces 0 and 2
195 {
196 vc[0]= vsom(1,0);
197 vc[1]= vsom(1,1);
198 break;
199 }
200
201 case 6: // the element has two Dirichlet faces: faces 0 and 1
202 {
203 vc[0]= vsom(2,0);
204 vc[1]= vsom(2,1);
205 break;
206 }
207
208 } // end of switch
209
210}
211
212/*! @brief Computes the coordinates xg of the centre of a non-standard element.
213 *
214 * @brief Also computes idirichlet = number of Dirichlet faces of the element.
215 * If idirichlet=2, n1 is the index of the vertex coinciding with G.
216 * @param xg Output centre coordinates.
217 * @param x Vertex coordinate table for the element.
218 * @param type_elem_Cl Element boundary condition type.
219 * @param idirichlet Output number of Dirichlet faces.
220 * @param n1 Output index of the vertex coinciding with G (when idirichlet=2).
221 */
222void Point_EF::calcul_xg(DoubleVect& xg, const DoubleTab& x,
223 const int type_elem_Cl,int& idirichlet,int& n1,int& ,int& ) const
224{
225 abort();
226 int j,dim=xg.size();
227 switch(type_elem_Cl)
228 {
229
230 case 0: // the element has no Dirichlet face; it has 3 facets
231 // G is the barycentre of the element vertices
232 {
233 for (j=0; j<dim; j++)
234 xg[j]=(x(0,j)+x(1,j)+x(2,j))/3;
235
236 idirichlet=0;
237 break;
238 }
239
240 case 1: // the element has one Dirichlet face: face 2
241 // G is the barycentre of the vertices of face 2
242
243 {
244 for (j=0; j<dim; j++)
245 xg[j]=(x(0,j)+x(1,j))/2;
246
247 idirichlet=1;
248 break;
249 }
250
251 case 2: // the element has one Dirichlet face: face 1
252 // G is the barycentre of the vertices of face 1
253
254 {
255 for (j=0; j<dim; j++)
256 xg[j]=(x(0,j)+x(2,j))/2;
257
258 idirichlet=1;
259 break;
260 }
261
262 case 4: // the element has one Dirichlet face: face 0
263 // G is the barycentre of the vertices of face 0
264
265 {
266 for (j=0; j<dim; j++)
267 xg[j]=(x(1,j)+x(2,j))/2;
268
269 idirichlet=1;
270 break;
271 }
272
273 case 6 : // the element has two Dirichlet faces: faces 0 and 1
274 // G is vertex 2 of the element
275
276 {
277 for (j=0; j<dim; j++)
278 xg[j]=x(2,j);
279
280 idirichlet=2;
281 n1 = 2;
282 break;
283
284 }
285
286 case 5 : // the element has two Dirichlet faces: faces 0 and 2
287 // G is vertex 1 of the element
288
289 {
290 for (j=0; j<dim; j++)
291 xg[j]=x(1,j);
292
293 idirichlet=2;
294 n1 = 1;
295 break;
296
297 }
298
299 case 3 : // the element has two Dirichlet faces: faces 1 and 2
300 // G is vertex 0 of the element
301
302 {
303 for (j=0; j<dim; j++)
304 xg[j]=x(0,j);
305
306 idirichlet=2;
307 n1 = 0;
308 break;
309
310 }
311
312 } // end of switch
313
314}
Class Champ_Inc_base.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
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
void normale(int, DoubleTab &, const IntTab &, const IntTab &, const IntTab &, const Domaine &) const override
Fills the face_normales array in the Domaine_EF.
Definition Point_EF.cpp:48
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 Point_EF.cpp:222
void calcul_vc(const ArrOfInt &, ArrOfDouble &, const ArrOfDouble &, const DoubleTab &, const Champ_Inc_base &, int) const override
Definition Point_EF.cpp:144
static void abort()
Abort routine for TRUST on a fatal error.
Definition Process.cpp:573
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45