TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Diff_PolyMAC_MPFA_base.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 <Echange_contact_PolyMAC_MPFA.h>
17#include <Op_Diff_PolyMAC_MPFA_base.h>
18#include <Frottement_impose_base.h>
19#include <Champ_Elem_PolyMAC_MPFA.h>
20#include <Champ_Face_PolyMAC_MPFA.h>
21#include <Champ_Don_Fonc_xyz.h>
22#include <Domaine_Cl_PolyMAC_family.h>
23#include <Aire_interfaciale.h>
24#include <Champ_Uniforme.h>
25#include <Pb_Multiphase.h>
26#include <Milieu_base.h>
27
28Implemente_base(Op_Diff_PolyMAC_MPFA_base, "Op_Diff_PolyMAC_MPFA_base", Op_Diff_PolyMAC_CDO_Gen_base);
29
31
33
35{
37 //if the field is constant in time, no need to recompute nu_ and the interpolations
38 if (t <= t_last_maj_)
39 return;
40
41 if (!nu_constant_)
42 nu_a_jour_ = 0, phif_a_jour_ = 0;
43
44 t_last_maj_ = t;
45}
46
48{
50 const Equation_base& eq = equation();
51 int N = eq.inconnue().valeurs().line_size(), N_mil = eq.milieu().has_masse_volumique() ? eq.milieu().masse_volumique().valeurs().line_size() : N;
52 int N_diff = diffusivite().valeurs().line_size(), D = dimension, N_nu = std::max(N * dimension_min_nu(), N_diff);
53
54 if ((N_nu == N_mil) | (N_nu == N))
55 nu_.resize(0, N); //isotrope
56 else if ((N_nu == N_mil * D) | (N_nu == N * D))
57 nu_.resize(0, N, D); //diagonal
58 else if ((N_nu == N_mil * D * D) | (N_nu == N * D * D))
59 nu_.resize(0, N, D, D); //complet
60 else
61 Process::exit(Nom("Op_Diff_PolyMAC_MPFA_base : diffusivity component count ") + Nom(N_nu) + " not among (" + Nom(N) + ", " + Nom(N * D) + ", " + Nom(N * D * D) + ")!");
62
63 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, le_dom_poly_.valeur());
64 domaine.domaine().creer_tableau_elements(nu_);
67 if (nu_constant_)
68 for (auto &itr : cls)
69 if (sub_type(Echange_impose_base, itr.valeur()) || sub_type(Frottement_impose_base, itr.valeur()))
70 nu_constant_ = 0;
71}
72
74{
75 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, le_dom_poly_.valeur());
76 const DoubleTab& nu_src = diffusivite().valeurs();
77 int e, i, m, n, c_nu = nu_src.dimension_tot(0) == 1, d, db, D = dimension;
78 int N = equation().inconnue().valeurs().line_size(),
80 N_nu = nu_.line_size(), N_nu_src = nu_src.line_size(), mult = N_nu / N;
81 assert(N_nu % N == 0);
82
83 const bool is_aire_int = sub_type(Aire_interfaciale, equation()); /* Aire_interfaciale case: no laminar nu ... */
84
85 if (is_aire_int)
86 {
87 nu_ = 0.;
88 /* modification by a derived class */
90 nu_a_jour_ = 1;
91 return;
92 }
93
94 /* nu_: if necessary, the source field must be extended */
95 if (N_nu == N && N_nu_src == N_mil)
96 for (e = 0; e < domaine.nb_elem_tot(); e++)
97 for (n = 0; n < N; n++)
98 nu_.addr()[N_nu * e + n] = nu_src(!c_nu * e, n); //facile
99 else if (N_nu == N * D && N_nu_src == N_mil)
100 for (e = 0; e < domaine.nb_elem_tot(); e++)
101 for (n = 0; n < N; n++)
102 for (d = 0; d < D; d++) //diagonal
103 nu_(e, n, d) = nu_src(!c_nu * e, n);
104 else if (N_nu == N * D * D && (N_nu_src == N_mil || N_nu_src == N_mil * D))
105 for (e = 0; e < domaine.nb_elem_tot(); e++)
106 for (n = 0; n < N; n++) //complet
107 for (d = 0; d < D; d++)
108 for (db = 0; db < D; db++)
109 nu_(e, n, d, db) = (d == db) * nu_src(!c_nu * e, N_nu_src == N_mil ? n : D * n + d);
110 else
111 abort();
112
113 /* weighting of nu by porosity and by alpha (if pb_Multiphase) */
114 const DoubleTab *alp = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe() : nullptr;
115 for (e = 0; e < domaine.nb_elem_tot(); e++)
116 for (n = 0, i = 0; n < N; n++)
117 for (m = 0; m < mult; m++, i++)
118 nu_.addr()[N_nu * e + i] *= equation().milieu().porosite_elem()(e) * (alp ? std::max((*alp)(e, n), 1e-8) : 1);
119
120 /* modification by a derived class */
122
123 nu_a_jour_ = 1;
124}
125
126void Op_Diff_PolyMAC_MPFA_base::update_phif(int full_stencil) const
127{
128 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, le_dom_poly_.valeur());
129 if (!domaine.domaine().mesh_update_required() && !full_stencil && phif_a_jour_)
130 return; //already done, unless the full stencil is requested
131 const Champ_Inc_base& ch = equation().inconnue();
132 const IntTab& fcl = sub_type(Champ_Face_PolyMAC_MPFA, ch) ? ref_cast(Champ_Face_PolyMAC_MPFA, ch).fcl() : ref_cast(Champ_Elem_PolyMAC_MPFA, ch).fcl();
133 domaine.fgrad(ch.valeurs().line_size(), 0, la_zcl_poly_->les_conditions_limites(), fcl, &nu(), &som_ext, sub_type(Champ_Face_PolyMAC_MPFA, ch), full_stencil, phif_d, phif_e, phif_c);
134 phif_a_jour_ = 1;
135}
Transport equation for the interfacial area.
class Champ_Don_Fonc_xyz This class represents a data field that is a function
: class Champ_Elem_PolyMAC_MPFA
: class Champ_Face_PolyMAC_MPFA
Class Champ_Inc_base.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
Echange_impose_base: This boundary condition is used only for the energy equation.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Classe Frottement_impose_base Base class for Navier-type boundary conditions (v.
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
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
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
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
class Op_Diff_PolyMAC_CDO_Gen_base
virtual void modifier_mu(DoubleTab &) const
const Champ_base & diffusivite() const override
class Op_Diff_PolyMAC_MPFA_base
void completer() override
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
void update_phif(int full_stencil=0) const
void mettre_a_jour(double t) override
DOES NOTHING - to override in derived classes.
virtual void mettre_a_jour(double temps)
DOES NOTHING - to override in derived classes.
virtual void completer()
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
Multiphase thermohydraulics problem of type "3*N equations":
static void abort()
Abort routine for TRUST on a fatal error.
Definition Process.cpp:573
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67