TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Diff_K_Eps_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_Eps_VEF_Face.h>
17#include <Paroi_hyd_base_VEF.h>
18#include <Debog.h>
19
20Implemente_instanciable(Op_Diff_K_Eps_VEF_Face,"Op_Diff_K_Eps_VEF_P1NC",Op_Diff_K_Eps_VEF_base);
21
23{
24 return s << que_suis_je() ;
25}
27{
28 return s ;
29}
30
31void Op_Diff_K_Eps_VEF_Face::divide_nu_turb_by_prandtl(DoubleTab& tab_nu_turb_m) const
32{
33 double Prdt0 = Sigma_[0];
34 double Prdt1 = Sigma_[1];
35 int n_tot = nu_.dimension_tot(0);
36 tab_nu_turb_m.resize(n_tot, 2);
37 CDoubleArrView nu_turb = static_cast<const ArrOfDouble&>(diffusivite_turbulente().valeurs()).view_ro();
38 DoubleTabView nu_turb_m = tab_nu_turb_m.view_wo();
39 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), n_tot, KOKKOS_LAMBDA(const int k)
40 {
41 nu_turb_m(k,0) = nu_turb(k)/Prdt0;
42 nu_turb_m(k,1) = nu_turb(k)/Prdt1;
43 });
44 end_gpu_timer(__KERNEL_NAME__);
45}
46
47DoubleTab& Op_Diff_K_Eps_VEF_Face::ajouter(const DoubleTab& inconnue_org, DoubleTab& resu) const
48{
49 remplir_nu(nu_); // On remplit le tableau nu car ajouter peut se faire avant le premier pas de temps
50
51 // On dimensionne et initialise le tableau des bilans de flux:
52 const int nb_comp = resu.line_size();
53 flux_bords_.resize(le_dom_vef->nb_faces_bord(), nb_comp);
54 flux_bords_ = 0.;
55
56 DoubleTrav nu_turb_m;
57 divide_nu_turb_by_prandtl(nu_turb_m);
58
59 ajouter_bord_gen<Type_Champ::SCALAIRE, true>(inconnue_org, resu, flux_bords_, nu_, nu_turb_m);
61
62 modifier_flux(*this);
63
64 return resu;
65}
66
67void Op_Diff_K_Eps_VEF_Face::contribuer_a_avec(const DoubleTab& inco, Matrice_Morse& matrice) const
68{
70 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
71
72 DoubleTrav nu_turb_m;
73 divide_nu_turb_by_prandtl(nu_turb_m);
74
75 int marq = phi_psi_diffuse(equation());
76
77 DoubleTrav porosite_eventuelle(equation().milieu().porosite_face());
78 porosite_eventuelle = equation().milieu().porosite_face();
79 if (!marq) porosite_eventuelle = 1;
80
81 ajouter_contribution_bord_gen<Type_Champ::SCALAIRE, false, true>(inco, matrice, nu_, nu_turb_m, porosite_eventuelle);
82 ajouter_contribution_interne_gen<Type_Champ::SCALAIRE, false, true>(inco, matrice, nu_, nu_turb_m, porosite_eventuelle);
83
85}
86
87
88void Op_Diff_K_Eps_VEF_Face::modifier_pour_Cl(Matrice_Morse& matrice, DoubleTab& tab_secmem) const
89{
90 Op_Dift_VEF_base::modifier_pour_Cl(matrice, tab_secmem);
91
92 const Turbulence_paroi_base& mod=le_modele_turbulence->loi_paroi();
93 const Paroi_hyd_base_VEF& paroi=ref_cast(Paroi_hyd_base_VEF,mod);
94 if (paroi.face_keps_imposee().size_array()>0) //TODO a reformuler (Kokkos ?)
95 {
96 int size = tab_secmem.dimension(0);
97 const int nb_comp = equation().inconnue().valeurs().line_size();
98
99 // en plus des dirichlets ????
100 // on change la matrice et le resu sur toutes les lignes ou k_eps_ est imposee....
101 CIntArrView face_keps_imposee = paroi.face_keps_imposee().view_ro();
102 auto tab1 = matrice.get_tab1().view_ro();
103 CDoubleTabView val = equation().inconnue().valeurs().view_ro();
104 DoubleArrView coeff = matrice.get_set_coeff().view_wo();
105 DoubleTabView secmem = tab_secmem.view_wo();
106 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), size, KOKKOS_LAMBDA(const int face)
107 {
108 if (face_keps_imposee(face)!=-2)
109 {
110 for (int comp=0; comp<nb_comp; comp++)
111 {
112 // on doit remettre la ligne a l'identite et le secmem a l'inconnue
113 int idiag = tab1(face*nb_comp+comp)-1;
114 coeff(idiag) = 1;
115 // pour les voisins
116 int nbvois = tab1(face*nb_comp+1+comp) - tab1(face*nb_comp+comp);
117 for (int k=1; k < nbvois; k++)
118 coeff(idiag+k) = 0;
119 secmem(face,comp) = val(face,comp);
120 }
121 }
122 });
123 end_gpu_timer(__KERNEL_NAME__);
124 }
125}
126
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.
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
class Op_Diff_K_Eps_VEF_Face Cette classe represente l'operateur de diffusion turbulente
DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const override
void modifier_pour_Cl(Matrice_Morse &matrice, DoubleTab &secmem) const override
DOES NOTHING - to override in derived classes.
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const override
DOES NOTHING - to override in derived classes.
class Op_Diff_K_Eps_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.
Base class for output streams.
Definition Sortie.h:52
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_wo()
Definition TRUSTTab.h:276
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
Definition TRUSTTab.h:261
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
Base class for the hierarchy of wall-law models computing turbulent quantities near walls....