TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Force_Tchen_PolyMAC_MPFA.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 <Force_Tchen_PolyMAC_MPFA.h>
17#include <Champ_Face_base.h>
18#include <Pb_Multiphase.h>
19
20Implemente_instanciable(Force_Tchen_PolyMAC_MPFA, "Force_Tchen_Face_PolyMAC_MPFA|Tchen_force_Face_PolyMAC_MPFA", Source_Force_Tchen_base);
21
22Sortie& Force_Tchen_PolyMAC_MPFA::printOn(Sortie& os) const { return os; }
24
26{
27 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
28 const DoubleTab& inco = ref_cast(Champ_Face_base, equation().inconnue()).valeurs();
29 int N = inco.line_size(), D = dimension, nf_tot = domaine.nb_faces_tot();
30
31 /* elements */
32 for (int e = 0; e < domaine.nb_elem_tot(); e++)
33 for (int d = 0 ; d <D ; d++)
34 for (int k = 0 ; k<N ; k++)
35 if (k != n_l) //gas phase
36 stencil.append_line( N *(nf_tot + D * e + d) + k , N *(nf_tot + D * e + d) + n_l) ;
37}
38
39void Force_Tchen_PolyMAC_MPFA::ajouter_blocs_aux(matrices_t matrices, DoubleTab& secmem) const
40{
41 const Champ_Face_base& ch = ref_cast(Champ_Face_base, equation().inconnue());
42 Matrice_Morse *mat = matrices.count(ch.le_nom().getString()) ? matrices.at(ch.le_nom().getString()) : nullptr;
43 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
44 const DoubleTab& inco = ch.valeurs(), &pvit = ch.passe(), &alpha = ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe(),
45 &rho = equation().milieu().masse_volumique().passe();
46
47 double pas_tps = equation().probleme().schema_temps().pas_de_temps();
48 int N = inco.line_size(), D = dimension, nf_tot = domaine.nb_faces_tot();
49 const DoubleVect& pe = equation().milieu().porosite_elem(), &ve = domaine.volumes();
50
51 /* elements */
52 for (int e = 0; e < domaine.nb_elem_tot(); e++)
53 for (int d = 0 ; d <D ; d++)
54 for (int k = 0 ; k<N ; k++)
55 if (k != n_l) //gas phase
56 {
57 double fac = pe(e) * ve(e) * alpha(e, k) * rho(e, n_l) ;
58
59 secmem(nf_tot + D * e + d, k ) += fac * (inco(nf_tot + D * e + d, n_l)-pvit(nf_tot + D * e + d, n_l))/pas_tps;
60 secmem(nf_tot + D * e + d,n_l) -= fac * (inco(nf_tot + D * e + d, n_l)-pvit(nf_tot + D * e + d, n_l))/pas_tps;
61 if (mat)
62 {
63 (*mat)( N *(nf_tot + D * e + d) + k , N *(nf_tot + D * e + d) + n_l) -= fac/pas_tps ;
64 (*mat)( N *(nf_tot + D * e + d) + n_l, N *(nf_tot + D * e + d) + n_l) += fac/pas_tps ;
65 }
66 }
67}
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
class Domaine_VF
Definition Domaine_VF.h:44
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
Probleme_base & probleme()
Returns the problem associated with the equation.
const Nom & le_nom() const override
Returns the name of the field.
void dimensionner_blocs_aux(Stencil &) const override
void ajouter_blocs_aux(matrices_t, DoubleTab &) const override
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
const std::string & getString() const
Definition Nom.h:92
static int dimension
Definition Objet_U.h:94
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Multiphase thermohydraulics problem of type "3*N equations":
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
double pas_de_temps() const
Returns the current time step (delta_t).
Base class for output streams.
Definition Sortie.h:52
Tchen force in a multiphase flow.
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
int line_size() const
Definition TRUSTVect.tpp:67