TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_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 <Schema_Temps_base.h>
17#include <Champ_Don_base.h>
18#include <Probleme_base.h>
19#include <Op_Moyenne.h>
20
21Implemente_instanciable(Op_Moyenne, "Op_Moyenne", Operateur_Statistique_tps_base);
22
24{
25 return s << que_suis_je() << " " << le_nom();
26}
27
29{
30 return s;
31}
32
34{
35 return is >> ch_moyenne_convergee_;
36}
37
38void Op_Moyenne::completer(const Probleme_base& Pb, const Nom& prefix)
39{
40 Nom nom_pour_post = "Moyenne_";
41
42 const OBS_PTR(Champ_Generique_base) &mon_champ = integrale_champ_.le_champ();
43 const Noms noms = mon_champ->get_property("nom");
44 nom_pour_post += Motcle(noms[0]);
45
46 integrale_champ_.le_champ_calcule().nommer(nom_pour_post);
47
48 Nom pdi_name = prefix + nom_pour_post;
49 integrale_champ_.le_champ_calcule().set_pdi_name(pdi_name);
50
51 // Size the integrale_champ field to the same size as mon_champ
52 OWN_PTR(Champ_base) espace_stockage_source;
53 const Champ_base& source = mon_champ->get_champ(espace_stockage_source);
54 const DoubleTab& tab1 = source.valeurs();
55
56 // The valeurs() method for this class is overridden and returns
57 // integrale_champ->valeurs(). The mean is not stored directly in memory;
58 // the time integral is stored and the mean is post-processed from it.
59 // Copy the vector structure and initialize to zero.
60 valeurs().copy(tab1, RESIZE_OPTIONS::NOCOPY_NOINIT);
61 if (!ch_moyenne_convergee_)
62 valeurs() = 0.;
63 int nb_comp = source.nb_comp();
64 integrale_champ_.le_champ_calcule().associer_domaine_dis_base(Pb.domaine_dis());
65 integrale_champ_.le_champ_calcule().fixer_nb_comp(nb_comp);
66 if (nb_comp == 1)
67 integrale_champ_.le_champ_calcule().fixer_unite(source.unite());
68 else
69 integrale_champ_.le_champ_calcule().fixer_unites(source.unites());
70
71 integrale_champ_.le_champ_calcule().changer_temps(Pb.schema_temps().temps_courant());
72}
73
75{
76 double dt = dt_integration();
77 DoubleTrav moyenne(valeurs());
78 moyenne = valeurs();
79 if (dt > 0)
80 moyenne /= dt;
81 return moyenne;
82}
class Champ_Generique_base
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & unite() const
Returns the unit of a scalar field whose all components have the same unit.
virtual int nb_comp() const
Definition Field_base.h:56
const Noms & unites() const
Returns the units of the field components.
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:71
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 Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
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
const DoubleTab & valeurs() const
Definition Op_Moyenne.h:33
OWN_PTR(Champ_Don_base) ch_moyenne_convergee_
Entree & lire_ch_moyenne(Entree &is)
Integrale_tps_Champ integrale_champ_
Definition Op_Moyenne.h:49
void completer(const Probleme_base &, const Nom &) override
DoubleTab calculer_valeurs() const override
class Operateur_Statistique_tps_base
class Probleme_base It is a Probleme_U that is not a coupling.
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
const Domaine_dis_base & domaine_dis() const
Returns the discretized domain associated with the problem (const version).
double temps_courant() const
Returns the current time.
Base class for output streams.
Definition Sortie.h:52
void copy(const TRUSTTab &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:622