TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Grad_PolyMAC_HFV_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_HFV_Face.h>
17#include <Champ_Elem_PolyMAC_HFV.h>
18#include <Masse_PolyMAC_HFV_Face.h>
19#include <Champ_Face_PolyMAC_HFV.h>
20#include <Check_espace_virtuel.h>
21#include <Neumann_sortie_libre.h>
22#include <Domaine_Cl_PolyMAC_family.h>
23#include <Schema_Temps_base.h>
24#include <Navier_Stokes_std.h>
25#include <Probleme_base.h>
26#include <Pb_Multiphase.h>
27#include <Matrix_tools.h>
28#include <Array_tools.h>
29#include <Milieu_base.h>
30#include <Dirichlet.h>
31#include <TRUSTTrav.h>
32#include <cfloat>
33#include <Perf_counters.h>
34
35Implemente_instanciable(Op_Grad_PolyMAC_HFV_Face, "Op_Grad_PolyMAC_HFV_Face", Op_Grad_PolyMAC_CDO_Face);
36
38
40
42{
44 const Domaine_PolyMAC_HFV& domaine = ref_cast(Domaine_PolyMAC_HFV, ref_domaine.valeur());
45
46 /* initialisation des inconnues auxiliaires de la pression... */
47 ref_cast(Champ_Elem_PolyMAC_HFV, ref_cast(Navier_Stokes_std, equation()).pression()).init_auxiliary_variables();
48
49 /* et de grad P si la vitesse en a */
50 if (equation().inconnue().valeurs().get_md_vector() == domaine.mdv_faces_aretes)
51 if (ref_cast(Navier_Stokes_std, equation()).has_grad_P())
52 ref_cast(Champ_Face_PolyMAC_HFV, ref_cast(Navier_Stokes_std, equation()).grad_P()).init_auxiliary_variables();
53
54 /* besoin d'un joint de 1 */
55 if (domaine.domaine().nb_joints() && domaine.domaine().joint(0).epaisseur() < 1)
56 {
57 Cerr << "Op_Grad_PolyMAC_HFV_Face : largeur de joint insuffisante (minimum 1)!" << finl;
59 }
60}
61
62void Op_Grad_PolyMAC_HFV_Face::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
63{
64 if (!matrices.count("pression")) return; //rien a faire
65
66 const Domaine_PolyMAC_HFV& domaine = ref_cast(Domaine_PolyMAC_HFV, ref_domaine.valeur());
67 const Champ_Face_PolyMAC_HFV& ch = ref_cast(Champ_Face_PolyMAC_HFV, equation().inconnue());
68 const IntTab& e_f = domaine.elem_faces(), &fcl = ch.fcl();
69 const DoubleTab& vit = ch.valeurs(), &press = ref_cast(Navier_Stokes_std, equation()).pression().valeurs();
70 const int ne_tot = domaine.nb_elem_tot(), N = vit.line_size(), M = press.line_size();
71 Matrice_Morse *mat = matrices["pression"], mat2;
72 Stencil sten(0, 2);
73 DoubleTrav w2;
74
75 for (int e = 0; e < ne_tot; e++)
76 {
77 domaine.W2(nullptr, e, w2);
78
79 for (int i = 0; i < w2.dimension(0); i++)
80 {
81 const int f = e_f(e, i);
82
83 if (f < domaine.nb_faces()) /* faces reelles seulement */
84 {
85 int m = 0;
86 for (int n = 0; n < N; n++, m += (M > 1))
87 sten.append_line(N * f + n, M * e + m); /* bloc (face, elem )*/
88
89 for (int j = 0; j < w2.dimension(1); j++)
90 {
91 const int fb = e_f(e, j);
92 if (fcl(fb, 0) != 1 && w2(i, j, 0)) /* bloc (face, face) */
93 {
94 m = 0;
95 for (int n = 0; n < N; n++, m += (M > 1))
96 sten.append_line(N * f + n, M * (ne_tot + fb) + m);
97 }
98 }
99 }
100 }
101 }
102
103 /* allocation / remplissage */
104 tableau_trier_retirer_doublons(sten);
105 Matrix_tools::allocate_morse_matrix(vit.size_totale(), press.size_totale(), sten, mat2);
106
107 if (mat->nb_colonnes())
108 *mat += mat2;
109 else
110 *mat = mat2;
111}
112
113void Op_Grad_PolyMAC_HFV_Face::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
114{
115 const Domaine_PolyMAC_HFV& domaine = ref_cast(Domaine_PolyMAC_HFV, ref_domaine.valeur());
116 const IntTab& f_e = domaine.face_voisins(), &e_f = domaine.elem_faces(),
117 &fcl = ref_cast(Champ_Face_PolyMAC_HFV, equation().inconnue()).fcl();
118
119 const DoubleTab& vfd = domaine.volumes_entrelaces_dir(),
120 &press = semi_impl.count("pression") ? semi_impl.at("pression") : ref_cast(Navier_Stokes_std, equation()).pression().valeurs(),
121 *alp = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe() : nullptr;
122
123 const DoubleVect& fs = domaine.face_surfaces(), &vf = domaine.volumes_entrelaces(), &pe = equation().milieu().porosite_elem();
124 const int ne_tot = domaine.nb_elem_tot(), N = secmem.line_size(), M = press.line_size();
125
126 Matrice_Morse *mat = !semi_impl.count("pression") && matrices.count("pression") ? matrices.at("pression") : nullptr;
127
128 DoubleTrav w2, alpha(N), coeff_e(N); //matrice W2 dans chaque element, taux de vide a la face
129
130 for (int e = 0; e < ne_tot; e++)
131 {
132 domaine.W2(nullptr, e, w2);
133 for (int i = 0; i < w2.dimension(0); i++)
134 {
135 const int f = e_f(e, i);
136
137 if (f < domaine.nb_faces())
138 {
139 /* taux de vide a la face (identique a celui de Masse_PolyMAC_HFV_Face) */
140 double prefac = (e == f_e(f, 0) ? 1 : -1) * pe(e) * vfd(f, e != f_e(f, 0)) / fs(f); /* ponderation pour elimner p_f si on est en TPFA */
141
142 alpha = 0.;
143
144 for (int j = 0; j < 2; j++)
145 {
146 const int eb = f_e(f, j);
147 if (eb < 0) continue;
148
149 for (int n = 0; n < N; n++)
150 alpha(n) += vfd(f, j) * (alp ? (*alp)(eb, n) : 1) / vf(f);
151 }
152
153 coeff_e = 0.;
154
155 for (int j = 0; j < w2.dimension(1); j++)
156 if (w2(i, j, 0))
157 {
158 const int fb = e_f(e, j);
159 int m = 0;
160
161 for (int n = 0; n < N; n++, m += (M > 1))
162 {
163 const double fac = alpha(n) * w2(i, j, 0) * prefac;
164 secmem(f, n) -= fac * (press(ne_tot + fb, m) - press(e, m));
165
166 if (mat && fcl(fb, 0) != 1)
167 (*mat)(N * f + n, M * (ne_tot + fb) + m) += fac; /* bloc (face, face) */
168
169 coeff_e(n) += fac;
170 }
171 }
172
173 if (mat)
174 {
175 int m = 0;
176 for (int n = 0; n < N; n++, m += (M > 1))
177 (*mat)(N * f + n, M * e + m) -= coeff_e(n); /* bloc (face, elem) */
178 }
179 }
180 }
181 }
182}
: class Champ_Elem_PolyMAC_HFV
: class Champ_Face_PolyMAC_HFV
const IntTab & fcl() const
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
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
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
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)
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
classe Navier_Stokes_std Cette classe porte les termes de l'equation de la dynamique
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
class Op_Grad_PolyMAC_HFV_Face
void completer() override
Associe l'operateur au domaine_dis, le domaine_Cl_dis, et a l'inconnue de son equation.
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={ }) const override
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={ }) const override
virtual void completer()
Associe l'operateur au domaine_dis, le domaine_Cl_dis, et a l'inconnue de son equation.
classe Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
int line_size() const
Definition TRUSTVect.tpp:67