TRUST 1.9.8
HPC thermohydraulic platform
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 * Les correlations donnent nu_turb et 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 * On recalcule mu_turb et 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 * Les correlations donnent nu_turb et 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 * On recalcule mu_turb et 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 //si la correlation a besoin du gradient de u, on doit le creer maintenant
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 * Les correlations donnent nu_turb et lambda_turb
130 */
131 if (nu_ou_lambda_turb_post_[n]) // viscosite/diffusivite turbulente : toujours scalaire
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 * On recalcule mu_turb et alpha_turb
143 */
144 if (mu_ou_alpha_turb_post_[n]) // viscosite/diffusivite turbulente : toujours scalaire
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
Renvoie le tableau des valeurs du champ au temps courant.
classe Discret_Thyd Cette classe est la classe de base representant une discretisation
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
creation d'un tableau parallele de valeurs aux elements.
Definition Domaine.cpp:851
const Domaine & domaine() const
virtual const Champ_Inc_base & inconnue() const =0
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
int rang(const char *const ch) const
Definition Motcle.cpp:338
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Un tableau de chaine de caracteres (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_
classe Operateur_Diff_base Cette classe est la base de la hierarchie des operateurs representant
classe Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67