TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_P0_base.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 <Champ_Fonc_P0_base.h>
17#include <Frontiere_dis_base.h>
18#include <Domaine_dis_base.h>
19#include <Domaine.h>
20#include <Domaine_VF.h>
21
22Implemente_base(Champ_Fonc_P0_base, "Champ_Fonc_P0_base", Champ_Fonc_base);
23// XD champ_input_base field_base champ_input_base BRACE not_set
24// XD attr nb_comp entier nb_comp REQ not_set
25// XD attr nom chaine nom REQ not_set
26// XD attr initial_value list initial_value OPT not_set
27// XD attr probleme chaine probleme REQ not_set
28// XD attr sous_zone ref_sous_zone sous_zone OPT not_set
29
30Sortie& Champ_Fonc_P0_base::printOn(Sortie& os) const { return os << que_suis_je() << " " << le_nom(); }
31
32Entree& Champ_Fonc_P0_base::readOn(Entree& is) { return is; }
33
35{
36 // Encore une syntaxe a la con, sinon on ne sait pas s'il faut appeler
37 // domaine_dis_base() de champ_inc_base ou de champ_impl...
38 const Domaine_dis_base& domainedis = ref_cast(Champ_Fonc_base, *this).domaine_dis_base();
39 assert(n == domainedis.domaine().nb_elem());
40 const MD_Vector& md = domainedis.domaine().md_vector_elements();
42 return 1;
43}
44
46{
48 return *this;
49 else
51}
52
53/*! @brief Trace du champ P0 sur la frontiere
54 *
55 */
56DoubleTab& Champ_Fonc_P0_base::trace(const Frontiere_dis_base& fr, DoubleTab& x, double tps, int distant) const
57{
58 return Champ_implementation_P0::trace(fr, valeurs(), x, distant);
59}
60
61double Champ_Fonc_P0_base::moyenne(const DoubleVect& porosite_elem, int ncomp) const
62{
63 const Domaine_VF& zvf = le_dom_VF.valeur();
64 const DoubleVect& volumes = zvf.volumes();
65 const DoubleTab& val = valeurs();
66
67 double moy = 0, sum_vol = 0;
68
69 for (int e = 0; e < zvf.nb_elem(); e++)
70 {
71 const double coef = porosite_elem(e) * volumes(e);
72 moy += val(e, ncomp) * coef;
73 sum_vol += coef;
74 }
75 moy = mp_sum(moy);
76 sum_vol = mp_sum(sum_vol);
77 moy /= sum_vol;
78 return moy;
79}
80
81DoubleVect Champ_Fonc_P0_base::moyenne(const DoubleVect& porosite_elem) const
82{
83 const Domaine_VF& zvf = le_dom_VF.valeur();
84 const DoubleVect& volumes = zvf.volumes();
85 const DoubleTab& val = valeurs();
86
87 const int nb_compo = nb_comp();
88 DoubleVect moy(nb_compo);
89 moy = 0;
90 double sum_vol = 0;
91
92 for (int e = 0; e < zvf.nb_elem(); e++)
93 {
94 const double coef = porosite_elem(e) * volumes(e);
95 for (int k = 0; k < nb_compo; k++)
96 moy[k] += val(e, k) * coef;
97 sum_vol += coef;
98 }
99
100 moy /= sum_vol;
101 return moy;
102}
103
104int Champ_Fonc_P0_base::imprime(Sortie& os, int ncomp) const
105{
106 imprime_P0(os, ncomp);
107 return 1;
108}
109
114
116{
117 double val_bord;
118 const DoubleTab& val = valeurs();
119 const Domaine_VF& zvf = le_dom_VF.valeur();
120
121 int n0 = zvf.face_voisins(face, 0);
122 if (n0 != -1)
123 val_bord = val[n0];
124 else
125 val_bord = val[zvf.face_voisins(face, 1)];
126 return val_bord;
127}
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
double valeur_au_bord(int face) const
Champ_base & affecter_(const Champ_base &) override
Affecte un Champ_base dans un Champ_Fonc_base.
DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const override
Trace du champ P0 sur la frontiere.
double moyenne(const DoubleVect &porosite_elem, int) const
void mettre_a_jour(double) override
Mise a jour en temps du champ.
int imprime(Sortie &, int) const override
NE FAIT RIEN.
int fixer_nb_valeurs_nodales(int n) override
Fixe le nombre de degres de liberte par composante.
classe Champ_Fonc_base Classe de base des champs qui sont fonction d'une grandeur calculee
Champ_base & affecter_(const Champ_base &) override
Affecte un Champ_base dans un Champ_Fonc_base.
void mettre_a_jour(double temps) override
Mise a jour en temps du champ.
virtual void creer_tableau_distribue(const MD_Vector &, RESIZE_OPTIONS=RESIZE_OPTIONS::COPY_INIT)
Champ_base()
Constructeur par defaut d'un Champ_base.
int imprime_P0(Sortie &, int) const
int affecter_(const Champ_base &)
DoubleTab & trace(const Frontiere_dis_base &fr, const DoubleTab &y, DoubleTab &x, int distant) const
int_t nb_elem() const
Definition Domaine.h:131
virtual const MD_Vector & md_vector_elements() const
renvoie le descripteur parallele des tableaux aux elements du domaine
Definition Domaine.cpp:860
class Domaine_VF
Definition Domaine_VF.h:44
double volumes(int i) const
Definition Domaine_VF.h:113
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Renvoie le nom du champ.
virtual int nb_comp() const
Definition Field_base.h:56
classe Frontiere_dis_base Classe representant une frontiere discretisee.
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
Definition MD_Vector.h:48
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
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
Definition Process.cpp:146
Classe de base des flux de sortie.
Definition Sortie.h:52