17#include <DomaineAxi1d.h>
18#include <communications.h>
19#include <Linear_algebra_tools_impl.h>
20#include <TRUSTLists.h>
36template <
typename _SIZE_>
40 s <<
"vide_0D" << finl;
43 s << (type(type_face_)) << finl;
62template <
typename _SIZE_>
66 s <<
"vide_0D" << finl;
69 s << (
type(type_face_)) << finl;
71 faces_voisins.ecrit(s);
88template <
typename _SIZE_>
104 faces_voisins.resize(0,2);
122template <
typename _SIZE_>
131 faces_voisins.lit(s);
138 faces_voisins.resize(0,2);
152template <
typename _SIZE_>
155 int_t som = sommet(face,0);
156 for(
int imin=1; imin < nb_som; imin++)
157 som=std::min(som,sommet(face,imin));
171template <
typename _SIZE_>
172bool Faces_32_64<_SIZE_>::same_face(int_t f1,
const Faces_32_64& faces2, int_t f2,
int nb_som)
const
176 for(
int i=0; i<nb_som && ok ; i++)
179 for(
int j=0; j<nb_som && nok ; j++)
181 if(sommet(f1, i) == faces2.
sommet(f2, j))
206template <
typename _SIZE_>
211 les_mots[0]=
"vide_0D";
212 les_mots[1]=
"point_1D";
213 les_mots[2]=
"point_1D_axi";
214 les_mots[3]=
"segment_2D";
215 les_mots[4]=
"triangle_3D";
216 les_mots[5]=
"quadrangle_3D";
217 les_mots[6]=
"segment_2D_axi";
218 les_mots[7]=
"quadrangle_3D_axi";
219 les_mots[8]=
"quadrilatere_2D_axi";
220 les_mots[9]=
"polygone_3d";
222 int rang=les_mots.
search(mot);
226 return Type_Face::vide_0D;
228 return Type_Face::point_1D;
230 return Type_Face::point_1D_axi;
232 return Type_Face::segment_2D;
234 return Type_Face::triangle_3D;
236 return Type_Face::quadrangle_3D;
238 return Type_Face::segment_2D_axi;
240 return Type_Face::quadrangle_3D_axi;
242 return Type_Face::quadrilatere_2D_axi;
244 return Type_Face::polygone_3D;
247 Cerr <<
"In the area number " <<
Process::me() <<
" " << mot <<
" is not a type of face." << finl;
248 Cerr <<
"Check your splitting." << finl;
252 Cerr <<
"Your splitting seems to have been done with a TRUST version 1.5 or earlier. Since" << finl;
253 Cerr <<
"the 1.5.1, the files format of .Zones containing the splitting of your mesh has evolved." << finl;
254 Cerr <<
"You must therefore rebuild the splitting of your mesh with TRUST version 1.5.1 or newer." <<
261 return Type_Face::point_1D;
272template <
typename _SIZE_>
278 case Type_Face::vide_0D :
281 case Type_Face::point_1D :
284 case Type_Face::point_1D_axi :
287 case Type_Face::segment_2D :
290 case Type_Face::segment_2D_axi :
291 mot=
"segment_2D_axi";
293 case Type_Face::triangle_3D :
296 case Type_Face::quadrangle_3D :
299 case Type_Face::quadrangle_3D_axi :
300 mot=
"quadrangle_3D_axi";
302 case Type_Face::quadrilatere_2D_axi :
303 mot=
"quadrilatere_2D_axi";
305 case Type_Face::polygone_3D:
310 Cerr <<
"Error TRUST in Motcle& Faces_32_64<_SIZE_>::type(const Type_Face& typ)" << finl;
324template <
typename _SIZE_>
327 assert(sommets.dimension(1)==tab_sommet.
dimension(1));
328 int_t oldsz=sommets.dimension(0);
331 for(
int_t i=0; i<addsz; i++)
332 for(
int j=0; j<tab_sommet.
dimension(1); j++)
333 sommets(oldsz+i,j)=tab_sommet(i,j);
343template <
typename _SIZE_>
348 if (sommets.size()!=0) sommets.detach_vect();
349 sommets.resize(i,nombre_som_faces);
350 faces_voisins.resize(i, 2);
351 for(
int_t j=oldsz; j<i; j++)
353 for(
int k=0; k<nombre_som_faces; k++)
355 faces_voisins(j,0)=faces_voisins(j,1)=-1;
364template <
typename _SIZE_>
367 for(
int_t i=0; i<nb_faces_joint; i++)
369 faces_voisins(i,0)=faces_voisins(i,1)=-1;
376template <
typename _SIZE_>
379 for(
int_t i=0; i<nb_faces_joint; i++)
389template <
typename _SIZE_>
400template <
typename _SIZE_>
408 case Type_Face::vide_0D :
411 case Type_Face::point_1D :
412 case Type_Face::point_1D_axi :
415 case Type_Face::segment_2D :
418 case Type_Face::segment_2D_axi :
421 case Type_Face::triangle_3D :
424 case Type_Face::quadrangle_3D :
427 case Type_Face::quadrangle_3D_axi :
430 case Type_Face::quadrilatere_2D_axi :
433 case Type_Face::polygone_3D:
438 Cerr <<
"Error TRUST in Faces_32_64<_SIZE_>::typer(const Motcle& typ)" << finl;
449 if (
dimension<std::min(max_dim,nb_som_face))
451 Cerr <<
"You are in dimension " <<
dimension << finl;
452 Cerr <<
"and the mesh contains faces with " << nb_som_face <<
" nodes." << finl;
453 Cerr <<
"and this seems to be a mesh of dimension " << std::min(max_dim,nb_som_face) <<
" ..." << finl;
465template <
typename _SIZE_>
468 if (
voisin(face,0) == -1)
469 voisin(face, 0) = num_elem;
470 else if(
voisin(face,1) == -1)
471 voisin(face, 1) = num_elem;
475 Cerr <<
"Problem for the face number " << face <<
" and the cell " << num_elem << finl;
476 Cerr <<
"Indeed, the face already belongs to the cells " <<
voisin(face, 0) <<
" and " <<
voisin(face, 1) << finl;
477 Cerr <<
"The nodes of this face are:" << finl;
478 for (
int i=0; i<nb_som_face; i++)
479 Cerr <<
"Node " <<
sommet(face,i) << finl;
480 Cerr <<
"Check your mesh. Perhaps some cells " << finl;
481 Cerr <<
"are defined 2 times." << finl;
494template <
typename _SIZE_>
505 for (
int_t i = 0; i < nb_som; i++)
506 rmax = std::max(rmax, std::fabs(dom.
coord(i,0)));
508 for (
int_t i = 0; i < nb_som; i++)
510 const double r = dom.
coord(i,0);
513 Cerr <<
"In axisymmetric, the coordinates of the mesh according to radius" << finl;
514 Cerr <<
"ie along X, cannot be negative beyond tolerance." << finl;
515 Cerr <<
"The revolution axis must be at x=0." << finl;
516 Cerr <<
"we got x = " << r <<
" (tolerance = " << tol <<
")" << finl;
523 case Type_Face::segment_2D :
532 const double dx = x0 - x1;
533 const double dy = y0 - y1;
534 const double L = std::sqrt(dx*dx + dy*dy);
540 if(surfaces(face) == 0.)
542 Cerr <<
"area("<<face<<
")=0 ! Check your mesh." << finl;
550 const double r0 = x0;
551 const double r1 = x1;
552 const double rbar = 0.5 * (r0 + r1);
553 surfaces(face) = 2.0 * M_PI * L * rbar;
558 case Type_Face::quadrilatere_2D_axi :
567 const double dr = r1 - r0;
568 const double dz = z1 - z0;
569 const double L = std::sqrt(dr*dr + dz*dz);
570 const double rbar = 0.5*(r0 + r1);
571 surfaces(face) = 2.0 * M_PI * rbar * L;
576 case Type_Face::segment_2D_axi :
579 double r0,r1,teta0,teta1,d_teta;
584 if ( est_egal(r0,r1) )
588 d_teta = std::fabs(teta1-teta0);
589 if(d_teta > M_PI) d_teta=2.*M_PI-d_teta;
590 surfaces(face)=r0*d_teta;
593 surfaces(face)=std::fabs(r1-r0);
597 case Type_Face::triangle_3D :
601 double delta0, delta1, delta2;
602 double longueur0, longueur1;
611 longueur0=(delta0*delta0+delta1*delta1+delta2*delta2);
621 longueur1=(delta0*delta0+delta1*delta1+delta2*delta2);
622 surfaces(face)=0.5*(sqrt(longueur0*longueur1-prod*prod));
623 if(surfaces(face)==0.)
625 Cerr <<
"area("<<face<<
")=0 ! Check your mesh." << finl;
631 case Type_Face::quadrangle_3D :
643 double x1 = dom.
coord(n0, 0) - dom.
coord(n1, 0);
644 double y1 = dom.
coord(n0, 1) - dom.
coord(n1, 1);
645 double z1 = dom.
coord(n0, 2) - dom.
coord(n1, 2);
647 double x2 = dom.
coord(n3, 0) - dom.
coord(n1, 0);
648 double y2 = dom.
coord(n3, 1) - dom.
coord(n1, 1);
649 double z2 = dom.
coord(n3, 2) - dom.
coord(n1, 2);
651 double nx = (y1*z2 - y2*z1)/2;
652 double ny = (-x1*z2 + x2*z1)/2;
653 double nz = (x1*y2 - x2*y1)/2;
663 nx -= (y1*z2 - y2*z1)/2;
664 ny -= (-x1*z2 + x2*z1)/2;
665 nz -= (x1*y2 - x2*y1)/2;
667 surfaces(face)=sqrt(nx*nx+ny*ny+nz*nz);
671 case Type_Face::quadrangle_3D_axi :
674 double r0,r1,teta0,teta1,teta2,z0,z2,d_teta,delta_r;
679 delta_r = std::fabs(r1 - r0);
680 if ( est_egal(r0,r1) )
686 d_teta = std::fabs(teta1-teta0);
687 if(d_teta > M_PI) d_teta=2.*M_PI-d_teta;
688 surfaces(face)=r0*d_teta*std::fabs(z2-z0);
698 surfaces(face) = delta_r*std::fabs(z2-z0);
702 d_teta=std::fabs(teta2-teta0);
703 if(d_teta > M_PI) d_teta=2.*M_PI-d_teta;
704 surfaces(face) = 0.5*(r0+r1)*d_teta*delta_r;
710 case Type_Face::point_1D:
711 case Type_Face::vide_0D :
714 surfaces(face) = 1.0;
718 case Type_Face::point_1D_axi:
733 double r = sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
734 surfaces(face) = 2.*M_PI*r;
738 case Type_Face::polygone_3D:
744 double n0=0,n1=0,n2=0;
746 while (n >= 0 &&
sommet(face,n)==-1) n--;
747 for (
int i0=0; i0<=n; i0++)
751 if (i0<n) ip1_0=i0+1;
754 n0+=coord(i,1)*coord(ip1,2)-coord(i,2)*coord(ip1,1);
755 n1+=coord(i,2)*coord(ip1,0)-coord(i,0)*coord(ip1,2);
756 n2+=coord(i,0)*coord(ip1,1)-coord(i,1)*coord(ip1,0);
758 surfaces(face)=sqrt(n0*n0+n1*n1+n2*n2)/2.;
764 Cerr <<
"Error TRUST in type of Faces_32_64 not recognized " << finl;
775template <
typename _SIZE_>
785template <
typename _SIZE_>
803 case Type_Face::segment_2D_axi :
808 xv(face, 0)+=coord(
sommet(face ,som), 0);
809 double teta_0=coord(
sommet(face ,0), 1);
810 double teta_1=coord(
sommet(face ,1), 1);
811 double teta_min=std::min(teta_1, teta_0);
812 double teta_max=std::max(teta_1, teta_0);
813 double d_teta=teta_max-teta_min;
814 if( (teta_min==0.) && (d_teta>M_PI) )
819 xv(face, 1)+=(teta_min+teta_max);
824 case Type_Face::quadrangle_3D_axi :
829 xv(face, 0)+=coord(
sommet(face ,som), 0);
831 xv(face, 2)+=coord(
sommet(face ,som), 2);
832 double teta_0=coord(
sommet(face ,0), 1);
833 double teta_1=coord(
sommet(face ,1), 1);
834 double teta_2=coord(
sommet(face ,2), 1);
835 double teta_3=coord(
sommet(face ,3), 1);
836 double teta_min=std::min(teta_1, teta_0);
837 teta_min=std::min(teta_min, teta_2);
838 teta_min=std::min(teta_min, teta_3);
839 double teta_max=std::max(teta_1, teta_0);
840 teta_max=std::max(teta_min, teta_2);
841 teta_max=std::max(teta_min, teta_3);
842 double d_teta=teta_max-teta_min;
843 if( (teta_min==0.) && (d_teta>M_PI) )
845 if(teta_0==0.) teta_0+=2.*M_PI;
846 if(teta_1==0.) teta_1+=2.*M_PI;
847 if(teta_2==0.) teta_2+=2.*M_PI;
848 if(teta_3==0.) teta_3+=2.*M_PI;
851 xv(face, 1)+=(teta_0+teta_1+teta_2+teta_3) ;
858 Cerr <<
"Face type number " << (int)type_face_ <<
" not provided in Faces_32_64<_SIZE_>::calculer_centres_gravite" << finl;
869 while (
sommet(face,nb_som-1)==-1) nb_som--;
872 for(
int k=0; k<dim; k++)
873 for(
int som=0; som < nb_som; som++)
874 xv(face, k)+=coord(
sommet(face ,som), k);
875 for(
int k=0; k<dim; k++)
888template <
typename _SIZE_>
894 case Type_Face::point_1D :
895 case Type_Face::point_1D_axi :
899 case Type_Face::segment_2D :
905 case Type_Face::quadrilatere_2D_axi :
913 for(
int_t face=0; face < nombre_faces; face++)
939 case Type_Face::segment_2D_axi :
944 case Type_Face::triangle_3D :
949 case Type_Face::quadrangle_3D :
956 double xmin, ymin, zmin;
957 double xmax, ymax, zmax;
959 for(
int_t face=0; face < nombre_faces; face++)
971 int_t s0=S[0], s1=S[1], s2=S[2], s3=S[3];
972 double x03=coord(s3,0)-coord(s0,0);
973 double y03=coord(s3,1)-coord(s0,1);
974 double z03=coord(s3,2)-coord(s0,2);
975 double x02=coord(s2,0)-coord(s0,0);
976 double y02=coord(s2,1)-coord(s0,1);
977 double z02=coord(s2,2)-coord(s0,2);
979 double x01=coord(s1,0)-coord(s0,0);
980 double y01=coord(s1,1)-coord(s0,1);
981 double z01=coord(s1,2)-coord(s0,2);
1004 Cerr <<
"Permutation of local nodes 2 and 3 on the face " <<face<<finl;
1011 xmin=std::min(dom.
coord(S[0], 0), dom.
coord(S[1], 0));
1012 xmin=std::min(xmin, dom.
coord(S[2], 0));
1013 xmax=std::max(dom.
coord(S[0], 0), dom.
coord(S[1], 0));
1014 xmax=std::max(xmax, dom.
coord(S[2], 0));
1015 ymin=std::min(dom.
coord(S[0], 1), dom.
coord(S[1], 1));
1016 ymin=std::min(ymin, dom.
coord(S[2], 1));
1017 ymax=std::max(dom.
coord(S[0], 1), dom.
coord(S[1], 1));
1018 ymax=std::max(ymax, dom.
coord(S[2], 1));
1019 zmin=std::min(dom.
coord(S[0], 2), dom.
coord(S[1], 2));
1020 zmin=std::min(zmin, dom.
coord(S[2], 2));
1021 zmax=std::max(dom.
coord(S[0], 2), dom.
coord(S[1], 2));
1022 zmax=std::max(zmax, dom.
coord(S[2], 2));
1024 if(est_egal(zmin, zmax))
1027 if ( est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 1),ymin))
1030 if ( !est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 1),ymin))
1033 if ( est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 1),ymin))
1036 if ( !est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 1),ymin))
1039 if(est_egal(ymin, ymax))
1042 if ( est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 2),zmin))
1045 if ( !est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 2),zmin))
1048 if ( est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 2),zmin))
1051 if ( !est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 2),zmin))
1054 if(est_egal(xmin, xmax))
1057 if ( est_egal(dom.
coord(S[i], 1),ymin) && est_egal(dom.
coord(S[i], 2),zmin))
1060 if ( !est_egal(dom.
coord(S[i], 1),ymin) && est_egal(dom.
coord(S[i], 2),zmin))
1063 if ( est_egal(dom.
coord(S[i], 1),ymin) && !est_egal(dom.
coord(S[i], 2),zmin))
1066 if ( !est_egal(dom.
coord(S[i], 1),ymin) && !est_egal(dom.
coord(S[i], 2),zmin))
1079 case Type_Face::quadrangle_3D_axi :
1084 case Type_Face::polygone_3D:
1089 Cerr <<
"Error TRUST in type of Faces_32_64 not recognized " << finl;
1101template <
typename _SIZE_>
1106 if ( (
nb_faces() != faces.
nb_faces()) || ( type_face_ != faces.type_face_) )
1117 int_t numerol, face;
1121 for(face=0; face<
nb_faces(); face++)
1123 numerol=this->ppsf(face, nb_som_face);
1124 assert(numerol < std::numeric_limits<int>::max());
1125 numeroli = (int)numerol;
1126 listes[numeroli].add(premier++);
1128 for(face=0; face<
nb_faces(); face++)
1130 numerol=faces.ppsf(face, nb_som_face);
1131 assert(numerol < std::numeric_limits<int>::max());
1132 numeroli = (int)numerol;
1135 while (curseur && ok)
1138 ok=!faces.same_face(face, *
this, rang, nb_som_face);
const DoubleTab_t & origine_repere()
DoubleTab_t & les_sommets()
const DoubleTab_t & coord_sommets() const
double coord(int_t i, int j) const
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Class defining operators and methods for all reading operation in an input flow (file,...
Classe Faces Faces decrit un ensemble de faces par leur type (point ,segment, triangle ou quadrangle)...
int_t nb_faces_tot() const
Renvoie le nombre total de Faces i (reelles et virt) sur le proc courant.
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
void typer(const Motcle &)
Type les faces.
void initialiser_sommets_faces_joint(int_t nb_faces_joints)
Initialise les sommets des faces joints a -1.
void calculer_surfaces(DoubleVect_t &surf) const
Calcule la surface des faces.
DoubleVect_T< _SIZE_ > DoubleVect_t
void reordonner()
Reordonne les faces.
Type_Face type(const Motcle &) const
Renvoie un objet de Type_Face representant le type de nom specifie.
const Domaine_t & domaine() const
IntVect_t & compare(const Faces_32_64 &other_fac, IntVect_t &renum)
Compare l'objet Faces_32_64 passe en parametre avec l'objet Faces_32_64 lui-meme (this).
void completer(int_t face, int_t num_elem)
Complete la face specifie: met a jour ses voisins.
Entree & lit(Entree &)
Lit les specifications d'un objet face a partir d'un flot d'entree.
void calculer_centres_gravite(DoubleTab_t &xv) const
Calcule les centres de gravite de chaque face.
int_t dimensionner(int_t)
(Re-)dimensionne les faces On redimensionne les voisins en consequence.
Sortie & ecrit(Sortie &) const
Ecrit les faces sur un flots de sortie.
IntTab_T< _SIZE_ > IntTab_t
Domaine_32_64< _SIZE_ > Domaine_t
int_t voisin(int_t, int) const
Renvoie le numero du i-ieme voisin de face.
IntVect_T< _SIZE_ > IntVect_t
void initialiser_faces_joint(int_t nb_faces_joints)
Initialise les voisins des faces joints a -1.
DomaineAxi1d_32_64< _SIZE_ > DomaineAxi1d_t
const IntTab_t & les_sommets() const
Renvoie le tableau des sommets de toutes les faces.
void ajouter(const IntTab_t &)
Ajoute des faces.
int_t sommet(int_t, int) const
Renvoie le numero du j-ieme sommet de la i-ieme face.
DoubleTab_T< _SIZE_ > DoubleTab_t
static void Calculer_centres_gravite(DoubleTab_t &xv, Type_Face type_face_, const DoubleTab_t &coord, const IntTab_t &sommet)
int nb_som_faces() const
Renvoie le nombre de sommet par face.
Une chaine de caractere (Nom) en majuscules.
Un tableau d'objets de la classe Motcle.
int search(const Motcle &t) const
classe Objet_U Cette classe est la classe de base des Objets de TRUST
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
static double precision_geom
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static int me()
renvoie mon rang dans le groupe de communication courant.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.
: List_Curseur de reels int/double precision
: Un tableau de listes de type IntList
void set_md_vector(const MD_Vector &) override
int dimension_int(int d) const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
static double produit_scalaire(const Vecteur3 &x, const Vecteur3 &y)
static void produit_vectoriel(const Vecteur3 &x, const Vecteur3 &y, Vecteur3 &resu)