TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Convection_Diffusion_Chaleur_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 <Convection_Diffusion_Chaleur_Fluide_Dilatable_base.h>
17#include <EcritureLectureSpecial.h>
18#include <Fluide_Dilatable_base.h>
19#include <Neumann_sortie_libre.h>
20#include <Navier_Stokes_std.h>
21#include <Probleme_base.h>
22#include <Discret_Thyd.h>
23#include <TRUST_2_PDI.h>
24#include <Domaine.h>
25#include <Avanc.h>
26
27Implemente_base(Convection_Diffusion_Chaleur_Fluide_Dilatable_base,"Convection_Diffusion_Chaleur_Fluide_Dilatable_base",Convection_Diffusion_Fluide_Dilatable_base);
28
30{
32}
33
35{
37 terme_convectif.set_fichier("Convection_chaleur");
38 terme_convectif.set_description((Nom)"Convective heat transfer rate=Integral(-rho*cp*T*u*ndS) [W] if SI units used");
39 terme_diffusif.set_fichier("Diffusion_chaleur");
40 terme_diffusif.set_description((Nom)"Conduction heat transfer rate=Integral(lambda*grad(T)*ndS) [W] if SI units used");
41 // Rename the field here so it can be recognized if an enthalpy probe is requested.
42 if (le_fluide->type_fluide()=="Gaz_Reel") l_inco_ch->nommer("enthalpie");
43 return is;
44}
45
50
52{
53 const Probleme_base& pb = probleme();
54 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std,pb.equation(0));
55 const Champ_Inc_base& vitessetransportante = eqn_hydr.rho_la_vitesse(); // rho * u
56 return vitessetransportante;
57}
58
60{
61 const Discret_Thyd& dis=ref_cast(Discret_Thyd, discretisation());
62 Cerr << "Energy equation discretization " << finl;
63 dis.temperature(schema_temps(), domaine_dis(), l_inco_ch);
64 if (le_fluide->type_fluide()=="Gaz_Reel") l_inco_ch->add_synonymous("enthalpie");
65 champs_compris_.ajoute_champ(l_inco_ch);
67 Cerr << "Convection_Diffusion_Chaleur_Fluide_Dilatable_base::discretiser() ok" << finl;
68}
69
71{
72 derivee=0;
73 return derivee_en_temps_inco_sans_solveur_masse_impl(*this,derivee,true /* explicit */);
74}
75
76void Convection_Diffusion_Chaleur_Fluide_Dilatable_base::assembler( Matrice_Morse& matrice,const DoubleTab& inco, DoubleTab& resu)
77{
79}
80
81void Convection_Diffusion_Chaleur_Fluide_Dilatable_base::assembler_blocs_avec_inertie(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl)
82{
83 statistics().begin_count(STD_COUNTERS::ajouter_blocs,statistics().get_last_opened_counter_level()+1);
84 Convection_Diffusion_Fluide_Dilatable_Proto::assembler_blocs(*this,matrices, secmem, semi_impl);
85 schema_temps().ajouter_blocs(matrices, secmem, *this);
86 if (!discretisation().is_poly_family())
87 {
88 const std::string& nom_inco = inconnue().le_nom().getString();
89 Matrice_Morse *mat = matrices.count(nom_inco) ? matrices.at(nom_inco) : nullptr;
90 modifier_pour_Cl(*mat,secmem);
91 }
92 statistics().end_count(STD_COUNTERS::ajouter_blocs);
93}
94
95/*! @brief for PDI IO: retrieve name and type and dimensions of the thermo pressure
96 *
97 */
99{
100 std::vector<YAML_data> data = Equation_base::data_a_sauvegarder();
101 Nom pth("pression_thermo");
102 pth += probleme().domaine().le_nom();
103 YAML_data d(pth.getString(), "double");
104 d.set_local(false /*same value for everyone*/);
105 data.push_back(d);
106 return data;
107}
108
110{
111 int bytes=0;
112 bytes += Equation_base::sauvegarder(os);
113 // in special write mode only the master writes
114 int a_faire,special;
116
117 Nom ident_Pth("pression_thermo");
118 ident_Pth += probleme().domaine().le_nom();
119 if (a_faire)
120 {
121 double temps = inconnue().temps();
122 ident_Pth += Nom(temps,"%e");
123 os << ident_Pth<<finl;
124 os << "constante"<<finl;
125 os << le_fluide->pression_th();
126 os << flush ;
127 Cerr << "Saving thermodynamic pressure at time : " << Nom(temps,"%e") << finl;
128 }
130 {
131 bytes += 8;
132 TRUST_2_PDI pdi_interface;
133 pdi_interface.TRUST_start_sharing(ident_Pth.getString(), &le_fluide->get_pression_th());
134 }
135 return bytes;
136}
137
138/*! @brief Resumes computation from an input stream.
139 *
140 * Calls Equation_base::reprendre() and resumes the heat unknown and the thermodynamic pressure.
141 *
142 * @param is Input stream.
143 * @return Always returns 1.
144 */
146{
147 if (le_fluide->type_fluide() != "Gaz_Parfait") l_inco_ch->nommer("enthalpie");
149 Nom ident_Pth("pression_thermo");
150 ident_Pth += probleme().domaine().le_nom();
151 double pth;
153 {
154 TRUST_2_PDI pdi_interface;
155 pdi_interface.read(ident_Pth.getString(), &pth);
156 }
157 else
158 {
159 double temps = schema_temps().temps_courant();
160 ident_Pth += Nom(temps,probleme().reprise_format_temps());
161 if (probleme().discretisation().is_poly_family())
162 {
163 Nom field_tag_syno = create_polymacfamily_syno(ident_Pth);
164 avancer_fichier_with_syno(is,ident_Pth,field_tag_syno);
165 }
166 // end of the backward compatibility
167 else
168 avancer_fichier(is, ident_Pth);
169 is>>pth;
170 }
171 le_fluide->set_pression_th(pth);
172 return 1;
173}
174
180
181/*! @brief @brief Fills the modified boundary condition domain with 1 everywhere on the boundary.
182 *
183 */
185{
186 zcl_modif_= domaine_Cl_dis();
187 Conds_lim& condlims=zcl_modif_->les_conditions_limites();
188 int nb=condlims.size();
189 // for each boundary condition, retrieve the front field and set it to 1
190 // even if the boundary condition is a flux (in that case convection will remain zero)
191 for (int i=0; i<nb; i++)
192 {
193 DoubleTab& T=condlims[i]->champ_front().valeurs();
194 T=1.;
195 if (sub_type(Neumann_sortie_libre,condlims[i].valeur()))
196 ref_cast(Neumann_sortie_libre,condlims[i].valeur()).tab_ext()=1;
197 }
198 zcl_modif_->les_conditions_limites().set_modifier_val_imp(0);
199 return 1;
200}
201
202/*! @brief Returns the name of the equation's application domain.
203 *
204 * Here "Thermique".
205 *
206 * @return Name of the equation's application domain.
207 */
209{
210 static Motcle domaine = "Thermique_H";
211 if (le_fluide->type_fluide()=="Gaz_Parfait") domaine = "Thermique";
212 return domaine;
213}
Class Champ_Inc_base.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
double temps() const
Returns the time of the field.
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
void set_modifier_val_imp(int)
Sets the modifier_val_imp flag for all boundary conditions in the vector.
Definition Conds_lim.h:107
Particular case of Convection_Diffusion_std for a quasi-dilatable fluid when the transported scalar i...
int reprendre(Entree &) override
Resumes computation from an input stream.
void assembler(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &resu) override
std::vector< YAML_data > data_a_sauvegarder() const override
for PDI IO: retrieve name and type and dimensions of the thermo pressure
DoubleTab & derivee_en_temps_inco(DoubleTab &) override
Returns the time derivative of the unknown I of the equation: dI/dt = M-1*(sum(operators(I) + sources...
int sauvegarder(Sortie &) const override
Saves an Objet_U to an output stream. Virtual method to override.
const Motcle & domaine_application() const override
Returns the name of the equation's application domain.
int preparer_calcul() override
Everything that does not depend on other possible problems.
void assembler_blocs_avec_inertie(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl) override
int remplir_cl_modifiee()
Fills the modified boundary condition domain with 1 everywhere on the boundary.
DoubleTab & derivee_en_temps_inco_sans_solveur_masse_impl(Convection_Diffusion_Fluide_Dilatable_base &eqn, DoubleTab &derivee, const bool is_expl)
Returns the time derivative of the equation's unknown.
public_for_cuda void assembler_impl(Convection_Diffusion_Fluide_Dilatable_base &eqn, Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem)
void assembler_blocs(Convection_Diffusion_Fluide_Dilatable_base &eqn, matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl)
Base class for convection-diffusion equations for a dilatable fluid.
void temperature(const Schema_Temps_base &, Domaine_dis_base &, OWN_PTR(Champ_Inc_base)&, int nb_comp=1) const
class Discret_Thyd This class is the base class representing a discretization
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
static int is_ecriture_special(int &special, int &a_faire)
Indicates whether the special format was requested in active writing by xyz save.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
int reprendre(Entree &) override
We resume the unknown from an input stream.
virtual std::vector< YAML_data > data_a_sauvegarder() const
for PDI IO: retrieve name, type and dimensions of the data to save/restore. This has to be overrode f...
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
Nom create_polymacfamily_syno(const Nom &field_tag) const
Create a synonym of a field name in order to ensure backward compatibility with old names of the Poly...
virtual int preparer_calcul()
Everything that does not depend on other possible problems.
virtual void modifier_pour_Cl(Matrice_Morse &mat_morse, DoubleTab &secmem) const
int sauvegarder(Sortie &) const override
We save the unknown, then the source terms to an output stream.
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void discretiser()
Discretizes the equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
const Nom & le_nom() const override
Returns the name of the field.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
virtual const Champ_Don_base & diffusivite() const
Returns the diffusivity of the medium (const version).
A character string (Nom) in uppercase.
Definition Motcle.h:26
Navier_Stokes_std This class carries the terms of the momentum equation.
virtual const Champ_Inc_base & rho_la_vitesse() const
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
virtual void nommer(const Nom &)
Assigns a name to the Objet_U. Virtual method to override.
Definition Objet_U.cpp:327
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
class Probleme_base It is a Probleme_U that is not a coupling.
const Domaine & domaine() const
Returns the domain associated with the problem.
virtual const Equation_base & equation(int) const =0
double temps_courant() const
Returns the current time.
virtual void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const Equation_base &eqn, const tabs_t &semi_impl={}) const
Base class for output streams.
Definition Sortie.h:52
TRUST_2_PDI Encapsulation of PDI methods (library used for IO operations). See the website pdi....
Definition TRUST_2_PDI.h:59
void read(const std::string &name, void *data)
static int is_PDI_checkpoint()
static int is_PDI_restart()
void TRUST_start_sharing(const std::string &name, const void *data)
YAML_data class: collection of all needed information for data to save/restore in order to write the ...
Definition YAML_data.h:26
void set_local(bool l)
Definition YAML_data.h:35