17#include <DomaineAxi1d.h>
18#include <communications.h>
19#include <Linear_algebra_tools_impl.h>
20#include <TRUSTLists.h>
35template <
typename _SIZE_>
39 s <<
"vide_0D" << finl;
42 s << (type(type_face_)) << finl;
60template <
typename _SIZE_>
64 s <<
"vide_0D" << finl;
67 s << (
type(type_face_)) << finl;
69 faces_voisins.ecrit(s);
85template <
typename _SIZE_>
101 faces_voisins.resize(0,2);
118template <
typename _SIZE_>
127 faces_voisins.lit(s);
134 faces_voisins.resize(0,2);
146template <
typename _SIZE_>
149 int_t som = sommet(face,0);
150 for(
int imin=1; imin < nb_som; imin++)
151 som=std::min(som,sommet(face,imin));
163template <
typename _SIZE_>
164bool Faces_32_64<_SIZE_>::same_face(int_t f1,
const Faces_32_64& faces2, int_t f2,
int nb_som)
const
168 for(
int i=0; i<nb_som && ok ; i++)
171 for(
int j=0; j<nb_som && nok ; j++)
173 if(sommet(f1, i) == faces2.
sommet(f2, j))
198template <
typename _SIZE_>
203 les_mots[0]=
"vide_0D";
204 les_mots[1]=
"point_1D";
205 les_mots[2]=
"point_1D_axi";
206 les_mots[3]=
"segment_2D";
207 les_mots[4]=
"triangle_3D";
208 les_mots[5]=
"quadrangle_3D";
209 les_mots[6]=
"segment_2D_axi";
210 les_mots[7]=
"quadrangle_3D_axi";
211 les_mots[8]=
"quadrilatere_2D_axi";
212 les_mots[9]=
"polygone_3d";
214 int rang=les_mots.
search(mot);
218 return Type_Face::vide_0D;
220 return Type_Face::point_1D;
222 return Type_Face::point_1D_axi;
224 return Type_Face::segment_2D;
226 return Type_Face::triangle_3D;
228 return Type_Face::quadrangle_3D;
230 return Type_Face::segment_2D_axi;
232 return Type_Face::quadrangle_3D_axi;
234 return Type_Face::quadrilatere_2D_axi;
236 return Type_Face::polygone_3D;
239 Cerr <<
"In the area number " <<
Process::me() <<
" " << mot <<
" is not a type of face." << finl;
240 Cerr <<
"Check your splitting." << finl;
244 Cerr <<
"Your splitting seems to have been done with a TRUST version 1.5 or earlier. Since" << finl;
245 Cerr <<
"the 1.5.1, the files format of .Zones containing the splitting of your mesh has evolved." << finl;
246 Cerr <<
"You must therefore rebuild the splitting of your mesh with TRUST version 1.5.1 or newer." <<
253 return Type_Face::point_1D;
264template <
typename _SIZE_>
270 case Type_Face::vide_0D :
273 case Type_Face::point_1D :
276 case Type_Face::point_1D_axi :
279 case Type_Face::segment_2D :
282 case Type_Face::segment_2D_axi :
283 mot=
"segment_2D_axi";
285 case Type_Face::triangle_3D :
288 case Type_Face::quadrangle_3D :
291 case Type_Face::quadrangle_3D_axi :
292 mot=
"quadrangle_3D_axi";
294 case Type_Face::quadrilatere_2D_axi :
295 mot=
"quadrilatere_2D_axi";
297 case Type_Face::polygone_3D:
302 Cerr <<
"Error TRUST in Motcle& Faces_32_64<_SIZE_>::type(const Type_Face& typ)" << finl;
316template <
typename _SIZE_>
319 assert(sommets.dimension(1)==tab_sommet.
dimension(1));
320 int_t oldsz=sommets.dimension(0);
323 for(
int_t i=0; i<addsz; i++)
324 for(
int j=0; j<tab_sommet.
dimension(1); j++)
325 sommets(oldsz+i,j)=tab_sommet(i,j);
335template <
typename _SIZE_>
340 if (sommets.size()!=0) sommets.detach_vect();
341 sommets.resize(i,nombre_som_faces);
342 faces_voisins.resize(i, 2);
343 for(
int_t j=oldsz; j<i; j++)
345 for(
int k=0; k<nombre_som_faces; k++)
347 faces_voisins(j,0)=faces_voisins(j,1)=-1;
356template <
typename _SIZE_>
359 for(
int_t i=0; i<nb_faces_joint; i++)
361 faces_voisins(i,0)=faces_voisins(i,1)=-1;
368template <
typename _SIZE_>
371 for(
int_t i=0; i<nb_faces_joint; i++)
381template <
typename _SIZE_>
392template <
typename _SIZE_>
400 case Type_Face::vide_0D :
403 case Type_Face::point_1D :
404 case Type_Face::point_1D_axi :
407 case Type_Face::segment_2D :
410 case Type_Face::segment_2D_axi :
413 case Type_Face::triangle_3D :
416 case Type_Face::quadrangle_3D :
419 case Type_Face::quadrangle_3D_axi :
422 case Type_Face::quadrilatere_2D_axi :
425 case Type_Face::polygone_3D:
430 Cerr <<
"Error TRUST in Faces_32_64<_SIZE_>::typer(const Motcle& typ)" << finl;
441 if (
dimension<std::min(max_dim,nb_som_face))
443 Cerr <<
"You are in dimension " <<
dimension << finl;
444 Cerr <<
"and the mesh contains faces with " << nb_som_face <<
" nodes." << finl;
445 Cerr <<
"and this seems to be a mesh of dimension " << std::min(max_dim,nb_som_face) <<
" ..." << finl;
457template <
typename _SIZE_>
460 if (
voisin(face,0) == -1)
461 voisin(face, 0) = num_elem;
462 else if(
voisin(face,1) == -1)
463 voisin(face, 1) = num_elem;
467 Cerr <<
"Problem for the face number " << face <<
" and the cell " << num_elem << finl;
468 Cerr <<
"Indeed, the face already belongs to the cells " <<
voisin(face, 0) <<
" and " <<
voisin(face, 1) << finl;
469 Cerr <<
"The nodes of this face are:" << finl;
470 for (
int i=0; i<nb_som_face; i++)
471 Cerr <<
"Node " <<
sommet(face,i) << finl;
472 Cerr <<
"Check your mesh. Perhaps some cells " << finl;
473 Cerr <<
"are defined 2 times." << finl;
486template <
typename _SIZE_>
497 for (
int_t i = 0; i < nb_som; i++)
498 rmax = std::max(rmax, std::fabs(dom.
coord(i,0)));
500 for (
int_t i = 0; i < nb_som; i++)
502 const double r = dom.
coord(i,0);
505 Cerr <<
"In axisymmetric, the coordinates of the mesh according to radius" << finl;
506 Cerr <<
"ie along X, cannot be negative beyond tolerance." << finl;
507 Cerr <<
"The revolution axis must be at x=0." << finl;
508 Cerr <<
"we got x = " << r <<
" (tolerance = " << tol <<
")" << finl;
515 case Type_Face::segment_2D :
524 const double dx = x0 - x1;
525 const double dy = y0 - y1;
526 const double L = std::sqrt(dx*dx + dy*dy);
532 if(surfaces(face) == 0.)
534 Cerr <<
"area("<<face<<
")=0 ! Check your mesh." << finl;
542 const double r0 = x0;
543 const double r1 = x1;
544 const double rbar = 0.5 * (r0 + r1);
545 surfaces(face) = 2.0 * M_PI * L * rbar;
550 case Type_Face::quadrilatere_2D_axi :
559 const double dr = r1 - r0;
560 const double dz = z1 - z0;
561 const double L = std::sqrt(dr*dr + dz*dz);
562 const double rbar = 0.5*(r0 + r1);
563 surfaces(face) = 2.0 * M_PI * rbar * L;
568 case Type_Face::segment_2D_axi :
571 double r0,r1,teta0,teta1,d_teta;
576 if ( est_egal(r0,r1) )
580 d_teta = std::fabs(teta1-teta0);
581 if(d_teta > M_PI) d_teta=2.*M_PI-d_teta;
582 surfaces(face)=r0*d_teta;
585 surfaces(face)=std::fabs(r1-r0);
589 case Type_Face::triangle_3D :
593 double delta0, delta1, delta2;
594 double longueur0, longueur1;
603 longueur0=(delta0*delta0+delta1*delta1+delta2*delta2);
613 longueur1=(delta0*delta0+delta1*delta1+delta2*delta2);
614 surfaces(face)=0.5*(sqrt(longueur0*longueur1-prod*prod));
615 if(surfaces(face)==0.)
617 Cerr <<
"area("<<face<<
")=0 ! Check your mesh." << finl;
623 case Type_Face::quadrangle_3D :
635 double x1 = dom.
coord(n0, 0) - dom.
coord(n1, 0);
636 double y1 = dom.
coord(n0, 1) - dom.
coord(n1, 1);
637 double z1 = dom.
coord(n0, 2) - dom.
coord(n1, 2);
639 double x2 = dom.
coord(n3, 0) - dom.
coord(n1, 0);
640 double y2 = dom.
coord(n3, 1) - dom.
coord(n1, 1);
641 double z2 = dom.
coord(n3, 2) - dom.
coord(n1, 2);
643 double nx = (y1*z2 - y2*z1)/2;
644 double ny = (-x1*z2 + x2*z1)/2;
645 double nz = (x1*y2 - x2*y1)/2;
655 nx -= (y1*z2 - y2*z1)/2;
656 ny -= (-x1*z2 + x2*z1)/2;
657 nz -= (x1*y2 - x2*y1)/2;
659 surfaces(face)=sqrt(nx*nx+ny*ny+nz*nz);
663 case Type_Face::quadrangle_3D_axi :
666 double r0,r1,teta0,teta1,teta2,z0,z2,d_teta,delta_r;
671 delta_r = std::fabs(r1 - r0);
672 if ( est_egal(r0,r1) )
678 d_teta = std::fabs(teta1-teta0);
679 if(d_teta > M_PI) d_teta=2.*M_PI-d_teta;
680 surfaces(face)=r0*d_teta*std::fabs(z2-z0);
690 surfaces(face) = delta_r*std::fabs(z2-z0);
694 d_teta=std::fabs(teta2-teta0);
695 if(d_teta > M_PI) d_teta=2.*M_PI-d_teta;
696 surfaces(face) = 0.5*(r0+r1)*d_teta*delta_r;
702 case Type_Face::point_1D:
703 case Type_Face::vide_0D :
706 surfaces(face) = 1.0;
710 case Type_Face::point_1D_axi:
725 double r = sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
726 surfaces(face) = 2.*M_PI*r;
730 case Type_Face::polygone_3D:
736 double n0=0,n1=0,n2=0;
738 while (n >= 0 &&
sommet(face,n)==-1) n--;
739 for (
int i0=0; i0<=n; i0++)
743 if (i0<n) ip1_0=i0+1;
746 n0+=coord(i,1)*coord(ip1,2)-coord(i,2)*coord(ip1,1);
747 n1+=coord(i,2)*coord(ip1,0)-coord(i,0)*coord(ip1,2);
748 n2+=coord(i,0)*coord(ip1,1)-coord(i,1)*coord(ip1,0);
750 surfaces(face)=sqrt(n0*n0+n1*n1+n2*n2)/2.;
756 Cerr <<
"Error TRUST in type of Faces_32_64 not recognized " << finl;
767template <
typename _SIZE_>
777template <
typename _SIZE_>
795 case Type_Face::segment_2D_axi :
800 xv(face, 0)+=coord(
sommet(face ,som), 0);
801 double teta_0=coord(
sommet(face ,0), 1);
802 double teta_1=coord(
sommet(face ,1), 1);
803 double teta_min=std::min(teta_1, teta_0);
804 double teta_max=std::max(teta_1, teta_0);
805 double d_teta=teta_max-teta_min;
806 if( (teta_min==0.) && (d_teta>M_PI) )
811 xv(face, 1)+=(teta_min+teta_max);
816 case Type_Face::quadrangle_3D_axi :
821 xv(face, 0)+=coord(
sommet(face ,som), 0);
823 xv(face, 2)+=coord(
sommet(face ,som), 2);
824 double teta_0=coord(
sommet(face ,0), 1);
825 double teta_1=coord(
sommet(face ,1), 1);
826 double teta_2=coord(
sommet(face ,2), 1);
827 double teta_3=coord(
sommet(face ,3), 1);
828 double teta_min=std::min(teta_1, teta_0);
829 teta_min=std::min(teta_min, teta_2);
830 teta_min=std::min(teta_min, teta_3);
831 double teta_max=std::max(teta_1, teta_0);
832 teta_max=std::max(teta_min, teta_2);
833 teta_max=std::max(teta_min, teta_3);
834 double d_teta=teta_max-teta_min;
835 if( (teta_min==0.) && (d_teta>M_PI) )
837 if(teta_0==0.) teta_0+=2.*M_PI;
838 if(teta_1==0.) teta_1+=2.*M_PI;
839 if(teta_2==0.) teta_2+=2.*M_PI;
840 if(teta_3==0.) teta_3+=2.*M_PI;
843 xv(face, 1)+=(teta_0+teta_1+teta_2+teta_3) ;
850 Cerr <<
"Face type number " << (int)type_face_ <<
" not provided in Faces_32_64<_SIZE_>::calculer_centres_gravite" << finl;
861 while (
sommet(face,nb_som-1)==-1) nb_som--;
864 for(
int k=0; k<dim; k++)
865 for(
int som=0; som < nb_som; som++)
866 xv(face, k)+=coord(
sommet(face ,som), k);
867 for(
int k=0; k<dim; k++)
880template <
typename _SIZE_>
886 case Type_Face::point_1D :
887 case Type_Face::point_1D_axi :
891 case Type_Face::segment_2D :
897 case Type_Face::quadrilatere_2D_axi :
905 for(
int_t face=0; face < nombre_faces; face++)
931 case Type_Face::segment_2D_axi :
936 case Type_Face::triangle_3D :
941 case Type_Face::quadrangle_3D :
948 double xmin, ymin, zmin;
949 double xmax, ymax, zmax;
951 for(
int_t face=0; face < nombre_faces; face++)
963 int_t s0=S[0], s1=S[1], s2=S[2], s3=S[3];
964 double x03=coord(s3,0)-coord(s0,0);
965 double y03=coord(s3,1)-coord(s0,1);
966 double z03=coord(s3,2)-coord(s0,2);
967 double x02=coord(s2,0)-coord(s0,0);
968 double y02=coord(s2,1)-coord(s0,1);
969 double z02=coord(s2,2)-coord(s0,2);
971 double x01=coord(s1,0)-coord(s0,0);
972 double y01=coord(s1,1)-coord(s0,1);
973 double z01=coord(s1,2)-coord(s0,2);
996 Cerr <<
"Permutation of local nodes 2 and 3 on the face " <<face<<finl;
1003 xmin=std::min(dom.
coord(S[0], 0), dom.
coord(S[1], 0));
1004 xmin=std::min(xmin, dom.
coord(S[2], 0));
1005 xmax=std::max(dom.
coord(S[0], 0), dom.
coord(S[1], 0));
1006 xmax=std::max(xmax, dom.
coord(S[2], 0));
1007 ymin=std::min(dom.
coord(S[0], 1), dom.
coord(S[1], 1));
1008 ymin=std::min(ymin, dom.
coord(S[2], 1));
1009 ymax=std::max(dom.
coord(S[0], 1), dom.
coord(S[1], 1));
1010 ymax=std::max(ymax, dom.
coord(S[2], 1));
1011 zmin=std::min(dom.
coord(S[0], 2), dom.
coord(S[1], 2));
1012 zmin=std::min(zmin, dom.
coord(S[2], 2));
1013 zmax=std::max(dom.
coord(S[0], 2), dom.
coord(S[1], 2));
1014 zmax=std::max(zmax, dom.
coord(S[2], 2));
1016 if(est_egal(zmin, zmax))
1019 if ( est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 1),ymin))
1022 if ( !est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 1),ymin))
1025 if ( est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 1),ymin))
1028 if ( !est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 1),ymin))
1031 if(est_egal(ymin, ymax))
1034 if ( est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 2),zmin))
1037 if ( !est_egal(dom.
coord(S[i], 0),xmin) && est_egal(dom.
coord(S[i], 2),zmin))
1040 if ( est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 2),zmin))
1043 if ( !est_egal(dom.
coord(S[i], 0),xmin) && !est_egal(dom.
coord(S[i], 2),zmin))
1046 if(est_egal(xmin, xmax))
1049 if ( est_egal(dom.
coord(S[i], 1),ymin) && est_egal(dom.
coord(S[i], 2),zmin))
1052 if ( !est_egal(dom.
coord(S[i], 1),ymin) && est_egal(dom.
coord(S[i], 2),zmin))
1055 if ( est_egal(dom.
coord(S[i], 1),ymin) && !est_egal(dom.
coord(S[i], 2),zmin))
1058 if ( !est_egal(dom.
coord(S[i], 1),ymin) && !est_egal(dom.
coord(S[i], 2),zmin))
1071 case Type_Face::quadrangle_3D_axi :
1076 case Type_Face::polygone_3D:
1081 Cerr <<
"Error TRUST in type of Faces_32_64 not recognized " << finl;
1093template <
typename _SIZE_>
1098 if ( (
nb_faces() != faces.
nb_faces()) || ( type_face_ != faces.type_face_) )
1109 int_t numerol, face;
1113 for(face=0; face<
nb_faces(); face++)
1115 numerol=this->ppsf(face, nb_som_face);
1116 assert(numerol < std::numeric_limits<int>::max());
1117 numeroli = (int)numerol;
1118 listes[numeroli].add(premier++);
1120 for(face=0; face<
nb_faces(); face++)
1122 numerol=faces.ppsf(face, nb_som_face);
1123 assert(numerol < std::numeric_limits<int>::max());
1124 numeroli = (int)numerol;
1127 while (curseur && ok)
1130 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
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
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),...
int_t nb_faces_tot() const
Returns the total number of Faces i (real and virtual) on the current processor.
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
void typer(const Motcle &)
Sets the type of the faces.
void initialiser_sommets_faces_joint(int_t nb_faces_joints)
Initializes the vertices of joint faces to -1.
void calculer_surfaces(DoubleVect_t &surf) const
Computes the surface area of the faces.
DoubleVect_T< _SIZE_ > DoubleVect_t
void reordonner()
Reorders the faces.
Type_Face type(const Motcle &) const
Returns a Type_Face object representing the type with the specified name.
const Domaine_t & domaine() const
IntVect_t & compare(const Faces_32_64 &other_fac, IntVect_t &renum)
Compares the Faces_32_64 object passed as parameter with this Faces_32_64 object.
void completer(int_t face, int_t num_elem)
Completes the specified face: updates its neighbors.
Entree & lit(Entree &)
Reads the specifications of a face object from an input stream (binary format).
void calculer_centres_gravite(DoubleTab_t &xv) const
Computes the centers of gravity of each face.
int_t dimensionner(int_t)
(Re-)sizes the faces. The neighbors are resized accordingly.
Sortie & ecrit(Sortie &) const
Writes the faces to an output stream (binary format).
IntTab_T< _SIZE_ > IntTab_t
Domaine_32_64< _SIZE_ > Domaine_t
int_t voisin(int_t, int) const
Returns the number of the i-th neighbor of face.
IntVect_T< _SIZE_ > IntVect_t
void initialiser_faces_joint(int_t nb_faces_joints)
Initializes the neighbors of joint faces to -1.
DomaineAxi1d_32_64< _SIZE_ > DomaineAxi1d_t
const IntTab_t & les_sommets() const
Returns the array of vertices of all faces.
void ajouter(const IntTab_t &)
Adds faces.
int_t sommet(int_t, int) const
Returns the number of the j-th vertex of the i-th 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
Returns the number of vertices per face.
A character string (Nom) in uppercase.
An array of Motcle objects.
int search(const Motcle &t) const
Base class for TRUST objects (Objet_U).
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
static double precision_geom
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
: List_Curseur de reels int/double precision
: An array of lists of 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)