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