TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_Moyenne.cpp
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Champ_Generique_Moyenne.h>
17#include <Discretisation_base.h>
18#include <Schema_Temps_base.h>
19#include <Champs_compris.h>
20#include <Synonyme_info.h>
21#include <Postraitement.h>
22#include <Param.h>
23
24Implemente_instanciable(Champ_Generique_Moyenne,"Champ_Post_Statistiques_Moyenne|Moyenne",Champ_Generique_Statistiques_base);
25// XD moyenne champ_post_statistiques_base moyenne INHERITS_BRACE to calculate the average of the field over time
26
28{
29 return s << que_suis_je() << " " << le_nom();
30}
31
33{
35}
36
37//condition_initiale : to set the value of the integral
38//of the mean operator using Champ_Fonc_reprise
39//to read the mean recovered from a .xyz file
41{
43 param.ajouter_non_std("moyenne_convergee",(this)); // XD attr moyenne_convergee field_base moyenne_convergee OPT This
44 // XD_CONT option allows to read a converged time averaged field in a .xyz file in order to calculate, when resuming
45 // XD_CONT the calculation, the statistics fields (rms, correlation) which depend on this average. In that case, the
46 // XD_CONT time averaged field is not updated during the resume of calculation. In this case, the time averaged field
47 // XD_CONT must be fully converged to avoid errors when calculating high order statistics.
48}
49
51{
52 if (mot=="moyenne_convergee")
53 {
54 ref_cast(Op_Moyenne,Operateur_Statistique()).lire_ch_moyenne(is);
55 return 1;
56 }
57 else
59}
60
62{
64
65 const Probleme_base& Pb = get_ref_pb_base();
66 const Champ_Generique_base& ch_integre = get_source(0);
68
69 Op_Moyenne_.associer(zdis,ch_integre,tstat_deb_,tstat_fin_);
70
71 Nom prefix = Pb.le_nom() + "_";
72 if(post.le_nom() != "??" && post.le_nom() != "neant")
73 prefix += post.le_nom() +"_";
75 prefix += parent_name_ + "_";
76 Op_Moyenne_.completer(Pb, prefix);
77}
78
80{
81 const OBS_PTR(Champ_Generique_base)& mon_champ = integrale().le_champ();
82 OWN_PTR(Champ_base) espace_stockage_source;
83 const Champ_base& source = mon_champ->get_champ(espace_stockage_source);
84 Nature_du_champ nature_source = source.nature_du_champ();
85 int nb_comp = source.nb_comp();
86 OWN_PTR(Champ_Fonc_base) es_tmp;
87 espace_stockage = creer_espace_stockage(nature_source,nb_comp,es_tmp);
88 return espace_stockage;
89}
90
92{
93 // Creation of the storage space
94 const OBS_PTR(Champ_Generique_base)& mon_champ = integrale().le_champ();
95 OWN_PTR(Champ_base) espace_stockage_source;
96 const Champ_base& source = mon_champ->get_champ(espace_stockage_source);
97 Nature_du_champ nature_source = source.nature_du_champ();
98 int nb_comp = source.nb_comp();
99 if (!espace_stockage_)
100 creer_espace_stockage(nature_source,nb_comp,espace_stockage_);
101 else
102 espace_stockage_->changer_temps(temps());
103 DoubleTab& tab_moy = espace_stockage_->valeurs();
104 tab_moy = Op_Moyenne_.calculer_valeurs();
105 tab_moy.echange_espace_virtuel();
106 return espace_stockage_;
107}
108
110{
111
112 //Component creation should be done dynamically (Moyenne_...)
113
114 Motcles motcles(1);
115 motcles[0] = "composantes";
116
117 int rang = motcles.search(query);
118 switch(rang)
119 {
120
121 case 0:
122 {
123 //We set the specific components for Champ_Generique_Moyenne
124 //because in Format_Post_Lml::ecrire_champ_lml() in the case of ELEM localisation
125 //they are used
126
127 //Currently the choice is simply to add the component number
128 /*
129 const Noms compo_cibles = get_source(0).get_property("composantes");
130 int size = compo_cibles.size();
131 Noms mots(size);
132 for (int i=0; i<size; i++) {
133 mots[i] = "Moyenne_";
134 mots[i] += compo_cibles[i];
135 }
136
137 return mots;
138
139 break;
140 */
141
142 const Noms source_compos = get_source(0).get_property("composantes");
143 int nb_comp = source_compos.size();
144 Noms compo(nb_comp);
145
146 for (int i=0; i<nb_comp; i++)
147 {
148 Nom nume(i);
149 compo[i] = nom_post_+nume;
150 }
151
152 return compo;
153 }
154 }
156}
157
158//Name the field as a source by default
159//"Moyenne_"+nom_champ_source
161{
162 if (nom_post_=="??")
163 {
164 Nom nom_post_source, nom_champ_source;
165 const Noms nom = get_source(0).get_property("nom");
166 nom_champ_source = nom[0];
167 nom_post_source = "Moyenne_";
168 nom_post_source += nom_champ_source;
169 nommer(nom_post_source);
170 }
171}
172
174{
176 return true;
177
178 Noms nom_source = get_source(0).get_property("nom");
179 Motcle nom_champ = nom_source[0];
180 Motcle nom_champ_moyenne("Moyenne_");
181 nom_champ_moyenne += nom_champ;
182 nom_champ_moyenne += "_";
183 nom_champ_moyenne += Nom(tstat_deb_, "%e");
184 nom_champ_moyenne += "_";
185 nom_champ_moyenne += Nom(tstat_fin_, "%e");
186
187 if (nom_champ_moyenne == nom)
188 return true;
189
190 return false; /* nothing found */
191}
192
194{
197
198 OBS_PTR(Champ_Generique_base) ref_champ;
199
200 Noms nom_source = get_source(0).get_property("nom");
201 Motcle nom_champ = nom_source[0];
202 Motcle nom_champ_moyenne("Moyenne_");
203 nom_champ_moyenne += nom_champ;
204 nom_champ_moyenne += "_";
205 nom_champ_moyenne += Nom(tstat_deb_, "%e");
206 nom_champ_moyenne += "_";
207 nom_champ_moyenne += Nom(tstat_fin_, "%e");
208
209 if (nom_champ_moyenne == nom)
210 {
211 ref_champ = *this;
212 ref_champ->fixer_identifiant_appel(nom);
213 return ref_champ;
214 }
215
216 throw std::runtime_error(std::string("Field ") + nom.getString() + std::string(" not found !"));
217}
218
220{
222 return 1;
223
224 //Additional name tested because it is the name used by:
225 //Champ_Generique_Ecart_Type::completer()
226 //Champ_Generique_Correlation::completer()
227 Noms nom_source = get_source(0).get_property("nom");
228 Motcle nom_champ = nom_source[0];
229 Motcle nom_champ_moyenne("Moyenne_");
230 nom_champ_moyenne += nom_champ;
231 nom_champ_moyenne += "_";
232 nom_champ_moyenne += Nom(tstat_deb_,"%e");
233 nom_champ_moyenne += "_";
234 nom_champ_moyenne += Nom(tstat_fin_,"%e");
235
236 if (nom_champ_moyenne==identifiant)
237 return 1;
238
239 return 0;
240}
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
int comprend_champ_post(const Motcle &identifiant) const override
const Noms get_property(const Motcle &query) const override
Returns the requested property.
const Champ_Generique_base & get_champ_post(const Motcle &nom) const override
void completer(const Postraitement_base &post) override
const Probleme_base & get_ref_pb_base() const override
Returns the problem that carries the target field.
bool has_champ_post(const Motcle &nom) const override
virtual const Champ_Generique_base & get_source(int i) const
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.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
class Champ_Generique_Moyenne OWN_PTR(Champ_base) intended to post-process an average of a generic fi...
const Champ_base & get_champ(OWN_PTR(Champ_base)&espace_stockage) const override
const Noms get_property(const Motcle &query) const override
Returns the requested property.
void set_param(Param &param) const override
int comprend_champ_post(const Motcle &identifiant) const override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void completer(const Postraitement_base &post) override
double temps() const override
const Integrale_tps_Champ & integrale() const override
const Operateur_Statistique_tps_base & Operateur_Statistique() const override
bool has_champ_post(const Motcle &nom) const override
const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const override
const Champ_Generique_base & get_champ_post(const Motcle &nom) const override
Classe Champ_Generique_Statistiques_base Base class for generic field classes dedicated to statistics...
class Champ_Generique_base
virtual const Noms get_property(const Motcle &query) const
Returns the requested property.
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
OBS_PTR(Probleme_base) ref_pb_
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
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,...
Definition Entree.h:42
virtual int nb_comp() const
Definition Field_base.h:56
virtual Nature_du_champ nature_du_champ() const
Definition Field_base.h:77
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
An array of character strings (VECT(Nom)).
Definition Noms.h:26
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
Base class for all post-processing objects.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
class Probleme_base It is a Probleme_U that is not a coupling.
Base class for output streams.
Definition Sortie.h:52
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")