TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Prisme.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 <Prisme.h>
17#include <Domaine.h>
18
19// 5
20// /|
21// 3----4
22// | | |
23// | 2 |
24// |/ |
25// 0----1
26
27static int faces_sommets_prisme[5][4] =
28{
29 { 0, 1, 3, 4 },
30 { 0, 2, 3, 5 },
31 { 1, 2, 4, 5 },
32 { 0, 1, 2, -1 },
33 { 3, 4, 5, -1 }
34};
35
36
37Implemente_instanciable_32_64(Prisme_32_64,"Prisme",Elem_geom_base_32_64<_T_>);
38
39template <typename _SIZE_>
41{
42 return s;
43}
44
45template <typename _SIZE_>
47{
48 return s;
49}
50
51
52/*! @brief Reordonne les sommets du Prisme.
53 *
54 * NE FAIT RIEN: A CODER
55 *
56 */
57template <typename _SIZE_>
59{
60 Cerr << "Prisme_32_64<_SIZE_>::reordonner must be coded " << finl;
62 // a coder. remise en conformite de la numerotation des noeuds.
63}
64
65
66/*! @brief Renvoie le nom LML d'un prisme = "PRISM6".
67 *
68 * @return (Nom&) toujours egal a "PRISM6"
69 */
70template <typename _SIZE_>
72{
73 static Nom nom="PRISM6";
74 return nom;
75}
76
77
78/*! @brief NE FAIT RIEN: A CODER, renvoie toujours 0.
79 *
80 * Renvoie 1 si l'element "element" du domaine associe a
81 * l'element geometrique contient le point
82 * de coordonnees specifiees par le parametre "pos".
83 * Renvoie 0 sinon.
84 *
85 * @param (DoubleVect& pos) coordonnees du point que l'on cherche a localiser
86 * @param (int element) le numero de l'element du domaine dans lequel on cherche le point.
87 * @return (int) 1 si le point de coordonnees specifiees appartient a l'element "element" 0 sinon
88 */
89template <typename _SIZE_>
90int Prisme_32_64<_SIZE_>::contient(const ArrOfDouble& pos, int_t ielem ) const
91{
92 // a coder :
93 // est-ce que le prisme de numero element contient le point de
94 // coordonnees pos ?
95 // adaptation de tetraedre contient
96 assert(pos.size_array()==3);
97 const Domaine_t& domaine=this->mon_dom.valeur();
98 const Domaine_t& dom=domaine;
99 double prod1,prod2,xn,yn,zn;
100 int_t som0, som1, som2, som3,som4,som5;
101
102 // On regarde tout d'abord si le pintr cherche n'est pas un des
103 // sommets du triangle
104 som0 = domaine.sommet_elem(ielem,0);
105 som1 = domaine.sommet_elem(ielem,1);
106 som2 = domaine.sommet_elem(ielem,2);
107 som3 = domaine.sommet_elem(ielem,3);
108 som4 = domaine.sommet_elem(ielem,4);
109 som5 = domaine.sommet_elem(ielem,5);
110 if( ( est_egal(dom.coord(som0,0),pos[0]) && est_egal(dom.coord(som0,1),pos[1]) && est_egal(dom.coord(som0,2),pos[2]) )
111 || (est_egal(dom.coord(som1,0),pos[0]) && est_egal(dom.coord(som1,1),pos[1]) && est_egal(dom.coord(som1,2),pos[2]))
112 || (est_egal(dom.coord(som2,0),pos[0]) && est_egal(dom.coord(som2,1),pos[1]) && est_egal(dom.coord(som2,2),pos[2]))
113 || (est_egal(dom.coord(som3,0),pos[0]) && est_egal(dom.coord(som3,1),pos[1]) && est_egal(dom.coord(som3,2),pos[2]))
114 || (est_egal(dom.coord(som4,0),pos[0]) && est_egal(dom.coord(som4,1),pos[1]) && est_egal(dom.coord(som4,2),pos[2]))
115 || (est_egal(dom.coord(som5,0),pos[0]) && est_egal(dom.coord(som5,1),pos[1]) && est_egal(dom.coord(som5,2),pos[2]))
116 )
117 return 1;
118
119 for (int j=0; j<5; j++)
120 {
121 switch(j)
122 {
123 case 0 :
124 som0 = domaine.sommet_elem(ielem,0);
125 som1 = domaine.sommet_elem(ielem,1);
126 som2 = domaine.sommet_elem(ielem,3);
127 som3 = domaine.sommet_elem(ielem,2);
128 break;
129 case 1 :
130 som0 = domaine.sommet_elem(ielem,0);
131 som1 = domaine.sommet_elem(ielem,2);
132 som2 = domaine.sommet_elem(ielem,3);
133 som3 = domaine.sommet_elem(ielem,4);
134 break;
135 case 2 :
136 som0 = domaine.sommet_elem(ielem,1);
137 som1 = domaine.sommet_elem(ielem,2);
138 som2 = domaine.sommet_elem(ielem,4);
139 som3 = domaine.sommet_elem(ielem,0);
140 break;
141 case 3 :
142 som0 = domaine.sommet_elem(ielem,0);
143 som1 = domaine.sommet_elem(ielem,1);
144 som2 = domaine.sommet_elem(ielem,2);
145 som3 = domaine.sommet_elem(ielem,3);
146 break;
147 case 4 :
148 som0 = domaine.sommet_elem(ielem,3);
149 som1 = domaine.sommet_elem(ielem,4);
150 som2 = domaine.sommet_elem(ielem,5);
151 som3 = domaine.sommet_elem(ielem,0);
152 break;
153 }
154
155 // Algorithme : le sommet 3 et le point M doivent pour j=0 a 3 du meme cote
156 // que le plan formes par les points som0,som1,som2.
157 // calcul de la normale au plan som0,som1,som2 :
158 xn = (dom.coord(som1,1)-dom.coord(som0,1))*(dom.coord(som2,2)-dom.coord(som0,2))
159 - (dom.coord(som1,2)-dom.coord(som0,2))*(dom.coord(som2,1)-dom.coord(som0,1));
160 yn = (dom.coord(som1,2)-dom.coord(som0,2))*(dom.coord(som2,0)-dom.coord(som0,0))
161 - (dom.coord(som1,0)-dom.coord(som0,0))*(dom.coord(som2,2)-dom.coord(som0,2));
162 zn = (dom.coord(som1,0)-dom.coord(som0,0))*(dom.coord(som2,1)-dom.coord(som0,1))
163 - (dom.coord(som1,1)-dom.coord(som0,1))*(dom.coord(som2,0)-dom.coord(som0,0));
164 prod1 = xn * ( dom.coord(som3,0) - dom.coord(som0,0) )
165 + yn * ( dom.coord(som3,1) - dom.coord(som0,1) )
166 + zn * ( dom.coord(som3,2) - dom.coord(som0,2) );
167 prod2 = xn * ( pos[0] - dom.coord(som0,0) )
168 + yn * ( pos[1] - dom.coord(som0,1) )
169 + zn * ( pos[2] - dom.coord(som0,2) );
170 // Si le point est sur le plan (prod2 quasi nul) : on ne peut pas conclure...
171 if (prod1*prod2 < 0 && std::fabs(prod2)>std::fabs(prod1)*Objet_U::precision_geom) return 0;
172 }
173 return 1;
174}
175
176
177/*! @brief NE FAIT RIEN: A CODER, renvoie toujours 0 Renvoie 1 si les sommets specifies par le parametre "pos"
178 *
179 * sont les sommets de l'element "element" du domaine associe a
180 * l'element geometrique.
181 *
182 * @param (IntVect& pos) les numeros des sommets a comparer avec ceux de l'elements "element"
183 * @param (int element) le numero de l'element du domaine dont on veut comparer les sommets
184 * @return (int) 1 si les sommets passes en parametre sont ceux de l'element specifie, 0 sinon
185 */
186template <typename _SIZE_>
188{
189 // a coder :
191 return 0;
192}
193
194
195/*! @brief NE FAIT RIEN: A CODER Calcule les volumes des elements du domaine associe.
196 *
197 * @param (DoubleVect& volumes) le vecteur contenant les valeurs des des volumes des elements du domaine
198 */
199template <typename _SIZE_>
201{
202 const Domaine_t& domaine=this->mon_dom.valeur();
203 const IntTab_t& elem=domaine.les_elems();
204 const DoubleTab_t& coord=domaine.coord_sommets();
205 int_t size_tot = domaine.nb_elem_tot();
206 assert(volumes.size_totale()==size_tot);
207 for (int_t num_poly=0; num_poly<size_tot; num_poly++)
208 {
209 int_t i1=elem(num_poly,0),
210 i2=elem(num_poly,1),
211 i3=elem(num_poly,2),
212 i4=elem(num_poly,3),
213 i5=elem(num_poly,4),
214 i6=elem(num_poly,5);
215
216 // recuperer de MEDMEM_Formulae.hxx
217 double a1 = (coord(i2,0)-coord(i3,0))/2.0, a2 = (coord(i2,1)-coord(i3,1))/2.0, a3 = (coord(i2,2)-coord(i3,2))/2.0;
218 double b1 = (coord(i5,0)-coord(i6,0))/2.0, b2 = (coord(i5,1)-coord(i6,1))/2.0, b3 = (coord(i5,2)-coord(i6,2))/2.0;
219 double c1 = (coord(i4,0)-coord(i1,0))/2.0, c2 = (coord(i4,1)-coord(i1,1))/2.0, c3 = (coord(i4,2)-coord(i1,2))/2.0;
220 double d1 = (coord(i5,0)-coord(i2,0))/2.0, d2 = (coord(i5,1)-coord(i2,1))/2.0, d3 = (coord(i5,2)-coord(i2,2))/2.0;
221 double e1 = (coord(i6,0)-coord(i3,0))/2.0, e2 = (coord(i6,1)-coord(i3,1))/2.0, e3 = (coord(i6,2)-coord(i3,2))/2.0;
222 double f1 = (coord(i1,0)-coord(i3,0))/2.0, f2 = (coord(i1,1)-coord(i3,1))/2.0, f3 = (coord(i1,2)-coord(i3,2))/2.0;
223 double h1 = (coord(i4,0)-coord(i6,0))/2.0, h2 = (coord(i4,1)-coord(i6,1))/2.0, h3 = (coord(i4,2)-coord(i6,2))/2.0;
224
225 double A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 +
226 a3*c1*f2 - a3*c2*f1;
227 double B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 +
228 b3*c1*h2 - b3*c2*h1;
229 double C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) -
230 (a2*c1*h3 + b2*c1*f3) + (a2*c3*h1 + b2*c3*f1) +
231 (a3*c1*h2 + b3*c1*f2) - (a3*c2*h1 + b3*c2*f1);
232 double D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 +
233 a3*d1*f2 - a3*d2*f1;
234 double E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 +
235 b3*d1*h2 - b3*d2*h1;
236 double F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) -
237 (a2*d1*h3 + b2*d1*f3) + (a2*d3*h1 + b2*d3*f1) +
238 (a3*d1*h2 + b3*d1*f2) - (a3*d2*h1 + b3*d2*f1);
239 double G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 +
240 a3*e1*f2 - a3*e2*f1;
241 double H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 +
242 b3*e1*h2 - b3*e2*h1;
243 double P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) -
244 (a2*e1*h3 + b2*e1*f3) + (a2*e3*h1 + b2*e3*f1) +
245 (a3*e1*h2 + b3*e1*f2) - (a3*e2*h1 + b3*e2*f1);
246 volumes[num_poly]=std::fabs(-2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0);
247
248 }
249
250}
251
252/*! @brief remplit le tableau faces_som_local(i,j) qui donne pour 0 <= i < nb_faces() et 0 <= j < nb_som_face(i) le numero local du sommet
253 *
254 * sur l'element.
255 * On a 0 <= faces_sommets_locaux(i,j) < nb_som()
256 * Si toutes les faces de l'element n'ont pas le meme nombre de sommets, le nombre
257 * de colonnes du tableau est le plus grand nombre de sommets, et les cases inutilisees
258 * du tableau sont mises a -1
259 * On renvoie 1 si toutes les faces ont le meme nombre d'elements, 0 sinon.
260 *
261 */
262template <typename _SIZE_>
264{
265 faces_som_local.resize(5,4);
266 for (int i=0; i<5; i++)
267 for (int j=0; j<4; j++)
268 faces_som_local(i,j) = faces_sommets_prisme[i][j];
269 return 1;
270}
271
272
273template class Prisme_32_64<int>;
274#if INT_is_64_ == 2
275template class Prisme_32_64<trustIdType>;
276#endif
277
double coord(int_t i, int j) const
Definition Domaine.h:110
Classe Elem_geom_base Cette classe est la classe de base pour la definition d'elements.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
static double precision_geom
Definition Objet_U.h:86
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Classe Prisme Cette represente l'element geometrique Prisme.
Definition Prisme.h:34
DoubleTab_T< _SIZE_ > DoubleTab_t
Definition Prisme.h:44
const Nom & nom_lml() const override
Renvoie le nom LML d'un prisme = "PRISM6".
Definition Prisme.cpp:71
IntTab_T< _SIZE_ > IntTab_t
Definition Prisme.h:41
void reordonner() override
Reordonne les sommets du Prisme.
Definition Prisme.cpp:58
void calculer_volumes(DoubleVect_t &vols) const override
NE FAIT RIEN: A CODER Calcule les volumes des elements du domaine associe.
Definition Prisme.cpp:200
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
Definition Prisme.h:42
Domaine_32_64< _SIZE_ > Domaine_t
Definition Prisme.h:45
_SIZE_ int_t
Definition Prisme.h:40
int contient(const ArrOfDouble &pos, int_t elem) const override
NE FAIT RIEN: A CODER, renvoie toujours 0.
Definition Prisme.cpp:90
DoubleVect_T< _SIZE_ > DoubleVect_t
Definition Prisme.h:43
int get_tab_faces_sommets_locaux(IntTab &faces_som_local) const override
remplit le tableau faces_som_local(i,j) qui donne pour 0 <= i < nb_faces() et 0 <= j < nb_som_face(i)...
Definition Prisme.cpp:263
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61