16#include <Traitement_particulier_NS_EC.h>
17#include <Navier_Stokes_std.h>
18#include <Domaine_VF.h>
19#include <Terme_Source_Acceleration.h>
20#include <Milieu_base.h>
22#include <Probleme_base.h>
23#include <Schema_Temps_base.h>
59 Motcle accouverte =
"{" , accfermee =
"}" ;
62 periode = mon_equation->probleme().schema_temps().pas_temps_min();
64 if (motbidon == accouverte)
68 les_mots[1] =
"Ec_dans_repere_fixe";
71 while(motlu != accfermee)
73 int rang=les_mots.
search(motlu);
84 Cerr<<
"We expected the keyword periode after " << les_mots[rang] <<
"."<<finl;
92 Cerr <<
"Error while reading Traitement_particulier_NS_EC";
93 Cerr <<
"Possible keywords are "<< les_mots <<
" { and }" << finl;
94 Cerr <<
"You read:" << motlu << finl;
102 if (motlu != accfermee)
104 Cerr <<
"Error while reading Traitement_particulier_NS_EC";
105 Cerr <<
"We expected a }" << finl;
112 Cerr <<
"Error while reading Traitement_particulier_NS_EC";
113 Cerr <<
"We expected a {" << finl;
125 nom_fich+=
"_dans_repere_fixe";
133 s.
ouvrir(nom_fich,ios::app);
134 s.
setf(ios::scientific);
140 tinit = mon_equation->inconnue().temps();
149 le_fichier<<
"# Temps Energie_cinetique_totale"<<finl;
150 le_fichier<<
tinit<<
" "<<Ec<<finl;
155 double temps = mon_equation->inconnue().temps();
166 le_fichier<<temps<<
" "<<Ec<<finl;
176static double trait_part_calculer_ec_faces(
const int face_debut,
179 const DoubleTab& vitesse,
180 const DoubleVect& volumes_entrelaces,
182 const DoubleTab& masse_volumique,
183 const ArrOfDouble& translation,
184 const ArrOfDouble& rotation,
185 const int repere_mobile_,
186 const ArrOfInt& faces_doubles
189 const int face_fin = face_debut + nb_faces;
192 const int nb_dim_1 = (vitesse.
line_size() == 1);
195 for (
int face = face_debut; face < face_fin; face++)
200 ve[0]=translation[0];
201 ve[1]=translation[1];
204 ve[2]=translation[2];
205 ve[0]+=rotation[1]*xv(face,2)-rotation[2]*xv(face,1);
206 ve[1]+=rotation[2]*xv(face,0)-rotation[0]*xv(face,2);
207 ve[2]+=rotation[0]*xv(face,1)-rotation[1]*xv(face,0);
218 const double v = vitesse(face);
221 Cerr <<
"The computation of kinetic energy in a fixed frame" <<finl;
222 Cerr <<
"is not implemented in VDF." << finl;
227 volume = (frontiere ? 0.5 : 1) * volumes_entrelaces(face);
233 for (
int i = 0; i < dim; i++)
235 const double v_i = vitesse(face, i);
236 v2 += (v_i + ve[i]) * (v_i + ve[i]);
239 volume = volumes_entrelaces(face);
241 const int k = (masse_volumique.
dimension(0)==1) ? 0 : face;
242 rho = masse_volumique(k, 0);
243 double contribution = (faces_doubles[face]==1) ? 0.5 : 1 ;
244 ec += contribution * 0.5 * v2 * volume * rho;
263 const Domaine_dis_base& zdisbase = mon_equation->inconnue().domaine_dis_base();
266 const DoubleTab& xv = domaine_VF.
xv();
267 const DoubleTab& vitesse = mon_equation->inconnue().valeurs();
268 OBS_PTR(ArrOfDouble) translation(xv);
269 OBS_PTR(ArrOfDouble) rotation(xv);
277 const Sources& les_sources=mon_equation->sources();
279 for (
const auto& itr : les_sources)
290 if (terme_source_acceleration.
has_omega())
293 rotation=rotation_nulle;
300 Cerr <<
"You cannot compute kinetic energy in a fixed frame" << finl;
301 Cerr <<
"unless the calculation frame is moving, i.e. you have" << finl;
302 Cerr <<
"defined an acceleration source term in the Navier Stokes equation." << finl;
303 Cerr <<
"Or the definition of the velocity of the" << finl;
304 Cerr <<
"moving frame in the fixed frame is missing in this source term. Modify your data file." << finl;
314 if (rho->dimension(0) != domaine_VF.
nb_faces() || rho->line_size() != 1)
316 Cerr <<
"Error in Traitement_particulier_NS_EC::calculer_Ec" << finl;
317 Cerr <<
"the density field is not a scalar field at faces" << finl;
323 rho = mon_equation->milieu().masse_volumique().valeurs();
328 for (
int i = 0; i < nb_front; i++)
333 ec += trait_part_calculer_ec_faces(debut, nb_faces, 1,
334 vitesse, volumes_entrelaces, xv, rho, translation, rotation,
repere_mobile_, faces_doubles);
340 ec += trait_part_calculer_ec_faces(debut, nb_faces, 0,
341 vitesse, volumes_entrelaces, xv, rho, translation, rotation,
repere_mobile_, faces_doubles);
344 energie_cinetique = ec;
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
int nb_faces() const
Returns the total number of faces.
DoubleVect & volumes_entrelaces()
int nb_faces_internes() const
A face is internal if and only if it separates two elements.
double xv(int num_face, int k) const
ArrOfInt & faces_doubles()
Returns 1 for faces belonging to a periodic boundary or a shared item, 0 by default.
int premiere_face_int() const
A face is internal if and only if it separates two elements.
const Front_VF & front_VF(int i) const
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
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.
A character string (Nom) in uppercase.
An array of Motcle objects.
int search(const Motcle &t) const
class Nom: a character string for naming TRUST objects.
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.
class Probleme_base It is a Probleme_U that is not a coupling.
bool & reprise_effectuee()
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
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.
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
void precision(int pre) override
void setf(IOS_FORMAT code) override
Base class for output streams.
class Sources Sources represents a list of Source objects.
virtual const Champ_base & get_champ_masse_volumique() const
Returns the density field.
virtual int has_champ_masse_volumique() const
Returns 1 if the density field has been associated, 0 otherwise.
_SIZE_ dimension(int d) const
const Champ_Don_base & omega() const
const Champ_Don_base & champ_vitesse() const
bool has_champ_vitesse() const
Traitement_particulier_EC This class performs specific post-processing treatments.
void preparer_calcul_particulier() override
void ouvrir_fichier(SFichier &s) const
Entree & lire(Entree &) override
virtual void calculer_Ec(double &)
Same computation method for VDF and VEF.
void post_traitement_particulier() override
Traitement_particulier_NS_base Derives from Support_Champ_Masse_Volumique: use of rho.
OBS_PTR(Navier_Stokes_std) mon_equation