16#include <Modele_rayo_transp.h>
17#include <Discretisation_base.h>
18#include <Domaine_Cl_dis_base.h>
19#include <Frontiere_dis_base.h>
20#include <Schema_Temps_base.h>
21#include <communications.h>
22#include <Pb_Fluide_base.h>
23#include <LecFicDiffuse.h>
24#include <SFichierBin.h>
25#include <EFichierBin.h>
26#include <Fluide_base.h>
27#include <Interprete.h>
31Implemente_instanciable(
Modele_rayo_transp,
"Modele_rayonnement_milieu_transparent|Transparent_medium_radiation_model",
Objet_U);
40 Nom fichier_face_rayo, fichier_fij;
41 Cerr <<
"Reading params of " <<
que_suis_je() << finl;
43 param.ajouter(
"fichier_face_rayo", &fichier_face_rayo,
Param::REQUIRED);
47 param.ajouter(
"fichier_matrice", &nom_fic_mat_ray_inv_);
49 param.ajouter(
"relaxation", &relaxation_);
51 param.ajouter_flag(
"format_binaire", &fic_mat_ray_inv_bin_);
53 param.lire_avec_accolades_depuis(is);
55 Cerr <<
"Modele_rayo_transp::reading files" << finl;
56 if (fic_mat_ray_inv_bin_)
57 lire_fichiers(fichier_face_rayo, fichier_fij, nom_fic_mat_ray_inv_);
59 lire_fichiers(fichier_face_rayo, fichier_fij);
64void Modele_rayo_transp::lire_fichiers(
Nom& fich_faces_rayo,
Nom& fich_fij,
Nom& fich_mat)
66 Cerr <<
"matrix_file = " << fich_mat << finl;
71 const char *facteur_file = fich_fij;
72 const char *emissivite_file = fich_faces_rayo;
73 const char *matrice_inverse_file = fich_mat;
75 if (stat(facteur_file, &f))
77 Cerr << facteur_file <<
" doesn't exist." << finl;
81 if (stat(emissivite_file, &e))
83 Cerr << emissivite_file <<
" doesn't exist." << finl;
87 if (stat(matrice_inverse_file, &m))
88 lire_matrice_inv_ =
false;
90 lire_matrice_inv_ =
true;
93 if (lire_matrice_inv_ && (f.st_mtime > m.st_mtime || e.st_mtime > m.st_mtime))
94 lire_matrice_inv_ =
false;
98 lire_fichiers(fich_faces_rayo, fich_fij);
101void Modele_rayo_transp::lire_fichiers(
Nom& fich_faces_rayo,
Nom& fich_fij)
103 Cerr <<
"radiation_face_file = " << fich_faces_rayo << finl;
104 Cerr <<
"fij_file = " << fich_fij << finl;
106 LecFicDiffuse fic1(fich_faces_rayo);
107 LecFicDiffuse fic2(fich_fij);
110 Cerr <<
"Reading file: " << fich_faces_rayo << finl;
112 fic1 >> nb_faces_totales_ >> nb_faces_rayonnantes_;
113 Cerr <<
"You have defined " << nb_faces_rayonnantes_ <<
" radiation faces out of " << nb_faces_totales_ <<
" faces in total" << finl;
114 les_faces_rayonnantes_.dimensionner(nb_faces_totales_);
117 int irayo = 0, jrayo = 0;
118 for (
int i = 0; i < nb_faces_totales_; i++)
120 fic1 >> les_faces_rayonnantes_[i];
121 if (les_faces_rayonnantes_[i].emissivite() != -1)
123 if (les_faces_rayonnantes_[i].emissivite() < 0.)
125 Cerr <<
"Error in " << fich_faces_rayo <<
" !!! emissivity <0 and != -1: " << les_faces_rayonnantes_[i].emissivite() << finl;
128 if (irayo >= nb_faces_rayonnantes_)
130 Cerr <<
"Error in " << fich_faces_rayo << finl;
131 Cerr <<
" nb_faces_rayonnantes user " << nb_faces_rayonnantes_ << finl;
132 Cerr <<
" nb_faces_rayonnantes deduced from emissivities " << irayo + 1 << finl;
134 Cerr <<
"Note: emissivity = 0 does not mean no radiation ... " << finl;
135 Cerr <<
"You must now set emissivity to -1 to ignore certain boundaries " << finl;
145 if (irayo != nb_faces_rayonnantes_)
147 Cerr <<
"Error in " << fich_faces_rayo << finl;
148 Cerr <<
" nb_faces_rayonnantes user " << nb_faces_rayonnantes_ << finl;
149 Cerr <<
" nb_faces_rayonnantes deduced from emissivities " << irayo << finl;
153 if (!lire_matrice_inv_)
155 Cerr <<
"Reading file: " << fich_fij << finl;
157 fic2 >> ordre_mat_forme_;
158 if (ordre_mat_forme_ != nb_faces_totales_)
160 Cerr <<
"The number of faces in the view factor matrix differs from that of the radiation faces file" << finl;
161 Cerr <<
"Check your file " << fich_fij << finl;
165 Cerr <<
"the matrix order is " << ordre_mat_forme_ << finl;
171 for (
int ii = 0; ii < nb_faces_totales_; ii++)
173 if (les_faces_rayonnantes_[ii].emissivite() != -1)
175 for (
int j = 0; j < nb_faces_totales_; j++)
176 if (les_faces_rayonnantes_[j].emissivite() != -1)
178 fic2 >> les_facteurs_de_forme_(irayo, jrayo);
187 for (
int j = 0; j < nb_faces_totales_; j++)
195 Cerr <<
"The view factor matrix is not read since " << finl;
196 Cerr <<
"the inverse matrix already computed in a previous calculation will be read directly." << finl;
198 Cerr <<
"Reading of the preprocessor files is complete. Files are correct." << finl;
203 nom_pb_rayonnant_ = pb.
le_nom();
204 Cerr <<
"The fluid radiation problem found : " << nom_pb_rayonnant_ << finl;
209 Process::exit(
"Error in Modele_rayo_transp::associer_pb_fluide_rayo ! You try to associate a non-fluid problem !!! \n");
215 if (les_faces_rayonnantes_[i].emissivite() != -1)
216 les_faces_rayonnantes_[i].calculer_temperature();
246 les_flux_radiatifs_(ii) = 0.;
248 les_flux_radiatifs_(ii) += matrice_rayo_(ii, jj) * secmem[jj];
251 envoyer_broadcast(les_flux_radiatifs_, 0);
253 for (
int i = 0; i < nb_faces_totales_; i++)
268 if (pb_fluide_rayo_->schema_temps().limpr())
270 Cout <<
"Printing radiative fluxes on radiation boundaries" << finl;
271 Cout <<
"----------------------------------------------------------------" << finl;
284 fichier1 += nom_pb_rayonnant_;
285 fichier1 +=
"_Flux_radiatif.out";
291 fichier2 += nom_pb_rayonnant_;
292 fichier2 +=
"_Temperature_rayonnante.out";
294 if (deja_imprime_ == 0)
299 os1 <<
"# Impression sur les bords rayonnants de l'equation du transfert radiatif" << finl <<
"# Flux radiatif [W]" << finl <<
"# Bord:";
300 os2 <<
"# Impression sur les bords rayonnants de l'equation du transfert radiatif" << finl <<
"# Temperature de bord moyenne en K" << finl <<
"# Bord:";
302 if (les_faces_rayonnantes_[i].emissivite() != -1)
305 os1 << espace << les_faces_rayonnantes_[i].nom_bord_rayo_lu();
306 os2 << espace << les_faces_rayonnantes_[i].nom_bord_rayo_lu();
308 os1 << espace <<
"Total" << finl <<
"# Temps" << finl;
309 os2 << finl <<
"# Temps" << finl;
316 os1.
setf(ios::scientific);
318 os2.
setf(ios::scientific);
325 if (les_faces_rayonnantes_[i].emissivite() != -1)
326 flux_tot += les_faces_rayonnantes_[i].imprimer_flux_radiatif(os, os1, os2);
328 os1 <<
"\t" << flux_tot << finl;
330 os <<
"Bilan flux radiatifs : " << flux_tot <<
" W" << finl;
335 if (corres_.size() == 0)
339 while (((les_faces_rayonnantes_[i0].ensembles_faces_bord(0).nb_faces_bord() == 0) || (les_faces_rayonnantes_[i0].emissivite() == -1)) && (i0 <
nb_faces_totales()))
342 int nbre_face_de_bord = -123;
345 nbre_face_de_bord = 0;
347 nbre_face_de_bord = les_faces_rayonnantes_[i0].ensembles_faces_bord(0).la_cl_base().domaine_Cl_dis().nb_faces_Cl();
349 corres_.resize(nbre_face_de_bord);
353 if (les_faces_rayonnantes_[i].emissivite() != -1)
361 for (
int face = 0; face < nbfaces; face++)
365 int nglob = ndeb + face;
366 if (corres_[nglob] != -1)
368 Cerr <<
me() <<
"face " << nglob <<
" seems to be contained by radiation faces " << i <<
" and " << corres_[nglob] << finl;
369 Cerr <<
me() << les_faces_rayonnantes_[i].nom_bord_rayo_lu() <<
" " << les_faces_rayonnantes_[corres_[nglob]].nom_bord_rayo_lu() << finl;
380 for (
int i = 0; i < nbre_face_de_bord; i++)
381 if (corres_[i] == -1)
382 Cout <<
"Face " << i <<
" sans groupes " << finl;
384 return les_faces_rayonnantes_[corres_[num_face]].flux_radiatif();
401 int compte_nb_bords_rayo = 0;
403 for (
int j = 0; j < pb_fluide_rayo_->nombre_d_equations(); j++)
406 for (
int num_cl = 0; num_cl < la_zcl.
nb_cond_lim(); num_cl++)
423 compte_nb_bords_rayo += 1;
428 Cerr <<
"The boundary condition named " << la_cl.
frontiere_dis().
le_nom() <<
" is defined as radiating" << finl;
429 Cerr<<
"but is not in the list of radiation faces or its emissivity is -1" << finl;
439 Cerr << finl <<
"ATTENTION !!! ERROR !!! The boundary " <<
face_rayonnante(i).
nom_bord_rayo_lu() <<
" is not associated to a radiation boundary condition !!!" << finl;
440 Cerr <<
"You have two options : either use a radiation BC for the boundary " <<
face_rayonnante(i).
nom_bord_rayo() <<
" or specify the emissivity to -1 at this boundary ..." << finl;
446 Cerr << finl <<
"Error in Modele_rayo_transp::preparer_calcul -- compte_nb_bords_rayo != nb_faces_rayonnantes() !!!" << finl;
447 Cerr <<
"Verify the boundary conditions you use in the problem " << pb_fluide_rayo_->le_nom() <<
" !!!" << finl;
448 Process::exit(
"It is a radiation problem and it seems you are using a non-radiation BC ... \n");
455 if (compte_nb_bords_rayo != 0)
457 LIST(
Nom) collectnoms;
462 Cerr <<
me() << collectnoms << finl;
472 Cerr <<
"Resizing the boundary face array" << finl;
473 Cerr <<
" compte_nb_bords_rayo = " << compte_nb_bords_rayo << finl;
489void Modele_rayo_transp::init_matrice_rayo()
494 int irayo = 0, jrayo = 0;
498 if (!lire_matrice_inv_)
500 for (
int i = 0; i < nb_faces_totales_; i++)
502 for (
int j = 0; j < nb_faces_totales_; j++)
504 if (les_faces_rayonnantes_[i].emissivite() != -1)
509 matrice_rayo_(irayo, jrayo) = 1 - (1 - les_faces_rayonnantes_[i].emissivite()) * les_facteurs_de_forme_(irayo, jrayo);
511 matrice_rayo_(irayo, jrayo) = (les_faces_rayonnantes_[i].emissivite() - 1) * les_facteurs_de_forme_(irayo, jrayo);
517 if (les_faces_rayonnantes_[i].emissivite() != -1)
528 Nom version(
"version_2beta3");
531 if (!lire_matrice_inv_)
533 Cerr <<
"Inverting the radiation matrix at the start of the computation" << finl;
549 secmem_tmp(irayo) = 0.;
550 secmem_tmp(jrayo) = 1.;
555 matrice_rayo_(irayo, jrayo) = sol_tmp(irayo);
563 les_facteurs_de_forme_ *= -1;
565 les_facteurs_de_forme_(jrayo, jrayo) += 1;
571 sol_tmp(irayo) = matrice_rayo_(irayo, jrayo);
577 res += les_facteurs_de_forme_(irayo, krayo) * sol_tmp(krayo);
578 matrice_rayo_(irayo, jrayo) = res;
586 const Face_rayo_transp& Facej = les_faces_rayonnantes_[j];
590 matrice_rayo_(irayo, jrayo) *= Facej.
emissivite() * sigma_;
597 les_facteurs_de_forme_.resize(0, 0);
600 if (nom_fic_mat_ray_inv_ !=
"??")
602 if (!fic_mat_ray_inv_bin_)
604 SFichier fic(nom_fic_mat_ray_inv_);
605 fic.setf(ios::scientific);
611 fic <<
" " << matrice_rayo_(irayo, jrayo);
618 SFichierBin fic_bin(nom_fic_mat_ray_inv_);
619 fic_bin << version << finl << matrice_rayo_;
626 if (!fic_mat_ray_inv_bin_)
628 Cerr <<
"Reading ASCII file " << nom_fic_mat_ray_inv_ << finl;
629 EFichier fic(nom_fic_mat_ray_inv_);
632 Cerr <<
"Reading file: " << nom_fic_mat_ray_inv_ << finl;
637 Cerr <<
"You must delete your file " << nom_fic_mat_ray_inv_ <<
" because the stored matrix has changed." << finl;
640 fic >> ordre_mat_forme_;
643 Cerr <<
"The order of the inverse radiation matrix differs from the number of radiation faces" << finl;
644 Cerr <<
"Check your file " << nom_fic_mat_ray_inv_ << finl;
647 Cerr <<
"the matrix order is " << ordre_mat_forme_ << finl;
649 for (i = 0; i < ordre_mat_forme_; i++)
650 for (j = 0; j < ordre_mat_forme_; j++)
651 fic >> matrice_rayo_(i, j);
655 Cerr <<
"Reading BINARY file " << nom_fic_mat_ray_inv_ << finl;
656 EFichierBin fic_bin(nom_fic_mat_ray_inv_);
658 Cerr <<
"Reading file: " << nom_fic_mat_ray_inv_ << finl;
663 Cerr <<
"You must delete your file " << nom_fic_mat_ray_inv_ <<
" because the stored matrix has changed." << finl;
666 fic_bin >> matrice_rayo_;
667 ordre_mat_forme_ = matrice_rayo_.
dimension(0);
670 Cerr <<
"The order of the inverse radiation matrix differs from the number of radiation faces" << finl;
671 Cerr <<
"Check your file " << nom_fic_mat_ray_inv_ << finl;
674 Cerr <<
"the matrix order is " << ordre_mat_forme_ << finl;
676 Cerr <<
"Reading of the inverse radiation matrix from file " << finl;
677 Cerr << nom_fic_mat_ray_inv_ <<
" is complete. File correct." << finl;
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
virtual bool is_bc_rayo_milieu_transp(Cond_lim_rayo_milieu_transp *&la_cl_rayo)
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
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.
void lire(const Nom &, const Nom &, const Domaine &)
void associer_les_cl(Cond_lim_base &)
const Cond_lim_base & la_cl_base() const
int nb_faces_bord() const
Class defining operators and methods for all reading operation in an input flow (file,...
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
double T_face_rayo() const
void mettre_a_jour_flux_radiatif(double J)
const Nom & nom_bord_rayo_lu() const
const Nom & nom_bord_rayo() const
double emissivite() const
int nb_ensembles_faces() const
const Ensemble_faces_rayo_transp & ensembles_faces_bord(int j) const
int_t num_premiere_face() const
int_t nb_faces() const
Returns the number of faces of the boundary.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
const Nom & le_nom() const override
Returns the name of the geometric boundary.
void associer_processeur_rayonnant(int proc)
int nb_faces_totales() const
Face_rayo_transp & face_rayonnante(int j)
double flux_radiatif(int num_face_global) const
void calculer_temperatures()
int processeur_rayonnant()
int nb_faces_rayonnantes() const
void mettre_a_jour(double temps)
void imprimer_flux_radiatifs(Sortie &) const
void calculer_flux_radiatifs()
void associer_pb_fluide_rayo(const Pb_Fluide_base &)
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
class Nom: a character string for naming TRUST objects.
Base class for TRUST objects (Objet_U).
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Pb_Fluide_base This class provides a base class for.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
static bool is_sequential()
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
void precision(int pre) override
void setf(IOS_FORMAT code) override
Base class for output streams.
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)