TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Masse_Fluide_Dilatable_base.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Source_Masse_Fluide_Dilatable_base.h>
17#include <Champ_front_uniforme.h>
18#include <Schema_Temps_base.h>
19#include <Probleme_base.h>
20#include <Equation_base.h>
21#include <Domaine_VF.h>
22#include <SFichier.h>
23#include <Param.h>
24
25Implemente_base(Source_Masse_Fluide_Dilatable_base, "Source_Masse_Fluide_Dilatable_base", Objet_U);
26// XD mass_source interprete nul BRACE Mass source used in a dilatable simulation to add/reduce a mass at the boundary
27// XD_CONT (volumetric source in the first cell of a given boundary).
28
30{
31 return os;
32}
33
35{
36 Param param(que_suis_je());
37 param.ajouter("bord", &nom_bord_, Param::REQUIRED); // XD_ADD_P chaine
38 // XD_CONT Name of the boundary where the source term is applied
39 param.ajouter("surfacic_flux", &ch_front_source_, Param::REQUIRED); // XD_ADD_P front_field_base
40 // XD_CONT The boundary field that the user likes to apply: for example, champ_front_uniforme, ch_front_input_uniform
41 // XD_CONT or champ_front_fonc_t
42 param.lire_avec_accolades_depuis(is);
43
44 if (!sub_type(Champ_front_base, ch_front_source_.valeur()))
45 {
46 Cerr << "Source_Masse_Fluide_Dilatable_base::readOn() - param 'surfacic_flux' must be a Champ_front!!" << finl;
48 }
49 return is;
50}
51
56
58{
59 Cerr << "Source_Masse_Fluide_Dilatable_base::completer() ..." << finl;
60 // Initialize properly the champ_front - not done automatically because we are not in the scope of
61 // boundary conditions. This will:
62 // - call associer_fr_dis_base()
63 // - fix the number of temporal values for champ_front.
64 // - call initialiser()
65 // This is all inspired by what happens in Conds_lim::completer() and Conds_lim::initialiser() ...
66 bool ok = false;
67 for (int n_bord = 0; n_bord < domaine_cl_dis_->nb_cond_lim(); n_bord++)
68 {
69 const Cond_lim& la_cl = domaine_cl_dis_->les_conditions_limites(n_bord);
70 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
71 if (le_bord.le_nom() == nom_bord_)
72 {
73 ch_front_source_->associer_fr_dis_base(la_cl->frontiere_dis());
74 ok = true;
75 break;
76 }
77 }
78
79 if (!ok)
80 {
81 Cerr << "Source_Masse_Fluide_Dilatable_base::associer_domaine(): Internal error - should not happen !!" << finl;
83 }
84
85 // Fix the number of temporal values for champ_front.
86 int nb_cases = domaine_cl_dis_->equation().schema_temps().nb_valeurs_temporelles();
87 ch_front_source_->fixer_nb_valeurs_temporelles(nb_cases);
88
89 // Initialisation of the champ_front:
90 double tps = domaine_cl_dis_->equation().schema_temps().temps_courant();
91 ch_front_source_->initialiser(tps, domaine_cl_dis_->inconnue());
92
93 ncomp_ = ch_front_source_->valeurs().line_size();
94
96 file_out_ += "_source_Masse_flux_";
97 file_out_ += domaine_cl_dis_->equation().probleme().le_nom();
98 file_out_ += ".out";
99
100 Cerr << "Source_Masse_Fluide_Dilatable_base => File " << file_out_ << " created ..." << finl;
101
102 if (je_suis_maitre())
103 {
104 SFichier fic(file_out_);
105 fic << "# Convective and Diffusive mass source flux at the " << nom_bord_ << " boundary" << finl;
106 fic << "# Time";
107
108 for (int i = 0; i < ncomp_; i++)
109 fic << " \t Convective_flux_species_" << i << " \t Diffusive_flux_species_" << i;
110
111 fic << finl;
112 }
113}
114
116{
117 //ch_front_source_->avancer(temps);
118
119 double sum_conv = 0.;
120 std::vector<double> sum_diff_vect(ncomp_);
121 const DoubleTab& val_flux0 = ch_front_source_->valeurs();
122
123 const Domaine_Cl_dis_base& zclb = domaine_cl_dis_.valeur();
124 const Domaine_VF& zvf = ref_cast(Domaine_VF, zclb.domaine_dis());
125
126 for (int n_bord = 0; n_bord < domaine_cl_dis_->nb_cond_lim(); n_bord++)
127 {
128 const Cond_lim& la_cl = domaine_cl_dis_->les_conditions_limites(n_bord);
129 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
130
131 if (le_bord.le_nom() == nom_bord_)
132 {
133 // Handle uniform case ... such a pain:
134 const int is_uniforme = sub_type(Champ_front_uniforme, ch_front_source_.valeur());
135 const int ndeb = le_bord.num_premiere_face(), nfin = ndeb + le_bord.nb_faces();
136
137 for (int i = 0; i < ncomp_; i++)
138 {
139 double sum_diff = 0.;
140 for (int f = ndeb; f < nfin; f++)
141 {
142 const double surf = zvf.face_surfaces(f);
143 sum_diff += is_uniforme ? val_flux0(0, i) * surf : val_flux0(f - ndeb, i) * surf;
144 }
145
146 sum_diff_vect[i] = Process::mp_sum(sum_diff);
147 }
148 }
149 }
150
151 if (je_suis_maitre())
152 {
153 SFichier fic(file_out_, ios::app);
154 fic.setf(ios::scientific);
155 fic << temps;
156
157 for (int i = 0; i < ncomp_; i++)
158 fic << " \t " << sum_conv << " \t " << sum_diff_vect[i];
159
160 fic << finl;
161 }
162}
163
165{
166 ch_front_source_->changer_temps_futur(temps, i);
167}
168
170{
171 ch_front_source_->set_temps_defaut(temps);
172}
173
175{
176 const DoubleTab& val_flux0 = ch_front_source_->valeurs();
177 /*
178 * XXX Elie Saikali May 2025 : issue with ICoCo ...
179 * Note: val_flux has the dimension of nb_faces whereas val_flux0 has the dimension of nb_faces of boundary nom_bord_ ...
180 * the correct faces must be filled.
181 * We start by filling val_flux only for the correct faces ...
182 */
183 for (int n_bord = 0; n_bord < domaine_cl_dis_->nb_cond_lim(); n_bord++)
184 {
185 const Cond_lim& la_cl = domaine_cl_dis_->les_conditions_limites(n_bord);
186 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
187
188 if (le_bord.le_nom() == nom_bord_)
189 {
190 // Handle uniform case ... such a pain:
191 const int is_uniforme = sub_type(Champ_front_uniforme, ch_front_source_.valeur());
192 const int ndeb = le_bord.num_premiere_face(), nfin = ndeb + le_bord.nb_faces();
193
194 for (int num_face = ndeb; num_face < nfin; num_face++)
195 for (int ncomp = 0; ncomp < val_flux0.line_size(); ncomp++)
196 val_flux(num_face, 0) += is_uniforme ? val_flux0(0, ncomp) : val_flux0(num_face - ndeb, ncomp);
197 }
198 }
199}
class Champ_front_uniforme Derived class of Champ_front_base representing
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
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
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.
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.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
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 const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
Definition Objet_U.cpp:145
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
@ REQUIRED
Definition Param.h:115
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
virtual int nb_valeurs_temporelles() const =0
void setf(IOS_FORMAT code) override
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 associer_domaine_cl(const Domaine_Cl_dis_base &)
int line_size() const
Definition TRUSTVect.tpp:67