TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_Correlation.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_Correlation.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_Correlation,"Champ_Post_Statistiques_Correlation|Correlation",Champ_Generique_Statistiques_base);
24// XD correlation champ_post_statistiques_base correlation INHERITS_BRACE to calculate the correlation between the two
25// XD_CONT fields.
26
28{
29 return s << que_suis_je() << " " << le_nom();
30}
31
33{
35}
36
38{
40 const Probleme_base& Pb = get_ref_pb_base();
41
42 Noms nom = get_source(0).get_property("nom");
43 Motcle nom_champ = nom[0];
44 Noms nom2 = get_source(1).get_property("nom");
45 Motcle nom_champ2 = nom2[0];
46
47 const Champ_Generique_base& ch_integre = get_source(0);
48 const Champ_Generique_base& ch_integre2 = get_source(1);
50
51 Op_Correlation_.associer(zdis,ch_integre,ch_integre2,tstat_deb_,tstat_fin_);
52 const Postraitement& mon_post = ref_cast(Postraitement,post);
53
54 Motcle nom_champ_moyenne("Moyenne_");
55 nom_champ_moyenne += nom_champ;
56 nom_champ_moyenne += "_";
57 nom_champ_moyenne += Nom(tstat_deb_,"%e");
58 nom_champ_moyenne += "_";
59 nom_champ_moyenne += Nom(tstat_fin_,"%e");
60
61 Motcle nom_champ_moyenne2("Moyenne_");
62 nom_champ_moyenne2 += nom_champ2;
63 nom_champ_moyenne2 += "_";
64 nom_champ_moyenne2 += Nom(tstat_deb_,"%e");
65 nom_champ_moyenne2 += "_";
66 nom_champ_moyenne2 += Nom(tstat_fin_,"%e");
67
68 if ((mon_post.comprend_champ_post(nom_champ_moyenne)) && (mon_post.comprend_champ_post(nom_champ_moyenne2)))
69 {
70 const Champ_Generique_base& champ_stat_base = mon_post.get_champ_post(nom_champ_moyenne);
71 const Operateur_Statistique_tps_base& operateur = ref_cast(Champ_Generique_Moyenne,champ_stat_base).Operateur_Statistique();
72 const Op_Moyenne& op_moyenne = ref_cast(Op_Moyenne,operateur);
73 Op_Correlation_.associer_op_stat(op_moyenne);
74
75 const Champ_Generique_base& champ_stat_base2 = mon_post.get_champ_post(nom_champ_moyenne2);
76 const Operateur_Statistique_tps_base& operateur2 = ref_cast(Champ_Generique_Moyenne,champ_stat_base2).Operateur_Statistique();
77 const Op_Moyenne& op_moyenne2 = ref_cast(Op_Moyenne,operateur2);
78 Op_Correlation_.associer_op_stat(op_moyenne2);
79 }
80 else
81 {
82 Cerr<<"The specification of the post-processing correlation field "<<finl;
83 Cerr<<get_property("nom")[0]<<finl;
84 Cerr<<"implies to specify before the corresponding "<<finl;
85 Cerr<<"post-processing statistics average fields."<<finl;
86 Cerr<<"Please, modify your data set to specify the post-processing statistics"<<finl;
87 Cerr<<"average fields before (instead of after) the post-processing correlation field"<<finl;
88 Cerr<<get_property("nom")[0]<<finl;
89 exit();
90 }
91
92 Nom prefix = Pb.le_nom() + "_";
93 if(post.le_nom() != "??" && post.le_nom() != "neant")
94 prefix += post.le_nom() +"_";
96 prefix += parent_name_ + "_";
97 Op_Correlation_.completer(Pb, prefix);
98}
99
101{
103 //Nature_du_champ nature_source = source.nature_du_champ();
104 //Not completely exact because there is the vector-vector correlation case where
105 //a tensor is manipulated (the nature is neither scalar nor vectorial)
106 Nature_du_champ nature_source = (nb_comp==1)?scalaire:vectoriel;
107 OWN_PTR(Champ_Fonc_base) es_tmp;
108 espace_stockage = creer_espace_stockage(nature_source,nb_comp,es_tmp);
109 return espace_stockage;
110}
111
112const Champ_base& Champ_Generique_Correlation::get_champ(OWN_PTR(Champ_base)& espace_stockage) const
113{
115 //Nature_du_champ nature_source = source.nature_du_champ();
116 //Not completely exact because there is the vector-vector correlation case where
117 //a tensor is manipulated (the nature is neither scalar nor vectorial)
118 Nature_du_champ nature_source = (nb_comp==1)?scalaire:vectoriel;
119 if (!espace_stockage_)
120 creer_espace_stockage(nature_source,nb_comp,espace_stockage_);
121 else
122 espace_stockage_->changer_temps(temps());
123 DoubleTab& tab_correlation = espace_stockage_->valeurs();
124 tab_correlation = Op_Correlation_.calculer_valeurs();
125 tab_correlation.echange_espace_virtuel();
126 return espace_stockage_;
127}
128
130{
131 //Component creation should be done dynamically (Correlation_...)
132 Motcles motcles(2);
133 motcles[0] = "unites";
134 motcles[1] = "composantes";
135
136 int rang = motcles.search(query);
137 switch(rang)
138 {
139 case 0:
140 {
141 const Noms noms_unites = integrale().le_champ_calcule().unites();
142 return noms_unites;
143 }
144 case 1:
145 {
146 //We set the specific components for Champ_Generique_Moyenne
147 //because in Format_Post_Lml::ecrire_champ_lml() in the case of ELEM localisation
148 //they are used
149
150 /*
151 const Noms compo_cibles = get_source(0).get_property("composantes");
152 int size = compo_cibles.size();
153 Noms mots(size);
154 for (int i=0; i<size; i++) {
155 mots[i] = "Moyenne_";
156 mots[i] += compo_cibles[i];
157 }
158
159 return mots;
160
161 break;
162 */
163
164 /*
165 const Noms source_compos = get_source(0).get_property("composantes");
166 int nb_comp = source_compos.size();
167 Noms compo(nb_comp);
168
169 for (int i=0; i<nb_comp; i++) {
170 Nom nume(i);
171 compo[i] = nom_post_+nume;
172 }
173 */
174
175 const Noms noms_compo = integrale().le_champ_calcule().noms_compo();
176 return noms_compo;
177 }
178 }
180}
181
182//Name the field as a source by default
183//"Correlation_"+nom_champ_source_1+nom_champ_source_2
185{
186
187 if (nom_post_=="??")
188 {
189 Nom nom_post_source, nom_champ_source_1, nom_champ_source_2;
190 const Noms nom_1 = get_source(0).get_property("nom");
191 const Noms nom_2 = get_source(1).get_property("nom");
192 nom_champ_source_1 = nom_1[0];
193 nom_champ_source_2 = nom_2[0];
194
195 nom_post_source = "Correlation_";
196 nom_post_source += nom_champ_source_1;
197 nom_post_source += "_";
198 nom_post_source += nom_champ_source_2;
199 nommer(nom_post_source);
200 }
201}
202
203//Returns 1 if tensor to post-process, otherwise 0
205{
206 const Noms compo = get_property("composantes");
207 if (compo.size()>1)
208 return 1;
209 else
210 return 0;
211}
212
214{
215 Motcle directive;
216
217 int support_corr = ref_cast(Integrale_tps_produit_champs,integrale()).get_support_different();
218
219 if (support_corr==1)
220 directive = "champ_elem";
221 else
222 directive = Op_Correlation_.la_moyenne_a().integrale().le_champ()->get_directive_pour_discr();
223
224 return directive;
225}
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_Correlation
const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const override
const Noms get_property(const Motcle &query) const override
Returns the requested property.
void completer(const Postraitement_base &post) override
const Integrale_tps_Champ & integrale() const override
const Champ_base & get_champ(OWN_PTR(Champ_base)&espace_stockage) const override
const Motcle get_directive_pour_discr() const override
Returns the directive (champ_elem, champ_sommets, champ_face or pression) to launch the discretizatio...
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.
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
const Noms & unites() const
Returns the units of the field components.
const Noms & noms_compo() const
Returns the array of names of the field components.
const Champ_Fonc_base & le_champ_calcule() const
class Integrale_tps_produit_champs
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")