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