TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Traitement_particulier_NS_temperature_VEF.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Traitement_particulier_NS_temperature_VEF.h>
17#include <Domaine_VEF.h>
18#include <Champ_P1NC.h>
19#include <Champ_Uniforme.h>
20#include <SFichier.h>
21#include <EcrFicPartage.h>
22#include <Convection_Diffusion_Temperature.h>
23#include <Convection_Diffusion_Chaleur_QC.h>
24#include <Probleme_base.h>
25#include <Fluide_Incompressible.h>
26#include <Navier_Stokes_std.h>
27
28Implemente_instanciable(Traitement_particulier_NS_temperature_VEF,"Traitement_particulier_NS_temperature_VEF",Traitement_particulier_NS_temperature);
29
30
31/*! @brief Prints the object to an output stream.
32 *
33 * @param (Sortie& is) output stream
34 * @return (Sortie&) modified output stream
35 */
37{
38 return is;
39}
40
41
42/*! @brief Reads the object from an input stream.
43 *
44 * @param (Entree& is) input stream
45 * @return (Entree&) modified input stream
46 */
48{
49 return is;
50}
51
53{
54 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
55 const Domaine_VEF& domaine_VEF=ref_cast(Domaine_VEF, zdisbase);
56 const Domaine_Cl_VEF& domaine_Cl_VEF = ref_cast(Domaine_Cl_VEF,mon_equation->domaine_Cl_dis() );
57 // const DoubleTab& xv = domaine_VEF.xv(); // face centers of gravity
58 int nb_front=domaine_VEF.nb_front_Cl();
59
60
61 const Probleme_base& pb = mon_equation->probleme();
62 int flag=0;
63
64 for(int i=0; i<pb.nombre_d_equations(); i++)
65 {
67 {
68 mon_equation_NRJ = ref_cast(Convection_Diffusion_Temperature,pb.equation(i));
69 flag=1;
70 }
71 else if(sub_type(Convection_Diffusion_Chaleur_QC,pb.equation(i)))
72 {
73 mon_equation_NRJ = ref_cast(Convection_Diffusion_Chaleur_QC,pb.equation(i));
74 flag=1;
75 }
76 }
77
78 if (flag==0)
79 {
80 Cerr << "Error : none equation for temperature was found...!" << finl;
81 Cerr << "User can not ask for Traitement_particulier_NS_temperature_VEF" << finl;
82 Cerr << "if code does not solve a heat equation." << finl;
83 exit();
84 }
85
86 const DoubleTab& tab_temperature = mon_equation_NRJ->inconnue().valeurs();
87
88 const DoubleTab& vitesse = pb.get_champ(Motcle("vitesse")).valeurs();
89 const Champ_base& rho_ = pb.milieu().masse_volumique();
90 const DoubleTab& rho = rho_.valeurs();
91 int taille_rho=rho.dimension(0);
92 const double temps = mon_equation->inconnue().temps();
93
94
95 for (int n_bord=0; n_bord<nb_front; n_bord++)
96 {
97 const Cond_lim& la_cl = domaine_Cl_VEF.les_conditions_limites(n_bord);
98 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
99 int num1 = le_bord.num_premiere_face();
100 int num2 = num1 + le_bord.nb_faces();
101
102 if (le_bord.le_nom()==nom_cl )
103 {
104 double Tmoyen=0.;
105 double Tmax=-10e6;
106 double Tmin=10e6;
107 double rhoUS=0.;
108 double tmp=0.;
109 for (int iface=num1; iface<num2; iface++)
110 {
111 if (taille_rho==1) tmp = rho(0,0) *vitesse(iface,dir)*domaine_VEF.face_surfaces(iface);
112 else tmp = rho(iface)*vitesse(iface,dir)*domaine_VEF.face_surfaces(iface);
113 Tmoyen += tmp*tab_temperature(iface);
114 rhoUS += tmp;
115 if(tab_temperature(iface)>Tmax) Tmax=tab_temperature(iface);
116 if(tab_temperature(iface)<Tmin) Tmin=tab_temperature(iface);
117 }
118
119 // PQ : 06/04/09 : developments for parallel execution
120 rhoUS = mp_sum(rhoUS);
121 Tmoyen = mp_sum(Tmoyen);
122 Tmin = mp_min(Tmin);
123 Tmax = mp_max(Tmax);
124
125
127 {
128 if (rhoUS==0)
129 {
130 Cerr << "rhoUS=0..." << finl;
131 Cerr << "May be the direction of Traitement_particulier { temperature is wrong..." << finl;
132 exit();
133 }
134 Tmoyen /= rhoUS;
135 Nom nom_fic1("Tmoyen_");
136 nom_fic1 += le_bord.le_nom();
137 SFichier fic1(nom_fic1, ios::app);
138 fic1 << temps << " " << Tmoyen << " " << Tmin << " " << Tmax << finl;
139
140 Nom nom_fic2("RhoU_");
141 nom_fic2 += le_bord.le_nom();
142 SFichier fic2(nom_fic2, ios::app);
143 fic2 << temps << " " << rhoUS << finl;
144 }
145 }
146
147 /*
148 /////////////////////////////////////////////////////////////////////////
149 // PQ : 04/08/08 formerly used for solid thermalization
150 // to be kept for future use
151 /////////////////////////////////////////////////////////////////////////
152
153 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()))
154 {
155 Nom fichier1 = "temp_face_paroi_";
156 fichier1+=le_bord.le_nom();
157 fichier1+=".xyz";
158 EcrFicPartage fic1 (fichier1);
159
160 fic1<<le_bord.nb_faces()<<finl;
161
162 if(dimension==2)
163 for (int num_face=num1; num_face<num2; num_face++)
164 {
165 fic1<<xv(num_face,0)<<" "<<xv(num_face,1)<<" "<<temperature(num_face)<<finl;
166 }
167 else if(dimension==3)
168 for (int num_face=num1; num_face<num2; num_face++)
169 {
170 fic1<<xv(num_face,0)<<" "<<xv(num_face,1)<<" "<<xv(num_face,2)<<" "<<temperature(num_face)<<finl;
171 }
172
173 fic1.flush();
174 fic1.syncfile();
175 fic1.close();
176
177 }
178 */
179 }
180}
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Particular case of Convection_Diffusion_Chaleur_Fluide_Dilatable_base for a quasi-compressible fluid,...
Convection_Diffusion_Temperature Special case of Convection_Diffusion_std.
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VEF
Definition Domaine_VEF.h:53
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
int nb_front_Cl() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
const Nom & le_nom() const override
Returns the name of the geometric boundary.
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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 Probleme_base It is a Probleme_U that is not a coupling.
const Champ_base & get_champ(const Motcle &nom) const override
virtual const Milieu_base & milieu() const
Returns the physical medium associated with the problem (const version).
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
static double mp_min(double)
Definition Process.cpp:391
static double mp_max(double)
Definition Process.cpp:379
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
class Traitement_particulier_NS_temperature_VEF This class performs special post-processing
Traitement_particulier_NS_temperature This class performs specific post-processing treatments.