16#include <Echange_contact_Correlation_VDF.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Champ_front_calc.h>
19#include <communications.h>
20#include <Champ_Uniforme.h>
21#include <Probleme_base.h>
22#include <Milieu_base.h>
23#include <Domaine_VDF.h>
24#include <Conduction.h>
44 param.lire_avec_accolades_depuis(is);
46 le_champ_front.typer(
"Champ_front_fonc");
48 h_imp_.typer(
"Champ_front_fonc");
49 h_imp_->fixer_nb_comp(1);
57 param.
ajouter_condition(
"(value_of_dir_ge_0)_AND_(value_of_dir_le_2)",
"The direction must be 0, 1 or 2 in Echange_contact_Correlation_VDF");
104 rho_T.setString(tmp);
117 else if (mot==
"volume")
171 for (
int i=0; i<
N; i++)
174 DoubleTab& mon_h= h_imp_->valeurs();
179 const int nb_faces_bord = ma_front_vf.
nb_faces();
181 Text_valeurs.
resize(nb_faces_bord,1);
183 mon_h.
resize(nb_faces_bord,1);
185 for (
int ii=0; ii<nb_faces_bord; ii++)
206 DoubleVect y_envoye(2);
207 DoubleVect y_recu(2);
208 y_envoye(0) =
coord(1);
213 const int nb_voisins = joints.size();
218 for (
int i=0; i<nb_voisins; i++)
220 int mon_voisin = joints[i].PEvoisin();
221 Cerr <<
" Echange_contact_Correlation_VDF::init_tab_echange() To check for blocking send" << finl;
223 envoyer(y_envoye,ME,mon_voisin,ME);
225 recevoir(y_recu,mon_voisin,ME,mon_voisin);
226 if (y_recu(1)<
coord(1))
230 else if (y_recu(0)>
coord(
N-2))
243 for (
int i=0; i<
N; i++)
246 mu_T.setVar(
"T",
T(i));
275 const int nb_faces_bord = ma_front_vf.
nb_faces();
279 DoubleTab& Ts = inco.
valeurs();
280 DoubleTab& mon_h= h_imp_->valeurs();
284 for(
int iface=0; iface<nb_faces_bord; iface++)
287 int elem = face_voisins(ndeb+iface,0);
289 elem = face_voisins(ndeb+iface,1);
290 Qvol(corresp)+=mon_h(iface,0)*(Ts(elem)-
T(corresp))*surfaces(ndeb+iface);
292 for (
int i=0; i<
N; i++)
305 const int nb_faces_bord = ma_front_vf.
nb_faces();
307 IntVect face_triee(nb_faces_bord);
308 const DoubleTab& xv = ma_zvdf.
xv();
314 for(i=0; i<nb_faces_bord; i++)
315 face_triee(i) = ndeb+i;
317 for(i=1; i<nb_faces_bord; i++)
321 while ( j>=0 && xv(face_triee(j),
dir)>xv(tmp,
dir))
323 face_triee(j+1) = face_triee(j);
326 face_triee(j+1) = tmp;
334 for(i=1; i<nb_faces_bord; i++)
336 if (xv(face_triee(i),
dir) != xv(face_triee(i-1),
dir))
357 surf(0) = surf(
N-1) = 0.;
358 for(
int iface=0; iface<nb_faces_bord; iface++)
361 surf(corresp)+=surfaces(ndeb+iface);
362 coord(corresp) = xv(ndeb+iface,
dir);
366 for (i=1; i<
N-1; i++)
398 const int nb_voisins = joints.size();
400 DoubleVect les_cl_envoyees(2);
401 DoubleVect les_cl_recues(2);
402 les_cl_envoyees(0) =
T(1);
403 les_cl_envoyees(1) =
T(
N-2);
407 for (
int i=0; i<nb_voisins; i++)
409 int mon_voisin = joints[i].PEvoisin();
411 Cerr <<
" Echange_contact_Correlation_VDF::calculer_CL() To check for blocking send" << finl;
413 envoyer(les_cl_envoyees,ME,mon_voisin,ME);
415 recevoir(les_cl_recues,mon_voisin,ME,mon_voisin);
416 if (
tab_ech(mon_voisin,ME) == 1)
418 T_CL0 = 0.5*(les_cl_recues(1)+
T(1));
421 else if (
tab_ech(mon_voisin,ME) == 0)
423 T_CL1 = 0.5*(les_cl_recues(0)+
T(
N-2));
428 Cerr <<
"Communication error between processors " <<ME<<
" and " <<mon_voisin << finl;
429 Cerr <<
"in Echange_contact_Correlation_VDF::calculer_CL" << finl;
430 if (
Process::is_parallel()) Cerr <<
"Verify that your partition is in slices along the axis of the 1D model." << finl;
443 for (
int i=0; i<
N; i++)
459 const int sgn = (
debit>0) ? 1 : -1;
469 for (i=1; i<
N-1; i++)
471 const double dtrhoCp = dt/
rho(i)/
Cp;
477 ma(i)=1+dtrhoCp*(sgn*
Cp*
debit/dz1+2*(l1/dz1+l2/dz2)/(dz1+dz2));
479 sm(i) =
T(i)+dtrhoCp*
Qvol(i);
481 mc(i) = dtrhoCp*(0.5*(1-sgn)*
Cp*
debit/dz1-2*l1/dz1/(dz1+dz2));
483 mb(i-1) = dtrhoCp*(-2*l2/dz2/(dz1+dz2));
484 mb(i-1) += dtrhoCp*(-0.5*(1+sgn)*
Cp*
debit/dz1);
508 Fichier_sauv_nom+=
"_";
510 Fichier_sauv_nom+=
".sauv";
520 Cerr <<
"To check for blocking send" << finl;
525 double temps_lu=0., Temperature_reprise=0.;
528 Fichier_sauv=fopen(Fichier_sauv_nom,
"r");
529 if (Fichier_sauv!=
nullptr)
531 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
532 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
533 if (!fscanf(Fichier_sauv,
"%lf",&temps_lu))
exit();
536 for (
int p=0; p<nbproc; p++)
538 Cerr <<
"Resuming temperature field (" << Fichier_sauv_nom <<
") for the correlation on processor " << p <<
"...";
540 recevoir(T_tmp,p,0,p);
541 for (
int i=0; i<T_tmp.
size(); i++)
543 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
544 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
545 if (!fscanf(Fichier_sauv,
"%lf",&Temperature_reprise))
exit();
546 T_tmp(i) = Temperature_reprise;
548 envoyer(T_tmp,0,p,0);
549 Cerr <<
" OK!" << finl;
551 fclose(Fichier_sauv);
555 Cerr <<
"\nThe time indicated in the file \""<< Fichier_sauv_nom <<
"\" "<< temps_lu << finl;
556 Cerr <<
"differs from the restart time of the computation "<< temps <<
" !!!" << finl << finl;
557 Cerr <<
"You cannot resume with this correlation. Remove" << finl;
558 Cerr <<
"the keyword \"Reprise\" from the correlation. The transient phase" << finl;
559 Cerr <<
"of the computation will be wrong, but the steady state will be correct." << finl << finl;
560 fclose(Fichier_sauv);
566 Cerr <<
"\nThe resume cannot be performed: the file \"" << Fichier_sauv_nom <<
"\" is missing !!!" << finl << finl;
574 Fichier_sauv=fopen(Fichier_sauv_nom,
"r");
575 double temps_lu=0., Temperature_reprise=0.;
578 if (Fichier_sauv!=
nullptr)
580 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
581 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
582 if (!fscanf(Fichier_sauv,
"%lf",&temps_lu))
exit();
585 Cerr <<
"Resuming temperature field (" << Fichier_sauv_nom <<
") for the correlation...";
586 for (
int i=0; i<
N; i++)
588 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
589 if (!fscanf(Fichier_sauv,
"%s",&tmp_lu))
exit();
590 if (!fscanf(Fichier_sauv,
"%lf",&Temperature_reprise))
exit();
591 T(i) = Temperature_reprise;
593 fclose(Fichier_sauv);
594 Cerr <<
" OK!" << finl;
598 Cerr <<
"\nThe time indicated in the file \""<< Fichier_sauv_nom <<
"\" "<< temps_lu << finl;
599 Cerr <<
"differs from the restart time of the computation "<< temps <<
" !!!" << finl << finl;
600 Cerr <<
"You cannot resume with this correlation. Remove" << finl;
601 Cerr <<
"the keyword \"Reprise\" from the correlation. The transient phase" << finl;
602 Cerr <<
"of the computation will be wrong, but the steady state will be correct." << finl << finl;
603 fclose(Fichier_sauv);
609 Cerr <<
"\nThe resume cannot be performed: the file \"" << Fichier_sauv_nom <<
"\" is missing !!!" << finl << finl;
624 for (
int i=0; i<
N; i++)
630 DoubleTab& mon_h= h_imp_->valeurs();
635 for (
int ii=0; ii<taille; ii++)
653 Fichier_sauv=fopen(Fichier_sauv_nom,
"w");
654 fprintf(Fichier_sauv,
"Temps\t=\t%f\n",temps);
656 for (
int p=0; p<nbproc; p++)
659 recevoir(T_tmp,p,0,p);
660 for (
int i=0; i<T_tmp.
size(); i++)
662 fprintf(Fichier_sauv,
"T(%i)\t=\t%f\n",(
int)j,T_tmp(i));
666 fclose(Fichier_sauv);
671 Fichier_sauv=fopen(Fichier_sauv_nom,
"w");
672 fprintf(Fichier_sauv,
"Temps\t=\t%f\n",temps);
673 for (
int i=0; i<
N; i++)
675 fprintf(Fichier_sauv,
"T(%i)\t=\t%f\n",(
int)i,
T(i));
677 fclose(Fichier_sauv);
688 int nfin = ndeb + front_vf.
nb_faces();
692 for (
int face=ndeb; face<nfin; face++)
700 for (
int face=ndeb; face<nfin; face++)
702 int elem = face_voisins(face,0);
704 elem = face_voisins(face,1);
705 for(i=0; i<nb_comp; i++)
708 tab(face-ndeb,i) = tab_lambda(elem,i)/e(face-ndeb);
714 for (
int face=ndeb; face<nfin; face++)
716 for(i=0; i<nb_comp; i++)
738 static const double epsilon = 1.e-9;
740 modf(temps_courant/
dt_impr + epsilon, &i);
741 modf((temps_courant-dt)/
dt_impr + epsilon, &j);
757 envoyer(
coord,ME,0,ME);
761 envoyer(
rho,ME,0,ME);
764 envoyer(
Qvol,ME,0,ME);
765 envoyer(
vol,ME,0,ME);
771 nom_bord+=
Nom(temps);
775 fic.
setf(ios::scientific);
777 fic <<
"# X T U h rho mu lambda Q[W]" << finl;
779 for (
int p=0; p<nbproc; p++)
781 DoubleVect coord_tmp;
787 DoubleVect lambda_tmp;
791 recevoir(coord_tmp,p,0,p);
792 recevoir(T_tmp,p,0,p);
793 recevoir(U_tmp,p,0,p);
794 recevoir(h_tmp,p,0,p);
795 recevoir(rho_tmp,p,0,p);
796 recevoir(mu_tmp,p,0,p);
797 recevoir(lambda_tmp,p,0,p);
798 recevoir(Qvol_tmp,p,0,p);
799 recevoir(vol_tmp,p,0,p);
801 for (
int i =0; i<coord_tmp.
size(); i++)
803 fic << coord_tmp(i) <<
" \t" << T_tmp(i) <<
" \t" << U_tmp(i) <<
" \t" << h_tmp(i) <<
" \t" << rho_tmp(i);
804 fic <<
" \t" << mu_tmp(i) <<
" \t" << lambda_tmp(i) <<
" \t" << Qvol_tmp(i)*vol_tmp(i) << finl;
805 Qt+=Qvol_tmp(i)*vol_tmp(i);
811 fic <<
"# Q total[W] = " << Qt << finl;
819 nom_bord+=
Nom(temps);
823 fic.
setf(ios::scientific);
825 fic <<
"# X T U h rho mu lambda Q[W]" << finl;
826 for (
int i =0; i<
N; i++)
829 fic <<
" \t" <<
mu(i) <<
" \t" <<
lambda(i) <<
" \t" <<
Qvol(i)*
vol(i) << finl;
832 fic <<
"# Q total[W] = " << Qt << finl;
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs() override
Returns the array of field values.
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual void completer()
DOES NOTHING must be overridden in derived classes.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
double dist_norm_bord(int num_face) const override
Returns the normal distance for a boundary face (Cartesian coordinates).
virtual const DoubleVect & face_surfaces() const
double xv(int num_face, int k) const
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Classe Echange_global_impose This class represents the special case of the class.
void mettre_a_jour(double temps) override
Performs a time update of the boundary condition.
virtual Champ_front_base & T_ext()
Returns the T_ext field of temperature imposed at the boundary.
Class defining operators and methods for all reading operation in an input flow (file,...
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
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 fixer_nb_comp(int i)
Sets the number of components of the field.
virtual int nb_comp() const
int num_premiere_face() const
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
Milieu_base This class is the base of the (physical) medium hierarchy.
virtual const Champ_Don_base & conductivite() const
Returns the conductivity of the medium (const version).
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
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.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Helper class to factorize the readOn method of Objet_U classes.
void ajouter_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
void ajouter_condition(const char *condition, const char *message, const char *name=0)
Declare a post-read logical condition that must hold on the parameter values.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
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.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
static bool is_parallel()
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
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.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
double temps_courant() const
Returns the current time.
double temps_max() const
Returns a reference to the maximum time.
double pas_de_temps() const
Returns the current time step (delta_t).
int nb_pas_dt() const
Returns the number of time steps performed.
int nb_pas_dt_max() const
Returns a reference to the maximum number of time steps.
static void resoudre(const DoubleVect &ma, const DoubleVect &mb, const DoubleVect &mc, const DoubleVect &sm, DoubleVect &vi, int M)
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)
_SIZE_ dimension(int d) const
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)