TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Eq_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 <Eq_rayo_semi_transp.h>
17#include <Pb_rayo_semi_transp.h>
18#include <Matrice_Morse_Sym.h>
19#include <Champ_Uniforme.h>
20#include <Matrice_Bloc.h>
21#include <Discret_Thyd.h>
22#include <Fluide_base.h>
23#include <EChaine.h>
24#include <Param.h>
25
26Implemente_instanciable(Eq_rayo_semi_transp, "Eq_rayo_semi_transp", Equation_base);
27
29{
30 schema_temps().set_dt() = dt;
32}
33
35{
36 rayo_solv_->resoudre(temps);
37}
38
40{
41 rayo_solv_->resoudre(schema_temps().temps_courant() + schema_temps().pas_de_temps());
42 return true;
43}
44
45Sortie& Eq_rayo_semi_transp::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
46
48
50{
51 param.ajouter_non_std("conditions_limites|boundary_conditions", (this), Param::REQUIRED);
52 param.ajouter_non_std("solveur", (this), Param::REQUIRED);
53}
54
56{
57 int retval = 1;
58 if (mot == "conditions_limites|boundary_conditions")
59 {
60 lire_cl(is);
61 verif_Cl();
62 }
63 else if (mot == "solveur")
64 {
65 Cerr << "Reading and typing of the radiation equation solver :" << finl;
66 Nom nom_solveur("Solv_");
67 Nom type_solv_sys;
68 is >> type_solv_sys;
69 nom_solveur += type_solv_sys;
70 Cerr << "Name of the radiation equation solver : " << nom_solveur << finl;
71 solveur_.typer(nom_solveur);
72 is >> solveur_.valeur();
73 solveur_.nommer("solveur_irradiance");
74 }
75 else
76 retval = -1;
77
78 return retval;
79}
80
82{
83 const Domaine_dis_base& dom_dis = domaine_dis();
84 for (int i = 0; i < dom_dis.nb_front_Cl(); i++)
85 {
86 const Frontiere_dis_base& la_fr_dis = dom_dis.frontiere_dis(i);
87 le_dom_Cl_dis->les_conditions_limites(i)->associer_fr_dis_base(la_fr_dis);
88 }
89
90 // typing of the diffusion operator
91 Cerr << "Reading and typing of the diffusion operator of equation " << que_suis_je() << finl;
92
93 if (sub_type(Fluide_base, fluide()))
94 if (fluide().is_rayo_semi_transp())
95 {
96 if (fluide().is_longueur_rayo_discretised())
97 terme_diffusif_.associer_diffusivite(fluide().longueur_rayo());
98 else
99 {
100 Cerr << "Error in Eq_rayo_semi_transp::completer." << finl;
101 Cerr << "You may not have discretized the problem of type Pb_Couple_rayo_semi_transp." << finl;
103 }
104 }
105 else
106 {
107 Cerr << "Error : the radiative properties of the incompressible fluid have not" << finl;
108 Cerr << "been defined while a semi transparent radiation problem is used." << finl;
109 Cerr << "The fields kappa and indice which respectively define the absoption coefficient" << finl;
110 Cerr << "and the refraction index must be added to the fluid properties." << finl;
112 }
113 else
114 {
115 Cerr << "Error while reading the Radiation equation. Your fluid is of type " << fluide().que_suis_je() << finl;
116 Cerr << "Currently only fluid of type Fluide_base can be considered with the semi transparent radiation model." << finl;
118 }
119
120 EChaine diff("{ }");
121 diff >> terme_diffusif_;
122 terme_diffusif_->associer_diffusivite(fluide().longueur_rayo());
123 terme_diffusif_.completer();
124 terme_diffusif_->dimensionner(la_matrice_);
125
127
128 // The matrix is assembled once and for all at the start of the computation
129 // XXX Warning: this is only valid if kappa is constant over time
130 rayo_solv_->assembler_matrice();
131}
132
133/*! @brief Associates a physical medium with the equation.
134 *
135 * @param un_milieu The physical medium to associate with the equation.
136 */
138{
139 if (sub_type(Fluide_base, un_milieu))
140 if (fluide().is_rayo_semi_transp())
141 {
142 const Fluide_base& un_fluide = ref_cast(Fluide_base, un_milieu);
143 associer_fluide(un_fluide);
144 le_fluide_ = un_fluide;
145 }
146 else
147 {
148 Cerr << "Error : the radiative properties of the incompressible fluid have not" << finl;
149 Cerr << "been defined while a semi transparent radiation problem is used." << finl;
150 Cerr << "The fields kappa and indice which respectively define the absoption coefficient" << finl;
151 Cerr << "and the refraction index must be added to the fluid properties." << finl;
153 }
154 else
155 {
156 Cerr << "Error while reading the Radiation equation. Your fluid is of type " << fluide().que_suis_je() << finl;
157 Cerr << "Currently only fluid of type Fluide_base can be considered with the semi transparent radiation model." << finl;
159 }
160}
161
162/*! @brief Returns the physical medium of the equation (the Fluide_base upcast to Milieu_base).
163 *
164 * @return The Fluide_base of the equation upcast to Milieu_base.
165 */
167{
168 if (!le_fluide_)
169 {
170 Cerr << "You forgot to associate the fluid to the problem named " << probleme().le_nom() << finl;
172 }
173 return le_fluide_.valeur();
174}
175
176/*! @brief Returns the physical medium of the equation (the Fluide_base upcast to Milieu_base).
177 *
178 * (non-const version)
179 *
180 * @return The Fluide_base of the equation upcast to Milieu_base.
181 */
183{
184 if (!le_fluide_)
185 {
186 Cerr << "You forgot to associate the fluid to the problem named " << probleme().le_nom() << finl;
188 }
189 return le_fluide_.valeur();
190}
191
192/*! @brief Returns the operator at the specified index: returns terme_diffusif if i = 0, exits if i > 0.
193 *
194 * (const version)
195 *
196 * @param i Index of the operator to return.
197 * @return The specified operator.
198 * @throws The equation has at most 1 operator.
199 */
201{
202 switch(i)
203 {
204 case 0:
205 return terme_diffusif_;
206 default:
207 Cerr << "Error for Eq_rayo_semi_transp::operateur(int i)" << finl;
208 Cerr << "Eq_rayo_semi_transp has " << nombre_d_operateurs() << " operators " << finl;
209 Cerr << "and you are trying to access the " << i << " th one." << finl;
211 }
212 return terme_diffusif_;
213}
214
215/*! @brief Returns the operator at the specified index: returns terme_diffusif if i = 0, exits if i > 0.
216 *
217 * (non-const version)
218 *
219 * @param i Index of the operator to return.
220 * @return The specified operator.
221 * @throws The equation has at most 1 operator.
222 */
224{
225 switch(i)
226 {
227 case 0:
228 return terme_diffusif_;
229 default:
230 Cerr << "Error for Eq_rayo_semi_transp::operateur(int i)" << finl;
231 Cerr << "Eq_rayo_semi_transp has " << nombre_d_operateurs() << " operators " << finl;
232 Cerr << "and you are trying to access the " << i << " th one." << finl;
234 }
235 return terme_diffusif_;
236}
237
239{
240 if (opt == DESCRIPTION)
241 Cerr << que_suis_je() << " : " << champs_compris_.liste_noms_compris() << finl;
242 else
243 noms.add(champs_compris_.liste_noms_compris());
244}
245
247{
248 // Discretisation of the radiation equation
249 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
250 Cerr << "Radiation equation discretisation" << finl;
251 dis.discretiser_champ("temperature", domaine_dis(), "irradiance", "w/m2", 1, 1 /* one slot */, schema_temps().temps_courant(), irradiance_);
252 champs_compris_.ajoute_champ(irradiance_);
253
255
256 // typing Rayo_semi_transp_solver_base
257 Nom discr = dis.que_suis_je(), type = "Rayo_semi_transp_solver_";
258 if (discr == "VEFPreP1B") discr = "VEF";
259 type += discr;
260 rayo_solv_.typer(type);
261 rayo_solv_->associer_equation_rayo(*this);
262}
263
264/*! @brief Returns the discretisation associated with the equation.
265 *
266 * @return The discretisation associated with the equation.
267 * @throws If no problem is associated.
268 */
270{
271 return pb_rayo_semi_transp_->discretisation();
272}
273
275{
277 pb_rayo_semi_transp_ = ref_cast(Pb_rayo_semi_transp, pb);
279}
280
282{
283 const int n1 = rayo_solv_->nb_colonnes_tot();
284 const int n2 = rayo_solv_->nb_colonnes();
285
286 Matrice_Bloc& matrice = ref_cast(Matrice_Bloc, matrice_tmp.valeur());
287 Matrice_Morse& MBrr = ref_cast(Matrice_Morse, matrice.get_bloc(0, 0).valeur());
288 Matrice_Morse& MBrv = ref_cast(Matrice_Morse, matrice.get_bloc(0, 1).valeur());
289
290 auto& tab1RR = MBrr.get_set_tab1();
291 auto& tab2RR = MBrr.get_set_tab2();
292 auto& coeffRR = MBrr.get_set_coeff();
293 auto& tab1RV = MBrv.get_set_tab1();
294 auto& tab2RV = MBrv.get_set_tab2();
295 auto& coeffRV = MBrv.get_set_coeff();
296
297 DoubleTab ligne_tmp(n1);
298 for (int i = 0; i < n2; i++)
299 {
300 int k;
301 // Copy the first block of the matrix into a temporary array:
302 // ligne_tmp = 0;
303 for (k = la_matrice_.get_tab1()(i) - 1; k < la_matrice_.get_tab1()(i + 1) - 1; k++)
304 ligne_tmp(la_matrice_.get_tab2()(k) - 1) = la_matrice_.get_coeff()(k);
305
306 // Fill in the real part of the matrix
307 for (k = tab1RR(i) - 1; k < tab1RR(i + 1) - 1; k++)
308 coeffRR[k] = ligne_tmp(tab2RR[k] - 1);
309
310 // Fill in the virtual part
311 for (k = tab1RV(i) - 1; k < tab1RV(i + 1) - 1; k++)
312 coeffRV[k] = ligne_tmp(n2 + tab2RV[k] - 1);
313 }
314}
315
317{
318 const int n1 = rayo_solv_->nb_colonnes_tot();
319 const int n2 = rayo_solv_->nb_colonnes();
320
321 int iligne;
322 const auto& tab1 = la_matrice_.get_set_tab1();
323 const auto& tab2 = la_matrice_.get_set_tab2();
324
325 matrice_tmp.typer("Matrice_Bloc");
326 Matrice_Bloc& matrice = ref_cast(Matrice_Bloc, matrice_tmp.valeur());
327 matrice.dimensionner(1, 2);
328 matrice.get_bloc(0, 0).typer("Matrice_Morse_Sym");
329 matrice.get_bloc(0, 1).typer("Matrice_Morse");
330
331 Matrice_Morse_Sym& MBrr = ref_cast(Matrice_Morse_Sym, matrice.get_bloc(0, 0).valeur());
332 Matrice_Morse& MBrv = ref_cast(Matrice_Morse, matrice.get_bloc(0, 1).valeur());
333 MBrr.dimensionner(n2, 0);
334 MBrv.dimensionner(n2, 0);
335
336 auto& tab1RR = MBrr.get_set_tab1();
337 auto& tab2RR = MBrr.get_set_tab2();
338 auto& tab1RV = MBrv.get_set_tab1();
339 auto& tab2RV = MBrv.get_set_tab2();
340
341 IntVect compteur_MBrr(n2);
342 IntVect compteur_MBrv(n2);
343 compteur_MBrr = 0;
344 compteur_MBrv = 0;
345
346 // Iterate over the rows of la_matrice to count the non-zero
347 // elements of each row
348 int jcolonne;
349 for (iligne = 0; iligne < n2; iligne++)
350 {
351 int k;
352 for (k = tab1(iligne) - 1; k < tab1(iligne + 1) - 1; k++)
353 {
354 jcolonne = tab2(k) - 1;
355 if (jcolonne < n2)
356 {
357 // the corresponding element is in the RR part of la_matrice
358 if ((jcolonne >= iligne) && (jcolonne < n2))
359 {
360 // the corresponding element is located above the diagonal of la_matrice
361 compteur_MBrr(iligne)++;
362 }
363 }
364 else
365 {
366 // the corresponding element is in the RV part of la_matrice
367 compteur_MBrv(iligne)++;
368 }
369 }
370 }
371
372 // Fill tab1RR and tab1RV
373 tab1RR(0) = 1;
374 tab1RV(0) = 1;
375 for (int i = 0; i < n2; i++)
376 {
377 tab1RR(i + 1) = compteur_MBrr(i) + tab1RR(i);
378 tab1RV(i + 1) = compteur_MBrv(i) + tab1RV(i);
379 }
380 // Size tab2RR and tab2RV
381 MBrr.dimensionner(n2, tab1RR(n2) - 1);
382 MBrv.dimensionner(n2, n1 - n2, tab1RV(n2) - 1);
383
384 // Fill tab2RR and tab2RV
385 int compteurRR, compteurRV;
386 for (iligne = 0; iligne < n2; iligne++)
387 {
388 int k;
389 compteurRR = tab1RR(iligne) - 1;
390 compteurRV = tab1RV(iligne) - 1;
391 for (k = tab1(iligne) - 1; k < tab1(iligne + 1) - 1; k++)
392 {
393 jcolonne = tab2(k) - 1;
394 if (jcolonne < n2)
395 {
396 // the corresponding element is in the RR part of la_matrice
397 if ((jcolonne >= iligne) && (jcolonne < n2))
398 {
399 // the corresponding element is located above the diagonal of la_matrice
400 tab2RR(compteurRR) = tab2(k);
401 compteurRR++;
402 }
403 }
404 else
405 {
406 // the corresponding element is in the RV part of la_matrice
407 tab2RV(compteurRV) = tab2(k) - n2;
408 compteurRV++;
409 }
410 }
411 }
412}
class Discret_Thyd This class is the base class representing a discretization
class Discretisation_base This class represents a spatial discretization scheme, which
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Frontiere_dis_base & frontiere_dis(const Nom &) const
Returns the boundary of Name nom.
int nb_front_Cl() const
An input stream whose source is a character string.
Definition EChaine.h:31
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Milieu_base & milieu() override
Returns the physical medium of the equation (the Fluide_base upcast to Milieu_base).
void associer_milieu_base(const Milieu_base &) override
Associates a physical medium with the equation.
void set_param(Param &titi) const override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void associer_pb_base(const Probleme_base &pb) override
Associates with the Problem passed as parameter.
void dimensionner_Mat_Bloc_Morse_Sym(Matrice &matrice_tmp)
void completer() override
Completes the construction (initialization) of objects associated with the equation.
void discretiser() override
Discretizes the equation.
bool initTimeStep(double dt) override
Allocation and initialization of the unknown and boundary conditions until present+dt.
void associer_fluide(const Fluide_base &un_fluide)
void Mat_Morse_to_Mat_Bloc(Matrice &matrice_tmp)
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
const Operateur & operateur(int) const override
Returns the operator at the specified index: returns terme_diffusif if i = 0, exits if i > 0.
Operateur_Diff terme_diffusif_
const Discretisation_base & discretisation() const
Returns the discretisation associated with the equation.
int nombre_d_operateurs() const override
class Equation_base The role of an equation is the calculation of one or more fields....
virtual int verif_Cl() const
Verifies the compatibility of boundary conditions with the equation.
virtual void associer_pb_base(const Probleme_base &)
Associates with the Problem passed as parameter.
virtual Entree & lire_cl(Entree &)
Reading of boundary conditions in an input stream.
virtual void completer()
Completes the construction (initialization) of objects associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual void associer_sch_tps_base(const Schema_Temps_base &)
Associates the time scheme with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual bool initTimeStep(double dt)
Allocation and initialization of the unknown and boundary conditions until present+dt.
virtual void discretiser()
Discretizes the equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
class Frontiere_dis_base Class representing a discretized boundary.
virtual void dimensionner(int N, int M)
virtual const Matrice & get_bloc(int i, int j) const
Matrice_Morse_Sym class - Represents a sparse symmetric matrix M stored in Morse format.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
auto & get_set_tab2()
void dimensionner(int n, _SIZE_ nnz)
Size the matrix with n lines and n columns and nnz zero-values coefficients.
auto & get_set_coeff()
auto & get_set_tab1()
Matrice class - Generic class in the matrix hierarchy.
Definition Matrice.h:34
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
A character string (Nom) in uppercase.
Definition Motcle.h:26
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
class Operateur Generic class of the operator hierarchy.
Definition Operateur.h:39
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
@ REQUIRED
Definition Param.h:115
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
Semi-transparent radiation problem. Pb_rayo_semi_transp is a Probleme_base with 4 specific features:
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
class Probleme_base It is a Probleme_U that is not a coupling.
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
Base class for output streams.
Definition Sortie.h:52