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