TrioCFD 1.9.9_beta
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 // Ugly syntax, otherwise we don't know whether to call
37 // domaine_dis_base() from champ_inc_base or from 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 of the P0 field on the boundary
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
Overrides Champ_base::valeurs() Returns the array of values.
double valeur_au_bord(int face) const
Champ_base & affecter_(const Champ_base &) override
Assigns a Champ_base to a Champ_Fonc_base.
DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const override
Trace of the P0 field on the boundary.
double moyenne(const DoubleVect &porosite_elem, int) const
void mettre_a_jour(double) override
Time update of the field.
int imprime(Sortie &, int) const override
DOES NOTHING.
int fixer_nb_valeurs_nodales(int n) override
Sets the number of degrees of freedom per component.
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
Champ_base & affecter_(const Champ_base &) override
Assigns a Champ_base to a Champ_Fonc_base.
void mettre_a_jour(double temps) override
Time update of the field.
virtual void creer_tableau_distribue(const MD_Vector &, RESIZE_OPTIONS=RESIZE_OPTIONS::COPY_INIT)
Champ_base()
Default constructor of a 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
Returns the parallel descriptor of element arrays of the domain.
Definition Domaine.cpp:859
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
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
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
Returns the name of the field.
virtual int nb_comp() const
Definition Field_base.h:56
class Frontiere_dis_base Class representing a discretized boundary.
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
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
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
Base class for output streams.
Definition Sortie.h:52