TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Reorienter_triangles.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_triangles.h>
17#include <Scatter.h>
18
19Implemente_instanciable_32_64(Reorienter_triangles_32_64,"Reorienter_triangles",Interprete_geometrique_base_32_64<_T_>);
20// XD reorienter_triangles interprete reorienter_triangles INHERITS_BRACE not_set
21// XD attr domain_name ref_domaine domain_name REQ Name of domain.
22
23template <typename _SIZE_>
25{
26 return Interprete::printOn(os);
27}
28
29template <typename _SIZE_>
31{
32 return Interprete::readOn(is);
33}
34
35template <typename _SIZE_>
37{
38 Cerr << "Reorientation of triangles for either direct..." << finl;
39 if (Objet_U::dimension != 2)
40 {
41 Cerr << "we can not reorientate (Reorienter) triangles in dimension " << Objet_U::dimension <<finl;
43 }
44 this->associer_domaine(is);
45 Domaine_t& dom=this->domaine();
47 this->reorienter(dom);
49 Cerr << "Reorientation of triangles... OK" << finl;
50 return is;
51}
52
53template <typename _SIZE_>
54Sens_Orient Reorienter_triangles_32_64<_SIZE_>::test_orientation_triangle(IntTab_t& les_elems, int_t ielem, const DoubleTab_t& coord_sommets) const
55{
56 static const int SOM_Z = 0;
57 static const int SOM_A = 1;
58 static const int SOM_B = 2;
59
60 const int_t som_Z = les_elems(ielem,SOM_Z);
61 const int_t som_A = les_elems(ielem,SOM_A);
62 const int_t som_B = les_elems(ielem,SOM_B);
63
64 double ZA0 = coord_sommets(som_A,0) - coord_sommets(som_Z,0);
65 double ZB0 = coord_sommets(som_B,0) - coord_sommets(som_Z,0);
66 double ZA1 = coord_sommets(som_A,1) - coord_sommets(som_Z,1);
67 double ZB1 = coord_sommets(som_B,1) - coord_sommets(som_Z,1);
68
69 //calcul pdt vect ZAxZB
70 double pdtvect = ZA0*ZB1 - ZA1*ZB0;
71
72 if (pdtvect<0.)
73 {
74 //le pdt scalaire est negatif : il s'agit d'un triangle mal oriente
75#ifdef _AFFDEBUG
76 {
77 Process::Journal<<" element "<<num_element<<" indirect"<<finl;
78 }
79#endif
80 return Sens_Orient::INDIRECT;
81 }
82#ifdef _AFFDEBUG
83 {
84 Process::Journal<<" element "<<num_element<<" direct"<<finl;
85 }
86#endif
87
88 return Sens_Orient::DIRECT;
89}
90
91template <typename _SIZE_>
93{
94 static const int SOM_A = 1;
95 static const int SOM_B = 2;
96
97 //pour reorienter le triangle, on va permuter les sommets 1 et 2
98 int_t tmp;
99 tmp = les_elems(num_element,SOM_A);
100 les_elems(num_element,SOM_A) = les_elems(num_element,SOM_B);
101 les_elems(num_element,SOM_B) = tmp;
102 return Sens_Orient::DIRECT;
103}
104
105/*!
106 * Cette methode permet de reorienter les triangles dans le sens direct
107 */
108template <typename _SIZE_>
110{
111 const DoubleTab_t& coord_sommets = dom.coord_sommets();
112
113 if (dom.type_elem()->que_suis_je() == "Triangle" )
114 {
115 //domaine de triangles
116 IntTab_t& les_elems = dom.les_elems();
117 int_t nb_elems = les_elems.dimension(0);
118
119 //balaye les triangles
120 for (int_t ielem=0 ; ielem<nb_elems ; ielem++)
121 {
122 if (test_orientation_triangle(les_elems, ielem, coord_sommets)==Sens_Orient::INDIRECT)
123 {
124 //triangle oriente en sens indirect -> a reorienter
125 reorienter_triangle(les_elems, ielem);
126
127#ifdef _AFFDEBUG
128 {
129 Process::Journal<<" #element reoriente "<<ielem<<finl;
130 static const int SOM_Z = 0;
131 static const int SOM_A = 1;
132 static const int SOM_B = 2;
133 const int som_Z = les_elems(ielem,SOM_Z);
134 const int som_A = les_elems(ielem,SOM_A);
135 const int som_B = les_elems(ielem,SOM_B);
136 Process::Journal<<" somZ= "<<som_Z<<" coords= "<<coord_sommets(som_Z, 0)<<" "<<coord_sommets(som_Z, 1)<<finl;
137 Process::Journal<<" somA= "<<som_A<<" coords= "<<coord_sommets(som_A, 0)<<" "<<coord_sommets(som_A, 1)<<finl;
138 Process::Journal<<" somB= "<<som_B<<" coords= "<<coord_sommets(som_B, 0)<<" "<<coord_sommets(som_B, 1)<<finl;
139 }
140#endif
141 }
142 }
143 }
144}
145
146
148#if INT_is_64_ == 2
150#endif
151
152
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_triangle Balaye les triangles du maillage pour qu'ils soient directs.
void reorienter(Domaine_t &) const
Sens_Orient reorienter_triangle(IntTab_t &les_elems, int_t ielem) const
Sens_Orient test_orientation_triangle(IntTab_t &les_elems, int_t ielem, const DoubleTab_t &coord_sommets) const
Domaine_32_64< _SIZE_ > Domaine_t
DoubleTab_T< _SIZE_ > DoubleTab_t
Entree & interpreter_(Entree &) override
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