TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Moyenne.h
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#ifndef Op_Moyenne_included
17#define Op_Moyenne_included
18
19#include <Operateur_Statistique_tps_base.h>
20#include <TRUSTTabs_forward.h>
21
22
24{
25 Declare_instanciable(Op_Moyenne);
26public:
28 inline const Nom& le_nom() const override { return integrale_champ_.le_champ_calcule().le_nom(); }
29 inline void set_pdi_name(const Nom& nom) { integrale_champ_.le_champ_calcule().set_pdi_name(nom); }
30 inline double temps() const override { return integrale_champ_.le_champ_calcule().temps(); }
31 inline Champ_Don_base& moyenne_convergee() { return ch_moyenne_convergee_; }
32 inline const Integrale_tps_Champ& integrale() const override { return integrale_champ_; }
33 inline const DoubleTab& valeurs() const { return integrale_champ_.le_champ_calcule().valeurs(); }
34 inline DoubleTab& valeurs() { return integrale_champ_.le_champ_calcule().valeurs(); }
35 inline double dt_integration() const { return integrale_champ_.dt_integration(); }
36
37 inline void mettre_a_jour(double temps) override;
38 inline void initialiser(double val) override;
39 inline void associer(const Domaine_dis_base& une_zdis, const Champ_Generique_base& le_champ, double t1, double t2) override;
40 inline void fixer_tstat_deb(double, double) override;
41 inline void fixer_tstat_fin(double tps) override;
42 inline std::vector<YAML_data> data_a_sauvegarder() const override;
43 inline int sauvegarder(Sortie& os) const override;
44 inline int reprendre(Entree& is) override;
45 void completer(const Probleme_base&, const Nom&) override;
46 DoubleTab calculer_valeurs() const override;
47
48protected:
50 OWN_PTR(Champ_Don_base) ch_moyenne_convergee_;
51};
52
53inline void Op_Moyenne::mettre_a_jour(double tps)
54{
55 integrale_champ_.mettre_a_jour(tps);
56 if (ch_moyenne_convergee_)
57 {
58 //const Champ_Fonc_reprise& ch_moy = ref_cast(Champ_Fonc_reprise,ch_moyenne_convergee_.valeur());
59 DoubleTab& valeurs_integrale = valeurs();
60 valeurs_integrale = ch_moyenne_convergee_->valeurs();
61 valeurs_integrale *= dt_integration();
62 }
63}
64
65inline void Op_Moyenne::initialiser(double val_init)
66{
67 integrale_champ_.le_champ_calcule().valeurs() = val_init;
68}
69
70inline void Op_Moyenne::associer(const Domaine_dis_base& une_zdis, const Champ_Generique_base& le_champ, double t1, double t2)
71{
72 OWN_PTR(Champ_base) espace_stockage_source;
73 const Champ_base& source = le_champ.get_champ(espace_stockage_source);
74 Nom type_le_champ = source.que_suis_je();
75
76 int renomme;
77 renomme = 0;
78 if (type_le_champ.debute_par("Champ"))
79 renomme = 1;
80
81 type_le_champ.suffix("Champ_");
82 type_le_champ.suffix("Fonc_");
83 Nom type("Champ_Fonc_");
84 if (renomme == 1)
85 type += type_le_champ;
86 else
87 type = type_le_champ;
88
89 integrale_champ_.typer_champ(type);
90 integrale_champ_.le_champ_calcule().associer_domaine_dis_base(une_zdis);
91 integrale_champ_.associer(le_champ, 1, t1, t2);
92}
93
94/*! @brief for PDI IO: retrieve name, type and dimensions of the field to save/restore
95 *
96 */
97inline std::vector<YAML_data> Op_Moyenne::data_a_sauvegarder() const
98{
99 const Nom& name = integrale_champ_.le_champ_calcule().get_pdi_name();
100 int nb_dim = integrale_champ_.le_champ_calcule().valeurs().nb_dim();
101 YAML_data d(name.getString(), "double", nb_dim);
102
103 std::vector<YAML_data> data;
104 data.push_back(d);
105 return data;
106}
107
108inline int Op_Moyenne::sauvegarder(Sortie& os) const
109{
110 return integrale_champ_.le_champ_calcule().sauvegarder(os);
111}
112
114{
115 return integrale_champ_.le_champ_calcule().reprendre(is);
116}
117
118inline void Op_Moyenne::fixer_tstat_deb(double tdeb, double tps)
119{
120 integrale_champ_.fixer_t_debut(tdeb);
121 integrale_champ_.fixer_tps_integrale(tps);
122 integrale_champ_.fixer_dt_integr(tps - tdeb);
123}
124
125inline void Op_Moyenne::fixer_tstat_fin(double tps)
126{
127 integrale_champ_.fixer_t_fin(tps);
128}
129
130#endif /* Op_Moyenne_included */
class Champ_Don_base base class of Given Fields (not calculated)
class Champ_Generique_base
virtual const Champ_base & get_champ(OWN_PTR(Champ_base) &espace_stockage) const =0
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
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
Nom & suffix(const char *const)
Suffix extraction: Nom x("azerty");.
Definition Nom.cpp:266
const std::string & getString() const
Definition Nom.h:92
friend class Entree
Definition Objet_U.h:71
friend class Sortie
Definition Objet_U.h:70
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
std::vector< YAML_data > data_a_sauvegarder() const override
for PDI IO: retrieve name, type and dimensions of the field to save/restore
Definition Op_Moyenne.h:97
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Op_Moyenne.h:28
double dt_integration() const
Definition Op_Moyenne.h:35
double temps() const override
Definition Op_Moyenne.h:30
const DoubleTab & valeurs() const
Definition Op_Moyenne.h:33
const Integrale_tps_Champ & integrale() const override
Definition Op_Moyenne.h:32
OWN_PTR(Champ_Don_base) ch_moyenne_convergee_
Entree & lire_ch_moyenne(Entree &is)
int sauvegarder(Sortie &os) const override
Saves an Objet_U to an output stream. Virtual method to override.
Definition Op_Moyenne.h:108
void fixer_tstat_deb(double, double) override
Definition Op_Moyenne.h:118
void initialiser(double val) override
Definition Op_Moyenne.h:65
Integrale_tps_Champ integrale_champ_
Definition Op_Moyenne.h:49
void completer(const Probleme_base &, const Nom &) override
void fixer_tstat_fin(double tps) override
Definition Op_Moyenne.h:125
DoubleTab & valeurs()
Definition Op_Moyenne.h:34
void mettre_a_jour(double temps) override
Definition Op_Moyenne.h:53
int reprendre(Entree &is) override
Restores an Objet_U from an input stream. Virtual method to override.
Definition Op_Moyenne.h:113
void set_pdi_name(const Nom &nom)
Definition Op_Moyenne.h:29
Champ_Don_base & moyenne_convergee()
Definition Op_Moyenne.h:31
void associer(const Domaine_dis_base &une_zdis, const Champ_Generique_base &le_champ, double t1, double t2) override
Definition Op_Moyenne.h:70
DoubleTab calculer_valeurs() const override
class Operateur_Statistique_tps_base
class Probleme_base It is a Probleme_U that is not a coupling.
Base class for output streams.
Definition Sortie.h:52
YAML_data class: collection of all needed information for data to save/restore in order to write the ...
Definition YAML_data.h:26