TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_Tparoi_VEF.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 <Champ_Generique_Tparoi_VEF.h>
17#include <Probleme_base.h>
18#include <Nom.h>
19#include <TRUSTTabs.h>
20#include <Domaine_VEF.h>
21#include <Domaine_Cl_VEF.h>
22#include <Equation_base.h>
23#include <Modele_turbulence_scal_base.h>
24#include <Neumann_paroi.h>
25#include <Neumann_homogene.h>
26#include <Discretisation_base.h>
27#include <Synonyme_info.h>
28
29Implemente_instanciable(Champ_Generique_Tparoi_VEF,"Tparoi_VEF",Champ_Gen_de_Champs_Gen);
30// XD tparoi_vef champ_post_de_champs_post tparoi_vef INHERITS_BRACE This keyword is used to post process (only for VEF
31// XD_CONT discretization) the temperature field with a slight difference on boundaries with Neumann condition where law
32// XD_CONT of the wall is applied on the temperature field. nom_pb is the problem name and field_name is the selected
33// XD_CONT field name. A keyword (temperature_physique) is available to post process this field without using
34// XD_CONT Definition_champs.
35
36Add_synonym(Champ_Generique_Tparoi_VEF,"Champ_Post_Tparoi_VEF");
37
39{
40 return s << que_suis_je() << " " << le_nom();
41}
42
43//cf Champ_Gen_de_Champs_Gen::readOn
45{
47 return s ;
48}
49
51{
52
53 OWN_PTR(Champ_base) source_espace_stockage;
54 const Champ_base& source = get_source(0).get_champ_without_evaluation(source_espace_stockage);
55
56 const Domaine_dis_base& domaine_dis = get_ref_domaine_dis_base();
57 Nature_du_champ nature_source = source.nature_du_champ();
58 Noms noms;
59 Noms unites;
60 noms.add("bidon");
61 unites.add("K");
62 int nb_comp = 1;
63 double temps;
64 temps=0.;
65
66 OWN_PTR(Champ_Fonc_base) espace_stockage_fonc;
68 Motcle directive = get_directive_pour_discr();
69 discr.discretiser_champ(directive,domaine_dis,nature_source,noms,unites,nb_comp,temps,espace_stockage_fonc);
70 espace_stockage = espace_stockage_fonc;
71
72
73 return espace_stockage;
74}
76{
77
78 OWN_PTR(Champ_base) source_espace_stockage;
79 const Champ_base& source = get_source(0).get_champ(source_espace_stockage);
80
81 const Domaine_dis_base& domaine_dis = get_ref_domaine_dis_base();
82 Nature_du_champ nature_source = source.nature_du_champ();
83 Noms noms;
84 Noms unites;
85 noms.add("bidon");
86 unites.add("K");
87 int nb_comp = 1;
88 double temps;
89 temps=0.;
90
91 OWN_PTR(Champ_Fonc_base) espace_stockage_fonc;
93 Motcle directive = get_directive_pour_discr();
94 discr.discretiser_champ(directive,domaine_dis,nature_source,noms,unites,nb_comp,temps,espace_stockage_fonc);
95 espace_stockage = espace_stockage_fonc;
96
97 DoubleTab& valeurs_espace = espace_stockage->valeurs();
98 const DoubleTab& source_so_val = source.valeurs();
99 const DoubleTab& inconnue = source_so_val;
100 valeurs_espace = source_so_val;
101
102 // For all faces where flux is imposed, if the turbulent flux is not computed, recompute the temperature
103 // retrieve the temperature equation
104 const Equation_base& my_eqn=ref_cast(Champ_Inc_base,source).equation();
105 const RefObjU& modele_turbulence = my_eqn.get_modele(TURBULENCE);
106 if ( modele_turbulence && sub_type(Modele_turbulence_scal_base,modele_turbulence.valeur()))
107 {
108 const Modele_turbulence_scal_base& mod_turb_scal = ref_cast(Modele_turbulence_scal_base,modele_turbulence.valeur());
109 const Turbulence_paroi_scal_base& loiparth = mod_turb_scal.loi_paroi();
110
111 if( loiparth.use_equivalent_distance() )
112 {
113 // const Paroi_scal_hyd_base_VEF& paroi_scal_vef = ref_cast(Paroi_scal_hyd_base_VEF,loiparth.valeur());
114
115 const Domaine_VEF& domaine_VEF=ref_cast(Domaine_VEF,my_eqn.domaine_dis());
116 const IntTab& elem_faces = domaine_VEF.elem_faces();
117 const DoubleVect& vol = domaine_VEF.volumes();
118 const IntTab& face_voisins = domaine_VEF.face_voisins();
119 const DoubleTab& face_normale = domaine_VEF.face_normales();
120 const Domaine_Cl_VEF& domaine_Cl_VEF=ref_cast(Domaine_Cl_VEF,my_eqn.domaine_Cl_dis());
121 int nb_dim_pb=Objet_U::dimension;
122 DoubleVect le_mauvais_gradient(nb_dim_pb);
123 int nb_front=domaine_VEF.nb_front_Cl();
124 for (int n_bord=0; n_bord<nb_front; n_bord++)
125 {
126 const Cond_lim& la_cl = domaine_Cl_VEF.les_conditions_limites(n_bord);
127 const Cond_lim_base& cl_base=la_cl.valeur();
128 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
129
130 // Wall laws only apply when the BC is of imposed-temperature type,
131 // because in other cases (imposed flux, adiabatic) the wall flux is known and fixed.
132 int ldp_appli=0;
133 if ((sub_type(Neumann_paroi,cl_base))||(sub_type(Neumann_homogene,cl_base)))
134 {
135 ldp_appli=1;
136 // if (paroi_scal_vef.get_flag_calcul_ldp_en_flux_impose() )
138 ldp_appli=0;
139 }
140
141 if (ldp_appli)
142 {
143 // const DoubleVect& d_equiv = paroi_scal_vef.equivalent_distance(n_bord);
144 const DoubleVect& d_equiv = loiparth.equivalent_distance(n_bord);
145 // d_equiv contains the equivalent distance for the boundary.
146 // In d_equiv, for faces that are not fixed-wall (e.g. periodic, symmetry, etc.)
147 // the geometric distance is used, set during initialization in the wall law.
148
149 int num1 = 0;
150 int num2 = le_bord.nb_faces_tot();
151 ToDo_Kokkos("boundary");
152 for (int ind_face=num1; ind_face<num2; ind_face++)
153 {
154 // Tf is the average fluid temperature in the first element,
155 // without accounting for the wall temperature.
156 double Tf=0.;
157 // double bon_gradient=0.; // norm of the temperature gradient normal to the wall, computed using the wall law.
158 le_mauvais_gradient=0.;
159 int num_face = le_bord.num_face(ind_face);
160 int elem1 = face_voisins(num_face,0);
161 if (elem1==-1) elem1 = face_voisins(num_face,1);
162 double surface_face = domaine_VEF.face_surfaces(num_face);
163
164 int nb_faces_elem = domaine_VEF.domaine().nb_faces_elem();
165 for (int i=0; i<nb_faces_elem; i++)
166 {
167 int j = elem_faces(elem1,i);
168 if ( j != num_face )
169 {
170 double surface_pond = 0.;
171 for (int kk=0; kk<nb_dim_pb; kk++)
172 surface_pond -= (face_normale(j,kk)*domaine_VEF.oriente_normale(j,elem1)*face_normale(num_face,kk)*
173 domaine_VEF.oriente_normale(num_face,elem1))/(surface_face*surface_face);
174 Tf+=inconnue(j)*surface_pond;
175 }
176
177 for(int kk=0; kk<nb_dim_pb; kk++)
178 le_mauvais_gradient(kk)+=inconnue(j)*face_normale(j,kk)*domaine_VEF.oriente_normale(j,elem1);
179 }
180 le_mauvais_gradient/=vol(elem1);
181 // mauvais_gradient = le_mauvais_gradient.n
182 double mauvais_gradient=0;
183 for(int kk=0; kk<nb_dim_pb; kk++)
184 mauvais_gradient+=le_mauvais_gradient(kk)*face_normale(num_face,kk)/surface_face;
185
186 // valeurs_espace(num_face) is the wall temperature: Tw.
187 // The sign of the good gradient does not matter since it is the norm of the
188 // temperature gradient in the element.
189 // It will then be multiplied by the normal vector to the wall face,
190 // which has the correct signs.
191 //bon_gradient=(Tf-inconnue(num_face))/d_equiv(ind_face)*(-domaine_VEF.oriente_normale(num_face,elem1));
192 // we must have bon=mauvais...
193 // compute so that bon_grad = mauvais
194 valeurs_espace(num_face)=Tf-mauvais_gradient*d_equiv(ind_face)*(-domaine_VEF.oriente_normale(num_face,elem1));
195 }
196 }
197 }
198 }
199 }
200 DoubleTab& espace_valeurs = espace_stockage->valeurs();
201 espace_valeurs.echange_espace_virtuel();
202
203 return espace_stockage;
204}
205
207{
208
209 Motcles motcles(1);
210 motcles[0] = "composantes";
211 int rang = motcles.search(query);
212 switch(rang)
213 {
214
215 case 0:
216 {
217 Noms source_compos = get_source(0).get_property("composantes");
218 int nb_comp = source_compos.size();
219 Noms compo(nb_comp);
220
221 for (int i=0; i<nb_comp; i++)
222 {
223 Nom nume(i);
224 compo[i] = nom_post_+nume;
225 }
226
227 return compo;
228 }
229
230 }
232}
233
234// Name the field as source by default
235// "Combinaison_"+nom_champ_source
237{
238 if (nom_post_=="??")
239 {
240 Nom nom_post_source, nom_champ_source;
241 const Noms nom = get_source(0).get_property("nom");
242 nom_champ_source = nom[0];
243 nom_post_source = "Tparoi_";
244 nom_post_source += nom_champ_source;
245 nommer(nom_post_source);
246 }
247}
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
Base class of generic fields having other generic fields as source. The use of the class methods reli...
const Noms get_property(const Motcle &query) const override
Returns the requested property.
virtual OWN_PTR(Champ_Fonc_base) &creer_espace_stockage(const Nature_du_champ &nature
virtual const Champ_Generique_base & get_source(int i) const
const Motcle get_directive_pour_discr() const override
Returns the directive (champ_elem, champ_sommets, champ_face or pression) to launch the discretizatio...
const Discretisation_base & get_discretisation() const override
Returns the discretization associated with the problem.
const Domaine_dis_base & get_ref_domaine_dis_base() const override
Returns a ref to the discretized domain on which the storage space will be evaluated.
class Champ_Generique_Tparoi_VEF
const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const override
const Noms get_property(const Motcle &query) const override
Returns the requested property.
const Champ_base & get_champ(OWN_PTR(Champ_base)&espace_stockage) const override
virtual const Noms get_property(const Motcle &query) const
Returns the requested property.
virtual const Champ_base & get_champ(OWN_PTR(Champ_base) &espace_stockage) const =0
virtual const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const =0
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
Class Champ_Inc_base.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class Discretisation_base This class represents a spatial discretization scheme, which
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
int nb_faces_elem(int=0) const
Returns the number of faces of type i of the geometric elements that make up the domain.
Definition Domaine.h:484
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
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
double volumes(int i) const
Definition Domaine_VF.h:113
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
int oriente_normale(int f, int e) const
Definition Domaine_VF.h:194
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
int nb_front_Cl() const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const RefObjU & get_modele(Type_modele type) const
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
virtual Nature_du_champ nature_du_champ() const
Definition Field_base.h:77
class Front_VF
Definition Front_VF.h:36
int nb_faces_tot() const
Definition Front_VF.h:58
int num_face(const int) const
Definition Front_VF.h:68
Base class for scalar turbulence models coupled to a Navier-Stokes convection-diffusion equation.
const Turbulence_paroi_scal_base & loi_paroi() const
Returns the scalar wall-law turbulence model (const version).
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
Classe Neumann_homogene This class is the base class of the hierarchy of homogeneous Neumann-type bou...
Classe Neumann_paroi This boundary condition corresponds to an imposed flux for the.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for output streams.
Definition Sortie.h:52
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
const Objet_U & valeur() const
Definition TRUST_Ref.h:134
Base class for the hierarchy of scalar wall-law models computing turbulent quantities near walls....
virtual bool use_equivalent_distance() const
Give a boolean indicating if we need to use equivant distance by default we consider that we use the ...
const DoubleVects & equivalent_distance() const
const int & get_flag_calcul_ldp_en_flux_impose() const