TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Generique_Face_PolyMAC_CDO.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Source_Generique_Face_PolyMAC_CDO.h>
17#include <Domaine_PolyMAC_MPFA.h>
18#include <Champ_Face_PolyMAC_CDO.h>
19#include <Domaine_Cl_PolyMAC_family.h>
20
21#include <Equation_base.h>
22#include <Milieu_base.h>
23
24Implemente_instanciable(Source_Generique_Face_PolyMAC_CDO, "Source_Generique_Face_PolyMAC_CDO", Source_Generique_base);
25
26Implemente_instanciable(Source_Generique_Face_PolyMAC_HFV, "Source_Generique_Face_PolyMAC_HFV|Source_Generique_Face_PolyMAC_MPFA", Source_Generique_Face_PolyMAC_CDO);
27
29
31
33
35
36// Method to compute the value on a face bounded by elem1 and elem2 from a uniform or multi-component field
37inline double valeur(const DoubleTab& valeurs_champ, int elem1, int elem2, const int compo)
38{
39 if (valeurs_champ.dimension(0) == 1)
40 return valeurs_champ(0, compo); // Uniform field
41 else
42 {
43 if (elem2 < 0)
44 elem2 = elem1; // boundary face
45 if (valeurs_champ.nb_dim() == 1)
46 return 0.5 * (valeurs_champ(elem1) + valeurs_champ(elem2));
47 else
48 return 0.5 * (valeurs_champ(elem1, compo) + valeurs_champ(elem2, compo));
49 }
50}
51
53{
54 le_dom_PolyMAC_CDO = ref_cast(Domaine_PolyMAC_CDO, domaine_dis);
55 la_zcl_PolyMAC_CDO = ref_cast(Domaine_Cl_PolyMAC_family, zcl_dis);
56}
57
62
63DoubleTab& Source_Generique_Face_PolyMAC_CDO::ajouter(DoubleTab& resu) const
64{
65 OWN_PTR(Champ_base) espace_stockage;
66 const Champ_base& la_source = ch_source_->get_champ(espace_stockage); // Aux faces
67 const Domaine_PolyMAC_CDO& domaine = le_dom_PolyMAC_CDO.valeur();
68 const Domaine_Cl_PolyMAC_family& Domaine_Cl_PolyMAC_family = la_zcl_PolyMAC_CDO.valeur();
69 const DoubleVect& pf = equation().milieu().porosite_face(), &fs = domaine.face_surfaces();
70 const IntTab& f_e = domaine.face_voisins();
71 const DoubleTab& xv = domaine.xv(), &xp = domaine.xp();
72 /* 1. boundary faces: contribute only to Neumann faces */
73 for (int n_bord = 0; n_bord < domaine.nb_front_Cl(); n_bord++)
74 {
76 if (!sub_type(Neumann, la_cl.valeur()) && !sub_type(Neumann_homogene, la_cl.valeur()))
77 continue;
78 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
79 for (int f = le_bord.num_premiere_face(); f < le_bord.num_premiere_face() + le_bord.nb_faces(); f++)
80 {
81 int e = domaine.face_voisins(f, 0);
82 double fac = pf(f) * fs(f);
83 for (int r = 0; r < dimension; r++)
84 resu(f) += fac * la_source.valeurs()(f) * (xv(f, r) - xp(e, r));
85 }
86 }
87 /* 2. internal faces -> upstream/downstream contributions */
88 for (int f = domaine.premiere_face_int(); f < domaine.nb_faces(); f++)
89 {
90 double fac = pf(f) * fs(f);
91 for (int i = 0; i < 2; i++)
92 for (int r = 0, e = f_e(f, i); r < dimension; r++)
93 resu(f) += fac * la_source.valeurs()(f) * (xv(f, r) - xp(e, r)) * (i ? -1 : 1);
94 }
95 return resu;
96}
97
98DoubleTab& Source_Generique_Face_PolyMAC_HFV::ajouter(DoubleTab& resu) const
99{
100 OWN_PTR(Champ_base) espace_stockage;
101 const Champ_base& la_source = ch_source_->get_champ(espace_stockage); // Aux faces
102 const Domaine_PolyMAC_CDO& domaine = le_dom_PolyMAC_CDO.valeur();
103 const DoubleVect& pf = equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces();
104 const IntTab& fcl = ref_cast(Champ_Face_PolyMAC_CDO, equation().inconnue()).fcl();
105 for (int f = 0, calc_cl = !sub_type(Domaine_PolyMAC_MPFA, domaine); f < domaine.nb_faces(); f++)
106 if (calc_cl || fcl(f, 0) < 2)
107 resu(f) += pf(f) * vf(f) * la_source.valeurs()(f);
108 return resu;
109}
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Classe Neumann_homogene This class is the base class of the hierarchy of homogeneous Neumann-type bou...
Classe Neumann This class is the base class of the hierarchy of Neumann-type boundary conditions.
Definition Neumann.h:31
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
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
Base class for output streams.
Definition Sortie.h:52
DoubleTab & ajouter(DoubleTab &) const override
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
DoubleTab & ajouter(DoubleTab &) const override
Source_Generique_base This class is the base of the source term hierarchy carrying.
OWN_PTR(Champ_Generique_base) ch_source_
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133