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