TrioCFD 1.9.9_beta
TrioCFD documentation
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 // Sizing the integrale_champ field to the same size as 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 // Initialization of the val array structure.
54 // Is this the right place to do it? (rather in 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
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
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.
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
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).
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
double temps_courant() const
Returns the current time.
Base class for output streams.
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)