TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Op_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 <Schema_Temps_base.h>
17#include <Op_Ecart_type.h>
18#include <Probleme_base.h>
19
20Implemente_instanciable(Op_Ecart_type, "Op_Ecart_type", Operateur_Statistique_tps_base);
21
23{
24 return s << que_suis_je() << " " << le_nom();
25}
26
28{
29 return s;
30}
31
32void Op_Ecart_type::completer(const Probleme_base& Pb, const Nom& prefix)
33{
34 Nom nom_pour_post = "Ecart_type_";
35
36 const OBS_PTR(Champ_Generique_base) &mon_champ = integrale_carre_champ_.le_champ();
37 const Noms noms = mon_champ->get_property("nom");
38 nom_pour_post += Motcle(noms[0]);
39
40 integrale_carre_champ_.le_champ_calcule().nommer(nom_pour_post);
41
42 Nom pdi_name = prefix + nom_pour_post;
43 integrale_carre_champ_.le_champ_calcule().set_pdi_name(pdi_name);
44
45 if (la_moyenne_)
46 integrale_champ_ = moyenne().integrale();
47
48 // Dimensionnement du champ integrale_champ a la meme taille que mon_champ
49 OWN_PTR(Champ_base) espace_stockage_source;
50 const Champ_base& source = mon_champ->get_champ(espace_stockage_source);
51 const DoubleTab& tab1 = source.valeurs();
52
53 // Initialisation de la structure du tableau val.
54 // Est-bien le bon endroit pour faire ca ? (plutot dans integrale_carre_champ ?)
55 integrale_carre_champ_.le_champ_calcule().associer_domaine_dis_base(Pb.domaine_dis());
56 int nb_comp = source.nb_comp();
57 integrale_carre_champ_.le_champ_calcule().fixer_nb_comp(nb_comp);
58 DoubleTab& val = valeurs_carre();
59 val.reset();
60 val = tab1;
61 val = 0.;
62
63 if (nb_comp == 1)
64 integrale_carre_champ_.le_champ_calcule().fixer_unite(source.unite());
65 else
66 integrale_carre_champ_.le_champ_calcule().fixer_unites(source.unites());
67
68 integrale_carre_champ_.le_champ_calcule().changer_temps(Pb.schema_temps().temps_courant());
69}
70
72{
73 double dt = dt_integration();
74 if (!est_egal(dt, dt_integration_carre()))
75 {
76 Cerr << "Not implemented yet in Op_Ecart_type::calculer_valeurs()" << finl;
77 exit();
78 }
79 DoubleTrav ecart_type(valeurs_carre());
80 ecart_type = valeurs_carre();
81 if (dt > 0)
82 {
83 ecart_type *= dt; // sum(I^2)*dt
84 ecart_type.ajoute_carre(-1, valeurs()); // sum(I^2)*dt-sum(I)^2
85 ecart_type /= (dt * dt); // sum(I^2)/dt-(sum(I)/dt)^2)
86 ecart_type.abs(); // To avoid negative number ?
87 ecart_type.racine_carree(); // sqrt(mean(I^2)-mean(I)^2)
88 }
89 return ecart_type;
90}
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
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.
DoubleTab & valeurs_carre()
double dt_integration_carre() const
Integrale_tps_Champ integrale_carre_champ_
double dt_integration() const
OBS_PTR(Op_Moyenne) la_moyenne_
void completer(const Probleme_base &, const Nom &) override
DoubleTab & valeurs()
DoubleTab calculer_valeurs() const override
const Op_Moyenne & moyenne() const
const Integrale_tps_Champ & integrale() const override
Definition Op_Moyenne.h:32
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.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
double temps_courant() const
Renvoie le temps courant.
Classe de base des flux de sortie.
Definition Sortie.h:52
void reset() override
Definition TRUSTTab.tpp:362
void abs(Mp_vect_options opt=VECT_ALL_ITEMS)
Definition TRUSTVect.h:132
void racine_carree(Mp_vect_options opt=VECT_ALL_ITEMS)
Definition TRUSTVect.h:134
void ajoute_carre(_SCALAR_TYPE_ alpha, const TRUSTVect &y, Mp_vect_options opt=VECT_ALL_ITEMS)