TrioCFD 1.9.8
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 // typage de l'operateur de diffusion
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 // On assemble la matrice une fois pour toute au debut du calcul
129 // XXX Attention, ceci n'est valable que si kappa est constant au cours du temps
130 rayo_solv_->assembler_matrice();
131}
132
133/*! @brief Associe un milieu physique a l'equation
134 *
135 * @param (Milieu_base& un_milieu) le milieu physique a associer a l'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 Renvoie le milieu physique de l'equation (le Fluide_base upcaste en Milieu_base)
163 *
164 * @return (Milieu_base&) le Fluide_base de l'equation upcaste en 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 Renvoie le milieu physique de l'equation (le Fluide_base upcaste en Milieu_base)
177 *
178 * (version const)
179 *
180 * @return (Milieu_base&) le Fluide_base de l'equation upcaste en 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 Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0
193 *
194 * exit si i>0
195 * (version const)
196 *
197 * @param (int i) l'index de l'operateur a renvoyer
198 * @return (Operateur&) l'operateur specifie
199 * @throws l'equation n'a pas plus de 1 operateur
200 */
202{
203 switch(i)
204 {
205 case 0:
206 return terme_diffusif_;
207 default:
208 Cerr << "Error for Eq_rayo_semi_transp::operateur(int i)" << finl;
209 Cerr << "Eq_rayo_semi_transp has " << nombre_d_operateurs() << " operators " << finl;
210 Cerr << "and you are trying to access the " << i << " th one." << finl;
212 }
213 return terme_diffusif_;
214}
215
216/*! @brief Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0
217 *
218 * exit si i>0
219 * (version const)
220 *
221 * @param (int i) l'index de l'operateur a renvoyer
222 * @return (Operateur&) l'operateur specifie
223 * @throws l'equation n'a pas plus de 1 operateur
224 */
226{
227 switch(i)
228 {
229 case 0:
230 return terme_diffusif_;
231 default:
232 Cerr << "Error for Eq_rayo_semi_transp::operateur(int i)" << finl;
233 Cerr << "Eq_rayo_semi_transp has " << nombre_d_operateurs() << " operators " << finl;
234 Cerr << "and you are trying to access the " << i << " th one." << finl;
236 }
237 return terme_diffusif_;
238}
239
241{
242 if (opt == DESCRIPTION)
243 Cerr << que_suis_je() << " : " << champs_compris_.liste_noms_compris() << finl;
244 else
245 noms.add(champs_compris_.liste_noms_compris());
246}
247
249{
250 // Discretisation de l'equation de rayonnement
251 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
252 Cerr << "Radiation equation discretisation" << finl;
253 dis.discretiser_champ("temperature", domaine_dis(), "irradiance", "w/m2", 1, 1 /* une case */, schema_temps().temps_courant(), irradiance_);
254 champs_compris_.ajoute_champ(irradiance_);
255
257
258 // typing Rayo_semi_transp_solver_base
259 Nom discr = dis.que_suis_je(), type = "Rayo_semi_transp_solver_";
260 if (discr == "VEFPreP1B") discr = "VEF";
261 type += discr;
262 rayo_solv_.typer(type);
263 rayo_solv_->associer_equation_rayo(*this);
264}
265
266/*! @brief Renvoie la discretisation associee a l'equation.
267 *
268 * @return (Discretisation_base&) a discretisation associee a l'equation
269 * @throws pas de probleme associe
270 */
272{
273 return pb_rayo_semi_transp_->discretisation();
274}
275
277{
279 pb_rayo_semi_transp_ = ref_cast(Pb_rayo_semi_transp, pb);
281}
282
284{
285 const int n1 = rayo_solv_->nb_colonnes_tot();
286 const int n2 = rayo_solv_->nb_colonnes();
287
288 Matrice_Bloc& matrice = ref_cast(Matrice_Bloc, matrice_tmp.valeur());
289 Matrice_Morse& MBrr = ref_cast(Matrice_Morse, matrice.get_bloc(0, 0).valeur());
290 Matrice_Morse& MBrv = ref_cast(Matrice_Morse, matrice.get_bloc(0, 1).valeur());
291
292 auto& tab1RR = MBrr.get_set_tab1();
293 auto& tab2RR = MBrr.get_set_tab2();
294 auto& coeffRR = MBrr.get_set_coeff();
295 auto& tab1RV = MBrv.get_set_tab1();
296 auto& tab2RV = MBrv.get_set_tab2();
297 auto& coeffRV = MBrv.get_set_coeff();
298
299 DoubleTab ligne_tmp(n1);
300 for (int i = 0; i < n2; i++)
301 {
302 int k;
303 // On recopie le premier bloc de la matrice dans un tableau :
304 // ligne_tmp = 0;
305 for (k = la_matrice_.get_tab1()(i) - 1; k < la_matrice_.get_tab1()(i + 1) - 1; k++)
306 ligne_tmp(la_matrice_.get_tab2()(k) - 1) = la_matrice_.get_coeff()(k);
307
308 // On complete la partie reelle de la matrice
309 for (k = tab1RR(i) - 1; k < tab1RR(i + 1) - 1; k++)
310 coeffRR[k] = ligne_tmp(tab2RR[k] - 1);
311
312 // On complete la partie virtuelle
313 for (k = tab1RV(i) - 1; k < tab1RV(i + 1) - 1; k++)
314 coeffRV[k] = ligne_tmp(n2 + tab2RV[k] - 1);
315 }
316}
317
319{
320 const int n1 = rayo_solv_->nb_colonnes_tot();
321 const int n2 = rayo_solv_->nb_colonnes();
322
323 int iligne;
324 const auto& tab1 = la_matrice_.get_set_tab1();
325 const auto& tab2 = la_matrice_.get_set_tab2();
326
327 matrice_tmp.typer("Matrice_Bloc");
328 Matrice_Bloc& matrice = ref_cast(Matrice_Bloc, matrice_tmp.valeur());
329 matrice.dimensionner(1, 2);
330 matrice.get_bloc(0, 0).typer("Matrice_Morse_Sym");
331 matrice.get_bloc(0, 1).typer("Matrice_Morse");
332
333 Matrice_Morse_Sym& MBrr = ref_cast(Matrice_Morse_Sym, matrice.get_bloc(0, 0).valeur());
334 Matrice_Morse& MBrv = ref_cast(Matrice_Morse, matrice.get_bloc(0, 1).valeur());
335 MBrr.dimensionner(n2, 0);
336 MBrv.dimensionner(n2, 0);
337
338 auto& tab1RR = MBrr.get_set_tab1();
339 auto& tab2RR = MBrr.get_set_tab2();
340 auto& tab1RV = MBrv.get_set_tab1();
341 auto& tab2RV = MBrv.get_set_tab2();
342
343 IntVect compteur_MBrr(n2);
344 IntVect compteur_MBrv(n2);
345 compteur_MBrr = 0;
346 compteur_MBrv = 0;
347
348 // On parcours les lignes de la_matrice pour compter les elements
349 // non nuls de chaque ligne
350 int jcolonne;
351 for (iligne = 0; iligne < n2; iligne++)
352 {
353 int k;
354 for (k = tab1(iligne) - 1; k < tab1(iligne + 1) - 1; k++)
355 {
356 jcolonne = tab2(k) - 1;
357 if (jcolonne < n2)
358 {
359 // l'element correspondant est dans la partie RR de la_matrice
360 if ((jcolonne >= iligne) && (jcolonne < n2))
361 {
362 // l'element correspondant est situe au dessus de la diagonale de la_matrice
363 compteur_MBrr(iligne)++;
364 }
365 }
366 else
367 {
368 // l'element correspondant est dans la partie RV de la_matrice
369 compteur_MBrv(iligne)++;
370 }
371 }
372 }
373
374 // On remplie tab1RR et tab1RV
375 tab1RR(0) = 1;
376 tab1RV(0) = 1;
377 for (int i = 0; i < n2; i++)
378 {
379 tab1RR(i + 1) = compteur_MBrr(i) + tab1RR(i);
380 tab1RV(i + 1) = compteur_MBrv(i) + tab1RV(i);
381 }
382 // On dimensionne tab2RR et tab2RV
383 MBrr.dimensionner(n2, tab1RR(n2) - 1);
384 MBrv.dimensionner(n2, n1 - n2, tab1RV(n2) - 1);
385
386 // On remplit tab2RR et tab2RV
387 int compteurRR, compteurRV;
388 for (iligne = 0; iligne < n2; iligne++)
389 {
390 int k;
391 compteurRR = tab1RR(iligne) - 1;
392 compteurRV = tab1RV(iligne) - 1;
393 for (k = tab1(iligne) - 1; k < tab1(iligne + 1) - 1; k++)
394 {
395 jcolonne = tab2(k) - 1;
396 if (jcolonne < n2)
397 {
398 // l'element correspondant est dans la partie RR de la_matrice
399 if ((jcolonne >= iligne) && (jcolonne < n2))
400 {
401 // l'element correspondant est situe au dessus de la diagonale de la_matrice
402 tab2RR(compteurRR) = tab2(k);
403 compteurRR++;
404 }
405 }
406 else
407 {
408 // l'element correspondant est dans la partie RV de la_matrice
409 tab2RV(compteurRV) = tab2(k) - n2;
410 compteurRV++;
411 }
412 }
413 }
414}
classe Discret_Thyd Cette classe est la classe de base representant une discretisation
classe Discretisation_base Cette classe represente un schema de discretisation en espace,...
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
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
const Frontiere_dis_base & frontiere_dis(const Nom &) const
Renvoie la frontiere de Nom nom.
int nb_front_Cl() const
Une entree dont la source est une chaine de caracteres.
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
Renvoie le milieu physique de l'equation (le Fluide_base upcaste en Milieu_base).
void associer_milieu_base(const Milieu_base &) override
Associe un milieu physique a l'equation.
void set_param(Param &titi) const override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
void associer_pb_base(const Probleme_base &pb) override
S'associe au Probleme passe en parametre.
void dimensionner_Mat_Bloc_Morse_Sym(Matrice &matrice_tmp)
void completer() override
Complete la construction (initialisation) des objets associes a l'equation.
void discretiser() override
Discretise l'equation.
bool initTimeStep(double dt) override
Allocation et initialisation de l'inconnue et des CLs jusqu'a 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
Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0.
Operateur_Diff terme_diffusif_
const Discretisation_base & discretisation() const
Renvoie la discretisation associee a l'equation.
int nombre_d_operateurs() const override
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
virtual int verif_Cl() const
Verifie la compatibilite des conditions limites avec l'equation.
virtual void associer_pb_base(const Probleme_base &)
S'associe au Probleme passe en parametre.
virtual Entree & lire_cl(Entree &)
Lecture des conditions limites sur un flot d'entree.
virtual void completer()
Complete la construction (initialisation) des objets associes a l'equation.
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
virtual void associer_sch_tps_base(const Schema_Temps_base &)
S'associe au schema_en_temps.
Schema_Temps_base & schema_temps()
Renvoie le schema en temps associe a l'equation.
virtual bool initTimeStep(double dt)
Allocation et initialisation de l'inconnue et des CLs jusqu'a present+dt.
virtual void discretiser()
Discretise l'equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
classe Fluide_base Cette classe represente un d'un fluide incompressible ainsi que
Definition Fluide_base.h:38
classe Frontiere_dis_base Classe representant une frontiere discretisee.
virtual void dimensionner(int N, int M)
virtual const Matrice & get_bloc(int i, int j) const
Classe Matrice_Morse_Sym Represente une matrice M (creuse) symetrique stockee au format Morse.
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
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()
Classe Matrice Classe generique de la hierarchie des matrices.
Definition Matrice.h:34
classe Milieu_base Cette classe est la base de la hierarchie des milieux (physiques)
Definition Milieu_base.h:50
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:76
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
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 Operateur Classe generique de la hierarchie des operateurs.
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
Le Pb_rayo_semi_transp est un Probleme_base qui a 4 particularites : * Son equation doit etre typee e...
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Probleme_U.h:109
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52