TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Reorienter_tetraedres.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 <Reorienter_tetraedres.h>
17#include <Scatter.h>
18
19Implemente_instanciable_32_64(Reorienter_tetraedres_32_64,"Reorienter_tetraedres",Interprete_geometrique_base_32_64<_T_>);
20// XD reorienter_tetraedres interprete reorienter_tetraedres INHERITS_BRACE This keyword is mandatory for front-tracking
21// XD_CONT computations with the VEF discretization. For each tetrahedral element of the domain, it checks if it has a
22// XD_CONT positive volume. If the volume (determinant of the three vectors) is negative, it swaps two nodes to reverse
23// XD_CONT the orientation of this tetrahedron.
24// XD attr domain_name ref_domaine domain_name REQ Name of domain.
25
26template <typename _SIZE_>
28{
29 return Interprete::printOn(os);
30}
31
32template <typename _SIZE_>
34{
35 return Interprete::readOn(is);
36}
37
38template <typename _SIZE_>
40{
41 Cerr << "Reorientation of tetrahedra for either direct..." << finl;
42 if (Objet_U::dimension != 3)
43 {
44 Cerr << "we can not reorientate (Reorienter) in dimension " << Objet_U::dimension <<finl;
46 }
47 this->associer_domaine(is);
48 Domaine_t& dom=this->domaine();
50 reorienter(dom);
52 Cerr << "Reorientation of tetrahedra... OK" << finl;
53 return is;
54}
55
56template <typename _SIZE_>
57Sens_Orient Reorienter_tetraedres_32_64<_SIZE_>::test_orientation_tetra(IntTab_t& les_elems, int_t ielem, const DoubleTab_t& coord_sommets) const
58{
59 static const int SOM_Z = 0;
60 static const int SOM_A = 1;
61 static const int SOM_B = 2;
62 static const int SOM_C = 3;
63
64 const int_t som_Z = les_elems(ielem,SOM_Z);
65 const int_t som_A = les_elems(ielem,SOM_A);
66 const int_t som_B = les_elems(ielem,SOM_B);
67 const int_t som_C = les_elems(ielem,SOM_C);
68
69 double ZA[3], ZB[3], ZC[3], pdtvect[3], pdtscal;
70 int k;
71 for (k=0 ; k < Objet_U::dimension ; k++)
72 {
73 ZA[k] = coord_sommets(som_A,k) - coord_sommets(som_Z,k);
74 ZB[k] = coord_sommets(som_B,k) - coord_sommets(som_Z,k);
75 ZC[k] = coord_sommets(som_C,k) - coord_sommets(som_Z,k);
76 }
77
78 //calcul pdt vect ZAxZB
79 pdtvect[0] = ZA[1]*ZB[2] - ZA[2]*ZB[1];
80 pdtvect[1] = ZA[2]*ZB[0] - ZA[0]*ZB[2];
81 pdtvect[2] = ZA[0]*ZB[1] - ZA[1]*ZB[0];
82
83 //calcul du pdtscal pdtvect.ZC
84 pdtscal = 0.;
85 for (k=0 ; k < Objet_U::dimension ; k++)
86 {
87 pdtscal += pdtvect[k] * ZC[k];
88 }
89
90 if (pdtscal<0.)
91 {
92 //le pdt scalaire est negatif : il s'agit d'un tetraedre mal oriente
93#ifdef _AFFDEBUG
94 {
95 Process::Journal<<" element "<<num_element<<" indirect"<<finl;
96 }
97#endif
98 return Sens_Orient::INDIRECT;
99 }
100#ifdef _AFFDEBUG
101 {
102 Process::Journal<<" element "<<num_element<<" direct"<<finl;
103 }
104#endif
105
106 return Sens_Orient::DIRECT;
107}
108
109template <typename _SIZE_>
111{
112 static const int SOM_A = 1;
113 static const int SOM_B = 2;
114
115 //pour reorienter le tetraedre, on va permuter les sommets 1 et 2
116 int_t tmp;
117 tmp = les_elems(num_element,SOM_A);
118 les_elems(num_element,SOM_A) = les_elems(num_element,SOM_B);
119 les_elems(num_element,SOM_B) = tmp;
120 return Sens_Orient::DIRECT;
121}
122
123template <typename _SIZE_>
125{
126 const DoubleTab_t& coord_sommets = dom.coord_sommets();
127
128 if (dom.type_elem()->que_suis_je() == "Tetraedre" )
129 {
130 //domaine de tetraedres
131 IntTab_t& les_elems = dom.les_elems();
132 int_t nb_elems = les_elems.dimension(0);
133
134 //balaye les tetraedres
135 for (int_t ielem=0 ; ielem<nb_elems ; ielem++)
136 {
137 if (test_orientation_tetra(les_elems, ielem, coord_sommets) == Sens_Orient::INDIRECT)
138 {
139 //tetraedre oriente en sens indirect -> a reorienter
140 reorienter_tetra(les_elems, ielem);
141
142#ifdef _AFFDEBUG
143 {
144 Process::Journal<<" #element reoriente "<<ielem<<finl;
145 static const int SOM_Z = 0; // indice du sommet qui servira d'origine
146 static const int SOM_A = 1; // indice du sommet qui servira pour le premier vecteur
147 static const int SOM_B = 2; // indice du sommet qui servira pour le second vecteur
148 static const int SOM_C = 3; // indice du sommet qui servira pour le troisieme vecteur
149 const int som_Z = les_elems(ielem,SOM_Z);
150 const int som_A = les_elems(ielem,SOM_A);
151 const int som_B = les_elems(ielem,SOM_B);
152 const int som_C = les_elems(ielem,SOM_C);
153 Process::Journal<<" somA= "<<som_A<<" coords= "<<coord_sommets(som_A, 0)<<" "<<coord_sommets(som_A, 1)<<" "<<coord_sommets(som_A, 2)<<finl;
154 Process::Journal<<" somB= "<<som_B<<" coords= "<<coord_sommets(som_B, 0)<<" "<<coord_sommets(som_B, 1)<<" "<<coord_sommets(som_B, 2)<<finl;
155 Process::Journal<<" somC= "<<som_C<<" coords= "<<coord_sommets(som_C, 0)<<" "<<coord_sommets(som_C, 1)<<" "<<coord_sommets(som_C, 2)<<finl;
156 Process::Journal<<" somA= "<<som_A<<" coords= "<<coord_sommets(som_A, 0)<<" "<<coord_sommets(som_A, 1)<<" "<<coord_sommets(som_A, 2)<<finl<<finl;
157 Process::Journal<<" somZ= "<<som_Z<<" coords= "<<coord_sommets(som_Z, 0)<<" "<<coord_sommets(som_Z, 1)<<" "<<coord_sommets(som_Z, 2)<<finl;
158 Process::Journal<<" somA= "<<som_A<<" coords= "<<coord_sommets(som_A, 0)<<" "<<coord_sommets(som_A, 1)<<" "<<coord_sommets(som_A, 2)<<finl<<finl;
159 Process::Journal<<" somZ= "<<som_Z<<" coords= "<<coord_sommets(som_Z, 0)<<" "<<coord_sommets(som_Z, 1)<<" "<<coord_sommets(som_Z, 2)<<finl;
160 Process::Journal<<" somB= "<<som_B<<" coords= "<<coord_sommets(som_B, 0)<<" "<<coord_sommets(som_B, 1)<<" "<<coord_sommets(som_B, 2)<<finl<<finl;
161 Process::Journal<<" somZ= "<<som_Z<<" coords= "<<coord_sommets(som_Z, 0)<<" "<<coord_sommets(som_Z, 1)<<" "<<coord_sommets(som_Z, 2)<<finl;
162 Process::Journal<<" somC= "<<som_C<<" coords= "<<coord_sommets(som_C, 0)<<" "<<coord_sommets(som_C, 1)<<" "<<coord_sommets(som_C, 2)<<finl<<finl;
163 }
164#endif
165 }
166 }
167 }
168}
169
170
172#if INT_is_64_ == 2
174#endif
175
176
IntTab_t & les_elems()
Definition Domaine.h:129
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
classe Interprete_geometrique_base .
friend class Entree
Definition Objet_U.h:76
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static Sortie & Journal(int message_level=0)
Renvoie un objet statique de type Sortie qui sert de journal d'evenements.
Definition Process.cpp:588
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
class Reorienter_tetra Balaye les tetraedres du maillage pour qu'ils soient directs.
Domaine_32_64< _SIZE_ > Domaine_t
DoubleTab_T< _SIZE_ > DoubleTab_t
Sens_Orient test_orientation_tetra(IntTab_t &les_elems, int_t ielem, const DoubleTab_t &coord_sommets) const
Entree & interpreter_(Entree &) override
Sens_Orient reorienter_tetra(IntTab_t &les_elems, int_t ielem) const
static void init_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
Create parallel descriptors for the vertex and element arrays of the domain (necessary because Scatte...
Definition Scatter.cpp:2742
static void uninit_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
methode utilisee par les interpretes qui modifient le domaine (sequentiel), detruit les descripteurs ...
Definition Scatter.cpp:2757
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133