TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Loi_paroi_Ramstorfer.cpp
1/****************************************************************************
2* Copyright (c) 2021, 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 <Loi_paroi_Ramstorfer.h>
17#include <Correlation_base.h>
18#include <Pb_Multiphase.h>
19#include <QDM_Multiphase.h>
20#include <Navier_Stokes_std.h>
21#include <Domaine_Poly_base.h>
22#include <TRUSTTrav.h>
23#include <Cond_lim_base.h>
24#include <Param.h>
25#include <math.h>
26#include <Nom.h>
27#include <Motcle.h>
28#include <TRUSTTab_parts.h>
29#include <Champ_Face_base.h>
30
31Implemente_instanciable(Loi_paroi_Ramstorfer, "Loi_paroi_Ramstorfer", Loi_paroi_base);
32
34{
35 return os;
36}
37
39{
40 return Loi_paroi_base::readOn(is);
41}
42
44{
46
47 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, pb_.valeur()) ? &ref_cast(Pb_Multiphase, pb_.valeur()) : nullptr;
48 if (!pbm || pbm->nb_phases() == 1)
49 Process::exit(que_suis_je() + " : This is a two-phase wall law!");
50
51 const DoubleTab * d_bulles = (pb_->has_champ("diametre_bulles")) ? &pb_->get_champ("diametre_bulles").valeurs() : nullptr ;
52 if (!d_bulles)
53 Process::exit(que_suis_je() + " : you must define a bubble diameter ! This is a two-phase wall law.");
54}
55
56void Loi_paroi_Ramstorfer::calc_y_plus(const DoubleTab& vit, const DoubleTab& nu_visc)
57{
58 const Domaine_VF& domaine = ref_cast(Domaine_VF, pb_->domaine_dis());
59 DoubleTab& u_t = valeurs_loi_paroi_["u_tau"];
60 DoubleTab& y_p = valeurs_loi_paroi_["y_plus"];
61 const DoubleTab& n_f = domaine.face_normales();
62 const DoubleVect& fs = domaine.face_surfaces();
63 const IntTab& f_e = domaine.face_voisins();
64 const DoubleTab& d_bulles = pb_->get_champ("diametre_bulles").valeurs();
65 const DoubleTab& alpha = pb_->get_champ("alpha").valeurs();
66
67 const int nf_tot = domaine.nb_faces_tot();
68 const int D = dimension;
69 const int N = vit.line_size();
70
71 DoubleTab pvit_elem(0, N * dimension);
72 if (nf_tot == vit.dimension_tot(0))
73 {
74 const Champ_Face_base& ch = ref_cast(Champ_Face_base, pb_->equation(0).inconnue());
75 domaine.domaine().creer_tableau_elements(pvit_elem);
76 ch.get_elem_vector_field(pvit_elem, true);
77 }
78
79 int n = 0; // pour l'instant, turbulence dans seulement une phase
80
81 for (int f = 0; f < nf_tot; f ++)
82 if (Faces_a_calculer_(f, 0) == 1)
83 {
84 const int c = (f_e(f,0) >= 0) ? 0 : 1 ;
85 if (f_e(f, (c == 0) ? 1 : 0 ) >= 0)
86 Process::exit("Error in the definition of the boundary conditions for wall laws");
87 const int e = f_e(f,c);
88
89 double u_orth = 0 ;
90 DoubleTrav u_parallel(D);
91 if (nf_tot == vit.dimension_tot(0))
92 {
93 // ! n_f pointe vers la face 1 donc vers l'exterieur de l'element, d'ou le signe -
94 for (int d = 0; d <D ; d++)
95 u_orth -= pvit_elem(e, N*d+n)*n_f(f,d)/fs(f);
96 for (int d = 0 ; d < D ; d++)
97 u_parallel(d) = pvit_elem(e, N*d+n) - u_orth*(-n_f(f,d))/fs(f);
98 }
99 else
100 {
101 // ! n_f pointe vers la face 1 donc vers l'exterieur de l'element, d'ou le signe -
102 for (int d = 0; d <D ; d++)
103 u_orth -= vit(nf_tot + e * D+d, n)*n_f(f,d)/fs(f);
104 for (int d = 0 ; d < D ; d++)
105 u_parallel(d) = vit(nf_tot + e * D + d, n) - u_orth*(-n_f(f,d))/fs(f) ;
106 }
107
108 double residu = 0 ;
109 for (int d = 0; d < D; d++)
110 residu += u_parallel(d)*n_f(f,d)/fs(f);
111 if (residu > 1e-8)
112 Process::exit("Loi_paroi_adaptative : Error in the calculation of the parallel velocity for wall laws");
113 const double norm_u_parallel = std::sqrt(domaine.dot(&u_parallel(0), &u_parallel(0)));
114
115 const double y_loc = (c == 0) ? domaine.dist_face_elem0(f, e) : domaine.dist_face_elem1(f, e);
116 const double y_p_loc = calc_y_plus_loc(norm_u_parallel, nu_visc(e, n), y_loc, y_p(f, n), &d_bulles(e, 0), &alpha(e, 0));
117
118 y_p(f, n) = std::max(y_p_min_, y_p_loc);
119 u_t(f, n) = y_p(f, n)*nu_visc(e, n)/y_loc;
120 }
121}
122
123double Loi_paroi_Ramstorfer::calc_y_plus_loc(double u_par, double nu, double y, double y_p_0, const double *d_bulles, const double *alpha)
124{
125 const double eps = eps_y_p_;
126 const int iter_max = 20;
127
128 int step = 1;
129 double y_p = y_p_0 ;
130 double u_tau = nu*y_p/y;
131
132 do
133 {
134 y_p = y_p - (u_plus_de_y_plus(y_p, nu, y, d_bulles, alpha) - u_par/u_tau)/(deriv_u_plus_de_y_plus(y_p, nu, y, d_bulles, alpha) + u_par/(u_tau*y_p) );
135 step = step + 1;
136 u_tau = nu*y_p/y;
137 }
138 while( (std::fabs(u_plus_de_y_plus(y_p, nu, y, d_bulles, alpha) - u_par/u_tau) > eps) and (step < iter_max));
139
140 assert ( (std::fabs(u_par/u_tau - u_plus_de_y_plus(y_p, nu, y, d_bulles, alpha)) < eps_y_p_*10) and (step < iter_max));
141
142 return y_p;
143}
144
145double Loi_paroi_Ramstorfer::u_plus_de_y_plus(double y_p, double nu, double y, const double *d_bulles, const double *alpha) // Ramstorfer model
146{
147 const Pb_Multiphase pbm = ref_cast(Pb_Multiphase, pb_.valeur());
148
149 const double u_tau = y_p*y/nu;
150 const double log_law = std::log(y_p + limiteur_y_p_)/von_karman_ + 5.1;
151
152 double kr_p = 0;
153 for (int i = 1 ; i < pbm.nb_phases() ; i++)
154 kr_p += d_bulles[i]*alpha[i];
155 kr_p *= u_tau/nu ;
156
157 return log_law - (kr_p < 11.3 ? 0 : std::log(1 + C_kr_*kr_p)/von_karman_);
158}
159
160double Loi_paroi_Ramstorfer::deriv_u_plus_de_y_plus(double y_p, double nu, double y, const double *d_bulles, const double *alpha) // Ramstorfer model
161{
162 const Pb_Multiphase pbm = ref_cast(Pb_Multiphase, pb_.valeur());
163
164 const double u_tau = y_p*y/nu;
165 const double d_log_law = 1/((y_p+limiteur_y_p_)*von_karman_);
166
167 double kr = 0;
168 for (int i = 1 ; i < pbm.nb_phases() ; i++)
169 kr += d_bulles[i]*alpha[i];
170 const double kr_p = kr * u_tau/nu;
171
172 return d_log_law - (kr_p < 11.3 ? 0 : (C_kr_*kr/y)/((1 + C_kr_*y_p*kr/y)/von_karman_));
173}
virtual DoubleTab & get_elem_vector_field(DoubleTab &, bool passe=false) const
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 Champ_Inc_base & inconnue() const =0
classe Loi_paroi_Ramstorfer correlation pour une loi de paroi adaptative qui calcule u_tau et du y_pl...
double calc_y_plus_loc(double u_par, double nu, double y, double yp, const double *d_bulles, const double *alpha)
double u_plus_de_y_plus(double u_tau, double nu, double y, const double *d_bulles, const double *alpha)
double deriv_u_plus_de_y_plus(double u_tau, double nu, double y, const double *d_bulles, const double *alpha)
void calc_y_plus(const DoubleTab &vit, const DoubleTab &nu_visc) override
classe Loi_paroi_base Classe de base pour les lois de paroi dans pb_mulitphase
IntTab Faces_a_calculer_
void completer() override
std::map< std::string, DoubleTab > valeurs_loi_paroi_
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...
int nb_phases() const
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67