TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Dift_Multiphase_proto.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_Dift_Multiphase_proto.h>
17#include <Transport_turbulent_base.h>
18#include <Convection_Diffusion_std.h>
19#include <Pb_Multiphase.h>
20#include <Discret_Thyd.h>
21
23{
24 pbm_ = pb;
25 le_chmp_compris_ = ch;
26
27 if (!sub_type(Pb_Multiphase, pbm_.valeur())) is_pbm_ = false;
28}
29
30void Op_Dift_Multiphase_proto::ajout_champs_(const bool is_face)
31{
32 /*
33 * The correlations provide nu_turb and lambda_turb
34 */
35 const int nb_phases = is_pbm_ ? ref_cast(Pb_Multiphase, pbm_.valeur()).nb_phases() : 1;
36 noms_nu_ou_lambda_turb_post_.dimensionner(nb_phases);
37 nu_ou_lambda_turb_post_.resize(nb_phases);
38
39 for (int i = 0; i < nb_phases; i++)
40 noms_nu_ou_lambda_turb_post_[i] = is_face ? (is_pbm_ ? Nom("nu_turbulente_") + ref_cast(Pb_Multiphase, pbm_.valeur()).nom_phase(i) : Nom("nu_turbulente")) :
41 (is_pbm_ ? Nom("conductivite_turbulente_") + ref_cast(Pb_Multiphase, pbm_.valeur()).nom_phase(i) : Nom("conductivite_turbulente"));
42
43 /*
44 * We recompute mu_turb and alpha_turb
45 */
46 noms_mu_ou_alpha_turb_post_.dimensionner(nb_phases);
47 mu_ou_alpha_turb_post_.resize(nb_phases);
48
49 for (int i = 0; i < nb_phases; i++)
50 noms_mu_ou_alpha_turb_post_[i] = is_face ? (is_pbm_ ? Nom("mu_turbulente_") + ref_cast(Pb_Multiphase, pbm_.valeur()).nom_phase(i) : Nom("mu_turbulente")) :
51 (is_pbm_ ? Nom("diffusivite_turbulente_") + ref_cast(Pb_Multiphase, pbm_.valeur()).nom_phase(i) : Nom("diffusivite_turbulente"));
52}
53
55{
56 Noms noms_compris;
57 const int nb_phases = is_pbm_ ? ref_cast(Pb_Multiphase, pbm_.valeur()).nb_phases() : 1;
58 for (int i = 0; i < nb_phases; i++)
59 {
60 noms_compris.add(noms_nu_ou_lambda_turb_post_[i]);
61 noms_compris.add(noms_mu_ou_alpha_turb_post_[i]);
62 }
63
64 if (opt == DESCRIPTION)
65 Cerr << classe << " : " << noms_compris << finl;
66 else
67 nom.add(noms_compris);
68}
69
70void Op_Dift_Multiphase_proto::creer_champ_(const Motcle& motlu, const bool is_face)
71{
72 /*
73 * The correlations provide nu_turb and lambda_turb
74 */
76 if (i >= 0 && !nu_ou_lambda_turb_post_[i])
77 {
78 const Discret_Thyd& dis = ref_cast(Discret_Thyd, pbm_->discretisation());
79 Noms noms(1), unites(1);
81 dis.discretiser_champ("CHAMP_ELEM", pbm_->domaine_dis(), scalaire, noms, unites, 1, 0, nu_ou_lambda_turb_post_[i]);
82 le_chmp_compris_->ajoute_champ(nu_ou_lambda_turb_post_[i]);
83 }
84
85 /*
86 * We recompute mu_turb and alpha_turb
87 */
88 i = noms_mu_ou_alpha_turb_post_.rang(motlu);
89 if (i >= 0 && !mu_ou_alpha_turb_post_[i])
90 {
91 const Discret_Thyd& dis = ref_cast(Discret_Thyd, pbm_->discretisation());
92 Noms noms(1), unites(1);
93 noms[0] = noms_mu_ou_alpha_turb_post_[i];
94 dis.discretiser_champ("CHAMP_ELEM", pbm_->domaine_dis(), scalaire, noms, unites, 1, 0, mu_ou_alpha_turb_post_[i]);
95 le_chmp_compris_->ajoute_champ(mu_ou_alpha_turb_post_[i]);
96 }
97}
98
99void Op_Dift_Multiphase_proto::completer_(const Operateur_Diff_base& op,const bool is_face)
100{
101 //if the correlation needs the gradient of u, we must create it now
102 if (is_face)
103 {
104 if (corr_ && ref_cast(Viscosite_turbulente_base, corr_.valeur()).gradu_required())
105 pbm_->creer_champ("gradient_vitesse");
106 }
107 else
108 {
109 if (corr_ && ref_cast(Transport_turbulent_base, corr_.valeur()).gradu_required())
110 pbm_->creer_champ("gradient_vitesse");
111 }
112
113 if (corr_)
114 corr_->completer();
115
116 const int N = op.equation().inconnue().valeurs().line_size();
117 nu_ou_lambda_turb_.resize(0, N);
118 const Domaine_VF& dvf = ref_cast(Domaine_VF, op.equation().domaine_dis());
121}
122
123void Op_Dift_Multiphase_proto::mettre_a_jour_(const double temps, const bool is_face)
124{
125 const int N = is_pbm_ ? ref_cast(Pb_Multiphase, pbm_.valeur()).nb_phases() : 1;
126 for (int n = 0; n < N; n++)
127 {
128 /*
129 * The correlations provide nu_turb and lambda_turb
130 */
131 if (nu_ou_lambda_turb_post_[n]) // turbulent viscosity/diffusivity: always scalar
132 {
133 DoubleTab& val = nu_ou_lambda_turb_post_[n]->valeurs();
134 const int nl = val.dimension(0);
135 for (int i = 0; i < nl; i++)
136 val(i, 0) = nu_ou_lambda_turb_(i, n);
137
138 nu_ou_lambda_turb_post_[n]->mettre_a_jour(temps);
139 }
140
141 /*
142 * We recompute mu_turb and alpha_turb
143 */
144 if (mu_ou_alpha_turb_post_[n]) // turbulent viscosity/diffusivity: always scalar
145 {
146 DoubleTab& val = mu_ou_alpha_turb_post_[n]->valeurs();
147 const DoubleTab& rho = pbm_->milieu().masse_volumique().passe();
148 const int nl = val.dimension(0), cR = (rho.dimension(0) == 1);
149 if (is_face)
150 {
151 for (int i = 0; i < nl; i++)
152 val(i, 0) = rho(!cR * i, n) * nu_ou_lambda_turb_(i, n);
153 }
154 else
155 {
156 const DoubleTab& cp = pbm_->milieu().capacite_calorifique().passe();
157 const int cCp = (cp.dimension(0) == 1);
158 for (int i = 0; i < nl; i++)
159 val(i, 0) = nu_ou_lambda_turb_(i, n) / (rho(!cR * i, n) * cp(!cCp * i, n));
160 }
161
162 mu_ou_alpha_turb_post_[n]->mettre_a_jour(temps);
163 }
164 }
165}
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Discret_Thyd This class is the base class representing a discretization
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
virtual void creer_tableau_elements(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates a parallel array of values at elements.
Definition Domaine.cpp:850
const Domaine & domaine() const
virtual const Champ_Inc_base & inconnue() const =0
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
A character string (Nom) in uppercase.
Definition Motcle.h:26
int rang(const char *const ch) const
Definition Motcle.cpp:336
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
void associer_proto(const Probleme_base &, Champs_compris &)
void get_noms_champs_postraitables_proto(const Nom &, Noms &nom, Option opt) const
std::vector< OWN_PTR(Champ_Fonc_base)> nu_ou_lambda_turb_post_
std::vector< OWN_PTR(Champ_Fonc_base)> mu_ou_alpha_turb_post_
Operateur_Diff_base This class is the base of the hierarchy of operators representing.
Multiphase thermohydraulics problem of type "3*N equations":
class Probleme_base It is a Probleme_U that is not a coupling.
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67