TrioCFD 1.9.8
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 // pour post
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 // On commence par remplir val_flux seulement pour les bonnes faces ...
93 DoubleTrav val_flux(zvf.nb_faces(), 1);
94 fill_val_flux_tab(val_flux);
95
96 // Maintennat on regarde 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); // on divise par volume (pas de solveur masse dans l'equation ...)
113 resu(elem) += srcmass;
114
115 if (post_src_ch)
116 (*post_src_ch).valeurs()(elem) = srcmass;
117 }
118 }
119 }
120
121 // pour post
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 // pour post
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 // On commence par remplir val_flux seulement pour les bonnes faces ...
137 DoubleTrav val_flux(zvf.nb_faces(), 1);
138 fill_val_flux_tab(val_flux);
139
140 // Maintennat on regarde 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 // pour post
165 if (post_src_ch)
166 (*post_src_ch).mettre_a_jour(fluide.inco_chaleur().temps());
167}
classe Champ_Don_base classe de base des Champs donnes (non calcules)
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
virtual DoubleTab & valeurs()=0
double temps() const
Renvoie le temps du champ.
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
classe Convection_Diffusion_Fluide_Dilatable_base pour un fluide dilatable
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
Domaine_dis_base & domaine_dis()
Renvoie une reference sur le domaine discretise associe aux conditions aux limites.
class Domaine_VF
Definition Domaine_VF.h:44
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
renvoie le nombre global de 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
renvoie l'element voisin de numface dans la 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
classe Fluide_Dilatable_base Cette classe represente un d'un fluide dilatable,
bool has_source_masse_espece_champ() const
bool has_source_masse_projection_champ() const
const Champ_Inc_base & inco_chaleur() const
classe Fluide_Weakly_Compressible Cette classe represente un d'un fluide faiblement compressible
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
Renvoie le nom de la frontiere geometrique.
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
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 de base des flux de sortie.
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
: classe Source_Masse_Fluide_Dilatable_base Une source speciale pour l'equation de masse (utilisee se...