TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Masse_Fluide_Dilatable_VDF.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 <Convection_Diffusion_Fluide_Dilatable_base.h>
17#include <Source_Masse_Fluide_Dilatable_VDF.h>
18#include <Fluide_Weakly_Compressible.h>
19#include <TRUSTTrav.h>
20#include <Domaine_VF.h>
21
22Implemente_instanciable(Source_Masse_Fluide_Dilatable_VDF,"Source_Masse_Fluide_Dilatable_VDF",Source_Masse_Fluide_Dilatable_base);
23
26/*
27 * Elie Saikali : Implementation notes
28 *
29 * - The classical system of binary mixture LMN equations (iso-thermal) is as follows
30 *
31 * Mass : d rho / dt + div (rho.u) = 0
32 * Momentum : ....
33 * Species : d(rho Y)/dt + div( rho*u*Y ) = div( rho*D*grad(Y) ), which using the mass equation
34 * is written in a non-conservative formulation as : rho d(Y)/dt + rho*u grad(Y) = div( rho*D*grad(Y) )
35 * and when divided by rho as : d(Y)/dt = div( rho*D*grad(Y) ) / rho - u grad(Y)
36 * EOS : ...
37 *
38 * - With the mass source term, the Mass equation becomes
39 *
40 * Mass : d rho / dt + div (rho.u) = S ( S in Kg / s / m3)
41 *
42 * This will induce an additional term in the Species equation that becomes
43 *
44 * Species : rho d(Y)/dt + rho*u grad(Y) = div( rho*D*grad(Y) ) - Y.S
45 * and when divided by rho as : d(Y)/dt = div( rho*D*grad(Y) ) / rho - u grad(Y) - Y.S / rho
46 *
47 * Other equations are not touched ...
48 *
49 *
50 * - Note that the mass equation is never explicitly solved. It is only used in the projection algorithm to correct the velocity using
51 *
52 * div (rho.u) = - d rho / dt + S
53 *
54 * Note that div (rho.u) is located as the pressure : on cell centers in VEF, cell centers + nodes in VEF
55 *
56 * - To code this source term, we have 2 situations (at present) : VDF and VEF. The source term is considered as a volumic one
57 * and is imposed on the first cell near the boundary where the mass is removed ...
58 *
59 *
60 * VDF : ////////////////////////
61 * --------------------------
62 * | | |
63 * | x | x |
64 * | | |
65 * --------------------
66 *
67 * - FOR VDF :
68 *
69 * Y, P on cell centers. All is then straight forward ...
70 *
71 * S = F * surf (F is in kg / m2 / s)
72 *
73 * For projection we code : F * surf / V , where
74 * surf is the surface of the cell touching the boundary and V is the volume of the cell. This gives well the unit Kg / s / m3 ...
75 *
76 * For the species equation we code : - Y * F * surf / (rho * V ), where
77 * Y, rho at cell center, same as before for surf and V... This gives well the unit 1 / s, as d(Y)/dt !
78 *
79 */
81{
82 assert(sub_type(Fluide_Weakly_Compressible,fluide));
83 const DoubleTab& Y = eqn.inconnue().valeurs(), &rho = fluide.masse_volumique().valeurs();
84
85 const Domaine_Cl_dis_base& zclb = domaine_cl_dis_.valeur();
86 const Domaine_VF& zvf = ref_cast(Domaine_VF, zclb.domaine_dis());
87 const IntTab& face_voisins = zvf.face_voisins();
88
89 // for post-processing
90 Champ_Don_base * post_src_ch = fluide.has_source_masse_espece_champ() ? &ref_cast_non_const(Fluide_Dilatable_base, fluide).source_masse_espece() : nullptr;
91
92 // First fill val_flux only for the correct faces ...
93 DoubleTrav val_flux(zvf.nb_faces(), 1);
94 fill_val_flux_tab(val_flux);
95
96 // Now look at resu ...
97 for (int n_bord = 0; n_bord < domaine_cl_dis_->nb_cond_lim(); n_bord++)
98 {
99 const Cond_lim& la_cl = domaine_cl_dis_->les_conditions_limites(n_bord);
100 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
101
102 if (le_bord.le_nom() == nom_bord_)
103 {
104 const int ndeb = le_bord.num_premiere_face(), nfin = ndeb + le_bord.nb_faces();
105 for (int num_face = ndeb; num_face < nfin; num_face++)
106 {
107 const int elem1 = face_voisins(num_face, 0), elem2 = face_voisins(num_face, 1);
108 int elem = elem1 == -1 ? elem2 : elem1;
109 const double surface_elem = zvf.face_surfaces(num_face);
110 double srcmass = -(Y(elem) * val_flux(num_face, 0) * surface_elem) / rho(elem);
111 if (is_expl)
112 srcmass /= zvf.volumes(elem); // divide by volume (no mass solver in the equation ...)
113 resu(elem) += srcmass;
114
115 if (post_src_ch)
116 (*post_src_ch).valeurs()(elem) = srcmass;
117 }
118 }
119 }
120
121 // for post-processing
122 if (post_src_ch)
123 (*post_src_ch).mettre_a_jour(fluide.inco_chaleur().temps());
124}
125
127{
128 assert(sub_type(Fluide_Weakly_Compressible,fluide));
129 const Domaine_Cl_dis_base& zclb = domaine_cl_dis_.valeur();
130 const Domaine_VF& zvf = ref_cast(Domaine_VF, zclb.domaine_dis());
131 const IntTab& face_voisins = zvf.face_voisins();
132
133 // for post-processing
134 Champ_Don_base* post_src_ch = fluide.has_source_masse_projection_champ() ? &ref_cast_non_const(Fluide_Dilatable_base, fluide).source_masse_projection() : nullptr;
135
136 // First fill val_flux only for the correct faces ...
137 DoubleTrav val_flux(zvf.nb_faces(), 1);
138 fill_val_flux_tab(val_flux);
139
140 // Now look at resu ...
141 for (int n_bord = 0; n_bord < domaine_cl_dis_->nb_cond_lim(); n_bord++)
142 {
143 const Cond_lim& la_cl = domaine_cl_dis_->les_conditions_limites(n_bord);
144 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
145
146 if (le_bord.le_nom() == nom_bord_)
147 {
148 const int ndeb = le_bord.num_premiere_face(), nfin = ndeb + le_bord.nb_faces();
149
150 for (int num_face = ndeb; num_face < nfin; num_face++)
151 {
152 const int elem1 = face_voisins(num_face, 0), elem2 = face_voisins(num_face, 1);
153 int elem = elem1 == -1 ? elem2 : elem1;
154 const double surf = zvf.face_surfaces(num_face);
155 const double source_per_dv = val_flux(num_face, 0) * surf / zvf.volumes(elem); // TODO multiple elements!! units [kg.s-1] / zvf.volumes(elem)
156 resu(elem) -= source_per_dv; // in [kg.m-3.s-1]
157
158 if (post_src_ch)
159 (*post_src_ch).valeurs()(elem) = source_per_dv;
160 }
161 }
162 }
163
164 // for post-processing
165 if (post_src_ch)
166 (*post_src_ch).mettre_a_jour(fluide.inco_chaleur().temps());
167}
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs()=0
double temps() const
Returns the time of the field.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Base class for convection-diffusion equations for a dilatable fluid.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
Domaine_dis_base & domaine_dis()
Returns a reference to the discretized domain associated with the boundary conditions.
class Domaine_VF
Definition Domaine_VF.h:44
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
double volumes(int i) const
Definition Domaine_VF.h:113
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Base class for a dilatable fluid, inheriting from Fluide_base.
bool has_source_masse_espece_champ() const
bool has_source_masse_projection_champ() const
const Champ_Inc_base & inco_chaleur() const
Fluide_Weakly_Compressible class This class represents a weakly compressible fluid,...
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
const Nom & le_nom() const override
Returns the name of the geometric boundary.
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
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
Base class for output streams.
Definition Sortie.h:52
void ajouter_eq_espece(const Convection_Diffusion_Fluide_Dilatable_base &eqn, const Fluide_Dilatable_base &fluide, const bool is_expl, DoubleVect &resu) const override
void ajouter_projection(const Fluide_Dilatable_base &fluide, DoubleVect &resu) const override
Special mass source term for the mass equation (used only during the projection/correction step).