16#include <Moyenne_volumique.h>
17#include <communications.h>
18#include <Equation_base.h>
19#include <Postraitement.h>
20#include <Octree_Double.h>
21#include <Domaine_VF.h>
54 param.dictionnaire(
"BOITE",
BOITE);
55 param.dictionnaire(
"CHAPEAU",
CHAPEAU);
57 param.dictionnaire(
"QUADRA",
QUADRA);
58 param.dictionnaire(
"PARSER",
PARSER);
60 param.ajouter(
"omega", &
l_);
62 param.lire_avec_accolades_depuis(is);
77 Cerr <<
"Error : OMEGA must be set to >= 0" << finl;
86 Cerr <<
"Error : EXPRESSION must be specified for the parser." << finl;
92 std::transform(s.begin(), s.end(), s.begin(), ::toupper);
105 Cerr <<
"l_ = " <<
l_ <<
"box_size_ = " <<
box_size_ << finl;
114inline double fonction_quadra(
double x,
double l_)
116 assert(std::fabs(x) <= l_);
117 double ax = 1. - std::fabs(x) / l_;
119 if (std::fabs(x) < (l_/3.))
121 double bx = -3. / l_ * std::fabs(x) + 1.;
124 return ax * (27. / (16. * l_));
142 for (
int i = 0; i < n; i++)
144 for (
int j = 0; j < dim; j++)
145 parser_.setVar(j, coords(i,j));
154 facteur = 1. / (
l_ *
l_ * 4.);
156 facteur = 1. / (
l_ *
l_ *
l_ * 8.);
158 for (
int i = 0; i < n; i++)
160 const double x = coords(i,0);
161 const double y = coords(i,1);
162 const double z = (dim==3) ? coords(i,2) : 0.;
164 if (x >
l_ || x < -
l_
166 || z >
l_ || z < -
l_)
175 const double L3D = L2D*
l_*
l_;
180 facteur = 1. / (L2D *
l_);
182 for (
int i = 0; i < nbis; i++)
184 const double x = coords(i, 0);
185 const double y = coords(i, 1);
186 const double z = (dim == 3) ? coords(i, 2) : 0.;
188 const double ax = std::fabs(x);
189 const double ay = std::fabs(y);
190 const double az = std::fabs(z);
191 if (ax <=
l_ && ay <=
l_ && az <=
l_)
192 resu = (
l_-ax) * (
l_-ay) * (
l_-az) * facteur;
199 double facteur1 = - 0.5 / (
l_ *
l_);
200 double facteur2 = 1. / (
l_ * sqrt(2 * M_PI));
202 facteur2 = facteur2 * facteur2;
204 facteur2 = facteur2 * facteur2 * facteur2;
205 for (
int i = 0; i < n; i++)
207 const double x = coords(i, 0);
208 const double y = coords(i, 1);
209 const double z = (dim == 3) ? coords(i, 2) : 0.;
210 const double k = (x*x + y*y + z*z) * facteur1;
211 result[i] = exp(k) * facteur2;
217 for (
int i = 0; i < n; i++)
219 const double x = coords(i, 0);
220 const double y = coords(i, 1);
221 const double z = (dim == 3) ? coords(i, 2) : 0.;
223 if (std::fabs(x) <
l_ && std::fabs(y) <
l_ && std::fabs(z) <
l_)
225 resu = fonction_quadra(x,
l_) * fonction_quadra(y,
l_);
227 resu *= fonction_quadra(z,
l_);
235 Cerr <<
"Error in Moyenne_volumique::eval() : filter function is not initialized." << finl;
250 const Nom& nom_champ,
256 Motcle mc_nom_champ(nom_champ);
257 for (
int i_post = 0; i_post < nb_post; i_post++)
263 const int nstat = stats.size();
264 for (
int i_stat = 0; i_stat < nstat; i_stat++)
268 if (tmp == mc_nom_champ)
297 const Nom& nom_pb,
const Nom& nom_dom,
298 const DoubleTab& coords,
301 const Motcle& localisation)
303 const Domaine& dom_post = ref_cast(Domaine,
objet(nom_dom));
304 const int nb_champs = noms_champs.size();
313 int nb_compo_tot = 0;
314 for (i_champ = 0; i_champ < nb_champs; i_champ++)
316 get_champ(nom_pb, noms_champs[i_champ], ref_champ);
321 ref_domaine_vf = zvf;
325 if (& (ref_domaine_vf.valeur()) != & zvf)
327 Cerr <<
"Error in Moyenne_volumique::traiter_champs all the fields must be discretized on the same Domaine." << finl;
332 const int nb_compo = champ.nb_comp();
333 nb_compo_tot += nb_compo;
336 const Domaine_VF& domaine_source = ref_domaine_vf.valeur();
340 DoubleTab valeurs_src;
341 const int nb_lignes = domaine_source.
nb_elem();
342 valeurs_src.
resize(nb_lignes, nb_compo_tot + 1);
346 IntVect liste_elems(nb_lignes);
347 for (
int i = 0; i < nb_lignes; i++)
349 const DoubleTab& xp = domaine_source.
xp();
350 for (i_champ = 0; i_champ < nb_champs; i_champ++)
352 get_champ(nom_pb, noms_champs[i_champ], ref_champ);
354 const int nb_compo = champ.
nb_comp();
356 tmp_val.
resize(nb_lignes, nb_compo);
357 champ.valeur_aux_elems(xp, liste_elems, tmp_val);
359 for (
int i = 0; i < nb_lignes; i++)
360 for (
int j = 0; j < nb_compo; j++)
361 valeurs_src(i, count+j) = tmp_val(i, j);
364 Cout <<
"Field name = " << ref_champ->le_nom()
365 <<
" Field type = " << ref_champ->que_suis_je() << finl;
369 for (
int i = 0; i < nb_lignes; i++)
370 valeurs_src(i, count) = 1.;
373 const int nb_coords = coords.
dimension(0);
374 DoubleTab resu(nb_coords, nb_compo_tot + 1);
388 for (i_champ = 0; i_champ < nb_champs; i_champ++)
390 get_champ(nom_pb, noms_champs[i_champ], ref_champ);
392 const int nb_compo = champ.
nb_comp();
393 DoubleTab extrait(nb_coords, nb_compo);
394 for (
int i = 0; i < nb_coords; i++)
395 for (
int j = 0; j < nb_compo; j++)
396 extrait(i, j) = resu(i, count + j);
398 Cout <<
"Post writting " << champ.le_nom() << finl;
399 Nom nature(
"scalar");
400 if (champ.nature_du_champ()==vectoriel) nature=
"vector";
405 noms_champs[i_champ], nom_dom, localisation,nature, extrait);
410 const int nb_compo = 1;
411 DoubleTab extrait(nb_coords, nb_compo);
412 for (
int i = 0; i < nb_coords; i++)
413 for (
int j = 0; j < nb_compo; j++)
414 extrait(i, j) = resu(i, count + j);
420 noms_compo.add(
"porosite");
421 nom_moyenne =
"porosite";
422 Cout <<
"Porosity post writing" << finl;
426 nom_moyenne, nom_dom, localisation,
"scalar",extrait);
448 Cerr <<
"Starting of Moyenne_volumique::interpreter" << finl;
452 const int id_elem = 0;
453 const int id_som = 1;
454 int localisation = id_elem;
455 Motcle format_post(
"lata_v1");
456 Nom nom_fichier_post;
467 param.
ajouter(
"fichier_post", & fichier_post);
468 param.
ajouter(
"format_post", & format_post);
470 param.
ajouter(
"nom_fichier_post", & nom_fichier_post);
490 param.
ajouter(
"localisation", & localisation);
498 const Domaine& dom = ref_cast(Domaine,
objet(nom_dom));
499 if (noms_champs.size() == 0)
501 Cerr <<
"Moyenne_volumique : no field to treat" << finl;
504 Cerr <<
"Writing of the post-processing domain : " << nom_dom << finl;
506 get_champ(nom_pb, noms_champs[0], ref_champ);
507 const double temps = ref_champ->temps();
510 if (nom_fichier_post ==
"??")
512 Cerr <<
"Error in Moyenne_volumique::interpreter:\n"
513 <<
" missing NOM_FICHIER_POST or FICHIER_POST keyword" << finl;
517 if (format_post ==
"lata_v2")
518 format_post =
"lata";
521 if (nom_fichier_post ==
"NOM_DU_CAS")
523 Cerr <<
"Post filename = NOM_DU_CAS => using " <<
nom_du_cas() <<
" instead" << finl;
526 fichier_post.typer(
Motcle(
"FORMAT_POST_") + format_post);
527 fichier_post->initialize(nom_fichier_post, 1 ,
"SIMPLE");
531 if (nom_fichier_post !=
"??")
533 Cerr <<
"Error in Moyenne_volumique::interpreter:\n"
534 <<
" you cannot give NOM_FICHIER_POST and FICHIER_POST. Choose one" << finl;
546 if (localisation == id_elem)
558 if (localisation == id_som)
580 const DoubleTab& champ_source);
581 void calculer(
double x,
double y,
double z, ArrOfDouble& resu);
604 const DoubleTab& champ_source) :
614 DoubleTab coords = domaine_source.
xp();
620 Cerr <<
"Error in Calcul_integrale_locale::Calcul_integrale_locale() :\n"
621 <<
" The source field is not discretized at the elements" << finl;
625 octree_.build_nodes(coords, 0 );
641 const double box_size =
filter_.box_size();
642 octree_.search_elements_box(x - box_size, y - box_size, z - box_size,
643 x + box_size, y + box_size, z + box_size,
651 for (
int i = 0; i < nb_items; i++)
666 for (
int i = 0; i < nb_items; i++)
670 const double volume = volumes(item);
671 const double facteur = valeur_filtre * volume;
672 for (
int j = 0; j < nb_comp; j++)
677 resu[j] += valeur_champ * facteur;
691 const DoubleTab& champ_source,
692 const DoubleTab& coords_to_compute,
693 DoubleTab& resu)
const
698 const int nb_coords_to_compute = coords_to_compute.
dimension(0);
699 const int nb_coords_max =
mp_max(nb_coords_to_compute);
705 DoubleTab coords(nbproc, 3);
706 ArrOfInt flag(nbproc);
707 ArrOfDouble resu_partiel(nb_comp);
708 DoubleTab resu_partiels(nbproc, nb_comp);
720 for (
int i_coord = 0; i_coord < nb_coords_max; i_coord++)
723 if (i_coord < nb_coords_to_compute)
725 for (j = 0; j < dim; j++)
727 double x = coords_to_compute(i_coord, j);
728 for (i = 0; i < nbproc; i++)
737 envoyer_all_to_all(coords, coords);
738 envoyer_all_to_all(flag, flag);
747 for (i = 0; i < nbproc; i++)
751 integrale_locale.
calculer(coords(i, 0), coords(i, 1), coords(i, 2), resu_partiel);
752 for (j = 0; j < nb_comp; j++)
753 resu_partiels(i, j) = resu_partiel[j];
757 envoyer_all_to_all(resu_partiels, resu_partiels);
759 if (i_coord < nb_coords_to_compute)
761 for (j = 0; j < nb_comp; j++)
764 for (i = 0; i < nbproc; i++)
765 x += resu_partiels(i, j);
766 resu(i_coord, j) = x;
784 const DoubleTab& champ_source,
785 const DoubleTab& coords_to_compute,
786 DoubleTab& resu)
const
790 coords_to_compute, resu);
805 const DoubleTab& champ_source,
806 const DoubleTab& coords_to_compute,
807 DoubleTab& resu)
const
809 Cerr <<
" Moyenne_volumique::calculer_convolution_champ_face is not coded" << finl;
Helper class used internally by calculer_convolution().
const DoubleTab & champ_source_
void calculer(double x, double y, double z, ArrOfDouble &resu)
Evaluates the convolution product "filter_ * champ_source_" at point x,y,z and stores the result in r...
const Moyenne_volumique & filter_
ArrOfDouble filter_results_
Calcul_integrale_locale(const Domaine_VF &domaine_source, const Moyenne_volumique &filter, const DoubleTab &champ_source)
Constructor of the helper class.
const Domaine_VF & domaine_source_
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class Champ_base This class is the base of the fields hierarchy.
void calculer_centres_gravite(DoubleTab_t &xp) const
Calculates the centers of gravity of the domain elements.
DoubleTab_t & les_sommets()
double xp(int num_elem, int k) const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
virtual int nb_comp() const
Base class for post-processing output formats for fields (lata, med, cgns, lml, single_lata).
virtual int finir(const int est_le_dernier_post)
virtual int ecrire_champ(const Domaine &domaine, const Noms &unite_, const Noms &noms_compo, int ncomp, double temps_, const Nom &id_du_champ, const Nom &id_du_domaine, const Nom &localisation, const Nom &nature, const DoubleTab &data)
Writing a field to the post-processing file.
virtual int ecrire_temps(const double temps)
Starts writing a time step.
virtual int ecrire_entete(const double temps_courant, const int reprise, const int est_le_premier_post)
virtual int ecrire_domaine(const Domaine &domaine, const int est_le_premier_post)
Writing a mesh.
const Champ_Fonc_base & le_champ_calcule() const
Base class for "interpreter" objects.
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.
This interpreter computes and stores in a lata file the convolution product.
virtual void calculer_convolution_champ_elem(const Domaine_VF &domaine_source, const DoubleTab &champ_source, const DoubleTab &coords_to_compute, DoubleTab &resu) const
Computes the convolution product between the filter function and the field "champ_source",...
virtual void calculer_convolution_champ_face(const Domaine_VF &domaine_source, const DoubleTab &champ_source, const DoubleTab &coords_to_compute, DoubleTab &resu) const
Same as calculer_convolution_champ_elem but for a VDF face field.
int get_champ(const Nom &nom_pb, const Nom &nom_champ, OBS_PTR(Champ_base) &ref_champ)
Searches for the field named "nom_champ" in the problem named "nom_pb" among the interpreter objects.
virtual void calculer_convolution(const Domaine_VF &domaine_source, const DoubleTab &champ_source, const DoubleTab &coords_to_compute, DoubleTab &resu) const
General method to compute a convolution from a field defined at elements or faces.
void traiter_champs(const Motcles &noms_champs, const Nom &nom_pb, const Nom &nom_dom, const DoubleTab &coords, Format_Post_base &post, double temps, const Motcle &localisation)
Helper function that performs the convolution calculations and writes the result to a lata file for a...
Entree & interpreter(Entree &) override
Reads the parameters from the data set.
virtual void eval_filtre(const DoubleTab &coords, ArrOfDouble &result) const
Evaluates the filter function at each coordinate in coords.
class Nom: a character string for naming TRUST objects.
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.
static double precision_geom
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
class Operateur_Statistique_tps_base
virtual const Integrale_tps_Champ & integrale() const =0
virtual DoubleTab calculer_valeurs() const =0
class Operateurs_Statistique_tps
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.
int lire_avec_accolades_depuis(Entree &is)
Parse the parameter block { ... } from is.
Base class for all post-processing objects.
class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
Operateurs_Statistique_tps & les_statistiques()
class Probleme_base It is a Probleme_U that is not a coupling.
const Champ_base & get_champ(const Motcle &nom) const override
Postraitements & postraitements()
static double mp_max(double)
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
static void barrier()
Synchronizes all processors in the current group (waits until all processors have reached the barrier...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const