TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Pb_rayo_semi_transp.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_rayo_semi_transp_base.h>
17#include <Cond_lim_rayo_semi_transp.h>
18#include <Pb_rayo_semi_transp.h>
19#include <Discretisation_base.h>
20#include <Flux_radiatif_base.h>
21#include <Schema_Temps_base.h>
22#include <Champ_Uniforme.h>
23#include <Fluide_base.h>
24#include <Symetrie.h>
25#include <Domaine.h>
26
27Implemente_instanciable(Pb_rayo_semi_transp, "Pb_rayo_semi_transp", Probleme_base);
28
30
31Sortie& Pb_rayo_semi_transp::printOn(Sortie& os) const { return os; }
32
34{
35 return eq_rayo().initTimeStep(dt);
36}
37
39{
40 converged = true;
41 return eq_rayo().resoudre();
42}
43
45{
46 double temps = pb_fluide_->presentTime();
47 eq_rayo().mettre_a_jour(temps);
49 les_postraitements_.mettre_a_jour(temps);
50 statistics().begin_count(STD_COUNTERS::update_variables, statistics().get_last_opened_counter_level() + 1);
52 statistics().end_count(STD_COUNTERS::update_variables);
53}
54
56{
57 le_schema_en_temps_ = un_schema_en_temps;
58 le_schema_en_temps_->associer_pb(*this);
59}
60
62{
63 for (int i=0; i<nombre_d_equations(); i++)
65}
66
68{
69 // Associate the fluid + various operations
70 if (sub_type(Fluide_base, pb_fluide_->milieu()))
71 {
72 Fluide_base& fluide = ref_cast(Fluide_base, pb_fluide_->milieu());
73 eq_rayo_.associer_fluide(fluide);
74
75 if (fluide.is_rayo_semi_transp())
76 {
77 Champ_Don_base& coeff_abs = fluide.kappa();
78
79 if (sub_type(Champ_Uniforme, coeff_abs))
80 {
81 // Type the OWN_PTR(Champ_Don_base) longueur_rayo_ as a Champ_Uniforme
82 fluide.typer_longeur_rayo("Champ_Uniforme");
83 Champ_Don_base& l_rayo = fluide.longueur_rayo();
84 Champ_Uniforme& ch_l_rayo = ref_cast(Champ_Uniforme, l_rayo);
85 ch_l_rayo.nommer("longueur_de_rayonnement");
86 ch_l_rayo.fixer_nb_comp(1);
87 // The number of nodal values is fixed to 1 here because this is a
88 // Champ_Uniforme; in other cases it must be set equal to the number of elements or faces depending on the field location
89 ch_l_rayo.fixer_nb_valeurs_nodales(1);
90 ch_l_rayo.fixer_unite("m");
91 ch_l_rayo.changer_temps(0);
92 }
93 else
94 {
95 Cerr << "The absorption coefficient is not a uniform OWN_PTR(Champ_base) but a " << coeff_abs.que_suis_je() << ". modify the method " << finl;
96 Cerr << "Pb_Couple_rayo_semi_transp::discretiser to be able to handle this type of Champ_Don" << finl;
97 }
98 fluide.initialiser(pb_fluide_->schema_temps().temps_courant());
99 }
100 else
101 {
102 Cerr << "Error 0 in Pb_Couple_rayo_semi_transp::discretiser you have probably not specified all the" << finl;
103 Cerr << "physical parameters of your incompressible fluid to handle a semi-transparent radiation problem" << finl;
105 }
106 }
107 else
108 {
109 Cerr << "Error in Pb_rayo_semi_transp::readOn: the semi-transparent radiation problem can only be used" << finl;
110 Cerr << "with a Fluide_base and not " << pb_fluide_->milieu().que_suis_je() << finl;
112 }
113}
114
116{
117 int contient_source_rayo_semi_transp = 0;
118
119 for (int j = 0; j < pb_fluide_->nombre_d_equations(); j++)
120 {
121
122 // Associate the problem to the radiation boundary conditions.
123 Domaine_Cl_dis_base& la_zcl = pb_fluide_->equation(j).domaine_Cl_dis();
124 for (int num_cl = 0; num_cl < la_zcl.nb_cond_lim(); num_cl++)
125 {
126 Cond_lim_base& la_cl = la_zcl.les_conditions_limites(num_cl).valeur();
127 Cond_lim_rayo_semi_transp *la_cl_rayo_semi_transp;
128
129 if (la_cl.is_bc_rayo_semi_transp(la_cl_rayo_semi_transp))
130 {
131 la_cl_rayo_semi_transp->associer_pb_rayo_semi_transp(*this);
132 la_cl_rayo_semi_transp->recherche_emissivite_et_A();
133
134 // In the case of a contact exchange, the opposite BC must also be completed
135 la_cl_rayo_semi_transp->completer_Cl_opposee_si_contact();
136 }
137 }
138
139 // Associate the problem to the radiation source term of the temperature equation
140 Sources& les_sources = pb_fluide_->equation(j).sources();
141 for (int num_source = 0; num_source < les_sources.size(); num_source++)
142 if ((sub_type(Source_rayo_semi_transp_base, les_sources[num_source].valeur())))
143 contient_source_rayo_semi_transp = 1;
144 }
145
146 if (contient_source_rayo_semi_transp == 0)
147 {
148 Cerr << "Warning, you have not defined a semi-transparent radiation source term" << finl;
149 Cerr << "remember to add the source term Source_rayo_semi_transp in the list of source terms " << finl;
150 Cerr << "of the energy equation" << finl;
152 }
153 eq_rayo().completer();
154}
155
157{
158 // Only discretise the equations
160}
161
162// Update the radiative flux for all boundaries of the problem
164{
166
167 for (int num_cl_rayo = 0; num_cl_rayo < les_cl_rayo.size(); num_cl_rayo++)
168 {
169 Cond_lim& la_cl_rayo = eq_rayo().domaine_Cl_dis().les_conditions_limites(num_cl_rayo);
170 if (sub_type(Flux_radiatif_base, la_cl_rayo.valeur()))
171 {
172 Flux_radiatif_base& la_cl_rayon = ref_cast(Flux_radiatif_base, la_cl_rayo.valeur());
173 Equation_base& eq_temp = pb_fluide_->equation(1);
174 la_cl_rayon.calculer_flux_radiatif(eq_temp);
175 }
176 else if (sub_type(Symetrie, la_cl_rayo.valeur()))
177 {
178 /* Do nothing */
179 }
180 else
181 {
182 Cerr << "Error: the boundary conditions of the radiation equation" << finl;
183 Cerr << "must necessarily be of radiation type" << finl;
185 }
186 }
187}
188
190{
191 // Loop over the boundaries to find the one whose name is nom_bord
192 const Conds_lim& les_cl_rayo = eq_rayo().domaine_Cl_dis().les_conditions_limites();
193
194 for (int num_cl_rayo = 0; num_cl_rayo < les_cl_rayo.size(); num_cl_rayo++)
195 {
196 const Cond_lim& la_cl_rayo = eq_rayo().domaine_Cl_dis().les_conditions_limites(num_cl_rayo);
197
198 if (la_cl_rayo->frontiere_dis().le_nom() == nom_bord)
199 {
200 if (sub_type(Flux_radiatif_base, la_cl_rayo.valeur()))
201 {
202 Flux_radiatif_base& la_cl_rayon = ref_cast_non_const(Flux_radiatif_base, la_cl_rayo.valeur());
203 return la_cl_rayon.flux_radiatif();
204 }
205 else
206 {
207 Cerr << "Error: the boundary conditions of the radiation equation" << finl;
208 Cerr << "must necessarily be of radiation type" << finl;
210
211 }
212 }
213 }
214 Cerr << "Error: Pb_rayo_semi_transp::flux_radiatif" << finl;
215 Cerr << "there is no boundary condition named " << nom_bord << finl;
217 //for the compilers
218 const Cond_lim& la_cl_rayo = eq_rayo().domaine_Cl_dis().les_conditions_limites(0);
219 Flux_radiatif_base& la_cl_rayon = ref_cast_non_const(Flux_radiatif_base, la_cl_rayo.valeur());
220 return la_cl_rayon.flux_radiatif();
221}
class Champ_Don_base base class of Given Fields (not calculated)
int fixer_nb_valeurs_nodales(int nb_noeuds) override
Sets the number of degrees of freedom per component.
Champ_Uniforme Represents a field that is constant in space and time.
virtual double changer_temps(const double t)
Sets the time at which the field is defined.
class Champ_front_base Base class for the hierarchy of boundary fields.
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
virtual bool is_bc_rayo_semi_transp(Cond_lim_rayo_semi_transp *&la_cl_rayo)
Base class for semi-transparent radiation boundary conditions.
virtual void associer_pb_rayo_semi_transp(const Pb_rayo_semi_transp &)
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
int nb_cond_lim() const
Returns the number of boundary conditions.
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void completer() override
Completes the construction (initialization) of objects associated with the equation.
bool initTimeStep(double dt) override
Allocation and initialization of the unknown and boundary conditions until present+dt.
class Equation_base The role of an equation is the calculation of one or more fields....
Sources & sources()
Returns the source terms associated with the equation.
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
void nommer(const Nom &) override
Gives a name to the field.
virtual const Nom & fixer_unite(const Nom &)
Specifies the unit of a scalar field or whose all components have the same unit.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
bool is_rayo_semi_transp() const override
Definition Fluide_base.h:81
void typer_longeur_rayo(const Nom &typ)
Definition Fluide_base.h:79
int initialiser(const double temps) override
Initializes the fluid parameters.
Champ_Don_base & kappa()
Definition Fluide_base.h:68
Champ_Don_base & longueur_rayo()
Definition Fluide_base.h:77
Champ_front_base & flux_radiatif()
virtual void calculer_flux_radiatif(const Equation_base &eq_temp)=0
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:71
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
Semi-transparent radiation problem. Pb_rayo_semi_transp is a Probleme_base with 4 specific features:
void preparer_calcul() override
Prepares the computation: initializes the medium parameters and prepares the computation of each equa...
const Champ_front_base & flux_radiatif(const Nom &nom_bord) const
bool iterateTimeStep(bool &converged) override
In the case solveTimeStep uses an iterative process, this method executes a single iteration.
void validateTimeStep() override
Validates the calculated unknown by moving the present time at the end of the time step.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
void typer_lire_milieu(Entree &is) override
int nombre_d_equations() const override
Eq_rayo_semi_transp & eq_rayo()
void associer_sch_tps_base(const Schema_Temps_base &) override
Associates a time scheme with the problem.
bool initTimeStep(double dt) override
This method allocates and initializes the unknown and given fields for the future time step.
const Equation_base & equation(int i) const override
Eq_rayo_semi_transp eq_rayo_
class Probleme_base It is a Probleme_U that is not a coupling.
virtual void discretiser_equations()
Postraitements les_postraitements_
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
class Schema_Temps_base
virtual void associer_pb(const Probleme_base &)
virtual int mettre_a_jour()
Updates the current time (t+=dt) and the number of time steps performed (nb_pas_dt_++).
Base class for output streams.
Definition Sortie.h:52
Source_rayo_semi_transp_base Base class of the source term hierarchy for the temperature.
class Sources Sources represents a list of Source objects.
Definition Sources.h:31
Symetrie On symmetry faces, the following properties hold:
Definition Symetrie.h:37