TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Hexa_EF.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <Hexa_EF.h>
17#include <Domaine.h>
18
19Implemente_instanciable_sans_constructeur(Hexa_EF,"Hexa_EF",Elem_EF_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 facet with local index fa7.
34 *
35 * @brief The local index of fa7 is that of the vertex that carries it.
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 */
51
52void Hexa_EF::normale(int num_Face,DoubleTab& Face_normales,
53 const IntTab& Face_sommets,
54 const IntTab& Face_voisins,
55 const IntTab& elem_faces,
56 const Domaine& domaine_geom) const
57{
58 const DoubleTab& les_coords = domaine_geom.coord_sommets();
59
60 double x1,y1,z1,x2,y2,z2;
61 double nx,ny,nz;
62 int f0,no4;
63 int elem1;
64
65 // the 4 vertices of the face
66 int n0 = Face_sommets(num_Face,0);
67 int n1 = Face_sommets(num_Face,1);
68 int n2 = Face_sommets(num_Face,2);
69 int n3 = Face_sommets(num_Face,3);
70
71 // split the face into two triangles
72 // initialise Face_normales(num_face,dimension) to 0
73 // because the two triangle face normals will be summed
74 Face_normales(num_Face,0) = 0;
75 Face_normales(num_Face,1) = 0;
76 Face_normales(num_Face,2) = 0;
77
78 // take vertices S1, S2 and S4
79
80 x1 = les_coords(n0,0) - les_coords(n1,0);
81 y1 = les_coords(n0,1) - les_coords(n1,1);
82 z1 = les_coords(n0,2) - les_coords(n1,2);
83
84 x2 = les_coords(n3,0) - les_coords(n1,0);
85 y2 = les_coords(n3,1) - les_coords(n1,1);
86 z2 = les_coords(n3,2) - les_coords(n1,2);
87
88 nx = (y1*z2 - y2*z1)/2;
89 ny = (-x1*z2 + x2*z1)/2;
90 nz = (x1*y2 - x2*y1)/2;
91
92 // Orient the normal from elem1 toward elem2
93 // by searching for the vertex of elem1 that is not on the Face
94
95 elem1=Face_voisins(num_Face,0);
96
97 if ( (f0 = elem_faces(elem1,0)) == num_Face )
98 f0 = elem_faces(elem1,1);
99
100 if ( (no4 = Face_sommets(f0,0)) != n0 && no4 != n1
101 && no4 != n2 && no4 != n3)
102 { /* Do nothing */}
103 else if ( (no4 = Face_sommets(f0,1)) != n0 && no4 != n1
104 && no4 != n2 && no4 != n3)
105 { /* Do nothing */}
106 else if ( (no4 = Face_sommets(f0,2)) != n0 && no4 != n1
107 && no4 != n2 && no4 != n3)
108 { /* Do nothing */}
109 else
110 no4 = Face_sommets(f0,3);
111
112 x1 = les_coords(no4,0) - les_coords(n0,0);
113 y1 = les_coords(no4,1) - les_coords(n0,1);
114 z1 = les_coords(no4,2) - les_coords(n0,2);
115
116 if ( (nx*x1+ny*y1+nz*z1) > 0 )
117 {
118 Face_normales(num_Face,0) += -nx;
119 Face_normales(num_Face,1) += -ny;
120 Face_normales(num_Face,2) += -nz;
121 }
122 else
123 {
124 Face_normales(num_Face,0) += nx;
125 Face_normales(num_Face,1) += ny;
126 Face_normales(num_Face,2) += nz;
127 }
128
129 // take vertices S1, S4 and S3
130
131 x1 = les_coords(n0,0) - les_coords(n2,0);
132 y1 = les_coords(n0,1) - les_coords(n2,1);
133 z1 = les_coords(n0,2) - les_coords(n2,2);
134
135 x2 = les_coords(n3,0) - les_coords(n2,0);
136 y2 = les_coords(n3,1) - les_coords(n2,1);
137 z2 = les_coords(n3,2) - les_coords(n2,2);
138
139 nx = (y1*z2 - y2*z1)/2;
140 ny = (-x1*z2 + x2*z1)/2;
141 nz = (x1*y2 - x2*y1)/2;
142
143 // Orient the normal from elem1 toward elem2
144 // by searching for the vertex of elem1 that is not on the Face
145
146 elem1=Face_voisins(num_Face,0);
147
148 if ( (f0 = elem_faces(elem1,0)) == num_Face )
149 f0 = elem_faces(elem1,1);
150
151 if ( (no4 = Face_sommets(f0,0)) != n0 && no4 != n1
152 && no4 != n2 && no4 != n3)
153 { /* Do nothing */}
154 else if ( (no4 = Face_sommets(f0,1)) != n0 && no4 != n1
155 && no4 != n2 && no4 != n3)
156 { /* Do nothing */}
157 else if ( (no4 = Face_sommets(f0,2)) != n0 && no4 != n1
158 && no4 != n2 && no4 != n3)
159 { /* Do nothing */}
160 else
161 no4 = Face_sommets(f0,3);
162
163 x1 = les_coords(no4,0) - les_coords(n0,0);
164 y1 = les_coords(no4,1) - les_coords(n0,1);
165 z1 = les_coords(no4,2) - les_coords(n0,2);
166
167 if ( (nx*x1+ny*y1+nz*z1) > 0 )
168 {
169 Face_normales(num_Face,0) += -nx;
170 Face_normales(num_Face,1) += -ny;
171 Face_normales(num_Face,2) += -nz;
172 }
173 else
174 {
175 Face_normales(num_Face,0) += nx;
176 Face_normales(num_Face,1) += ny;
177 Face_normales(num_Face,2) += nz;
178 }
179}
180
181
182
183/*! @brief
184 *
185 */
186void Hexa_EF::calcul_vc(const ArrOfInt& Face,ArrOfDouble& vc,
187 const ArrOfDouble& vs,const DoubleTab& vsom,
188 const Champ_Inc_base& vitesse,int type_cl) const
189{
190
191 vc[0] = vs[0]/6;
192 vc[1] = vs[1]/6;
193 vc[2] = vs[2]/6;
194}
195
196/*! @brief Computes the coordinates xg of the centre of a non-standard element.
197 *
198 * @brief Also computes idirichlet = number of Dirichlet faces of the element.
199 * If idirichlet=2, n1 is the index of the vertex coinciding with G.
200 * @param xg Output centre coordinates.
201 * @param x Vertex coordinate table for the element.
202 * @param type_elem_Cl Element boundary condition type.
203 * @param idirichlet Output number of Dirichlet faces.
204 * @param n1 Output index of the vertex coinciding with G (when idirichlet=2).
205 */
206void Hexa_EF::calcul_xg(DoubleVect& xg, const DoubleTab& x,
207 const int type_elem_Cl,int& idirichlet,int& n1,int& ,int& ) const
208{
209 int j,dim=xg.size();
210 for (j=0; j<dim; j++)
211 xg[j]=(x(0,j)+x(1,j)+x(2,j)+x(3,j)+x(4,j)+x(5,j)+x(6,j)+x(7,j))*0.125;
212 idirichlet=0;
213}
214
215
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
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 Hexa_EF.cpp:206
void calcul_vc(const ArrOfInt &, ArrOfDouble &, const ArrOfDouble &, const DoubleTab &, const Champ_Inc_base &, int) const override
Definition Hexa_EF.cpp:186
Hexa_EF()
KEL_(0,fa7), KEL_(1,fa7) are the local indices of the 2 faces surrounding facet with local index fa7.
Definition Hexa_EF.cpp:38
void normale(int, DoubleTab &, const IntTab &, const IntTab &, const IntTab &, const Domaine &) const override
Fills the face_normales array in the Domaine_EF.
Definition Hexa_EF.cpp:52
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