TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Grad_PolyMAC_CDO_Face.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 <Op_Grad_PolyMAC_CDO_Face.h>
17#include <Neumann_sortie_libre.h>
18#include <Check_espace_virtuel.h>
19#include <Domaine_Cl_PolyMAC_family.h>
20#include <Champ_Elem_PolyMAC_CDO.h>
21#include <Navier_Stokes_std.h>
22#include <Schema_Temps_base.h>
23#include <Probleme_base.h>
24#include <Matrix_tools.h>
25#include <Array_tools.h>
26#include <TRUSTTrav.h>
27#include <Dirichlet.h>
28
29Implemente_instanciable(Op_Grad_PolyMAC_CDO_Face, "Op_Grad_PolyMAC_CDO_Face", Operateur_Grad_base);
30
32
34
35void Op_Grad_PolyMAC_CDO_Face::associer(const Domaine_dis_base& domaine_dis, const Domaine_Cl_dis_base& domaine_Cl_dis, const Champ_Inc_base&)
36{
37 const Domaine_PolyMAC_CDO& zPolyMAC_HFV = ref_cast(Domaine_PolyMAC_CDO, domaine_dis);
38 const Domaine_Cl_PolyMAC_family& zclPolyMAC_HFV = ref_cast(Domaine_Cl_PolyMAC_family, domaine_Cl_dis);
39 ref_domaine = zPolyMAC_HFV;
40 ref_dcl = zclPolyMAC_HFV;
41 porosite_surf.ref(equation().milieu().porosite_face());
42 face_voisins.ref(zPolyMAC_HFV.face_voisins());
43}
44
46{
48 {
50 return;
51 }
52
53 const Domaine_PolyMAC_CDO& zPolyMAC_HFV = ref_domaine.valeur();
54 Stencil stencil(0, 2);
55
56 for (int f = 0; f < zPolyMAC_HFV.nb_faces(); f++)
57 for (int i = 0; i < 2; i++)
58 {
59 const int e = zPolyMAC_HFV.face_voisins(f, i);
60 if (e < 0) continue;
61
62 stencil.append_line(f, e);
63 }
64 tableau_trier_retirer_doublons(stencil);
65 Matrix_tools::allocate_morse_matrix(zPolyMAC_HFV.nb_faces_tot(), zPolyMAC_HFV.nb_elem_tot(), stencil, mat);
66}
67
68DoubleTab& Op_Grad_PolyMAC_CDO_Face::ajouter(const DoubleTab& inco, DoubleTab& resu) const
69{
70 if (has_interface_blocs()) return Operateur_Grad_base::ajouter(inco, resu);
71
72 assert_espace_virtuel_vect(inco);
73 const Domaine_PolyMAC_CDO& zPolyMAC_HFV = ref_domaine.valeur();
74 const Domaine_Cl_PolyMAC_family& zclPolyMAC_HFV = ref_dcl.valeur();
75 const DoubleVect& face_surfaces = zPolyMAC_HFV.face_surfaces();
76
77 double coef;
78 int n0, n1;
79
80 // Boucle sur les bords pour traiter les conditions aux limites
81 int ndeb, nfin, num_face;
82 for (int n_bord = 0; n_bord < zPolyMAC_HFV.nb_front_Cl(); n_bord++)
83 {
84
85 // pour chaque Condition Limite on regarde son type
86 // Si face de Dirichlet ou de Symetrie on ne fait rien
87 // Si face de Neumann on calcule la contribution au terme source
88
89 const Cond_lim& la_cl = zclPolyMAC_HFV.les_conditions_limites(n_bord);
90 if (sub_type(Neumann_sortie_libre, la_cl.valeur()))
91 {
92 const Neumann_sortie_libre& la_cl_typee = ref_cast(Neumann_sortie_libre, la_cl.valeur());
93 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
94 ndeb = le_bord.num_premiere_face();
95 nfin = ndeb + le_bord.nb_faces();
96
97 for (num_face = ndeb; num_face < nfin; num_face++)
98 {
99 double P_imp = la_cl_typee.flux_impose(num_face - ndeb);
100 n0 = face_voisins(num_face, 0);
101 if (n0 != -1)
102 {
103 coef = face_surfaces(num_face) * porosite_surf(num_face);
104 resu(num_face) += (coef * (P_imp - inco(n0)));
105 }
106 else
107 {
108 n1 = face_voisins(num_face, 1);
109 coef = face_surfaces(num_face) * porosite_surf(num_face);
110 resu(num_face) += (coef * (inco(n1) - P_imp));
111 }
112 }
113 }
114 // Fin de la boucle for
115 }
116
117 // Boucle sur les faces internes
118 for (num_face = zPolyMAC_HFV.premiere_face_int(); num_face < zPolyMAC_HFV.nb_faces(); num_face++)
119 {
120 n0 = face_voisins(num_face, 0);
121 n1 = face_voisins(num_face, 1);
122 coef = face_surfaces(num_face) * porosite_surf(num_face);
123 resu(num_face) += coef * (inco(n1) - inco(n0));
124 }
126 return resu;
127}
128
129DoubleTab& Op_Grad_PolyMAC_CDO_Face::calculer(const DoubleTab& inco, DoubleTab& resu) const
130{
131 resu = 0.;
132 return ajouter(inco, resu);
133}
134
135void Op_Grad_PolyMAC_CDO_Face::contribuer_a_avec(const DoubleTab& inco, Matrice_Morse& la_matrice) const
136{
138 {
140 return;
141 }
142
143 assert_espace_virtuel_vect(inco);
144 const Domaine_PolyMAC_CDO& zPolyMAC_HFV = ref_domaine.valeur();
145 const Domaine_Cl_PolyMAC_family& zclPolyMAC_HFV = ref_dcl.valeur();
146 const DoubleVect& face_surfaces = zPolyMAC_HFV.face_surfaces();
147
148 double coef;
149 int n0, n1;
150
151 // Boucle sur les bords pour traiter les conditions aux limites
152 int ndeb, nfin, num_face;
153 for (int n_bord = 0; n_bord < zPolyMAC_HFV.nb_front_Cl(); n_bord++)
154 {
155
156 // pour chaque Condition Limite on regarde son type
157 // Si face de Dirichlet ou de Symetrie on ne fait rien
158 // Si face de Neumann on calcule la contribution au terme source
159
160 const Cond_lim& la_cl = zclPolyMAC_HFV.les_conditions_limites(n_bord);
161 if (sub_type(Neumann_sortie_libre, la_cl.valeur()))
162 {
163 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
164 ndeb = le_bord.num_premiere_face();
165 nfin = ndeb + le_bord.nb_faces();
166
167 for (num_face = ndeb; num_face < nfin; num_face++)
168 {
169 n0 = face_voisins(num_face, 0);
170 if (n0 != -1)
171 {
172 coef = face_surfaces(num_face) * porosite_surf(num_face);
173 la_matrice(num_face, n0) += coef;
174 }
175 else
176 {
177 n1 = face_voisins(num_face, 1);
178 coef = face_surfaces(num_face) * porosite_surf(num_face);
179 la_matrice(num_face, n1) -= coef;
180 }
181 }
182 }
183 // Fin de la boucle for
184 }
185
186 // Boucle sur les faces internes
187 for (num_face = zPolyMAC_HFV.premiere_face_int(); num_face < zPolyMAC_HFV.nb_faces(); num_face++)
188 {
189 n0 = face_voisins(num_face, 0);
190 n1 = face_voisins(num_face, 1);
191 coef = face_surfaces(num_face) * porosite_surf(num_face);
192 la_matrice(num_face, n0) += coef;
193 la_matrice(num_face, n1) -= coef;
194 }
195}
196
198{
199 return 0;
200}
Classe Champ_Inc_base.
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.
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
renvoie le nombre global de faces.
Definition Domaine_VF.h:471
int nb_faces_tot() const
renvoie le nombre total de faces.
Definition Domaine_VF.h:481
int premiere_face_int() const
une face est interne ssi elle separe deux elements.
Definition Domaine_VF.h:463
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.
int nb_elem_tot() const
int nb_front_Cl() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
static void allocate_morse_matrix(const int nb_lines, const int nb_columns, const Stencil &stencil, Matrice_Morse &matrix, const bool &attach_stencil_to_matrix=false)
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
classe Neumann_sortie_libre Cette classe represente une frontiere ouverte sans vitesse imposee
virtual double flux_impose(int i) const
Renvoie la valeur du flux impose sur la i-eme composante du champ representant le flux a la frontiere...
Definition Neumann.cpp:35
friend class Sortie
Definition Objet_U.h:75
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
class Op_Grad_PolyMAC_CDO_Face
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &) override
void contribuer_a_avec(const DoubleTab &inco, Matrice_Morse &matrice) const override
DOES NOTHING - to override in derived classes.
DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const override
void dimensionner(Matrice_Morse &) const override
DOES NOTHING - to override in derived classes.
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
int impr(Sortie &os) const override
DOES NOTHING - to override in derived classes.
Classe Operateur_Grad_base Cette classe est la base de la hierarchie des operateurs representant.
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const override
DOES NOTHING - to override in derived classes.
DoubleTab & ajouter(const DoubleTab &inco, DoubleTab &secmem) const override
void dimensionner(Matrice_Morse &) const override
DOES NOTHING - to override in derived classes.
virtual int has_interface_blocs() const
Classe de base des flux de sortie.
Definition Sortie.h:52
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")