16#include <Champ_Generique_Interpolation.h>
17#include <Postraitement.h>
18#include <Discretisation_base.h>
19#include <Domaine_VF.h>
20#include <Synonyme_info.h>
22#include <Domaine_dis_cache.h>
23#include <Champ_Inc_P0_base.h>
24#include <Champ_Fonc_P0_base.h>
31Champ_Generique_Interpolation::Champ_Generique_Interpolation()
66 param.
ajouter(
"methode",&methode_);
68 param.
ajouter(
"domaine",&nom_domaine_lu_);
70 param.
ajouter(
"optimisation_sous_maillage",&optimisation_demande_);
84 methode_ =
"calculer_champ_post";
87 optimisation_sous_maillage_=-1;
88 optimisation_demande_=-1;
99 localisations[0] =
"elem";
100 localisations[1] =
"som";
101 localisations[2] =
"faces";
102 localisations[3] =
"elem_dg";
104 if (localisations.
search(loc) >= 0)
111 Cerr <<
"Error in Champ_Generique_Interpolation::set_localisation\n"
112 <<
" Keyword read : " << loc <<
"\n The localizations allowed are " << localisations << finl;
128 Motcles methodes_interpolation(1);
129 methodes_interpolation[0] =
"calculer_champ_post";
131 if (methodes_interpolation.
search(methode) >= 0)
138 Cerr <<
"Error in Champ_Generique_Interpolation::set_methode\n"
139 <<
" Keyword read : " << methode <<
"\n The methods allowed are " << methodes_interpolation << finl;
154 if (nom_domaine ==
"")
162 if (!sub_type(Domaine, ob))
164 Cerr <<
"Error in Champ_Generique_Interpolation::set_domaine(nom_domaine)\n"
165 <<
" The object " << nom_domaine <<
" is not a domain" << finl;
173 domaine_ = ref_cast(Domaine, ob);
184 OWN_PTR(
Champ_base) espace_stockage_source_tmp;
186 if (localisation_ ==
"")
188 Cerr <<
"Error in Champ_Generique_Interpolation::get_champ()\n"
189 <<
" Localisation has not been initialized" << finl;
194 if (localisation_==
"elem")
198 else if (localisation_!=
"elem_dg")
200 Cerr <<
"Error in Champ_Generique_Interpolation::get_champ\n"
201 <<
"with DG the only possible localisation for Transformation is \"elem\"" << finl;
206 if (methode_ ==
"calculer_champ_post")
212 Cerr <<
"Champ_Generique_Interpolation::get_champ : methode " << methode_ <<
" uncoded" << finl;
216 return espace_stockage_;
222 OWN_PTR(
Champ_base) espace_stockage_source_tmp;
243 Nature_du_champ nature_source = (ncomp==-1)?source.
nature_du_champ():scalaire;
248 espace_stockage = creer_espace_stockage(nature_source,
nb_comp,es_tmp);
249 return espace_stockage;
259 if (optimisation_sous_maillage_==-1)
265 const Champ_base& source = ((optimisation_sous_maillage_==-1)?source_bis.valeur():source0);
266 Nom nom_champ_interpole;
287 Nature_du_champ nature_source = (ncomp==-1)?source.
nature_du_champ():scalaire;
290 if (!espace_stockage_)
291 creer_espace_stockage(nature_source,
nb_comp, espace_stockage_);
292 espace_stockage_->changer_temps(source.
temps());
297 if (optimisation_sous_maillage_==-1)
299 espace_stockage_->valeurs()=0;
302 DoubleTab& val=source_bis->valeurs();
305 for (
int i=0; i<dim0; i++)
311 DoubleTab& espace_valeurs = espace_stockage_->valeurs();
313 if (optimisation_sous_maillage_==1)
315 const DoubleTab& val_temp= source.
valeurs();
317 for (
int i=0; i<dim0; i++)
321 int n=renumerotation_maillage_[i];
323 espace_valeurs(i,j) = val_temp(n,j);
325 else espace_valeurs(i, ncomp) = val_temp[renumerotation_maillage_[i]];
328 return espace_stockage_;
332 if (localisation_ ==
"elem" || localisation_==
"elem_DG")
334 const int nb_elements = domaine.nb_elem();
335 nb_comp = espace_stockage_->nb_comp();
345 CDoubleTabView val_temp_v = val_temp.
view_ro();
346 DoubleTabView espace_valeurs_v = espace_valeurs.
view_wo();
347 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
348 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
349 {imax,
nb_comp}), KOKKOS_LAMBDA(
353 espace_valeurs_v(i, j) = val_temp_v(i, j);
355 end_gpu_timer(__KERNEL_NAME__);
359 for (
int i_val=0; i_val<imax; i_val++)
360 for (
int j_val=0; j_val<
nb_comp; j_val++)
361 espace_valeurs(i_val,j_val) = val_temp(i_val,j_val);
375 CDoubleArrView val_temp_v =
static_cast<const DoubleVect&
>(val_temp).view_ro();
376 DoubleTabView espace_valeurs_v = espace_valeurs.
view_wo();
377 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
378 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
384 espace_valeurs_v(i, j) = val_temp_v(i);
386 end_gpu_timer(__KERNEL_NAME__);
391 for (
int i=0; i<dim0; i++)
394 espace_valeurs(i,j) = val_temp(i);
398 else if (localisation_==
"som")
400 const int nb_sommets = domaine.nb_som();
403 copie_source = source;
408 copie_source->calculer_valeurs_som_post(val_temp,
414 CDoubleTabView val_temp_v = val_temp.
view_ro();
415 DoubleTabView espace_valeurs_v = espace_valeurs.
view_wo();
416 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
417 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
418 {imax,
nb_comp}), KOKKOS_LAMBDA(
422 espace_valeurs_v(i, j) = val_temp_v(i, j);
424 end_gpu_timer(__KERNEL_NAME__);
428 for (
int i_val=0; i_val<imax; i_val++)
429 for (
int j_val=0; j_val<
nb_comp; j_val++)
430 espace_valeurs(i_val,j_val) = val_temp(i_val,j_val);
437 copie_source->calculer_valeurs_som_compo_post(val_temp,
444 CDoubleArrView val_temp_v =
static_cast<const DoubleVect&
>(val_temp).view_ro();
445 DoubleTabView espace_valeurs_v = espace_valeurs.
view_wo();
446 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
447 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
453 espace_valeurs_v(i, j) = val_temp_v(i);
455 end_gpu_timer(__KERNEL_NAME__);
460 for (
int i=0; i<dim0; i++)
463 espace_valeurs(i,j) = val_temp(i);
469 espace_stockage_->affecter(source);
472 if (optimisation_sous_maillage_==-1)
476 DoubleTab& val=espace_valeurs;
478 ArrOfInt& renumerotation_maillage=ref_cast_non_const(ArrOfInt, renumerotation_maillage_);
482 for (
int i=0; (i<dim0)&& ok; i++)
485 v=espace_valeurs(i,0) ;
491 if (std::fabs(iproche-v)>1e-5)
494 Cerr<<nom_champ[0]<<
" optimisation ko "<< finl;
498 renumerotation_maillage[i]=iproche-decal;
510 espace_stockage_test->valeurs()-=espace_stockage_->valeurs();
511 double dmax= mp_max_abs_vect(espace_stockage_test->valeurs());
514 Cerr<<nom_champ[0]<<
" optimisation ko "<< dmax<<finl;
518 Cerr<<nom_champ[0]<<
" optimisation ok "<< dmax<<finl;
523 if (optimisation_demande_==1)
525 Cerr<<nom_champ[0]<<
" optimisation not allowed "<<finl;
534 return espace_stockage_;
541 return champ_a_ecrire->valeurs();
554 if (localisation_==
"elem"||localisation_==
"elem_DG")
555 loc = Entity::ELEMENT;
556 else if (localisation_==
"som")
558 else if (localisation_==
"faces")
562 Cerr <<
"Error of type : localisation should be specified to elem or som or faces for the defined field " <<
nom_post_ << finl;
572 return domaine_.valeur();
602 motcles[0] =
"composantes";
603 motcles[1] =
"synonyms";
604 int rang = motcles.
search(query);
611 int nb_comp = source_compos.size();
650 Nom nom_post_source, nom_champ_source, nom_dom_interp;
652 nom_champ_source = nom[0];
654 nom_post_source = nom_champ_source +
"_" + localisation_ +
"_" +nom_dom_interp;
674 Cerr <<
"Error in Champ_Generique_Interpolation::readOn\n"
675 <<
" You must specify exactly 1 \"Source\"." << finl;
680 if (optimisation_demande_!=1)
681 optimisation_sous_maillage_=0;
682 if ( (nom_domaine_lu_!=
"") && (nom_domaine_lu_!=domaine_calcul.
le_nom()) )
689 if (optimisation_demande_==-1)
690 optimisation_sous_maillage_=0;
701 Cerr <<
"Error in Interpolation definition:" << finl;
702 Cerr <<
"The domain " << domaine_->le_nom() <<
" is not built." << finl;
705 return le_dom_dis.valeur();
717 if (localisation_==
"elem")
719 OWN_PTR(
Champ_base) espace_stockage_source_tmp;
723 else if (localisation_==
"elem_DG")
724 directive =
"champ_elem";
725 else if (localisation_==
"som")
726 directive =
"champ_sommets";
727 else if (localisation_==
"faces")
728 directive =
"champ_face";
731 Cerr<<
"Localisation "<<localisation_<<
" is not recognized by "<<
que_suis_je()<<finl;
748 if (type_discr ==
"VEFPreP1B") type_discr =
"VEF";
751 Nom type =
"NO_FACE_Domaine_";
752 if (localisation_==
"faces")
756 if (domaine_->type_elem()->nb_som_face()<=2 &&
dimension==3)
758 Cerr <<
"'localisation faces' is not possible in 3D on the 2D surface mesh " << domaine_->le_nom() <<
" with the field: " <<
get_property(
"NOM")[0] << finl;
759 Cerr <<
"Please use 'localisation elem' instead." << finl;
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
Base class of generic fields having other generic fields as source. The use of the class methods reli...
virtual int get_nb_sources() const
const Noms get_property(const Motcle &query) const override
Returns the requested property.
void completer(const Postraitement_base &post) override
const Probleme_base & get_ref_pb_base() const override
Returns the problem that carries the target field.
virtual const Champ_Generique_base & get_source(int i) const
void set_param(Param ¶m) const override
const Domaine_dis_base & get_ref_domaine_dis_base() const override
Returns a ref to the discretized domain on which the storage space will be evaluated.
virtual const int nb_comp
A generic field constructed as an interpolation of another generic field (interpolation at vertices o...
void get_copy_domain(Domaine &) const override
Creates a copy of the domain on which the storage space will be evaluated.
const Noms & fixer_noms_compo(const Noms &noms) override
const Motcle get_directive_pour_discr() const override
Returns the directive (champ_elem, champ_sommets, champ_face or pression) to launch the discretizatio...
void completer(const Postraitement_base &post) override
void set_param(Param ¶m) const override
const DoubleTab & get_ref_values() const override
Returns a reference to the array of discrete values if it exists in memory.
const DoubleTab & get_ref_coordinates() const override
Returns a reference to the array of coordinates of the vertices of the mesh supporting the field,...
void reset() override
Restore the initial configuration of the object: localisation not specified, source not specified,...
void discretiser_domaine()
virtual int set_domaine(const Nom &nom_domaine, int exit_on_error=1)
Class initialization: initialization of the interpolation domain. Valid parameters: "" => native doma...
void nommer_source() override
const Domaine_dis_base & get_ref_domaine_dis_base() const override
Returns a ref to the discretized domain on which the storage space will be evaluated.
const Domaine & get_ref_domain() const override
Returns a ref to the domain on which the storage space will be evaluated.
virtual const Champ_base & get_champ_with_calculer_champ_post() const
Interpolation of the source field using Champ_base::calculer_champ_xxx_post.
Entity get_localisation(const int index=-1) const override
Returns the type of geometric entities on which the discrete values are attached (NODE for a P1 field...
void get_copy_values(DoubleTab &) const override
Fills the values array with the discrete values of the field (creates a copy).
virtual int set_methode(const Motcle &methode, int exit_on_error=1)
Class initialization: initialization of the interpolation method. Valid parameters: calculer_champ_po...
const Noms get_property(const Motcle &query) const override
Returns the requested property.
void get_copy_coordinates(DoubleTab &) const override
const Champ_base & get_champ(OWN_PTR(Champ_base)&espace_stockage) const override
Interpolation of the source field based on the requested method, localisation, and domain.
const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const override
virtual int set_localisation(const Motcle &localisation, int exit_on_error=1)
Class initialization: initialization of the requested localisation.
const Noms & fixer_noms_synonyms(const Noms &noms) override
virtual const Noms get_property(const Motcle &query) const
Returns the requested property.
static int composante(const Nom &nom_test, const Nom &nom, const Noms &composantes, const Noms &synonyms)
virtual const Champ_base & get_champ(OWN_PTR(Champ_base) &espace_stockage) const =0
virtual const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const =0
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
virtual const Domaine & get_ref_domain() const
Returns a ref to the domain on which the storage space will be evaluated.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
void calculer_valeurs_elem_post(DoubleTab &valeurs, int nbelem, Nom &nom_post, const Domaine &dom) const
void calculer_valeurs_elem_compo_post(DoubleTab &valeurs, int ncomp, int nbelem, Nom &nom_post, const Domaine &dom) const
double temps() const
Returns the time of the field.
class Discretisation_base This class represents a spatial discretization scheme, which
const DoubleTab_t & coord_sommets() 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.
static Domaine_dis_base & Build_or_get(const Nom &type, const Domaine &dom, const Discretisation_base *disc=nullptr)
Class defining operators and methods for all reading operation in an input flow (file,...
virtual int nb_comp() const
bool is_quadrature() const
virtual Nature_du_champ nature_du_champ() const
bool is_basis_function() const
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
A character string (Nom) in uppercase.
An array of Motcle objects.
int search(const Motcle &t) const
class Nom: a character string for naming TRUST objects.
An array of character strings (VECT(Nom)).
const Interprete & interprete() const
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.
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Helper class to factorize the readOn method of Objet_U classes.
void dictionnaire(const char *option_name, int value)
Add an (option name, integer value) entry to the dictionary attached to a previously registered integ...
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Base class for all post-processing objects.
class Probleme_base It is a Probleme_U that is not a coupling.
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
static double mp_min(double)
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
bool isDataOnDevice() const
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_wo()
_SIZE_ dimension_tot(int) const override
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
_SIZE_ dimension(int d) const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")