TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Diff_K_Omega_VEF_Face.cpp
1/****************************************************************************
2* Copyright (c) 2019, 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_Diff_K_Omega_VEF_Face.h>
17#include <Modele_turbulence_hyd_K_Omega.h>
18#include <Champ_P1NC.h>
19#include <Periodique.h>
20#include <Neumann_paroi.h>
21#include <Paroi_hyd_base_VEF.h>
22#include <Discretisation_tools.h>
23#include <Champ_Uniforme.h>
24#include <Fluide_Incompressible.h>
25
26Implemente_instanciable(Op_Diff_K_Omega_VEF_Face,
27 "Op_Diff_K_Omega_VEF_P1NC",
29
31{
32 return s << que_suis_je() ;
33}
35{
36 return s ;
37}
38
39void Op_Diff_K_Omega_VEF_Face::compute(DoubleTab& tab_nu_turb_m) const
40{
41 const Domaine_VEF& domaine_VEF = le_dom_vef.valeur();
42 const int is_SST_or_BSL = is_SST_or_BSL_;
43 const double Sigma_K = Sigma_K_;
44 const double Sigma_Omega = Sigma_Omega_;
45 const double Sigma_K1 = Sigma_K1_;
46 const double Sigma_K2 = Sigma_K2_;
47 const double Sigma_OMEGA1 = Sigma_OMEGA1_;
48 const double Sigma_OMEGA2 = Sigma_OMEGA2_;
49 if (turbulence_model->is_SST_or_BSL() != is_SST_or_BSL) Process::exit("Error in Op_Diff_K_Omega_VEF_Face::ajouter");
50 DoubleTrav tab_F1elem(domaine_VEF.nb_elem_tot(), 1);
51 CDoubleArrView F1elem;
52 if (is_SST_or_BSL)
53 {
54 Discretisation_tools::faces_to_cells(domaine_VEF, tab_F1_face_, tab_F1elem);
55 F1elem = static_cast<const ArrOfDouble&>(tab_F1elem).view_ro();
56 }
57 const int nb_elem = domaine_VEF.nb_elem();
58 CDoubleArrView nu_turb = static_cast<const ArrOfDouble&>(diffusivite_turbulente().valeurs()).view_ro();
59 DoubleTabView nu_turb_m = tab_nu_turb_m.view_wo();
60 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), Kokkos::RangePolicy<>(0, nb_elem), KOKKOS_LAMBDA(const int elem)
61 {
62 double F1 = is_SST_or_BSL ? F1elem(elem) : 0;
63 nu_turb_m(elem,0) = nu_turb(elem) * (is_SST_or_BSL*(F1*Sigma_K1 + (1 - F1)*Sigma_K2) + (1 - is_SST_or_BSL)*Sigma_K);
64 nu_turb_m(elem,1) = nu_turb(elem) * (is_SST_or_BSL*(F1*Sigma_OMEGA1 + (1 - F1)*Sigma_OMEGA2)+ (1 - is_SST_or_BSL)*Sigma_Omega);
65 });
66 end_gpu_timer(__KERNEL_NAME__);
67 tab_nu_turb_m.echange_espace_virtuel();
68}
69
70DoubleTab& Op_Diff_K_Omega_VEF_Face::ajouter(const DoubleTab& inconnue_org, DoubleTab& resu) const
71{
72 remplir_nu(nu_); // On remplit le tableau nu car ajouter peut se faire avant le premier pas de temps
73
74 const int nb_comp = resu.line_size();
75
76 DoubleTab& nu_turb_m = ref_cast_non_const(DoubleTab, nu_turb_m_);
77 compute(nu_turb_m);
78
79 // On dimensionne et initialise le tableau des bilans de flux:
80 if (flux_bords_.dimension_tot(0)!=le_dom_vef->nb_faces_bord())
81 flux_bords_.resize(le_dom_vef->nb_faces_bord(), nb_comp);
82 flux_bords_ = 0.;
83
84 ajouter_bord_gen<Type_Champ::SCALAIRE, true>(inconnue_org, resu, flux_bords_, nu_, nu_turb_m);
86
87 modifier_flux(*this);
88
89 return resu;
90}
91
92
93/////////////////////////////////////////
94// Methode pour l'implicite
95/////////////////////////////////////////
96
98 Matrice_Morse& matrice) const
99
100{
101
103 remplir_nu(nu_); // On remplit le tableau nu car l'assemblage d'une matrice avec ajouter_contribution peut se faire avant le premier pas de temps
104
105 DoubleTab& nu_turb_m = ref_cast_non_const(DoubleTab, nu_turb_m_);
106 compute(nu_turb_m);
107
108 int marq = phi_psi_diffuse(equation());
109
110 DoubleTrav porosite_eventuelle(equation().milieu().porosite_face());
111 porosite_eventuelle = equation().milieu().porosite_face();
112 if (!marq) porosite_eventuelle = 1;
113
114 ajouter_contribution_bord_gen<Type_Champ::SCALAIRE, false, true>(inco, matrice, nu_, nu_turb_m, porosite_eventuelle);
115 ajouter_contribution_interne_gen<Type_Champ::SCALAIRE, false, true>(inco, matrice, nu_, nu_turb_m, porosite_eventuelle);
116
118}
119
120
121/*! @brief On modifie le second membre et la matrice dans le cas des conditions de dirichlet.
122 *
123 */
124void Op_Diff_K_Omega_VEF_Face::modifier_pour_Cl(Matrice_Morse& matrice, DoubleTab& tab_secmem) const
125{
126 Op_Dift_VEF_base::modifier_pour_Cl(matrice, tab_secmem);
127
128 // on recupere le tableau
129 const Turbulence_paroi_base& mod=le_modele_turbulence->loi_paroi();
130 const Paroi_hyd_base_VEF& paroi = ref_cast(Paroi_hyd_base_VEF, mod);
131 const ArrOfInt& tab_face_komega_imposee = paroi.face_keps_imposee();
132
133 if (tab_face_komega_imposee.size_array() > 0)
134 {
135 const int size = tab_secmem.dimension(0);
136 const int nb_comp = equation().inconnue().valeurs().line_size();
137 // en plus des dirichlets ????
138 // on change la matrice et le resu sur toutes les lignes ou k_omega_ est imposee....
139 CDoubleTabView val = equation().inconnue().valeurs().view_ro();
140 CIntArrView face_komega_imposee = static_cast<const ArrOfInt&>(tab_face_komega_imposee).view_ro();
141 auto tab1 = matrice.get_tab1().view_ro();
142 auto coeff = matrice.get_set_coeff().view_rw();
143 DoubleTabView secmem = tab_secmem.view_rw();
144 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), Kokkos::RangePolicy<>(0, size), KOKKOS_LAMBDA(const int face)
145 {
146 if (face_komega_imposee[face] != -2)
147 {
148 for (int comp = 0; comp < nb_comp; comp++)
149 {
150 // on doit remettre la ligne a l'identite et le secmem a l'inconnue
151 int j = face * nb_comp + comp;
152 const int idiag = tab1[j] - 1;
153 coeff[idiag] = 1;
154
155 // pour les voisins
156 const int nbvois = tab1[j+1] - tab1[j];
157 for (int k = 1; k < nbvois; k++)
158 coeff[idiag + k] = 0;
159 secmem(face, comp) = val(face, comp);
160 }
161 }
162 });
163 end_gpu_timer(__KERNEL_NAME__);
164 }
165}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
static void faces_to_cells(const Champ_base &Hf, Champ_base &He)
int nb_elem_tot() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
const auto & get_tab1() const
auto & get_set_coeff()
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const override
DOES NOTHING - to override in derived classes.
void modifier_pour_Cl(Matrice_Morse &matrice, DoubleTab &secmem) const override
On modifie le second membre et la matrice dans le cas des conditions de dirichlet.
DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const override
class Op_Diff_K_Omega_VEF_Face Cette classe represente l'operateur de diffusion turbulente
const Champ_Fonc_base & diffusivite_turbulente() const
int phi_psi_diffuse(const Equation_base &eq) const
Determine whether to compute div(phi nu grad Psi) or div(nu grad Phi psi).
virtual void remplir_nu(DoubleTab &) const
std::enable_if_t< _TYPE_==Type_Champ::VECTORIEL, void > ajouter_bord_gen(const DoubleTab &, DoubleTab &, DoubleTab &, const DoubleTab &, const DoubleTab &) const
void ajouter_contribution_bord_gen(const DoubleTab &, Matrice_Morse &, const DoubleTab &, const DoubleTab &, const DoubleVect &) const
std::enable_if_t< _TYPE_==Type_Champ::VECTORIEL, void > ajouter_interne_gen(const DoubleTab &, DoubleTab &, DoubleTab &, const DoubleTab &, const DoubleTab &) const
void ajouter_contribution_interne_gen(const DoubleTab &inco, Matrice_Morse &mat, const DoubleTab &nu, const DoubleTab &nu_turb, const DoubleVect &porosite_eventuelle) const
void modifier_pour_Cl(Matrice_Morse &matrice, DoubleTab &secmem) const override
DOES NOTHING - to override in derived classes.
void modifier_matrice_pour_periodique_apres_contribuer(Matrice_Morse &matrice, const Equation_base &) const
Sums the 2 rows of the associated periodic faces, allowing computations in the code without needing t...
void modifier_matrice_pour_periodique_avant_contribuer(Matrice_Morse &matrice, const Equation_base &) const
Divides the coefficients on the periodic face rows by 2 in preparation for applying modifier_matrice_...
void modifier_flux(const Operateur_base &) const
DoubleTab flux_bords_
CLASS: Paroi_hyd_base_VEF.
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_ size_array() const
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_wo()
Definition TRUSTTab.h:276
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
Definition TRUSTTab.h:261
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_rw()
Definition TRUSTTab.h:291
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
Base class for the hierarchy of wall-law models computing turbulent quantities near walls....