TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_front_xyz_debit.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 <Ch_front_input_uniforme.h>
17#include <Champ_front_xyz_debit.h>
18#include <Champ_front_uniforme.h>
19#include <Champ_front_Tabule.h>
20#include <Champ_Inc_base.h>
21#include <Champ_front_t.h>
22#include <Equation_base.h>
23#include <Milieu_base.h>
24#include <Param.h>
25
26
27Implemente_instanciable(Champ_front_xyz_debit,"Champ_front_xyz_debit",Champ_front_normal);
28// XD champ_front_xyz_debit front_field_base champ_front_xyz_debit BRACE This field is used to define a flow rate field
29// XD_CONT with a velocity profil which will be normalized to match the flow rate chosen.
30
32{
34}
35
36
38{
39 Param param(que_suis_je());
40 param.ajouter("velocity_profil", &velocity_profil_, Param::OPTIONAL); // XD_ADD_P front_field_base
41 // XD_CONT velocity_profil 0 velocity field to define the profil of velocity.
42 param.ajouter("flow_rate", &flow_rate_, Param::REQUIRED); // XD_ADD_P front_field_base
43 // XD_CONT flow_rate 1 uniform field in space to define the flow rate. It could be, for example, champ_front_uniforme,
44 // XD_CONT ch_front_input_uniform or champ_front_fonc_t
45 param.lire_avec_accolades_depuis(is);
46 fixer_nb_comp(dimension * flow_rate_->nb_comp());
47 return is;
48}
49
51{
52// Cerr << "Champ_front_xyz_debit::initialiser" << finl;
54 return 0;
55 ch_inco_ = inco;
56 const Front_VF& le_bord= ref_cast(Front_VF,frontiere_dis());
57 flow_rate_->initialiser(tps,inco);
58 if ( !sub_type(Champ_front_uniforme,flow_rate_.valeur()) && !sub_type(Ch_front_input_uniforme,flow_rate_.valeur()) && !sub_type(Champ_front_t,flow_rate_.valeur()) && !sub_type(Champ_front_Tabule,flow_rate_.valeur()))
59 {
60 Cerr << "\nError in Champ_front_xyz_debit::initialiser() \nflow_rate must be of type champ_front_uniforme, ch_front_input_uniforme, champ_front_tabule or champ_front_fonc_t!" << finl;
61 exit();
62 }
64 {
65 velocity_profil_->initialiser(tps,inco);
66 if (velocity_profil_->nb_comp()!=dimension)
67 {
68 Cerr << "\nError in Champ_front_xyz_debit::initialiser() \nvelocity_profil must have " << dimension << " components!" << finl;
69 exit();
70 }
71 }
72 initialiser_coefficient(inco, tps);
73
74 // For tabular sizing only
75 normal_vectors_=les_valeurs[0].valeurs();
76 integrale_.resize(flow_rate_->valeurs().line_size());
77 DoubleTab velocity_user;
79 velocity_user=velocity_profil_->valeurs();
80 calculer_normales_et_integrale(le_bord,velocity_user);
81
82 // the flow rate Q_user and the velocity profil U_user are imposed on the boundary
83 // so the velocity field u is computed as following :
84 // u = ( Q_user U_user n)/ Integrale( U_user . n dS)
85 // where n is the normal vector associated to the boundary
86
87 // fill at every time
88 int nb_cases=les_valeurs->nb_cases(); // cases number of the wheel
89 for (int t=0; t<nb_cases; t++)
90 {
91 DoubleTab& velocity_field=les_valeurs[t].valeurs(); // values of the field at time t, type Roue_ptr
92 calculer_champ_vitesse(le_bord, velocity_field, velocity_user, tps);
93 }
94 return 1;
95}
96
97void Champ_front_xyz_debit::calculer_normales_et_integrale(const Front_VF& le_bord, DoubleTab& velocity_user)
98{
99 const int N = flow_rate_->nb_comp();
100 const Domaine_VF& domaine_VF = ref_cast(Domaine_VF,domaine_dis());
101 integrale_ = 0.;
102
103 for(int i = 0; i < le_bord.nb_faces_tot(); i++)
104 {
105 int f = le_bord.num_face(i);
106 const double dS = domaine_VF.face_surfaces(f);
107 for (int n = 0; n < N; ++n)
108 {
109 double u_scal_n = 0;
110 for(int j = 0; j < dimension; j++)
111 {
112 normal_vectors_(i, j) = -domaine_VF.normalized_boundaries_outward_vector(f, 1.)(j); // inward normal
113 u_scal_n += normal_vectors_(i, j) * (velocity_user.size() ? velocity_user(velocity_user.size() > dimension ? i : 0, j) : normal_vectors_(i, j));
114 }
115 if (i < le_bord.nb_faces()) integrale_(n) += dS * u_scal_n / coeff_(i, n) * ch_inco_->equation().milieu().porosite_face(f); //real faces only
116 }
117 }
118 for (int n = 0; n < N; ++n)
120}
121
123{
124 const Front_VF& le_bord = ref_cast(Front_VF,frontiere_dis());
125 coeff_.resize(le_bord.nb_faces_tot(), flow_rate_->nb_comp());
126 coeff_ = 1.;
127}
128
129void Champ_front_xyz_debit::calculer_champ_vitesse(const Front_VF& le_bord, DoubleTab& velocity_field, DoubleTab& velocity_user, double temps)
130{
131 const int N = flow_rate_->nb_comp();
132
133 for(int i = 0; i < le_bord.nb_faces_tot(); i++)
134 for (int n = 0; n < N; ++n)
135 for(int j = 0; j < dimension; j++)
136 {
137 double v_mult = flow_rate_->valeurs_au_temps(temps)(0, n) / integrale_(n) ; //the profile/normals must be multiplied by this to get the correct inward flow
138 double n_mult = flow_rate_alone_ ? normal_vectors_(i,j) : (velocity_user(velocity_user.size() > dimension ? i : 0, j));
139 velocity_field(i, N * j + n) = v_mult * n_mult;
140 }
141}
142
144{
145 flow_rate_->associer_fr_dis_base(fr);
146// Cerr << "Champ_front_xyz_debit::associer_fr_dis_base flow_rate_alone_ " << flow_rate_alone_ << finl;
147 if (!flow_rate_alone_)
148 velocity_profil_->associer_fr_dis_base(fr);
150}
151
153{
154// Cerr << "Champ_front_xyz_debit::set_temps_defaut" << finl;
155 flow_rate_->set_temps_defaut(temps);
156 if (!flow_rate_alone_)
157 velocity_profil_->set_temps_defaut(temps);
159}
160
162{
163// Cerr << "Champ_front_xyz_debit::fixer_nb_valeurs_temporelles" << finl;
164 flow_rate_->fixer_nb_valeurs_temporelles(nb_cases);
165 if (!flow_rate_alone_)
166 velocity_profil_->fixer_nb_valeurs_temporelles(nb_cases);
168}
169
171{
172// Cerr << "Champ_front_xyz_debit::changer_temps_futur" << finl;
174 flow_rate_->changer_temps_futur(temps,i);
175 if (!flow_rate_alone_)
176 velocity_profil_->changer_temps_futur(temps,i);
177}
178
179/*! @brief Turn the wheel of the CL
180 *
181 */
183{
184// Cerr << "Champ_front_xyz_debit::avancer" << finl;
186 if (flow_rate_->avancer(temps))
187 if (!flow_rate_alone_)
188 return velocity_profil_->avancer(temps);
189 else
190 return 1;
191 else
192 return 0;
193}
194
195/*! @brief Turn the wheel of the CL
196 *
197 */
199{
200// Cerr << "Champ_front_xyz_debit::reculer" << finl;
202 if (flow_rate_->reculer(temps))
203 if (!flow_rate_alone_)
204 return velocity_profil_->reculer(temps);
205 else
206 return 1;
207 else
208 return 0;
209}
210
212{
213// Cerr << "Champ_front_xyz_debit::mettre_a_jour temps = " << temps << finl;
214 if (update_coeff_) update_coeff(temps);
215 DoubleTab velocity_user;
216
217 flow_rate_->mettre_a_jour(temps);
218 if (!flow_rate_alone_)
219 {
220 velocity_profil_->mettre_a_jour(temps);
221 velocity_user=velocity_profil_->valeurs_au_temps(temps);
222 }
223 else
224 {
225 velocity_user.resize(1,dimension);
226 velocity_user=1;
227 }
229 DoubleTab& velocity_field=valeurs_au_temps(temps); // values of the field at time t, type Roue_ptr
230 const Front_VF& le_bord= ref_cast(Front_VF,frontiere_dis());
231 if (velocity_field.size_array())
232 calculer_champ_vitesse(le_bord, velocity_field, velocity_user, temps);
233}
234
class Ch_front_input_uniforme
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialisation en debut de calcul.
Classe Champ_Inc_base.
classe Champ_front_Tabule Classe derivee de Champ_front_instationnaire_base qui
virtual void associer_fr_dis_base(const Frontiere_dis_base &)
Associe une frontiere discretisee au champ.
virtual void changer_temps_futur(double temps, int i)
Change la valeur du temps pour la ieme valeur temporelle apres le present.
virtual const Frontiere_dis_base & frontiere_dis() const
Renvoie la frontiere discretisee associee au champ.
virtual void set_temps_defaut(double temps)
virtual const Domaine_dis_base & domaine_dis() const
virtual void fixer_nb_valeurs_temporelles(int nb_cases)
Appele par Conds_lim::completer Par defaut ne fait rien.
virtual int reculer(double temps)
A implementer dans les classes derivees.
virtual int avancer(double temps)
A implementer dans les classes derivees.
class Champ_front_normal
classe Champ_front_t Classe derivee de Champ_front_var qui represente les
classe Champ_front_uniforme Classe derivee de Champ_front_base qui represente les
DoubleTab & valeurs_au_temps(double temps) override
Renvoie les valeurs au temps desire.
class Champ_front_xyz_debit
void associer_fr_dis_base(const Frontiere_dis_base &fr) override
Associe une frontiere discretisee au champ.
virtual void set_temps_defaut(double temps) override
int avancer(double temps) override
Turn the wheel of the CL.
void mettre_a_jour(double temps) override
NE FAIT RIEN, a surcharger.
void fixer_nb_valeurs_temporelles(int nb_cases) override
Surcharge Champ_front_base::fixer_nb_valeurs_temporelles.
void calculer_champ_vitesse(const Front_VF &le_bord, DoubleTab &velocity_field, DoubleTab &velocity_user, double temps)
virtual void initialiser_coefficient(const Champ_Inc_base &inco, double tps)
int reculer(double temps) override
Turn the wheel of the CL.
int initialiser(double tps, const Champ_Inc_base &inco) override
Initialisation en debut de calcul.
void calculer_normales_et_integrale(const Front_VF &le_bord, DoubleTab &velocity_user)
virtual void update_coeff(double temps)
void changer_temps_futur(double temps, int i) override
Change la valeur du temps pour la ieme valeur temporelle apres le present.
class Domaine_VF
Definition Domaine_VF.h:44
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
DoubleTab normalized_boundaries_outward_vector(int global_face_number, double scale_factor) const
Compute the normalized boundary outward vector associated to the face global_face_number and eventual...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int nb_faces_tot() const
Definition Front_VF.h:58
int num_face(const int) const
Definition Front_VF.h:68
classe Frontiere_dis_base Classe representant une frontiere discretisee.
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
@ OPTIONAL
Definition Param.h:115
@ REQUIRED
Definition Param.h:115
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
Definition Process.cpp:146
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ size() const
Definition TRUSTVect.tpp:45