16#include <Domaine_VDF.h>
17#include <Domaine_Cl_VDF.h>
22#include <Periodique.h>
23#include <Dirichlet_entree_fluide_leaves.h>
24#include <Neumann_sortie_libre.h>
25#include <EcrFicCollecte.h>
36 os <<
"orientation_" << orientation_ << finl;
37 os <<
"nb_faces_X_" << nb_faces_X_ << finl;
38 os <<
"nb_faces_Y_" << nb_faces_Y_ << finl;
39 os <<
"nb_faces_Z_" << nb_faces_Z_ << finl;
40 os <<
"nb_aretes_" << nb_aretes_ << finl;
41 os <<
"nb_aretes_joint_" << nb_aretes_joint_ << finl;
42 os <<
"nb_aretes_coin_" << nb_aretes_coin_ << finl;
43 os <<
"nb_aretes_bord_" << nb_aretes_bord_ << finl;
44 os <<
"nb_aretes_mixtes_" << nb_aretes_mixtes_ << finl;
45 os <<
"nb_aretes_internes_" << nb_aretes_internes_ << finl;
46 Qdm_.ecrit(os <<
"Qdm : ");
47 os << h_x_ <<
" " << h_y_ <<
" " << h_z_ << finl;
59 is >> nb_aretes_joint_;
60 is >> nb_aretes_coin_;
61 is >> nb_aretes_bord_;
62 is >> nb_aretes_mixtes_;
63 is >> nb_aretes_internes_;
65 is >> h_x_ >> h_y_ >> h_z_;
103 for (
int i = 0; i < nb_faces_front; i++)
109 for (
int i=nb_faces_front; i <
nb_faces; i++)
111 const int ori = orientation_[i];
112 sort_key(i, 0) = ori *
nb_faces + i;
127 IntVect old_orien(orientation_);
128 for (
int i=nb_faces_front; i <
nb_faces; i++)
130 const int idx = sort_key(i, 1);
131 orientation_[i] = old_orien[idx];
148 Domaine& domaine_geom=
domaine();
152 const Elem_geom_base& elem_geom = domaine_geom.type_elem().valeur();
156 if (!sub_type(Rectangle,elem_geom))
158 Cerr <<
" The geometric element type " << elem_geom.
que_suis_je() <<
" is incorrect" << finl;
159 Cerr <<
" Only the Rectangle and Rectangle_Axi types are compatible with VDF discretization in dimension 2" << finl;
165 if (!sub_type(Hexaedre,elem_geom))
167 Cerr <<
" The geometric element type " << elem_geom.
que_suis_je() <<
" is incorrect" << finl;
168 Cerr <<
" Only the Hexaedre and Hexaedre_Axi types are compatible with VDF discretization in dimension 3" << finl;
177 orientation_.echange_espace_virtuel();
178 orientation_.set_md_vector(md_nul);
185 for (
int i_face = 0; i_face < nbr_faces_tot; i_face++)
189 const int ori = orientation_[i_face];
190 const double x_face =
xv(i_face, ori);
196 delta = x_face -
xp(elem0, ori);
201 delta =
xp(elem1, ori) - x_face;
215 remplir_face_normales();
216 Cerr <<
"The Domaine_VDF object has been filled successfully " << finl;
220void Domaine_VDF::remplir_face_normales()
241 Cerr <<
"Computing staggered volumes" << finl;
248 for (
int num_face = 0; num_face<nbf; num_face++)
250 const double f = (num_face < nb_faces_front) ? 2. : 1.;
251 for (
int dir = 0; dir < 2; dir ++)
256 if ((
axi) && (orientation_[num_face]==0))
258 else if ((
bidim_axi) && (orientation_[num_face]==0))
271static inline int face_vois(
const Domaine_VDF& zvdf,
const Domaine& domaine,
int face,
int i)
276 face=domaine.face_bords_interne_conjuguee(face);
289void Domaine_VDF::genere_aretes()
291 Cerr <<
"Generating edges" << finl;
298 int nb_aretes_plus=-1;
300 nb_aretes_plus = mon_dom.
nb_som();
302 nb_aretes_plus = mon_dom.
nb_som()*3;
303 Cerr <<
"Creating edges " << finl;
304 Aretes les_aretes(nb_aretes_plus);
307 int el1, el2, el3, el4;
308 int face12, face13, face34, face24;
313 IntVect gauche(nb_dir);
320 IntVect droite(nb_dir);
327 IntVect haut(nb_dir);
351 ArrOfDouble P1(3), P2(3);
360 P1[i] =
xv(face, i) + (ori == i ? eps : 0);
361 P2[i] =
xv(face, i) - (ori == i ? eps : 0);
365 if (elem1 >= 0 && elem2 >= 0 && elem1 != elem2)
368 est_une_plaque(face) = 1;
372 est_une_plaque.echange_espace_virtuel();
374 for(
int dir=0; dir<nb_dir; dir++)
375 for (el1=0; el1<nb_poly_tot; el1++)
381 el2=face_vois(*
this, mon_dom, face12, 1);
388 el3=face_vois(*
this, mon_dom, face13, 1);
395 if( (el2>-1) && (el3>-1))
396 el4=face_vois(*
this, mon_dom, face24, 1);
398 el4=face_vois(*
this, mon_dom, face24, 1);
400 el4=face_vois(*
this, mon_dom, face34, 1);
404 if ( (el2==-1) && (el4>=0) )
406 if ( (el3==-1) && (el4>=0) )
410 if (el2 > -1 && el3 > -1 && el4 > -1)
411 les_aretes.affecter(nb_aretes_, dir, interne, nb_f, face13, face24, face12, face34, est_une_plaque);
412 else if ( (el3 > -1 && el4 > -1) ||
413 (el2 > -1 && el4 > -1) ||
414 (el2 > -1 && el3 > -1) )
415 les_aretes.affecter(nb_aretes_, dir, mixte, nb_f, face13, face24, face12, face34, est_une_plaque);
417 les_aretes.affecter(nb_aretes_, dir, bord, nb_f, face13, face24, face12, 1, est_une_plaque);
419 les_aretes.affecter(nb_aretes_, dir, bord, nb_f, face12, face34, face13, 1, est_une_plaque);
421 les_aretes.affecter(nb_aretes_, dir, coin, nb_f, face13, face24, face12, face34, est_une_plaque);
427 el3 = face_vois(*
this, mon_dom, face13, 0);
434 el4 = face_vois(*
this, mon_dom, face24, 0);
436 les_aretes.affecter(nb_aretes_, dir, bord, nb_f, face13, face24, face12, -1, est_une_plaque);
440 if (face_vois(*
this, mon_dom, face34, 0) == -1)
441 les_aretes.affecter(nb_aretes_, dir, mixte, nb_f, face13, face24, face34, face12, est_une_plaque);
445 les_aretes.affecter(nb_aretes_, dir, coin, nb_f, face13, -1, -1, face12, est_une_plaque);
451 el3 = face_vois(*
this, mon_dom, face13, 0);
456 el2 = face_vois(*
this, mon_dom, face12, 1);
460 el4 = face_vois(*
this, mon_dom, face24, 0);
462 les_aretes.affecter(nb_aretes_, dir, bord, nb_f, face13, face24, face12, -1, est_une_plaque);
465 les_aretes.affecter(nb_aretes_, dir, coin, nb_f, -1, face12, -1, face13, est_une_plaque);
471 el2 = face_vois(*
this, mon_dom, face12, 0);
473 el3 = face_vois(*
this, mon_dom, face13, 0);
474 if ((el2 < 0) && (el3 < 0))
476 les_aretes.affecter(nb_aretes_, dir, coin, nb_f, face13, -1, face12, -1, est_une_plaque);
481 les_aretes.dimensionner(nb_aretes_);
483 les_aretes.trier(nb_aretes_coin_,
486 nb_aretes_internes_);
487#ifdef SORT_POUR_DEBOG
489 les_aretes.trier_pour_debog(nb_aretes_coin_,
492 nb_aretes_internes_,
xv());
495 assert(nb_aretes_==nb_aretes_coin_+nb_aretes_bord_+nb_aretes_mixtes_
496 +nb_aretes_internes_+nb_aretes_joint_);
497 Qdm_.ref(les_aretes.faces());
520void Domaine_VDF::calcul_h()
522 Domaine& domaine_geom=
domaine();
524 const double deux_pi = M_PI * 2.0;
527 for (
int e = 0; e < domaine_geom.
nb_elem(); e++)
532 h_x_ = std::min(h_x_,
xv_(numfa[D], 0) -
xv_(numfa[0], 0));
536 double d_teta =
xv_(numfa[D + 1], 1) -
xv_(numfa[1], 1);
537 if (d_teta < 0) d_teta += deux_pi;
538 hy_loc = d_teta *
xv_(numfa[1], 0);
540 else hy_loc =
xv_(numfa[D + 1], 1) -
xv_(numfa[1], 1);
541 h_y_ = std::min(h_y_, hy_loc);
542 if (
dimension == 3) h_z_ = std::min(h_z_,
xv_(numfa[5], 2) -
xv_(numfa[2], 2));
555 int nb_cond_lim=conds_lim.size();
557 aretes_coin_traitees = -1;
559 for (
int num_cond_lim=0; num_cond_lim<nb_cond_lim; num_cond_lim++)
573 int fac1,fac2,sign,num_face,elem1,n_type;
574 for (
int n_arete=ndeb_arete; n_arete<ndeb_arete+
nb_aretes_bord(); n_arete++)
582 fac1 = Qdm_(n_arete,0);
583 fac2 = Qdm_(n_arete,1);
584 fac3 = Qdm_(n_arete,2);
585 sign = Qdm_(n_arete,3);
589 int nfin = ndeb + la_frontiere_dis.
nb_faces();
590 if ( ( ( ndeb <= fac1) && (fac1 < nfin) ) ||
591 ( ( ndeb <= fac2) && (fac2 < nfin) )
602 Qdm_(n_arete,3) = fac3;
612 Cerr <<
"Modifying Qdm for corner edges num_cond_lim=" << num_cond_lim << finl;
615 for (
int n_arete=ndeb_arete_coin; n_arete<ndeb_arete_coin+
nb_aretes_coin(); n_arete++)
617 if (aretes_coin_traitees[n_arete] != 1)
619 fac1 = Qdm_(n_arete,0);
620 fac2 = Qdm_(n_arete,1);
621 fac3 = Qdm_(n_arete,2);
622 fac4 = Qdm_(n_arete,3);
653 int nfin = ndeb + la_frontiere_dis.
nb_faces();
654 int elem, fac,dim0,dim1,indic_f0=-100,indic_f1=-100;
657 dim1 = orientation_[f(1)];
658 dim0 = orientation_[f(0)];
660 for (
int j=0; j<2; j++)
661 for (
int k=0; k<2; k++)
670 if ((f(0) >= ndeb)&&(f(0) < nfin))
672 Qdm_(n_arete,2)=f(0);
673 Qdm_(n_arete,indic_f0)=f(1);
677 Qdm_(n_arete,1-indic_f0)=fac;
679 Qdm_(n_arete,3)=1-2*indic_f1;
682 aretes_coin_traitees[n_arete] = 1;
686 if ((f(1) >= ndeb)&&(f(1) < nfin))
688 Qdm_(n_arete,2)=f(1);
689 Qdm_(n_arete,indic_f1)=f(0);
693 Qdm_(n_arete,1-indic_f1)=fac;
695 Qdm_(n_arete,3)=1-2*indic_f0;
698 aretes_coin_traitees[n_arete] = 1;
710 if ((f(0) >= ndeb)&&(f(0) < nfin))
712 Qdm_(n_arete,2+indic_f1)=f(0);
713 Qdm_(n_arete,indic_f0)=f(1);
717 Qdm_(n_arete,1-indic_f0)=fac;
721 Qdm_(n_arete,3-indic_f1)=fac;
724 aretes_coin_traitees[n_arete] = 1;
728 if ((f(1) >= ndeb)&&(f(1) < nfin))
730 Qdm_(n_arete,2+indic_f0)=f(1);
731 Qdm_(n_arete,indic_f1)=f(0);
735 Qdm_(n_arete,1-indic_f1)=fac;
739 Qdm_(n_arete,3-indic_f0)=fac;
742 aretes_coin_traitees[n_arete] = 1;
749 Cerr <<
"Warning: cases involving other corner edge types " << finl;
750 Cerr <<
"than perio-perio or perio-wall are not handled!!" << finl;
763 int fac1,fac2,n_type;
765 Cerr <<
"Modifying Qdm for corner edges touching a wall num_cond_lim=" << num_cond_lim << finl;
768 for (
int n_arete=ndeb_arete_coin; n_arete<ndeb_arete_coin+
nb_aretes_coin(); n_arete++)
770 if (aretes_coin_traitees[n_arete] != 1)
772 fac1 = Qdm_(n_arete,0);
773 fac2 = Qdm_(n_arete,1);
774 fac3 = Qdm_(n_arete,2);
775 fac4 = Qdm_(n_arete,3);
806 int nfin = ndeb + la_frontiere_dis.
nb_faces();
807 int indic_f0=-100,indic_f1=-100;
811 for (
int j=0; j<2; j++)
812 for (
int k=0; k<2; k++)
821 if ((f(0) >= ndeb)&&(f(0) < nfin))
823 Qdm_(n_arete,0)=f(1);
824 Qdm_(n_arete,1)=f(1);
825 Qdm_(n_arete,2)=f(0);
826 Qdm_(n_arete,3)=1-2*indic_f1;
827 aretes_coin_traitees[n_arete] = 1;
831 if ((f(1) >= ndeb)&&(f(1) < nfin))
833 Qdm_(n_arete,0)=f(0);
834 Qdm_(n_arete,1)=f(0);
835 Qdm_(n_arete,2)=f(1);
836 Qdm_(n_arete,3)=1-2*indic_f0;
837 aretes_coin_traitees[n_arete] = 1;
872 Cerr <<
"Domaine_VDF::creer_elements_fictifs() called" << finl;
890 for (face=ndeb; face<nfin; face++)
908 for (
int n_bord=0; n_bord<les_bords_.size(); n_bord++)
911 if (fr_vf.
le_nom() == nom_bord)
915 for (
int face=ndeb; face<ndeb+fr_vf.
nb_faces(); face++)
922 for (
int n_bord=0; n_bord<les_bords_.size(); n_bord++)
925 if (fr_vf.
le_nom() == nom_bord)
929 for (
int face=ndeb; face<ndeb+fr_vf.
nb_faces(); face++)
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
class Cond_lim Generic class used to represent any class
class Conds_lim This class represents a vector of boundary conditions.
Dirichlet_entree_fluide This class represents a boundary condition imposing a quantity.
int_t nb_elem_tot() const
SmallArrOfTID_t & chercher_elements(const DoubleTab &pos, SmallArrOfTID_t &elem, int reel=0) const
Searches for the elements containing the points whose coordinates are specified.
virtual void creer_tableau_elements(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates a parallel array of values at elements.
int_t nb_faces_frontiere() const
Returns the number of boundary faces of the domain (sum of boundaries, connections,...
int nb_faces_elem(int=0) const
Returns the number of faces of type i of the geometric elements that make up the domain.
int_t nb_som() const
Returns the number of vertices of the domain.
int type_arete_bord(int num_arete) const
const int & type_arete_coin(int num_arete) const
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
int nb_aretes_coin() const
void compute_sort_key(Faces &, IntTab &sort_key) override
Override. Compute sorting key so that internal faces are sorted by their orientation first (X,...
double dist_norm_bord_axi(int num_face) const
Returns the normal distance for a boundary face (cylindrical coordinates).
IntVect & orientation()
inline double Domaine_VDF::porosite_face(int i) const {
Faces * creer_faces() override
Returns a newly allocated Faces_VDF object.
void prepare_elem_non_std(Faces &) override
double dim_elem(int, int) const
std::map< std::array< int, 2 >, int > virt_e_map
void creer_elements_fictifs(const Domaine_Cl_dis_base &) override
Fills the face_voisins_fictifs_ array. Does NOT create fictitious elements.
int premiere_arete_bord() const
void discretiser() override
Calls Domaine_VF::discretiser(), computes element gravity centers,.
int premiere_arete_coin() const
int nb_aretes_bord() const
void modifier_pour_Cl(const Conds_lim &cl) override
void init_virt_e_map() const
void renumber_faces(Faces &les_faces, IntTab &sort_key) override
Override to also renumber orientation_ member.
void calculer_volumes_entrelaces()
Fills the staggered volumes (volumes entrelaces).
double dist_norm_bord(int num_face) const override
Returns the normal distance for a boundary face (Cartesian coordinates).
virtual const DoubleVect & face_surfaces() const
int nb_faces() const
Returns the total number of faces.
DoubleVect volumes_entrelaces_
double volume_entrelace_axi(double r_face, double r_elem, double axis_length) const
int nb_faces_tot() const
Returns the total number of faces.
void creer_tableau_faces(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
void discretiser() override
Generates the faces and builds the boundaries.
void modifier_pour_Cl(const Conds_lim &) override
IntTab & elem_faces()
Returns the element/face connectivity array.
virtual void renumber_faces(Faces &les_faces, IntTab &sort_key)
Re-index faces according to the new order given by 'sort_key'.
IntTab face_voisins_fictifs_
int premiere_face_int() const
A face is internal if and only if it separates two elements.
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
DoubleTab volumes_entrelaces_dir_
int nb_faces_bord() const
Returns the number of faces on which boundary conditions are applied:
const Front_VF & front_VF(int i) const
IntTab & face_voisins() override
Returns the face-element connectivity array; see above.
void marquer_faces_double_contrib(const Conds_lim &)
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
void calculer_orientation(IntVect &, int &, int &, int &)
int num_premiere_face() const
const Nom & le_nom() const override
Returns the name of the geometric boundary.
: This class is an OWN_PTR but the pointed object is shared among multiple
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
class Nom: a character string for naming TRUST objects.
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.
static double precision_geom
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
class Periodique This class represents a periodic boundary condition.
static double mp_min(double)
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.
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")