TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Qdm_Face_PolyMAC_HFV.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 <Terme_Source_Qdm_Face_PolyMAC_HFV.h>
17#include <Op_Grad_PolyMAC_HFV_Face.h>
18#include <Champ_Face_PolyMAC_HFV.h>
19#include <Domaine_PolyMAC_HFV.h>
20#include <Discretisation_base.h>
21#include <Domaine_PolyMAC_MPFA.h>
22#include <Domaine_Cl_PolyMAC_family.h>
23#include <Champ_Uniforme.h>
24
25#include <Equation_base.h>
26#include <Pb_Multiphase.h>
27#include <Milieu_base.h>
28
29Implemente_instanciable(Terme_Source_Qdm_Face_PolyMAC_HFV, "Source_Qdm_face_PolyMAC_HFV|Source_Qdm_face_PolyMAC_MPFA", Terme_Source_Qdm_Face_PolyMAC_CDO);
30
32
34
35void Terme_Source_Qdm_Face_PolyMAC_HFV::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
36{
37 const Domaine_Poly_base& domaine = ref_cast(Domaine_Poly_base, equation().domaine_dis());
38 const Champ_Face_PolyMAC_HFV& ch = ref_cast(Champ_Face_PolyMAC_HFV, equation().inconnue());
39 const DoubleTab& vals = la_source->valeurs(), &vfd = domaine.volumes_entrelaces_dir(), *rho = equation().milieu().has_masse_volumique() ? &equation().milieu().masse_volumique().passe() : nullptr, &nf = domaine.face_normales(),
40 *alp = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe() : nullptr;
41 const DoubleVect& pe = equation().milieu().porosite_elem(), &ve = domaine.volumes(), &pf = equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces(),
42 &fs = domaine.face_surfaces();
43 const IntTab& f_e = domaine.face_voisins(), &fcl = ch.fcl();
44 int e, f, i, cS = (vals.dimension_tot(0) == 1), cR = rho ? (*rho).dimension_tot(0) == 1 : 0, nf_tot = domaine.nb_faces_tot(), n, N = equation().inconnue().valeurs().line_size(), d,
45 D = dimension, calc_cl = !sub_type(Domaine_PolyMAC_MPFA, domaine); //en PolyMAC_HFV V1, on calcule aux CL
46
47 /* contributions aux faces (par chaque voisin), aux elems */
48 DoubleTrav a_f(N), rho_m(2);
49 for (a_f = 1, f = 0; f < domaine.nb_faces(); f++)
50 if (!fcl(f, 0)) //face interne
51 {
52 if (1)
53 {
54 for (i = 0; i < 2; i++)
55 for (e = f_e(f, i), n = 0; n < N; n++)
56 for (d = 0; d < D; d++)
57 secmem(f, n) += vfd(f, i) * pf(f) * (alp ? (*alp)(e, n) * (*rho)(!cR * e, n) : 1) * nf(f, d) / fs(f) * vals(!cS * e, N * d + n);
58 }
59
60 if (0)
61 {
62 if (alp)
63 for (a_f = 0, i = 0; i < 2; i++)
64 for (e = f_e(f, i), n = 0; n < N; n++)
65 a_f(n) += vfd(f, i) / vf(f) * (*alp)(e, n);
66 for (rho_m = 0, i = 0; i < 2; i++)
67 for (e = f_e(f, i), n = 0; n < N; n++)
68 rho_m(i) += (alp ? (*alp)(e, n) : 1) * (*rho)(!cR * e, n);
69 for (i = 0; i < 2; i++)
70 for (e = f_e(f, i), n = 0; n < N; n++)
71 {
72 double vnf = 0;
73 for (d = 0; d < D; d++)
74 vnf += nf(f, d) / fs(f) * vals(!cS * e, N * d + n);
75 int strat = (i ? 1 : -1) * (rho_m(i) - (*rho)(!cR * e, n)) * vnf > 0;
76 double R = alp && strat ? ((*alp)(e, n) < 1e-4 ? 1 : 0) /* min(max(1 - (*alp)(e, n) / 1e-4, 0.), 1.) */: 0;
77 secmem(f, n) += vfd(f, i) * pf(f) * a_f(n) * (R * rho_m(i) + (1 - R) * (*rho)(!cR * e, n)) * vnf;
78 }
79 }
80 }
81 else if (calc_cl || fcl(f, 0) < 2)
82 for (e = f_e(f, 0), n = 0; n < N; n++)
83 for (d = 0; d < D; d++) //face de bord non imposee -> avec le (alpha rho) de la maille
84 secmem(f, n) += pf(f) * vf(f) * (alp ? (*alp)(e, n) * (*rho)(!cR * e, n) : 1) * nf(f, d) / fs(f) * vals(!cS * e, N * d + n);
85
86 /* en PolyMAC_CDO V2 : partie aux elements */
87 if (sub_type(Domaine_PolyMAC_MPFA, domaine))
88 for (e = 0; e < domaine.nb_elem_tot(); e++)
89 for (d = 0; d < D; d++)
90 for (n = 0; n < N; n++)
91 secmem(nf_tot + D * e + d, n) += pe(e) * ve(e) * (alp ? (*rho)(!cR * e, n) * (*alp)(e, n) : 1) * vals(!cS * e, N * d + n);
92}
93
95{
96 equation().discretisation().nommer_completer_champ_physique(equation().domaine_dis(), "source_qdm", "", la_source.valeur(), equation().probleme());
97 la_source->initialiser(temps);
98 return Source_base::initialiser(temps);
99}
: class Champ_Face_PolyMAC_HFV
const IntTab & fcl() const
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
void nommer_completer_champ_physique(const Domaine_dis_base &domaine_vdf, const Nom &nom_champ, const Nom &unite, Champ_base &champ, const Probleme_base &pbi) const
class Domaine_Poly_base
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
const Discretisation_base & discretisation() const
Renvoie la discretisation associee a l'equation.
virtual const Champ_Inc_base & inconnue() const =0
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
bool has_masse_volumique() const
Definition Milieu_base.h:92
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
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
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 Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
Classe de base des flux de sortie.
Definition Sortie.h:52
virtual int initialiser(double temps)
Contrairement aux methodes mettre_a_jour, les methodes initialiser des sources ne peuvent pas dependr...
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67
int initialiser(double temps) override
Contrairement aux methodes mettre_a_jour, les methodes initialiser des sources ne peuvent pas dependr...
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override