TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Diffusion_croisee_echelle_temp_taux_diss_turb_VDF.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 <Diffusion_croisee_echelle_temp_taux_diss_turb_VDF.h>
17
18#include <Convection_diffusion_turbulence_multiphase.h>
19#include <Dissipation_type_helpers.h>
20#include <face_to_elem_VDF.h>
21#include <Champ_Inc_P0_base.h>
22#include <Domaine_VF.h>
23#include <Pb_Multiphase.h>
24
25Implemente_instanciable(Diffusion_croisee_echelle_temp_taux_diss_turb_VDF,"Diffusion_croisee_echelle_temp_taux_diss_turb_VDF_P0_VDF", Source_Diffusion_croisee_echelle_temp_taux_diss_turb);
26
28
30
31void Diffusion_croisee_echelle_temp_taux_diss_turb_VDF::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
32{
33 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
34 const Champ_Inc_P0_base& ch_k = ref_cast(Champ_Inc_P0_base, equation().probleme().get_champ("k"));
35 const DoubleTab& k_passe = ch_k.passe();
36 const DoubleVect& pe = equation().milieu().porosite_elem();
37 const DoubleVect& ve = domaine.volumes();
38
39 const Champ_Inc_P0_base& ch_diss = ref_cast(Champ_Inc_P0_base, equation().inconnue());
40 const DoubleTab& diss_passe = ch_diss.passe();
41 const DoubleTab& diss = ch_diss.valeurs();
42
43 const int nf_tot = domaine.nb_faces_tot();
44 const int D = dimension;
45 const int ne = domaine.nb_elem();
46 const int ne_tot = domaine.nb_elem_tot();
47 const int N = diss_passe.line_size();
48
49 const std::string Type_diss = get_dissipation_type(equation());
50 Matrice_Morse *Mdiss = matrices.count(Type_diss) ? matrices.at(Type_diss) : nullptr;
51
52 assert(N == 1 || k_passe.line_size() == 1);
53
54 /* Calcul de grad de tau ou de omega aux faces */
55
56 DoubleTab grad_f_diss(nf_tot, N);
57 assert(diss_passe.dimension_tot(0) == ne_tot);
59 const Operateur_Grad& Op_Grad_diss = eq_diss.operateur_gradient_inconnue();
60 Op_Grad_diss.calculer(diss_passe, grad_f_diss);
61
62 /* Calcul de grad de k aux faces */
63
64 DoubleTab grad_f_k(nf_tot, N);
65 assert(k_passe.dimension_tot(0) == ne_tot);
67 const Operateur_Grad& Op_Grad_k = eq_k.operateur_gradient_inconnue();
68 Op_Grad_k.calculer(k_passe, grad_f_k);
69
70 /* Interpolation des gradients aux elements */
71 DoubleTab grad_e_diss(ne_tot, N, D);
72 DoubleTab grad_e_k(ne_tot, N, D);
73 face_to_elem_VDF(domaine, grad_f_diss, grad_e_diss);
74 face_to_elem_VDF(domaine, grad_f_k, grad_e_k);
75
76 /* Calcul du produit scalaire grad(diss).grad(k) aux elements */
77
78 DoubleTab grad_diss_dot_grad_k(ne, N);
79 for (int n = 0; n < N; n++)
80 for (int e = 0; e < ne; e++)
81 {
82 grad_diss_dot_grad_k(e, n) = 0;
83 for (int d = 0; d < D; d++)
84 grad_diss_dot_grad_k(e, n) += grad_e_diss(e, n, d) * grad_e_k(e, n, d);
85 }
86
87 /* Remplissage des matrices et du second membre */
88
89 for (int e = 0; e < ne; e++)
90 for (int n = 0; n < N; n++)
91 {
92 const double peve = pe(e) * ve(e);
93
94 if (Type_diss == "tau")
95 {
96 // Source: sigma_d * tau * min(grad(tau).grad(k), 0)
97 const double dot_min = std::min(grad_diss_dot_grad_k(e, n), 0.);
98 secmem(e, n) += peve * sigma_d_ * diss(e, n) * dot_min;
99
100 // Jacobian w.r.t. tau
101 if (Mdiss)
102 (*Mdiss)(N * e + n, N * e + n) -= peve * sigma_d_ * dot_min;
103 }
104 else if (Type_diss == "omega")
105 {
106 if (diss(e, n) > 1.e-8)
107 {
108 // Source: sigma_d / omega * max(grad(omega).grad(k), 0) (linearized)
109 const double dp = std::max(diss_passe(e, n), 1.e-6);
110 const double dot_max = std::max(grad_diss_dot_grad_k(e, n), 0.);
111 secmem(e, n) += peve * sigma_d_ / dp * (2 - diss(e, n) / dp) * dot_max;
112
113 // Jacobian w.r.t. omega
114 if (Mdiss)
115 (*Mdiss)(N * e + n, N * e + n) -= peve * sigma_d_ * (-1 / (dp * dp)) * dot_max;
116 }
117 }
118 }
119}
: class Champ_Inc_P0_base
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
classe Convection_diffusion_turbulence_multiphase Equation de transport des quantites turbulentes (k,...
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
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 Milieu_base & milieu() const =0
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
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
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 Operateur_Grad Classe generique de la hierarchie des operateurs calculant le gradient.
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
Initialise le tableau passe en parametre avec la contribution de l'operateur.
Classe de base des flux de sortie.
Definition Sortie.h:52
const Champ_base & get_champ(const Motcle &nom) const override
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67