TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Conv_Amont_VPoly_VDF_Face.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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_Conv_Amont_VPoly_VDF_Face.h>
17#include <Masse_ajoutee_base.h>
18
19Implemente_instanciable_sans_constructeur(Op_Conv_Amont_VPoly_VDF_Face,"Op_Conv_Amont_VPoly_VDF_Face",Op_Conv_Amont_VDF_Face);
20
23
24void Op_Conv_Amont_VPoly_VDF_Face::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
25{
26 const Domaine_VDF& domaine = iter_->domaine();
27 // okok je sais ... tgv
28 DoubleTab& tab_flux_bords = flux_bords();
29 tab_flux_bords.resize(domaine.nb_faces_bord(), dimension);
30 tab_flux_bords = 0.;
31
32 const Champ_Face_VDF& ch = ref_cast(Champ_Face_VDF, equation().inconnue());
33 const Conds_lim& cls = iter_->domaine_Cl().les_conditions_limites();
34 const IntTab& f_e = domaine.face_voisins(), &e_f = domaine.elem_faces(), &fcl = ch.fcl();
35 const DoubleTab& vit = ch.passe(), &vfd = domaine.volumes_entrelaces_dir();
36 const DoubleVect& fs = domaine.face_surfaces(), &pe = equation().milieu().porosite_elem(), &ve = domaine.volumes();
37
38 /* a_r : produit alpha_rho si Pb_Multiphase -> par semi_implicite, ou en recuperant le champ_conserve de l'equation de masse */
39 const std::string& nom_inco = ch.le_nom().getString();
40 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()) : nullptr;
41 const Masse_ajoutee_base *corr = pbm && pbm->has_correlation("masse_ajoutee") ? &ref_cast(Masse_ajoutee_base, pbm->get_correlation("masse_ajoutee")) : nullptr;
42 const DoubleTab& inco = semi_impl.count(nom_inco) ? semi_impl.at(nom_inco) : ch.valeurs(),
43 *a_r = !pbm ? nullptr : semi_impl.count("alpha_rho") ? &semi_impl.at("alpha_rho") : &pbm->equation_masse().champ_conserve().valeurs(),
44 *alp = pbm ? &pbm->equation_masse().inconnue().passe() : nullptr,
45 &rho = equation().milieu().masse_volumique().passe();
46 Matrice_Morse *mat = matrices.count(nom_inco) && !semi_impl.count(nom_inco) ? matrices.at(nom_inco) : nullptr;
47
48 int i, j, k, e = -100, eb, f, fb, fd, m, n, N = inco.line_size(), d, D = dimension, comp = !incompressible_;
49
50 DoubleTrav dfac(2, N, N), masse(N, N);
51 for (f = 0; f < domaine.nb_faces_tot(); f++)
52 {
53 const bool is_interne = (f_e(f, 0) >= 0 && f_e(f, 1) >= 0);
54 const bool is_bord = ((f_e(f, 0) >= 0 && f_e(f, 1) < 0) || (f_e(f, 0) < 0 && f_e(f, 1) >= 0));
55 const bool is_neum_or_diric = (fcl(f, 0) == 1 || fcl(f, 0) == 3);
56
57 if (is_interne || (is_bord && is_neum_or_diric))
58 {
59 // etape 1 : masse + dfac
60 if (f_e(f, 0) < 0)
61 {
62 for (i = 1, dfac = 0; i >= 0; i--)
63 {
64 //masse : diagonale
65 for (masse = 0, e = f_e(f, f_e(f, i) >= 0 ? i : !i), n = 0; n < N; n++)
66 masse(n, n) = a_r ? (*a_r)(e, n) : 1;
67
68 // masse ajoutee si correlation
69 if (corr)
70 corr->ajouter(&(*alp)(e, 0), &rho(e, 0), masse);
71
72 //contribution a dfac
73 for (n = 0; n < N; n++)
74 {
75 e = f_e(f, i);
76 eb = e;
77 for (m = 0; m < N; m++)
78 {
79 const int ind = fcl(f, 0) == 1 ? 0 : i;
80 const int ind_por = eb >= 0 ? eb : f_e(f, f_e(f, i) >= 0 ? i : !i);
81 double dd = (vit(f, m) * (i ? -1 : 1) >= 0 ? 1. : vit(f, m) ? -1. : 0.);
82
83 dfac(ind, n, m) += fs(f) * vit(f, m) * pe(ind_por) * masse(n, m) * (1. + dd) / 2;
84 }
85 }
86 }
87 }
88 else
89 {
90 for (i = 0, dfac = 0; i < 2; i++)
91 {
92 //masse : diagonale
93 for (masse = 0, e = f_e(f, f_e(f, i) >= 0 ? i : !i), n = 0; n < N; n++)
94 masse(n, n) = a_r ? (*a_r)(e, n) : 1;
95
96 // masse ajoutee si correlation
97 if (corr)
98 corr->ajouter(&(*alp)(e, 0), &rho(e, 0), masse);
99
100 //contribution a dfac
101 for (n = 0; n < N; n++)
102 {
103 e = f_e(f, i);
104 eb = e;
105 for (m = 0; m < N; m++)
106 {
107 const int ind = fcl(f, 0) == 1 ? (f_e(f, 0) >= 0 ? 0 : 1) : i;
108 const int ind_por = eb >= 0 ? eb : f_e(f, f_e(f, i) >= 0 ? i : !i);
109 double dd = (vit(f, m) * (i ? -1 : 1) >= 0 ? 1. : vit(f, m) ? -1. : 0.);
110
111 dfac(ind, n, m) += fs(f) * vit(f, m) * pe(ind_por) * masse(n, m) * (1. + dd) / 2;
112 }
113 }
114 }
115 }
116
117 // etape 2 : secmem + derivee
118 for (i = 0; i < 2; i++)
119 if ((e = f_e(f, i)) >= 0)
120 {
121 for (k = 0; k < e_f.dimension(1); k++)
122 {
123 fb = e_f(e, k);
124 if (fb >= 0 && (domaine.orientation(fb) == domaine.orientation(f)))
125 if (fb < domaine.nb_faces())
126 if (f_e(f, i == 0 ? 1 : 0) < 0 || (f_e(f, 0) >= 0 && f_e(f, 1) >= 0))
127 {
128 if (f_e(f, 0) < 0)
129 for (j = 1; j >= 0; j--) //equivalence : face fd -> face fb
130 {
131 eb = f_e(f, j), fd = (j == i ? fb : domaine.face_amont_princ(fb, j) /* face */); //element/face sources
132
133 for (n = 0; n < N; n++)
134 for (m = 0; m < N; m++)
135 if (dfac(!j, n, m))
136 {
137 // secmem
138 double fac = (i ? -1 : 1) * vfd(fb, e != f_e(fb, 0)) * dfac(!j, n, m) / ve(e);
139 if (f_e(fb, 0) < 0)
140 fac *= 0.5;
141 if (fd >= 0)
142 secmem(fb, n) -= fac * inco(fd, m); //autre face calculee
143 else
144 {
145 for (d = 0; d < D; d++) //CL de Dirichlet
146 {
147 if (sub_type(Dirichlet, cls[fcl(f, 1)].valeur()))
148 throw;
149 secmem(fb, n) -= 0; //fac * domaine.face_normales(fb, d) / fs(fb) * ref_cast(Dirichlet, cls[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), N * d + m);
150 }
151 }
152
153 // si compressible :partie v div(alpha rho v)
154 if (comp)
155 secmem(fb, n) += fac * inco(fb, m);
156
157 // derivee
158 if (mat)
159 {
160 if (fd >= 0)
161 (*mat)(N * fb + n, N * fd + m) += fac;
162 if (comp)
163 (*mat)(N * fb + n, N * fb + m) -= fac;
164 }
165 }
166 }
167 else
168 for (j = 0; j < 2; j++) //equivalence : face fd -> face fb
169 {
170 eb = f_e(f, j), fd = (j == i ? fb : domaine.face_amont_princ(fb, j) /* face */); //element/face sources
171
172 for (n = 0; n < N; n++)
173 for (m = 0; m < N; m++)
174 if (dfac(j, n, m))
175 {
176 // secmem
177 double fac = (i ? -1 : 1) * vfd(fb, e != f_e(fb, 0)) * dfac(j, n, m) / ve(e);
178 if (f_e(fb, 0) < 0)
179 fac *= 0.5;
180 if (fd >= 0)
181 secmem(fb, n) -= fac * inco(fd, m); //autre face calculee
182 else
183 {
184 for (d = 0; d < D; d++) //CL de Dirichlet
185 {
186 if (sub_type(Dirichlet, cls[fcl(f, 1)].valeur()))
187 throw;
188 secmem(fb, n) -= 0; //fac * domaine.face_normales(fb, d) / fs(fb) * ref_cast(Dirichlet, cls[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), N * d + m);
189 }
190 }
191
192 // si compressible :partie v div(alpha rho v)
193 if (comp)
194 secmem(fb, n) += fac * inco(fb, m);
195
196 // derivee
197 if (mat)
198 {
199 if (fd >= 0)
200 (*mat)(N * fb + n, N * fd + m) += fac;
201 if (comp)
202 (*mat)(N * fb + n, N * fb + m) -= fac;
203 }
204 }
205 }
206 }
207
208 }
209 }
210 }
211 }
212}
213
class Champ_Face_VDF Cette classe sert a representer un champ vectoriel dont on ne calcule
const IntTab & fcl() const
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
classe Conds_lim Cette classe represente un vecteur de conditions aux limites.
Definition Conds_lim.h:32
classe Dirichlet Cette classe est la classe de base de la hierarchie des conditions aux limites de ty...
Definition Dirichlet.h:31
class Domaine_VDF
Definition Domaine_VDF.h:64
const Domaine & domaine() const
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
Champ_Inc_base & champ_conserve() const
virtual const Champ_Inc_base & inconnue() const =0
const Nom & le_nom() const override
Renvoie le nom du champ.
classe Masse_ajoutee_base masse ajoutee de la forme
virtual void ajouter(const double *alpha, const double *rho, DoubleTab &a_r) const =0
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
const std::string & getString() const
Definition Nom.h:92
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
class Op_Conv_Amont_VDF_Face Cette classe represente l'operateur de convection associe a une equation...
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
DoubleTab & flux_bords()
classe Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
virtual Equation_base & equation_masse()
int has_correlation(std::string nom_correlation) const
const Correlation_base & get_correlation(std::string nom_correlation) const
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
int line_size() const
Definition TRUSTVect.tpp:67