TrioCFD 1.9.8
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// Methode de calcul de la valeur sur une face encadree par elem1 et elem2 d'un champ uniforme ou non a plusieurs composantes
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); // Champ uniforme
41 else
42 {
43 if (elem2 < 0)
44 elem2 = elem1; // face frontiere
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. faces de bord -> on ne contribue qu'aux faces de Neumann */
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. faces internes -> contributions amont/aval */
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
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
const Cond_lim & les_conditions_limites(int) const
Renvoie la i-ieme condition aux limites.
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
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
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
Classe Neumann_homogene Cette classe est la classe de base de la hierarchie des conditions aux limite...
Classe Neumann Cette classe est la classe de base de la hierarchie des conditions aux limites de type...
Definition Neumann.h:31
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
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
Classe de base des flux de sortie.
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
classe Source_Generique_base Cette classe est la base de la hierarchie des sources portant
OWN_PTR(Champ_Generique_base) ch_source_
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133