TRUST 1.9.8
HPC thermohydraulic platform
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 // Dimensionnement du champ integrale_champ a la meme taille que 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 // La methode valeurs pour cette classe est surchargee et renvoie
57 // integrale_champ->valeurs(). Il n'y a pas de stockage en memoire
58 // de la moyenne. On stocke l'integrale en temps et on postraite la moyenne
59 // Copie de la structure du vecteur, initialisation a 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
classe Champ_base Cette classe est la base de la hierarchie des champs.
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
Renvoie l'unite d'un champ scalaire dont toutes les composantes ont la meme unite.
virtual int nb_comp() const
Definition Field_base.h:56
const Noms & unites() const
Renvoie les unites des composantes du champ.
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:76
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette 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
classe Operateur_Statistique_tps_base Represente des operations statistiques sur les champs.
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
const Domaine_dis_base & domaine_dis() const
Renvoie le domaine discretise associe au probleme.
double temps_courant() const
Renvoie le temps courant.
Classe de base des flux de sortie.
Definition Sortie.h:52
void copy(const TRUSTTab &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:622