TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Loi_paroi_log.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Discretisation_base.h>
17#include <Navier_Stokes_std.h>
18#include <Correlation_base.h>
19#include <Champ_Face_base.h>
20#include <QDM_Multiphase.h>
21#include <TRUSTTab_parts.h>
22#include <Cond_lim_base.h>
23#include <Pb_Multiphase.h>
24#include <Loi_paroi_log.h>
25#include <Domaine_VF.h>
26#include <TRUSTTrav.h>
27#include <Motcle.h>
28#include <Param.h>
29#include <math.h>
30#include <Nom.h>
31
32Implemente_instanciable(Loi_paroi_log, "Loi_paroi_log", Loi_paroi_base);
33
35{
36 return os;
37}
38
40{
41 return Loi_paroi_base::readOn(is);
42}
43
44void Loi_paroi_log::calc_y_plus(const DoubleTab& vit, const DoubleTab& nu_visc)
45{
46 const int cnu = nu_visc.dimension(0) == 1;
47 Domaine_VF& domaine = ref_cast(Domaine_VF, pb_->domaine_dis());
48 DoubleTab& u_t = valeurs_loi_paroi_["u_tau"], &y_p = valeurs_loi_paroi_["y_plus"], &y_loc = valeurs_loi_paroi_["y"];
49 const DoubleTab& n_f = domaine.face_normales();
50 const DoubleVect& fs = domaine.face_surfaces();
51 const IntTab& f_e = domaine.face_voisins();
52
53 const bool is_VDF = pb_->discretisation().is_vdf();
54
55 int nf_tot = domaine.nb_faces_tot(), D = dimension, N = vit.line_size();
56
57 DoubleTab pvit_elem(0, N * D);
58 if (is_VDF)
59 {
60 const Champ_Face_base& ch = ref_cast(Champ_Face_base, pb_->equation(0).inconnue());
61 domaine.domaine().creer_tableau_elements(pvit_elem);
62 ch.get_elem_vector_field(pvit_elem, true);
63 }
64
65 int n = 0; // for now, turbulence in one phase only
66
67 for (int f = 0; f < nf_tot; f++)
68 if (Faces_a_calculer_(f, 0) == 1)
69 {
70 int c = (f_e(f, 0) >= 0) ? 0 : 1;
71 if (f_e(f, (c == 0) ? 1 : 0) >= 0)
72 Process::exit("Error in the definition of the boundary conditions for wall laws");
73 int e = f_e(f, c);
74
75 double u_orth = 0.;
76 const double yloc = y_loc(f, n);
77 DoubleTrav u_parallel(D);
78 if (is_VDF) // VDF case: velocity at the element center
79 {
80 for (int d = 0; d < D; d++)
81 u_orth -= pvit_elem(e, N * d + n) * n_f(f, d) / fs(f); // ! n_f points toward face 1, i.e. outward from the element, hence the -
82 for (int d = 0; d < D; d++)
83 u_parallel(d) = pvit_elem(e, N * d + n) - u_orth * (-n_f(f, d)) / fs(f); // ! n_f points toward face 1, i.e. outward from the element, hence the -
84 }
85 else // PolyMAC_CDO case
86 {
87 for (int d = 0; d < D; d++)
88 u_orth -= vit(nf_tot + e * D + d, n) * n_f(f, d) / fs(f); // ! n_f points toward face 1, i.e. outward from the element, hence the -
89 for (int d = 0; d < D; d++)
90 u_parallel(d) = vit(nf_tot + e * D + d, n) - u_orth * (-n_f(f, d)) / fs(f); // ! n_f points toward face 1, i.e. outward from the element, hence the -
91 }
92
93 double norm_u_parallel = std::sqrt(domaine.dot(&u_parallel(0), &u_parallel(0)));
94
95 // double residu = 0 ;
96 // for (int d = 0; d <D ; d++) residu += u_parallel(d)*n_f(f,d)/fs(f);
97 // if (residu > 1e-8) Process::exit("Loi_paroi_adaptative : Error in the calculation of the parallel velocity for wall laws");
98
99 y_p(f, n) = std::max(y_p_min_, calc_y_plus_loc(norm_u_parallel, nu_visc(!cnu * e, n), yloc, y_p(f, n)));
100 u_t(f, n) = y_p(f, n) * nu_visc(!cnu * e, n) / yloc;
101 }
102}
103
104double Loi_paroi_log::calc_y_plus_loc(double u_par, double nu, double y, double y_p_0)
105{
106 if (u_par * y / nu < limiteur_y_p)
107 return limiteur_y_p;
108
109 double eps = eps_y_p_;
110 int step = 1, iter_max = 30;
111
112 double y_p = y_p_0;
113 double u_tau = nu * y_p / y;
114
115 do
116 {
117 y_p = std::max(limiteur_y_p, y_p - (u_plus_de_y_plus(y_p) - u_par / u_tau) / (deriv_u_plus_de_y_plus(y_p) + u_par / (u_tau * y_p)));
118 step = step + 1;
119 u_tau = nu * y_p / y;
120 }
121 while ((std::fabs(u_plus_de_y_plus(y_p) - u_par / u_tau) > eps) and (step < iter_max));
122
123 assert((std::fabs(u_par / u_tau - u_plus_de_y_plus(y_p)) < eps_y_p_ * 10) and (step < iter_max));
124
125 return y_p;
126}
127
128double Loi_paroi_log::u_plus_de_y_plus(double y_p) // Blended Reichardt model
129{
130 return std::log(y_p + limiteur_y_p) / von_karman_ + 5.1;
131}
132
134{
135 return 1. / ((y_p + limiteur_y_p) * von_karman_);
136}
137
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
Base class for wall laws in Pb_Multiphase.
IntTab Faces_a_calculer_
std::map< std::string, DoubleTab > valeurs_loi_paroi_
Adaptive wall-law correlation computing u_tau and y_plus (blended Reichardt model).
double calc_y_plus_loc(double y_p, double nu, double y, double y_p_0)
double limiteur_y_p
void calc_y_plus(const DoubleTab &vit, const DoubleTab &nu_visc) override
virtual double deriv_u_plus_de_y_plus(double y_p)
virtual double u_plus_de_y_plus(double y_p)
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
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(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67