TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
EOS_Tools_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Navier_Stokes_Fluide_Dilatable_base.h>
17#include <Source_Masse_Fluide_Dilatable_base.h>
18#include <Fluide_Dilatable_base.h>
19#include <Check_espace_virtuel.h>
20#include <Schema_Temps_base.h>
21#include <Champ_Face_VDF.h>
22#include <communications.h>
23#include <Equation_base.h>
24#include <EOS_Tools_VDF.h>
25#include <Domaine_VDF.h>
26#include <Debog.h>
27
28Implemente_instanciable(EOS_Tools_VDF,"EOS_Tools_VDF",EOS_Tools_base);
29
31{
32 return os <<que_suis_je()<< finl;
33}
34
36{
37 return is;
38}
39
41{
42 le_dom = ref_cast(Domaine_VDF,dds);
43 le_dom_Cl = domaine_cl;
44 Champ_Face_VDF toto;
46 toto.fixer_nb_comp(1);
47 toto.fixer_nb_valeurs_nodales(le_dom->nb_faces());
48 tab_rho_face=toto.valeurs();
51}
52
53/*! @brief @brief Computes the volumetric average of the given P0 quantity.
54 *
55 * @return rho discretized per face.
56 */
57double EOS_Tools_VDF::moyenne_vol(const DoubleTab& tab) const
58{
59 int nb_elem=le_dom->nb_elem();
60 const DoubleVect& volumes = le_dom->volumes();
61 assert(tab.dimension(0)==nb_elem);
62 ArrOfDouble sum(2);
63 sum = 0;
64 for (int elem=0 ; elem<nb_elem ; elem++)
65 {
66 double v = volumes(elem);
67 sum[0] += v;
68 sum[1] += v*tab(elem);
69 }
71 return sum[1]/sum[0];
72}
73
74void EOS_Tools_VDF::calculer_rho_face_np1(const DoubleTab& tab_rhoP0)
75{
76 int face, elem, nb_faces_tot = le_dom->nb_faces_tot();
77 Debog::verifier("tab_rhoP0",tab_rhoP0);
78 int i, nb_comp;
79 IntTab& face_voisins = le_dom->face_voisins();
80 for (face=0 ; face<nb_faces_tot ; face++)
81 {
82 nb_comp=0;
83 tab_rho_face_np1(face) = 0;
84 for (i=0 ; i<2 ; i++)
85 {
86 elem= face_voisins(face,i);
87 if (elem!=-1)
88 {
89 nb_comp++;
90 tab_rho_face_np1(face) += tab_rhoP0(elem);
91 }
92 }
93 tab_rho_face_np1(face) /= nb_comp;
94 }
95
96 tab_rho_face_np1.echange_espace_virtuel();
97 Debog::verifier("tab_rho_face_np1",tab_rho_face_np1);
98 for (face=0 ; face<nb_faces_tot ; face++)
99 tab_rho_face_demi(face)=(tab_rho_face_np1(face)+tab_rho_face(face))/2.;
100}
101
102/*! @brief @brief Returns rho with the same discretization as the velocity: one value per face in VDF.
103 *
104 * @return rho discretized per face.
105 */
106const DoubleTab& EOS_Tools_VDF::rho_discvit() const
107{
108 return tab_rho_face_demi;
109}
110
111/*! @brief @brief Returns div(u) with the same discretization as the velocity: one value per face in VDF.
112 *
113 * @return div(u) discretized per face.
114 */
115void EOS_Tools_VDF::divu_discvit(const DoubleTab& secmem1, DoubleTab& secmem2)
116{
117 assert_espace_virtuel_vect(secmem1);
118 int nb_faces_tot = le_dom->nb_faces_tot();
119 IntTab& face_voisins = le_dom->face_voisins();
120 //filling div(u) on the faces
121 for (int face=0 ; face<nb_faces_tot; face++)
122 {
123 int nb_comp=0;
124 secmem2(face)=0;
125 for (int i=0 ; i<2 ; i++)
126 {
127 int elem= face_voisins(face,i);
128 if (elem!=-1)
129 {
130 nb_comp++;
131 secmem2(face) += secmem1(elem);
132 }
133 }
134 secmem2(face) /= nb_comp;
135 }
136 secmem2.echange_espace_virtuel();
137}
138
139/*! @brief @brief Computes the right-hand side of the continuity equation: div(rhoU) = W = -dZ/dT with Z=rho.
140 *
141 * @return rho discretized per face.
142 */
143void EOS_Tools_VDF::secmembre_divU_Z(DoubleTab& tab_W) const
144{
145 double dt = le_fluide().vitesse().equation().schema_temps().pas_de_temps();
146 int elem,nb_elem = le_dom->nb_elem();//,nb_faces = le_dom->nb_faces();
147 DoubleVect tab_dZ(nb_elem);
148 //DoubleTab tab_gradZ(nb_faces);
149 const DoubleTab& tab_rhonP0 = le_fluide().loi_etat()->rho_n();
150 const DoubleTab& tab_rhonp1P0 = le_fluide().loi_etat()->rho_np1();
151 Debog::verifier("divU tab_rhonP0",tab_rhonP0);
152 Debog::verifier("divU tab_rhonp1P0",tab_rhonp1P0);
153 const DoubleVect& volumes = le_dom->volumes();
154
155 for (elem=0 ; elem<nb_elem ; elem++)
156 tab_dZ(elem) = (tab_rhonp1P0(elem)-tab_rhonP0(elem))/dt;
157
158 // Adding special source terms from the mass equation:
159 const bool has_mass_flux = (sub_type(Navier_Stokes_Fluide_Dilatable_base, le_fluide().vitesse().equation())) ?
160 ref_cast(Navier_Stokes_Fluide_Dilatable_base, le_fluide().vitesse().equation()).has_source_masse() : false;
161
162 if (has_mass_flux)
163 {
164 const Source_Masse_Fluide_Dilatable_base& src_mass = ref_cast(Navier_Stokes_Fluide_Dilatable_base, le_fluide().vitesse().equation()).source_masse();
165 src_mass.ajouter_projection(le_fluide(), static_cast<DoubleTab&>(tab_dZ));
166 }
167
168 for (elem = 0; elem < nb_elem; elem++)
169 tab_W(elem) = -tab_dZ(elem) * volumes(elem);
170}
171
173{
174 int n=tab_rho_face_np1.size_totale();
175 for (int i=0; i<n; i++)
176 {
179 }
180}
class Champ_Face_VDF
int fixer_nb_valeurs_nodales(int) override
void associer_domaine_dis_base(const Domaine_dis_base &) override
DoubleTab & valeurs() override
Returns the array of field values at the current time.
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VDF
Definition Domaine_VDF.h:61
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
class EOS_Tools_VDF This class is specific to VDF-type discretization.
const Fluide_Dilatable_base & le_fluide() const
void mettre_a_jour(double temps) override
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void divu_discvit(const DoubleTab &, DoubleTab &) override
Returns div(u) with the same discretization as the velocity: one value per face in VDF.
const DoubleTab & rho_discvit() const override
Returns rho with the same discretization as the velocity: one value per face in VDF.
DoubleTab tab_rho_face_np1
double moyenne_vol(const DoubleTab &) const override
Computes the volumetric average of the given P0 quantity.
void secmembre_divU_Z(DoubleTab &) const override
Computes the right-hand side of the continuity equation: div(rhoU) = W = -dZ/dT with Z=rho.
void calculer_rho_face_np1(const DoubleTab &rho) override
DoubleTab tab_rho_face_demi
DoubleTab tab_rho_face
Abstract base class for EOS tools used with dilatable fluids.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
const DoubleTab & rho_n() const
const Champ_Inc_base & vitesse() const
const DoubleTab & rho_np1() const
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Base class carrying the terms of the momentum equation for a fluid without turbulence modelling under...
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
static void mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:194
double pas_de_temps() const
Returns the current time step (delta_t).
Base class for output streams.
Definition Sortie.h:52
Special mass source term for the mass equation (used only during the projection/correction step).
virtual void ajouter_projection(const Fluide_Dilatable_base &fluide, DoubleVect &resu) const =0
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")