TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Dift_VDF_base.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 <Eval_Dift_Multiphase_VDF.h>
17#include <Modele_turbulence_hyd_base.h>
18#include <Op_Dift_VDF_base.h>
19#include <Eval_Dift_VDF.h>
20#include <Perf_counters.h>
21#include <TRUSTTrav.h>
22#include <Motcle.h>
23
24Implemente_base(Op_Dift_VDF_base,"Op_Dift_VDF_base",Op_Diff_VDF_base);
25
28
29void Op_Dift_VDF_base::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
30{
31 iter_->ajouter_blocs(matrices,secmem,semi_impl);
32
33 // We add terms if axi ...
34 Op_Dift_VDF_base::ajoute_terme_pour_axi_turb(matrices, secmem, semi_impl);
35}
36
37// Addition of the extra V/(R*R) term in the axisymmetric coordinate case
38void Op_Dift_VDF_base::ajoute_terme_pour_axi_turb(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
39{
40 if (equation().domaine_application() == Motcle("Hydraulique")) // We are in the case of the Navier_Stokes equations
41 {
42 const std::string& nom_inco = equation().inconnue().le_nom().getString();
43 Matrice_Morse *mat = matrices.count(nom_inco) ? matrices.at(nom_inco) : nullptr;
44 const DoubleTab& inco = semi_impl.count(nom_inco) ? semi_impl.at(nom_inco) : equation().inconnue().valeurs();
45
46 if (Objet_U::bidim_axi == 1)
47 {
48 const Domaine_VDF& zvdf = iter_->domaine();
49 const DoubleTab& xv = zvdf.xv();
50 const IntVect& ori = zvdf.orientation();
51 const IntTab& face_voisins = zvdf.face_voisins();
52 const DoubleVect& volumes_entrelaces = zvdf.volumes_entrelaces();
53 int face, nb_faces = zvdf.nb_faces(); //, cst;
54 double db_diffusivite;
55
56 const Eval_Diff_VDF& eval = dynamic_cast<const Eval_Diff_VDF&>(iter_->evaluateur());
57 const Champ_base& ch = eval.get_diffusivite();
58 const DoubleTab& tab_diffusivite = ch.valeurs();
59 const int N = tab_diffusivite.dimension(1);
60 DoubleTrav diffu_tot(zvdf.nb_elem_tot(), N);
61
62 int size = diffu_tot.dimension_tot(0);
63 int cM = (tab_diffusivite.dimension(0) == 1);
64
65 const RefObjU& modele_turbulence = equation().get_modele(TURBULENCE);
66 if (is_turb()) // Cas turbulence multiphase
67 {
68 const Eval_Dift_Multiphase_VDF& eval_dift = dynamic_cast<const Eval_Dift_Multiphase_VDF&>(iter_->evaluateur()) ;
69 const DoubleTab& diffusivite_turb = eval_dift.tab_nu_t() ;
70 const DoubleTab& alpharho = equation().probleme().equation(1).champ_conserve().passe();
71 assert(diffusivite_turb.nb_dim()==2);
72
73 for (int i = 0; i < size; i++)
74 for (int n=0; n<N; n++)
75 diffu_tot(i, n) = tab_diffusivite(!cM*i, n) + alpharho(i, n)*diffusivite_turb(i,n);
76 }
77 else if (sub_type(Modele_turbulence_hyd_base, modele_turbulence.valeur()))
78 {
79 const Eval_Dift_VDF& eval_dift = static_cast<const Eval_Dift_VDF&>(eval);
80 const Champ_Fonc_base& ch_diff_turb = eval_dift.diffusivite_turbulente();
81 const DoubleVect& diffusivite_turb = ch_diff_turb.valeurs();
82
83 for (int i = 0; i < size; i++)
84 diffu_tot[i] = tab_diffusivite[!cM*i] + diffusivite_turb[i];
85 }
86 else
87 {
88 Cerr << "Method Op_Dift_VDF_base::ajoute_terme_pour_axi_turb" << finl;
89 Cerr << "The type " << equation().que_suis_je() << " of the equation associated " << finl;
90 Cerr << "with the current operator " << que_suis_je() << "is not coherent." << finl;
91 Cerr << "It must be sub typing of Navier_Stokes_Turbulent" << finl;
93 }
94
95 for (face = 0; face < nb_faces; face++)
96 for (int n = 0; n < N; n++)
97 if (ori(face) == 0)
98 {
99 const int elem1 = face_voisins(face, 0), elem2 = face_voisins(face, 1);
100
101 if (elem1 == -1) db_diffusivite = diffu_tot(elem2, n);
102 else if (elem2 == -1) db_diffusivite = diffu_tot(elem1, n);
103 else db_diffusivite = 0.5 * (diffu_tot(elem2, n) + diffu_tot(elem1, n));
104
105 double r = xv(face, 0);
106 if (r >= 1.e-24)
107 {
108 if (mat) (*mat)(N * face + n, N * face + n) += db_diffusivite * volumes_entrelaces(face) / (r * r);
109 secmem(face, n) -= inco(face, n) * db_diffusivite * volumes_entrelaces(face) / (r * r);
110 }
111 }
112 }
113 }
114}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Domaine_VDF
Definition Domaine_VDF.h:61
int orientation(int) const override
inline DoubleVect& Domaine_VDF::porosite_face() {
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
int nb_elem_tot() const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const RefObjU & get_modele(Type_modele type) const
Champ_Inc_base & champ_conserve() const
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual const Champ_base & get_diffusivite() const final
const DoubleTab & tab_nu_t() const
const Champ_Fonc_base & diffusivite_turbulente() const
const Nom & le_nom() const override
Returns the name of the field.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
Base class for the turbulence model hierarchy for Navier-Stokes equations.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
A character string (Nom) in uppercase.
Definition Motcle.h:26
const std::string & getString() const
Definition Nom.h:92
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
static int bidim_axi
Definition Objet_U.h:97
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
class Op_Diff_VDF_base Classe de base des operateurs de diffusion VDF
void ajoute_terme_pour_axi_turb(matrices_t, DoubleTab &, const tabs_t &) const
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl) const override
virtual bool is_turb() const
virtual const Equation_base & equation(int) const =0
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
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
const Objet_U & valeur() const
Definition TRUST_Ref.h:134