16#include <Polyedriser.h>
35static int faces_sommets_poly[6][4] =
51template <
typename _SIZE_>
57template <
typename _SIZE_>
65static double computeAngleBetweenCoplanarVectors(std::vector<double> u, std::vector<double> v,
66 std::vector<double> normale)
68 double dot = u[0]*v[0] + u[1]*v[1] + u[2]*v[2];
69 double det = u[0]*v[1]*normale[2]
70 + v[0]*normale[1]*u[2]
71 + normale[0]*u[1]*v[2]
72 - u[2]* v[1] *normale[0]
73 - v[2]* normale[1] *u[0]
74 - normale[2]* u[1] *v[0];
76 double angle = atan2(det, dot);
80 while(v[dir] == 0.0) dir++;
81 double quotient = u[dir] / v[dir];
84 else if( quotient < 0 )
95template <
typename _SIZE_>
101 for(int_t face = 0; face < nb_faces; face++)
104 std::vector<double> center(3,0.0);
105 for(
int s=0; s < nb_sommets; s++)
106 for(
int dir=0; dir<3; dir++)
107 center[dir] += coords(faces.
sommet(face,s),dir);
108 for(
int dir=0; dir<3; dir++)
109 center[dir] /= nb_sommets;
112 int_t s0 = faces.
sommet(face, 0),
113 s1 = faces.
sommet(face, 1),
114 s2 = faces.
sommet(face, 2);
115 std::vector<double> u =
117 coords(s1,0) - coords(s0,0),
118 coords(s1,1) - coords(s0,1),
119 coords(s1,2) - coords(s0,2),
121 std::vector<double> v =
123 coords(s2,0) - coords(s0,0),
124 coords(s2,1) - coords(s0,1),
125 coords(s2,2) - coords(s0,2),
127 std::vector<double> normale =
129 u[1]*v[2] - u[2]*v[1] ,
130 u[2]*v[0] - u[0]*v[2] ,
131 u[0]*v[1] - u[1]*v[0] ,
133 double normale_norm = sqrt( normale[0]*normale[0] + normale[1]*normale[1] + normale[2]*normale[2] );
134 for(
int dir=0; dir<3; dir++) normale[dir] /= normale_norm;
137 std::vector<double> vec_ref = { coords(faces.
sommet(face,0),0) - center[0],
138 coords(faces.
sommet(face,0),1) - center[1],
139 coords(faces.
sommet(face,0),2) - center[2]
144 for (
int i = 0; i < nb_sommets-1; i++)
146 for (
int j = 0; j < nb_sommets-i-1; j++)
148 std::vector<double> vec1 = {coords(faces.
sommet(face,j),0)-center[0],
149 coords(faces.
sommet(face,j),1)-center[1],
150 coords(faces.
sommet(face,j),2)-center[2]
152 std::vector<double> vec2 = {coords(faces.
sommet(face,j+1),0)-center[0],
153 coords(faces.
sommet(face,j+1),1)-center[1],
154 coords(faces.
sommet(face,j+1),2)-center[2]
156 double angle1 = computeAngleBetweenCoplanarVectors(vec1, vec_ref, normale);
157 double angle2 = computeAngleBetweenCoplanarVectors(vec2, vec_ref, normale);
161 int_t tmp = faces.
sommet(face,j);
163 faces.
sommet(face, j+1) = tmp;
171template <
typename _SIZE_>
174 if(
domaine.type_elem()->que_suis_je() ==
"Hexaedre")
188 for (
int_t e = 0; e < nb_elems; e++)
192 for(
int f=0; f<6; f++)
195 for(
int s=0; s<4; s++)
197 int som_loc = faces_sommets_poly[f][s];
198 N[node] = elements(e, som_loc);
204 Fi[nb_elems*6] = node;
210 Cerr <<
"We do not yet know how to Polyedriser_32_64 the "
211 <<
domaine.type_elem()->que_suis_je() <<
"s"<<finl;
212 Cerr <<
"Try to use convertAllToPoly option of Lire_MED|Read_MED keyword if you read a MED file for your mesh." << finl;
218 for (
auto &itr :
domaine.faces_bord())
220 Faces_t& les_faces = itr.faces();
221 les_faces.
typer(Type_Face::polygone_3D);
222 reorder_vertices(les_faces, coords);
225 for (
auto &itr :
domaine.faces_raccord())
227 Faces_t& les_faces = itr->faces();
228 les_faces.
typer(Type_Face::polygone_3D);
229 reorder_vertices(les_faces, coords);
232 for (
auto &itr :
domaine.bords_int())
234 Faces_t& les_faces = itr.faces();
235 les_faces.
typer(Type_Face::polygone_3D);
236 reorder_vertices(les_faces, coords);
239 for (
auto &itr :
domaine.groupes_faces())
241 Faces_t& les_faces = itr.faces();
242 les_faces.
typer(Type_Face::polygone_3D);
243 reorder_vertices(les_faces, coords);
248template <
typename _SIZE_>
258 Cerr <<
"Interpreter "<<this->
que_suis_je()<<
" cannot be applied during a parallel calculation !" << finl;
259 Cerr <<
"The mesh can't be changed after it has been partitioned." << finl;
Class defining operators and methods for all reading operation in an input flow (file,...
Class Faces Faces describes a set of faces by their type (point, segment, triangle or quadrangle),...
void typer(const Motcle &)
Sets the type of the faces.
const IntTab_t & les_sommets() const
Returns the array of vertices of all faces.
int_t sommet(int_t, int) const
Returns the number of the j-th vertex of the i-th face.
Class Interprete_geometrique_base.
void associer_domaine(Nom &nom_dom)
Domaine_t & domaine(int i=0)
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Class Polyedre: represents the Polyedre geometric element.
void affecte_connectivite_numero_global(const ArrOfInt_t &Nodes, const ArrOfInt_t &FacesIndex, const ArrOfInt_t &PolyhedronIndex, IntTab_t &les_elems)
Polyedriser Class intended to convert a hexahedron into a polyhedron.
Domaine_32_64< _SIZE_ > Domaine_t
void polyedriser(Domaine_t &) const
Faces_32_64< _SIZE_ > Faces_t
DoubleTab_T< _SIZE_ > DoubleTab_t
ArrOfInt_T< _SIZE_ > ArrOfInt_t
Entree & interpreter_(Entree &) override
IntTab_T< _SIZE_ > IntTab_t
int dimension_application() const
static bool is_parallel()
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
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...
static void uninit_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
Method used by interpreters that modify the domain (sequential), destroys the descriptors of vertices...
Base class for output streams.
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
int dimension_int(int d) const
_SIZE_ dimension(int d) const