TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Iterateur_VDF_Elem_bis.tpp
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#ifndef Iterateur_VDF_Elem_bis_TPP_included
17#define Iterateur_VDF_Elem_bis_TPP_included
18
19template <class _TYPE_>
20void Iterateur_VDF_Elem<_TYPE_>::modifier_flux() const
21{
22 if (op_base->equation().inconnue().le_nom().debute_par("temperature")
23 && !( sub_type(Operateur_Diff_base,op_base.valeur()) && ref_cast(Operateur_Diff_base,op_base.valeur()).diffusivite().le_nom() == "conductivite" ) )
24 {
25 DoubleTab& flux_bords=op_base->flux_bords();
26 const Domaine_VDF& le_dom_vdf=ref_cast(Domaine_VDF,op_base->equation().domaine_dis());
27 const Champ_base& rho = (op_base->equation()).milieu().masse_volumique();
28 const Champ_Don_base& Cp = (op_base->equation()).milieu().capacite_calorifique();
29 const IntTab& face_voisins=le_dom_vdf.face_voisins();
30 int rho_uniforme = sub_type(Champ_Uniforme,rho) ? 1 : 0, cp_uniforme = sub_type(Champ_Uniforme,Cp) ? 1 : 0;
31 int is_rho_u=op_base->equation().probleme().is_dilatable();
32 if (is_rho_u)
33 {
34 const Operateur_base& op=op_base.valeur();
35 is_rho_u=0;
36 if (sub_type(Op_Conv_VDF_base,op))
37 if (ref_cast(Op_Conv_VDF_base,op).vitesse().le_nom()=="rho_u") is_rho_u = 1;
38 }
39 const int nb_faces_bords = le_dom_vdf.nb_faces_bord();
40 for (int face = 0; face < nb_faces_bords; face++)
41 for(int k = 0; k < flux_bords.dimension(1); k++)
42 {
43 int e = (face_voisins(face, 0) != -1) ? face_voisins(face, 0) : face_voisins(face, 1);
44 const double rho_ = (is_rho_u) ? 1.0 : rho.valeurs()(!rho_uniforme * e, k);
45 flux_bords(face, k) *= rho_ * Cp.valeurs()(!cp_uniforme * e, k);
46 }
47 }
48}
49
50template <class _TYPE_>
52{
53 const Domaine_VDF& le_dom_vdf=ref_cast(Domaine_VDF,op_base->equation().domaine_dis());
54 const Domaine& madomaine=le_dom->domaine();
55 const int impr_bord=(madomaine.bords_a_imprimer().est_vide() ? 0:1);
56 const Schema_Temps_base& sch = la_zcl->equation().probleme().schema_temps();
57 double temps = sch.temps_courant();
58 DoubleTab& flux_bords=op_base->flux_bords();
59 DoubleVect bilan(flux_bords.dimension(1));
60 int k,face;
61 int nb_front_Cl=le_dom->nb_front_Cl();
62 DoubleTrav flux_bords2( 3, nb_front_Cl , flux_bords.dimension(1));
63 flux_bords2=0;
64 /*flux_bord(k) -> flux_bords2(0,num_cl,k) */
65 /*flux_bord_perio1(k) -> flux_bords2(1,num_cl,k) */
66 /*flux_bord_perio2(k) -> flux_bords2(2,num_cl,k) */
67 for (int num_cl=0; num_cl<nb_front_Cl; num_cl++)
68 {
69 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
70 const Front_VF& frontiere_dis = ref_cast(Front_VF,la_cl->frontiere_dis());
71 int ndeb = frontiere_dis.num_premiere_face();
72 int nfin = ndeb + frontiere_dis.nb_faces();
73 int periodicite = (type_cl(la_cl)==periodique?1:0);
74 for (face=ndeb; face<nfin; face++)
75 for(k=0; k<flux_bords.dimension(1); k++)
76 {
77 flux_bords2(0,num_cl,k)+=flux_bords(face, k);
78 if(periodicite)
79 {
80 if( face < (ndeb+frontiere_dis.nb_faces()/2) ) flux_bords2(1,num_cl,k)+=flux_bords(face, k);
81 else flux_bords2(2,num_cl,k)+=flux_bords(face, k);
82 }
83 }
84 } /* fin for num_cl */
85 mp_sum_for_each_item(flux_bords2);
86 if (je_suis_maitre())
87 {
88 op_base->ouvrir_fichier(Flux,"",1);
89 Flux.add_col(temps);
90 for (int num_cl=0; num_cl<nb_front_Cl; num_cl++)
91 {
92 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
93 int periodicite = (type_cl(la_cl)==periodique?1:0);
94 for(k=0; k<flux_bords.dimension(1); k++)
95 {
96 bilan(k)+=flux_bords2(0,num_cl,k);
97 if(periodicite)
98 {
99 Flux.add_col(flux_bords2(1,num_cl,k));
100 Flux.add_col(flux_bords2(2,num_cl,k));
101 }
102 else Flux.add_col(flux_bords2(0,num_cl,k));
103 }
104 }
105 for(k=0; k<flux_bords.dimension(1); k++)
106 Flux.add_col(bilan(k));
107 Flux << finl;
108 }
109 const LIST(Nom)& Liste_bords_a_imprimer = le_dom->domaine().bords_a_imprimer();
110 if (!Liste_bords_a_imprimer.est_vide())
111 {
112 EcrFicPartage Flux_face;
113 op_base->ouvrir_fichier_partage(Flux_face,"",impr_bord);
114 for (int num_cl=0; num_cl<nb_front_Cl; num_cl++)
115 {
116 const Frontiere_dis_base& la_fr = la_zcl->les_conditions_limites(num_cl)->frontiere_dis();
117 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
118 const Front_VF& frontiere_dis = ref_cast(Front_VF,la_cl->frontiere_dis());
119 int ndeb = frontiere_dis.num_premiere_face(), nfin = ndeb + frontiere_dis.nb_faces();
120 if (madomaine.bords_a_imprimer().contient(la_fr.le_nom()))
121 {
122 Flux_face << "# Flux par face sur " << la_fr.le_nom() << " au temps " << temps << " : " << finl;
123 for (face=ndeb; face<nfin; face++)
124 {
125 if (dimension == 2)
126 Flux_face << "# Face a x= " << le_dom->xv(face,0) << " y= " << le_dom->xv(face,1);
127 else if (dimension == 3)
128 Flux_face << "# Face a x= " << le_dom->xv(face,0) << " y= " << le_dom->xv(face,1) << " z= " << le_dom->xv(face,2);
129 for(k=0; k<flux_bords.dimension(1); k++)
130 {
131 if (!est_egal(le_dom_vdf.face_surfaces(face),0., 1.e-20))
132 {
133 Flux_face << " surface_face(m2)= " << le_dom_vdf.face_surfaces(face);
134 Flux_face << " flux_par_surface(W/m2)= " << flux_bords(face, k)/le_dom_vdf.face_surfaces(face);
135 }
136 Flux_face << " flux(W)= " << flux_bords(face, k);
137 }
138 Flux_face << finl;
139 }
140 Flux_face.syncfile();
141 }
142 }
143 }
144 return 1;
145}
146
147////////////////////////////////////////////////////////////////////////////////////////////
148// A virer un jour .. voir avec le baltik Rayonnement
149template <class _TYPE_>
151{
152 ((_TYPE_&) flux_evaluateur).mettre_a_jour();
153 const int ncomp = resu.line_size();
154 assert(resu.nb_dim() < 3 && la_zcl && le_dom);
155 assert(op_base->flux_bords().dimension(0)==le_dom->nb_faces_bord()); /* resize deja fait */
156 if (ncomp == 1)
157 {
158 contribuer_au_second_membre_bords<SingleDouble>(ncomp,resu);
159 contribuer_au_second_membre_interne<SingleDouble>(ncomp,resu);
160 }
161 else
162 {
163 contribuer_au_second_membre_bords<ArrOfDouble>(ncomp,resu);
164 contribuer_au_second_membre_interne<ArrOfDouble>(ncomp,resu);
165 }
166}
167
168template <class _TYPE_> template <typename Type_Double>
169void Iterateur_VDF_Elem<_TYPE_>::contribuer_au_second_membre_bords(const int ncomp, DoubleTab& resu) const
170{
171 for (int num_cl = 0; num_cl < le_dom->nb_front_Cl(); num_cl++)
172 {
173 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
174 const Front_VF& frontiere_dis = ref_cast(Front_VF,la_cl->frontiere_dis());
175 const int ndeb = frontiere_dis.num_premiere_face(), nfin = ndeb + frontiere_dis.nb_faces();
176 switch(type_cl(la_cl))
177 {
178 case navier :
179 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_SYMM,Type_Double>((const Symetrie&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
180 break;
181 case sortie_libre :
182 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_SORTIE_LIB,Type_Double>((const Neumann_sortie_libre&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
183 break;
184 case entree_fluide :
185 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_ENTREE_FL,Type_Double>((const Dirichlet_entree_fluide&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
186 break;
187 case paroi_fixe :
188 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_PAR_FIXE,Type_Double>((const Dirichlet_paroi_fixe&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
189 break;
190 case paroi_defilante :
191 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_PAR_DEFIL,Type_Double>((const Dirichlet_paroi_defilante&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
192 break;
193 case paroi_adiabatique :
194 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_PAR_ADIAB,Type_Double>((const Neumann_paroi_adiabatique&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
195 break;
196 case paroi :
197 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_PAR,Type_Double>((const Neumann_paroi&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
198 break;
199 case echange_global_impose :
200 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_ECH_GLOB_IMP,Type_Double>((const Echange_global_impose&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
201 break;
202 case periodique :
203 contribuer_au_second_membre_bords_<_TYPE_::CALC_FLUX_FACES_PERIO,Type_Double>((const Periodique&) la_cl.valeur(),ndeb,nfin,ncomp,resu);
204 break;
205 case echange_externe_impose :
206 contribuer_au_second_membre_bords_<Type_Double>((const Echange_externe_impose&)la_cl.valeur(), ndeb,nfin,num_cl,ncomp,frontiere_dis,resu);
207 break;
208 default :
209 Cerr << "On ne reconnait pas la condition limite : " << la_cl.valeur() << " , dans T_It_VDF_Elem<_TYPE_>::contribuer_au_second_membre_bords" << finl;
211 break;
212 }
213 }
214}
215
216template <class _TYPE_> template <typename Type_Double>
217void Iterateur_VDF_Elem<_TYPE_>::contribuer_au_second_membre_interne(const int ncomp, DoubleTab& resu) const
218{
219 Type_Double flux(ncomp);
220 const Domaine_VDF& domaine_VDF = le_dom.valeur();
221 const int ndeb = domaine_VDF.premiere_face_int(), nfin = domaine_VDF.nb_faces();
222 for (int face = ndeb; face < nfin; face++)
223 {
224 const int elem0 = elem(face,0), elem1 = elem(face,1);
225 flux_evaluateur.secmem_faces_interne(face, flux);
226 for (int k = 0; k < ncomp; k++)
227 {
228 resu(elem0,k) += flux[k];
229 resu(elem1,k) -= flux[k];
230 }
231 }
232}
233
234template <class _TYPE_> template <bool should_calc_flux, typename Type_Double, typename BC>
235void Iterateur_VDF_Elem<_TYPE_>::contribuer_au_second_membre_bords_(const BC& cl, const int ndeb, const int nfin, const int ncomp, DoubleTab& resu) const
236{
237 constexpr bool is_Periodique = std::is_same<BC,Periodique>::value;
238 if (should_calc_flux)
239 {
240 Type_Double flux(ncomp);
241 for (int face = ndeb; face < nfin; face++)
242 {
243 flux_evaluateur.secmem_face(face, cl, ndeb, flux); // Generic code
244 is_Periodique ? fill_flux_tables_(face,ncomp,0.5 /* coeff */,flux,resu) : fill_flux_tables_(face,ncomp,1.0 /* coeff */,flux,resu);
245 }
246 }
247}
248
249template <class _TYPE_> template <typename Type_Double>
250void Iterateur_VDF_Elem<_TYPE_>::contribuer_au_second_membre_bords_(const Echange_externe_impose& cl, const int ndeb, const int nfin, const int num_cl, const int ncomp, const Front_VF& frontiere_dis, DoubleTab& resu) const
251{
252 if (_TYPE_::CALC_FLUX_FACES_ECH_EXT_IMP)
253 {
254 Type_Double flux(ncomp);
255 int boundary_index=-1;
256 if (le_dom->front_VF(num_cl).le_nom() == frontiere_dis.le_nom()) boundary_index = num_cl;
257 for (int face = ndeb; face < nfin; face++)
258 {
259 int local_face=le_dom->front_VF(boundary_index).num_local_face(face);
260 flux_evaluateur.secmem_face(boundary_index,face,local_face, cl, ndeb, flux);
261 fill_flux_tables_(face,ncomp,1.0 /* coeff */,flux,resu);
262 }
263 }
264}
265
266#endif /* Iterateur_VDF_Elem_bis_TPP_included */
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Champ_Uniforme Represents a field that is constant in space and time.
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
Dirichlet_entree_fluide This class represents a boundary condition imposing a quantity.
Dirichlet_paroi_defilante Imposes the wall velocity in an equation of type Navier_Stokes.
Dirichlet_paroi_fixe Represents a fixed wall in a Navier-Stokes type equation.
class Domaine_VDF
Definition Domaine_VDF.h:61
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
int nb_faces_bord() const
Returns the number of faces on which boundary conditions are applied:
Definition Domaine_VF.h:512
Classe Echange_externe_impose: This class represents the special case of the class.
Classe Echange_global_impose This class represents the special case of the class.
Sortie & syncfile() override
Triggers writing to disk of the data accumulated on the different processors since the last call to s...
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
class Frontiere_dis_base Class representing a discretized boundary.
const Nom & le_nom() const override
Returns the name of the geometric boundary.
int impr(Sortie &os) const override
void contribuer_au_second_membre(DoubleTab &) const override
Type_Cl_VDF type_cl(const Cond_lim &) const
Classe Neumann_paroi_adiabatique This boundary condition corresponds to an adiabatic wall in a.
Classe Neumann_paroi This boundary condition corresponds to an imposed flux for the.
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
class Op_Conv_VDF_base Classe de base des operateurs de convection VDF
Operateur_Diff_base This class is the base of the hierarchy of operators representing.
class Operateur_base This class is the base of the hierarchy of objects representing an
class Periodique This class represents a periodic boundary condition.
Definition Periodique.h:31
static void mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:194
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
class Schema_Temps_base
double temps_courant() const
Returns the current time.
Symetrie On symmetry faces, the following properties hold:
Definition Symetrie.h:37
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67