16#include <Domaine_Cl_dis_base.h>
17#include <Discretisation_base.h>
18#include <Dirichlet_homogene.h>
19#include <Format_Post_base.h>
20#include <communications.h>
21#include <Equation_base.h>
22#include <Probleme_base.h>
23#include <Schema_Comm.h>
24#include <Domaine_VF.h>
25#include <Champ_base.h>
26#include <TRUSTVects.h>
37 return os <<
le_nom() << finl;
73 DoubleTrav values(1,les_valeurs.
size());
74 int taille=pos.
size();
75 DoubleTrav pos2(1,taille);
76 for (
int dir=0; dir<taille; dir++) pos2(0,dir)=pos(dir);
78 for (
int comp=0; comp<les_valeurs.
size(); comp++)
79 les_valeurs(comp)=values(0,comp);
96 DoubleVect& les_valeurs,
100 Cerr <<
"::valeur_a_elem(...) is not coded " << finl ;
118 const double x = values[compo];
130 Cerr <<
"::valeur_a_elem_compo(...) is not coded " << finl ;
141 Cerr <<
"Warning, try to implement a " <<
que_suis_je() <<
"::valeur_aux_centres_de_gravite() for a faster compute." << finl;
144 DoubleTrav positions(nb_elem,
dimension);
151 if (zvf.
xp().isDataOnDevice())
154 CDoubleTabView xp = zvf.
xp().view_ro();
155 DoubleTabView positions_v = positions.
view_wo();
156 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
157 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
162 positions_v(i, j) = xp(i, j);
164 end_gpu_timer(__KERNEL_NAME__);
168 for (
int i=0; i<nb_elem; i++)
170 positions(i,k) = zvf.
xp(i,k);
178 IntTrav les_polys(nb_elem);
179 IntArrView les_polys_v =
static_cast<ArrOfInt&
>(les_polys).view_wo();
180 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_elem, KOKKOS_LAMBDA(
const int i)
184 end_gpu_timer(__KERNEL_NAME__);
200 DoubleTab& les_valeurs)
const
203 Cerr <<
"::valeur_aux(const DoubleTab& ,DoubleTab& ) is not coded " << finl ;
219 DoubleVect& les_valeurs,
226 DoubleTrav prov(nb_val,
nb_comp());
228 for (
int i=0; i<nb_val; i++)
229 les_valeurs(i)=prov(i,compo);
247 DoubleTab& les_valeurs)
const
250 Cerr <<
"::valeur_aux_elems(...) is not coded " << finl ;
270 DoubleVect& les_valeurs,
274 Cerr <<
"::valeur_aux_elems_compo(...) is not coded " << finl ;
281 DoubleTab& les_valeurs)
284 Cerr <<
"::valeur_aux_elems_smooth(...) is not coded " << finl ;
285 Cerr <<
"The chsom option of probes does apply for the moment only for the field of type P1NC in VEF " << finl ;
292 DoubleVect& les_valeurs,
296 Cerr <<
"::valeur_aux_elems_compo_smooth(...) is not coded " << finl ;
297 Cerr <<
"The chsom option of probes does apply for the moment only for the field of type P1NC in VEF " << finl ;
313 position(i)=dom.
coord(sommet,i);
324 Cerr <<
"::valeur_a_sommet_compo(...) is not coded " << finl ;
335 IntVect les_polys(positions.
dimension(0));
344 DoubleVect& val,
int compo)
const
347 IntVect les_polys(positions.
dimension(0));
400 message =
"The method ";
402 message +=
"::affecter has no sense.\n";
403 message +=
"TRUST has caused an error and will stop.\nUnexpected error during TRUST calculation.";
417 for(
int compo=0; compo<
nb_compo_; compo++)
469 if (isChamp_basis_function)
472 les_valeurs.
resize(nb_elem, ndim);
477 if(nom_dom==nom_dom_inc)
483 DoubleTrav centres_de_gravites(nb_elem,
dimension);
491 DoubleTrav centres_de_gravites(nb_elem,
dimension);
494 for (
int num_elem=0; num_elem<nb_elem; num_elem++)
496 teta = centres_de_gravites(num_elem,1);
497 vR=les_valeurs(num_elem, 0);
498 vT=les_valeurs(num_elem, 1);
499 les_valeurs(num_elem, 0) =vR*cos(teta)-vT*sin(teta);
500 les_valeurs(num_elem, 1) =vR*sin(teta)+vT*cos(teta);
504 nom_post+=
Nom(
"_elem_");
521 ToDo_Kokkos(
"Critical; rewrite as Champ_base::calculer_valeurs_elem_post");
522 DoubleTrav centres_de_gravites(nb_elem,
dimension);
523 les_valeurs.
resize(nb_elem);
524 if(nom_dom==nom_dom_inc)
530 for (
int i=0; i<nb_elem; i++)
532 centres_de_gravites(i,k) = zvf.
xp(i,k);
537 IntVect les_polys(nb_elem);
539 for(
int elem=0; elem<nb_elem; elem++)
541 les_polys(elem)=elem;
551 nom_post+=
Nom(
"_elem_");
556inline void add_sommets_communs(
const Domaine& dom, DoubleTab& les_valeurs, IntTab& compteur)
560 char* theValue = getenv(
"TRUST_POST_SOM_NON_PARA");
561 if (theValue !=
nullptr)
567 const int nb_joints = joints.size();
568 for (
int i_joint = 0; i_joint < nb_joints; i_joint++)
570 const Joint& joint = joints[i_joint];
571 const int PEvoisin = joint.
PEvoisin();
572 const Joint_Items& joint_item = joint.
joint_item(JOINT_ITEM::SOMMET);
573 const ArrOfInt& sommets_communs = joint_item.
items_communs();
576 IntTab envoie_sommets;
577 DoubleTab envoie_valeurs;
578 IntTab envoie_compteur;
579 IntTab recoit_sommets;
580 DoubleTab recoit_valeurs;
581 IntTab recoit_compteur;
584 int size_sommets_communs = sommets_communs.
size_array();
585 for (
int j=0; j<size_sommets_communs; j++)
587 int sommet = sommets_communs[j];
589 if ( compteur(sommet)>0)
597 envoie_sommets.
resize(size);
598 envoie_sommets(size-1) = sommet_voisin;
599 envoie_compteur.
resize(size);
600 envoie_compteur(size-1) = compteur(sommet);
601 envoie_valeurs.
resize(size, nb_compo_);
602 for(
int compo=0; compo<nb_compo_; compo++)
603 envoie_valeurs(size-1,compo) = les_valeurs(sommet,compo);
613 recevoir(recoit_sommets,PEvoisin,
Process::me(),PEvoisin+1000);
614 recevoir(recoit_valeurs,PEvoisin,
Process::me(),PEvoisin+2000);
615 recevoir(recoit_compteur,PEvoisin,
Process::me(),PEvoisin+3000);
620 recevoir(recoit_sommets,PEvoisin,
Process::me(),PEvoisin+1000);
621 recevoir(recoit_valeurs,PEvoisin,
Process::me(),PEvoisin+2000);
622 recevoir(recoit_compteur,PEvoisin,
Process::me(),PEvoisin+3000);
631 int recoit_size = recoit_sommets.
size_array();
632 for (
int i=0; i<recoit_size; i++)
634 int sommet = recoit_sommets(i);
637 if (recoit_compteur(i))
640 if (compteur(sommet)==0)
641 for(
int compo=0; compo<nb_compo_; compo++)
642 les_valeurs(sommet,compo)=0;
644 compteur(sommet)+=recoit_compteur(i);
645 for(
int compo=0; compo<nb_compo_; compo++)
646 les_valeurs(sommet,compo)+=recoit_valeurs(i,compo);
669 if(nom_dom==nom_dom_inc)
677 int old_traitement_symetrie=0;
679 char* theValue = getenv(
"TRUST_POST_SOM_SYMETRIE_ERREUR");
680 if (theValue !=
nullptr)
682 Cerr<<
"results depend on order of bc or faces in bc ..."<<finl;
683 old_traitement_symetrie=1;
686 int impose_cl_diri=1;
689 char* theValue = getenv(
"TRUST_POST_SOM_NO_DIRICHLET");
690 if (theValue !=
nullptr)
702 Cerr<<
"no equation associated to "<<
que_suis_je()<<finl;
715 && (dom==(ref_cast(
Champ_Inc_base, *
this).equation().probleme().domaine() ) ) )
717 IntTab compteur(dom.
nb_som());
722 for (num_cl=0; num_cl<nb_cond_lim; num_cl++)
726 const Frontiere& frontiere=frontiere_dis.
frontiere();
727 const Faces& faces=frontiere.
faces();
735 for(
int num_face=0; num_face<nb_faces ; num_face++)
736 for(
int num_som=0; num_som<nb_som_faces; num_som++)
738 int sommet=faces.
sommet(num_face, num_som);
740 if (sommet < 0)
continue;
742 for(
int compo=0; compo<
nb_compo_; compo++)
744 if (compteur(sommet) == 0)
745 les_valeurs(sommet, compo) = 0;
747 les_valeurs(sommet, compo) += diri.
val_imp(num_face, compo);
750 compteur(sommet) += 1;
755 for(
int num_face=0; num_face<nb_faces ; num_face++)
756 for(
int num_som=0; num_som<nb_som_faces; num_som++)
758 int sommet=faces.
sommet(num_face, num_som);
760 if (sommet < 0)
continue;
762 for(
int compo=0; compo<
nb_compo_; compo++)
764 if (compteur(sommet) == 0)
765 les_valeurs(sommet, compo) = 0;
767 les_valeurs(sommet, compo) += 0;
770 compteur(sommet) += 1;
773 else if((sub_type(
Symetrie, la_cl.valeur()))&&old_traitement_symetrie)
780 for(
int num_face=0; num_face<nb_faces_tot ; num_face++)
783 int sommet0=faces.
sommet(num_face, 0);
786 int sommet=faces.
sommet(num_face, k);
788 if (sommet < 0)
continue;
790 for(
int compo=0; compo<
dimension; compo++)
791 delta(k-1,compo)=coord_sommets(sommet,compo)-coord_sommets(sommet0,compo);
795 normale[0]=-delta(0,1);
796 normale[1]=delta(0,0);
800 normale[0]=delta(0,1)*delta(1,2) - delta(0,2)*delta(1,1);
801 normale[1]=delta(0,2)*delta(1,0) - delta(0,0)*delta(1,2);
802 normale[2]=delta(0,0)*delta(1,1) - delta(0,1)*delta(1,0);
806 Cerr <<
"We do not know treating the dimension : " <<
dimension << finl;
809 normale *= 1. / norme_array(normale);
810 for(
int num_som=0; num_som<nb_som_faces; num_som++)
812 int sommet=faces.
sommet(num_face, num_som);
814 if (sommet < 0)
continue;
820 psc+=normale[k]*les_valeurs(sommet,k);
821 for(
int compo=0; compo<
nb_compo_; compo++)
822 les_valeurs(sommet, compo) -= psc*normale[compo];
830 add_sommets_communs(dom, les_valeurs, compteur);
834 int nb_som_l = dom.
nb_som();
836 for (
int sommet = 0; sommet<nb_som_l; sommet++)
837 for(
int compo=0; compo<
nb_compo_; compo++)
838 if (compteur(sommet) != 0)
839 les_valeurs(sommet,compo) /= compteur(sommet);
848 for(
int sommet=0; sommet<nb_som; sommet++)
850 teta = coord_sommets(sommet,1);
851 vR=les_valeurs(sommet, 0);
852 vT=les_valeurs(sommet, 1);
853 les_valeurs(sommet, 0) =vR*cos(teta)-vT*sin(teta);
854 les_valeurs(sommet, 1) =vR*sin(teta)+vT*cos(teta);
858 nom_post+=
Nom(
"_som_");
875 les_valeurs.
resize(nb_som);
876 if(nom_dom==nom_dom_inc)
888 char* theValue = getenv(
"TRUST_POST_SOM_NO_DIRICHLET");
889 if (theValue !=
nullptr)
905 && (dom==(ref_cast(
Champ_Inc_base, *
this).equation().probleme().domaine() ) ) )
908 IntTab compteur(dom.
nb_som());
913 for (num_cl=0; num_cl<nb_cond_lim; num_cl++)
917 const Frontiere& frontiere=frontiere_dis.
frontiere();
918 const Faces& faces=frontiere.
faces();
925 for(
int num_face=0; num_face<nb_faces ; num_face++)
927 for(
int num_som=0; num_som<nb_som_faces; num_som++)
929 int sommet=faces.
sommet(num_face, num_som);
930 if (compteur(sommet) == 0)
931 les_valeurs(sommet) = 0;
933 les_valeurs(sommet) += diri.
val_imp(num_face,ncomp);
934 compteur(sommet) += 1;
941 for(
int num_face=0; num_face<nb_faces ; num_face++)
943 for(
int num_som=0; num_som<nb_som_faces; num_som++)
945 int sommet=faces.
sommet(num_face, num_som);
947 les_valeurs(sommet) = diri.
val_imp(num_face,ncomp);
948 compteur(sommet) += 1;
955 add_sommets_communs(dom, les_valeurs, compteur);
959 int nb_som_l = dom.
nb_som();
960 assert (nb_som==nb_som_l);
961 for (
int sommet = 0; sommet<nb_som_l; sommet++)
962 if (compteur(sommet) != 0)
963 les_valeurs(sommet) /= compteur(sommet);
967 nom_post+=
Nom(
"_som_");
976 const int nb_compo =
nb_comp();
979 format.
completer_post(dom,is_axi,la_nature,nb_compo,noms_composante,loc_post,le_nom_champ_post);
1013 Cerr <<
"Champ_base::fixer_nb_valeurs_nodales\n ";
1014 Cerr <<
que_suis_je() <<
" does not have nb_valeurs_nodales" << finl;
1023 Cerr <<
"Error in Champ_base::associer_domaine_dis_base\n";
1024 Cerr <<
" (field name : " <<
le_nom() <<
")\n";
1026 Cerr <<
"::associer_domaine_dis_base is not coded\n";
1027 Cerr <<
" or the field does not possess a domaine_dis_base." << finl;
1035 Cerr <<
"Error in Champ_base::domaine_dis_base\n";
1036 Cerr <<
" (field name : " <<
le_nom() <<
")\n";
1038 Cerr <<
"::domaine_dis_base is not coded\n";
1039 Cerr <<
" or the field does not possess a domaine_dis_base." << finl;
1067 Cerr <<
que_suis_je() <<
"did not overloaded Champ_base::trace" << finl;
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
virtual DoubleVect & valeur_aux_elems_compo_smooth(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp)
void calculer_valeurs_som_compo_post(DoubleTab &valeurs, int ncomp, int nbsom, Nom &nom_post, const Domaine &dom, int appliquer_cl=0) const
virtual double valeur_a_sommet_compo(int, int, int) const
Returns the compo-th coordinate of the values at the element le_poly at the vertex sommet.
virtual DoubleVect & valeur_a(const DoubleVect &position, DoubleVect &valeurs) const
Computes the "values" of the field at the point with coordinates "pos".
virtual DoubleTab & valeur_aux_elems_smooth(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs)
virtual DoubleVect & valeur_a_sommet(int, const Domaine &, DoubleVect &) const
Time update.
void calculer_valeurs_elem_post(DoubleTab &valeurs, int nbelem, Nom &nom_post, const Domaine &dom) const
virtual int completer_post_champ(const Domaine &dom, const int axi, const Nom &loc_post, const Nom &le_nom_champ_post, Format_Post_base &format) const
virtual int fixer_nb_valeurs_nodales(int n)
virtual void completer(const Domaine_Cl_dis_base &zcl)
Champ_base()
Default constructor of a Champ_base.
Champ_base & affecter(const Champ_base &)
Assign a field to another.
virtual const Domaine_dis_base & domaine_dis_base() const
virtual DoubleTab & eval_elem(DoubleTab &valeurs) const
virtual DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const
Causes an error! Must be overridden by derived classes.
virtual double changer_temps(const double t)
Sets the time at which the field is defined.
virtual DoubleTab valeur_aux_bords() const
Returns the field value at the boundary faces.
void calculer_valeurs_elem_compo_post(DoubleTab &valeurs, int ncomp, int nbelem, Nom &nom_post, const Domaine &dom) const
virtual Champ_base & affecter_(const Champ_base &)=0
double temps() const
Returns the time of the field.
virtual void associer_domaine_dis_base(const Domaine_dis_base &)
virtual DoubleVect & valeur_aux_sommets_compo(const Domaine &, DoubleVect &, int) const
Returns the compo-th value at the vertices of dom.
virtual DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &valeurs) const
Causes an error! Must be overridden by derived classes.
virtual DoubleTab & valeur_aux_faces(DoubleTab &result) const
Returns the field value at the faces.
virtual DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const
Causes an error! Must be overridden by derived classes.
void calculer_valeurs_som_post(DoubleTab &valeurs, int nbsom, Nom &nom_post, const Domaine &dom) const
virtual DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &valeurs, int le_poly) const
Causes an error! Must be overridden by derived classes.
virtual double valeur_a_compo(const DoubleVect &position, int ncomp) const
Computes the point value of the component "compo" of the field at the point with coordinates pos.
virtual double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const
Causes an error! Must be overridden by derived classes.
virtual void abortTimeStep()
void corriger_unite_nom_compo()
This method will set the units and the name of components, it is not actually const!...
virtual DoubleTab & valeur_aux_sommets(const Domaine &, DoubleTab &) const
Returns the values at the vertices of the Domain dom.
virtual DoubleVect & valeur_aux_compo(const DoubleTab &positions, DoubleVect &valeurs, int ncomp) const
Same as valeur_aux(const DoubleTab &, DoubleTab &), but computes only the component compo of the fiel...
virtual void mettre_a_jour(double)
Update of the base class Champ_base: does nothing!
virtual DoubleTab & valeur_aux_centres_de_gravite(const Domaine &, DoubleTab &valeurs) const
This method, generic but slow (calculation of gravity centers, filling les_poly, use of shape functio...
virtual DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const
Computes the trace of a field on a boundary at time tps.
class Cond_lim Generic class used to represent any class
Classe Dirichlet_homogene This class is the base class of the hierarchy of homogeneous Dirichlet-type...
double val_imp(int i) const
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
virtual double val_imp(int i) const
Returns the imposed value on the i-th component of the field at the boundary at the default time of c...
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.
void calculer_centres_gravite(DoubleTab_t &xp) const
Calculates the centers of gravity of the domain elements.
const DoubleTab_t & coord_sommets() const
double coord(int_t i, int j) const
int_t nb_som() const
Returns the number of vertices of the domain.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
int nb_cond_lim() const
Returns the number of boundary conditions.
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
double xp(int num_elem, int k) const
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
class Equation_base The role of an equation is the calculation of one or more fields....
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual const Champ_Inc_base & inconnue() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
int_t nb_faces_tot() const
Returns the total number of Faces i (real and virtual) on the current processor.
int_t sommet(int_t, int) const
Returns the number of the j-th vertex of the i-th face.
int nb_som_faces() const
Returns the number of vertices per face.
const Nom & nom_compo() const
Returns the name of a scalar field.
const Nom & le_nom() const override
Returns the name of the field.
void nommer(const Nom &) override
Gives a name to the field.
virtual const Nom & fixer_unite(const Nom &)
Specifies the unit of a scalar field or whose all components have the same unit.
virtual Nature_du_champ fixer_nature_du_champ(Nature_du_champ nat)
Sets the nature of a field: scalar, multiscalar, vectorial.
virtual int nb_comp() const
virtual const Noms & fixer_noms_compo(const Noms &)
Sets the names of the field components.
bool is_vectorial() const
virtual Nature_du_champ nature_du_champ() const
bool is_basis_function() const
const Noms & noms_compo() const
Returns the array of names of the field components.
Base class for post-processing output formats for fields (lata, med, cgns, lml, single_lata).
virtual int completer_post(const Domaine &dom, const int axi, const Nature_du_champ &nature, const int nb_compo, const Noms &noms_compo, const Motcle &loc_post, const Nom &le_nom_champ_post)
const Faces_t & faces() const
class Frontiere_dis_base Class representing a discretized boundary.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
const Joint_Items_t & joint_item(JOINT_ITEM type) const
Returns the joint information for the requested type (read-only).
const ArrOfInt_t & items_communs() const
const IntTab_t & renum_items_communs() const
Returns the renum_items_communs_ array (read-only). See renum_items_communs_.
int mon_equation_non_nul() const
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
class Nom: a character string for naming TRUST objects.
const Nom & le_nom() const override
Returns *this.
An array of character strings (VECT(Nom)).
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.
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.
Symetrie On symmetry faces, the following properties hold:
_SIZE_ size_array() const
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_wo()
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension_tot(int) const override
_SIZE_ dimension(int d) const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")