TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_Ecart_Type.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_Ecart_Type.h>
17#include <Champ_Generique_Moyenne.h>
18#include <Discretisation_base.h>
19#include <Schema_Temps_base.h>
20#include <Postraitement.h>
21#include <Synonyme_info.h>
22
23Implemente_instanciable(Champ_Generique_Ecart_Type,"Champ_Post_Statistiques_Ecart_Type|Ecart_Type",Champ_Generique_Statistiques_base);
24// XD ecart_type champ_post_statistiques_base ecart_type INHERITS_BRACE to calculate the standard deviation (statistic
25// XD_CONT rms) of the field nom_champ.
26
27
29{
30 return s << que_suis_je() << " " << le_nom();
31}
32
34{
36 return s ;
37}
38
40{
42 const Probleme_base& Pb = get_ref_pb_base();
43 const Champ_Generique_base& ch_integre = get_source(0);
45
46 Op_Ecart_Type_.associer(zdis,ch_integre,tstat_deb_,tstat_fin_);
47
48 Noms nom = get_source(0).get_property("nom");
49 Motcle nom_champ = nom[0];
50 Motcle nom_champ_moyenne("Moyenne_");
51 nom_champ_moyenne += nom_champ;
52 nom_champ_moyenne += "_";
53 nom_champ_moyenne += Nom(tstat_deb_,"%e");
54 nom_champ_moyenne += "_";
55 nom_champ_moyenne += Nom(tstat_fin_,"%e");
56
57 const Postraitement& mon_post = ref_cast(Postraitement,post);
58 if (mon_post.comprend_champ_post(nom_champ_moyenne))
59 {
60 const Champ_Generique_base& champ_stat_base = mon_post.get_champ_post(nom_champ_moyenne);
61 const Operateur_Statistique_tps_base& operateur = ref_cast(Champ_Generique_Moyenne,champ_stat_base).Operateur_Statistique();
62 const Op_Moyenne& op_moyenne = ref_cast(Op_Moyenne,operateur);
63 Op_Ecart_Type_.associer_op_stat(op_moyenne);
64
65 Nom prefix = Pb.le_nom() + "_";
66 if(post.le_nom() != "??" && post.le_nom() != "neant")
67 prefix += post.le_nom() +"_";
69 prefix += parent_name_ + "_";
70 Op_Ecart_Type_.completer(Pb, prefix);
71 }
72 else
73 {
74 Cerr<<"The specification of the post-processing rms field "<<finl;
75 Cerr<<get_property("nom")[0]<<finl;
76 Cerr<<"implies to specify before the corresponding "<<finl;
77 Cerr<<"post-processing statistics average field."<<finl;
78 Cerr<<"Please, modify your data set to specify the post-processing statistics"<<finl;
79 Cerr<<"average field before (instead of after) the rms field "<<finl;
80 Cerr<<get_property("nom")[0]<<finl;
81 exit();
82 }
83
84}
85
87{
88 const OBS_PTR(Champ_Generique_base)& mon_champ = integrale().le_champ();
89 OWN_PTR(Champ_base) espace_stockage_source;
90 const Champ_base& source = mon_champ->get_champ(espace_stockage_source);
91 Nature_du_champ nature_source = source.nature_du_champ();
92 int nb_comp = source.nb_comp();
93 OWN_PTR(Champ_Fonc_base) es_tmp;
94 espace_stockage = creer_espace_stockage(nature_source,nb_comp,es_tmp);
95 return espace_stockage;
96}
97
99{
100 // Creation of the storage space
101 const OBS_PTR(Champ_Generique_base)& mon_champ = integrale().le_champ();
102 OWN_PTR(Champ_base) espace_stockage_source;
103 const Champ_base& source = mon_champ->get_champ(espace_stockage_source);
104 Nature_du_champ nature_source = source.nature_du_champ();
105 int nb_comp = source.nb_comp();
106 if (!espace_stockage_)
107 creer_espace_stockage(nature_source,nb_comp,espace_stockage_);
108 else
109 espace_stockage_->changer_temps(temps());
110 DoubleTab& tab_ecart_type = espace_stockage_->valeurs();
111 tab_ecart_type = Op_Ecart_Type_.calculer_valeurs();
112 tab_ecart_type.echange_espace_virtuel();
113 return espace_stockage_;
114}
115
117{
118 //Component creation should be done dynamically (Ecart_Type_...)
119
120 Motcles motcles(1);
121 motcles[0] = "composantes";
122
123 int rang = motcles.search(query);
124 switch(rang)
125 {
126
127 case 0:
128 {
129 //We set the specific components for Champ_Generique_Ecart_Type
130 //because in Format_Post_Lml::ecrire_champ_lml() in the case of ELEM localisation
131 //they are used
132
133 //Currently the choice is simply to add the component number
134 /*
135 const Noms compo_cibles = get_source(0).get_property("composantes");
136 int size = compo_cibles.size();
137 Noms mots(size);
138 for (int i=0; i<size; i++) {
139 mots[i] = "Ecart_Type_";
140 mots[i] += compo_cibles[i];
141 }
142
143 return mots;
144
145 break;
146 */
147
148 const Noms source_compos = get_source(0).get_property("composantes");
149 int nb_comp = source_compos.size();
150 Noms compo(nb_comp);
151
152 for (int i=0; i<nb_comp; i++)
153 {
154 Nom nume(i);
155 compo[i] = nom_post_+nume;
156 }
157
158 return compo;
159 }
160 }
162}
163
164//Name the field as a source by default
165//"Ecart_Type_"+nom_champ_source
167{
168 if (nom_post_=="??")
169 {
170 Nom nom_post_source, nom_champ_source;
171 const Noms nom = get_source(0).get_property("nom");
172 nom_champ_source = nom[0];
173 nom_post_source = "Ecart_Type_";
174 nom_post_source += nom_champ_source;
175 nommer(nom_post_source);
176 }
177}
178
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
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
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.
class Champ_Generique_Ecart_Type OWN_PTR(Champ_base) intended to post-process a standard deviation (E...
const Noms get_property(const Motcle &query) const override
Returns the requested property.
const Integrale_tps_Champ & integrale() const override
void completer(const Postraitement_base &post) override
const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const override
const Champ_base & get_champ(OWN_PTR(Champ_base)&espace_stockage) const override
class Champ_Generique_Moyenne OWN_PTR(Champ_base) intended to post-process an average of a generic fi...
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
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
class Operateur_Statistique_tps_base
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.
class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
int comprend_champ_post(const Motcle &identifiant) const
virtual const Champ_Generique_base & get_champ_post(const Motcle &nom) const
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.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
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")