TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Echange_contact_VDF_FT_Disc.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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 <Echange_contact_VDF_FT_Disc.h>
17
18#include <Champ_front_calc.h>
19#include <Probleme_base.h>
20#include <Champ_Uniforme.h>
21#include <Schema_Temps_base.h>
22#include <Milieu_base.h>
23#include <Modele_turbulence_scal_base.h>
24#include <Domaine_VDF.h>
25#include <Equation_base.h>
26#include <Conduction.h>
27#include <Param.h>
28#include <Probleme_FT_Disc_gen.h>
29#include <Triple_Line_Model_FT_Disc.h>
30#include <Domaine_VF.h>
31#include <Front_VF.h>
32
33
34Implemente_instanciable( Echange_contact_VDF_FT_Disc, "Echange_contact_VDF_FT_Disc", Echange_contact_VDF ) ;
35// XD echange_contact_vdf_ft_disc condlim_base echange_contact_vdf_ft_disc BRACE echange_conatct_vdf en prescisant la
36// XD_CONT phase
37
39{
41 return os;
42}
43
45{
46 if (app_domains.size() == 0) app_domains = { Motcle("Thermique") };
47
48 // Echange_contact_VDF::readOn( is );
49 Cerr<<"Lecture des parametres du contact (Echange_contact_VDF_FT_Disc::readOn)"<<finl;
50 Param param("Echange_contact_VDF_FT_Disc::readOn");
51 param.ajouter("autre_probleme",&nom_autre_pb_,Param::REQUIRED); // XD_ADD_P chaine
52 // XD_CONT name of other problem
53 param.ajouter("autre_bord",&nom_bord,Param::REQUIRED); // XD_ADD_P chaine
54 // XD_CONT name of other boundary
55 param.ajouter("autre_champ_temperature",&nom_champ,Param::REQUIRED); // XD_ADD_P chaine
56 // XD_CONT name of other field
57 param.ajouter("nom_mon_indicatrice",&nom_champ_indicatrice_,Param::REQUIRED); // XD_ADD_P chaine
58 // XD_CONT name of indicatrice
59 param.ajouter("Ri_liq",&Ri_); // XD_ADD_P double
60 // XD_CONT interficial thermal resitence of liquid
61 int phase = INT_MAX; // should be overriden after reading. see next line
62 param.ajouter("phase",&phase,Param::REQUIRED); // XD_ADD_P int
63 // XD_CONT phase
64 param.lire_avec_accolades(s);
65 indicatrice_ref_ = double(phase);
67
68 h_paroi=1e10; // why not git 1/h_paroi = 0....?
69 // T_autre_pb(): temp type front from other calculation/OWN_PTR(Champ_base) dans le domaine
70 T_autre_pb_.typer("Champ_front_calc");
71 // T_ext(): mettre_a_jour utilise des donnees externes,
72 // Peut aussi initialized by a champ dans le domaine.
73 le_champ_front.typer("Ch_front_var_instationnaire_dep");
75
76 return s;
77}
79{
80 // Champ_front_calc:: mettre_a_jour()
81 // par default distant_= 1
82 // trace the value corresponding from champ inconnu
83 // Champ_Inc_P0_base::trace(), trace the element from distant
85 indicatrice_->mettre_a_jour(temps);
86
87 const DoubleTab& I = indicatrice_->valeurs_au_temps(temps);
88
90 // le_milieu = SOLID
91 const Milieu_base& le_milieu=ch.milieu();
92 int nb_comp = le_milieu.conductivite().nb_comp();
93 assert(nb_comp==1);
94
95
96 int is_pb_fluide=0;
97
98
99 DoubleTab& mon_h= h_imp_->valeurs();
100 int opt=0;
101 calculer_h_autre_pb( autre_h, 0., opt);
102 // Here, compute h_diff in the fluid side
103 calculer_h_mon_pb(mon_h,Ri_,opt);
104
105 // juste acceder la valeur..., et les remplir
106 // pas forcement des chose dedans et valable.
107 DoubleTab& mon_Tex= T_ext(). valeurs();
108 calculer_Teta_equiv(mon_Tex,mon_h,autre_h,is_pb_fluide,temps);
109
110 // Attention: Ti_wall_ should be updated after TCL model
111 // AS it will be used in TCL model, in particular,
112 // influence the heat flux in MESO zone
113 // OK here: TCL model is called in UpdateField
114 DoubleTab& mon_Ti= Ti_wall_-> valeurs();
115 DoubleTab Twalltmp(mon_Ti);
116 Twalltmp.detach_vect();
117 calculer_Teta_paroi(Twalltmp,mon_h,autre_h,is_pb_fluide,temps);
118
119 int taille=mon_h.dimension(0);
120
121 for (int ii=0; ii<taille; ii++)
122 for (int jj=0; jj<nb_comp; jj++)
123 {
124 if (est_egal(I(ii,0),indicatrice_ref_))
125 {
126 mon_h(ii,jj)=1./(1./autre_h(ii,jj)+1./mon_h(ii,jj));
127 mon_Ti(ii, jj) = Twalltmp(ii, jj);
128 }
129 else
130 {
131 // Using Ghost Fluid Method, mon_h and T in pure-L/pure-G cells are NO-PHYSICAL
132 // the BC here are not important
133 // Setting mon_h = 0 => isothermal BC
134 mon_h(ii,jj) = 0.;
135 // Update mon_Ti in the same way (to have a good convergence)
136 mon_Ti(ii, jj) = Twalltmp(ii, jj);
137 }
138 }
139
140
141 Nom nom_pb=mon_dom_cl_dis->equation().probleme().le_nom();
142 Probleme_base& pb_gen=ref_cast(Probleme_base, Interprete::objet(nom_pb));
143 Probleme_FT_Disc_gen *pbft = dynamic_cast<Probleme_FT_Disc_gen*>(&pb_gen);
144
145 const Domaine_VF& le_dom=ref_cast(Domaine_VF, mon_dom_cl_dis -> domaine_dis());
146 const DoubleVect& surface= le_dom.face_surfaces();
147
148
149 if (pbft-> tcl().is_activated())
150 {
151
152 // phi_ext_ used in *Eval_Diff_VDF_Elem_Gen.tpp* L97
153 DoubleTab& mon_phi = phi_ext_-> valeurs();
154 mon_phi = 0;
155// **************************************To be implemented*******************
156 // 2 - phase cells at pb-Boundary when solving T-eq at Liquid side
157 //mixed mesh => Text, Twall, mon_h
158 if (indicatrice_ref_ == 1)
159 {
160 Triple_Line_Model_FT_Disc *tcl = pbft ? &pbft->tcl() : nullptr;
161 const ArrOfDouble& Q_from_CL = tcl->Q();
162 const ArrOfInt& faces_with_CL_contrib = tcl-> boundary_faces();
163 const IntTab& face_voisins = le_dom.face_voisins();
164
165
166 const int nb_contact_line_contribution = faces_with_CL_contrib.size_array();
167
168
169 for (int jj = 0; jj < nb_comp; jj++)
170 {
171 // In case of parallelization:
172 // raccord in liquid domain and faces_with_CL_contrib are in the same processeur
173 // => have the same face Number in the same position
174 // use face number to check correspondence
175 // fill mon_phi
176 for (int idx = 0; idx < nb_contact_line_contribution; idx++)
177 {
178 const int facei = faces_with_CL_contrib[idx];
179 bool Not_find_ = true;
180
181 int ii;
182 for (ii=0; ii<taille; ii++)
183 {
184 const int face = ii + frontiere_dis ().frontiere ().num_premiere_face ();
185 if (facei == face)
186 {
187 Not_find_ = false;
188 break;
189 }
190 }
191
192 const double sign = (face_voisins (facei, 0) == -1) ? -1. : 1.;
193 const double TCL_wall_flux = Q_from_CL[idx] / surface (facei);
194 const double val = -sign * TCL_wall_flux;
195
196 if (!Not_find_)
197 mon_phi(ii, jj) += val;
198 else
199 Process::exit(Nom("Echange_contact_VDF_FT_Disc : missing element corresponding") + Nom(facei) + " ! Check all faces number in TCL are at BC?" );
200 }
201
202 // replace mon_h and mon_Ti;
203 for (int ii=0; ii<taille; ii++)
204 {
205 if (!est_egal(mon_phi(ii, jj), 0.))
206 {
207 mon_Ti(ii, jj) = T_ext().valeurs()(ii, jj) - mon_phi(ii, jj) /autre_h(ii) ;
208 mon_h(ii,jj) = 0.;
209 }
210 }
211 }
212 }
213 }
214
215 // put in the end: to make sure to update the *modified* h_imp_, phi_ext_, and T_ext
218 mon_Ti.echange_espace_virtuel();
219 Ti_wall_->mettre_a_jour(temps);
220
221
222 // check if to inject a new nuclateion seed
223 // only check in the liquid - equation
224
225 if ((pbft->tcl ().reinjection_tcl ()) && (indicatrice_ref_ == 1) )
226 {
227 bool& ready_inject = pbft->tcl ().ready_inject_tcl ();
228 ready_inject = false;
229
230 int BC_has_tcl = 0;
231
232 for (int ii = 0; ii < taille; ii++)
233 if (!est_egal (I (ii, 0), indicatrice_ref_))
234 {
235 BC_has_tcl = 1;
236 break;
237 }
238 BC_has_tcl = Process::mp_max (BC_has_tcl);
239
240 if (BC_has_tcl == 0)
241 {
242 double sum_T = 0;
243 double sum_surface = 0;
244
245 for (int ii = 0; ii < taille; ii++)
246 {
247 const int face = ii
249 if (le_dom.xv (face, 0) <= pbft->tcl ().Rc_inject ())
250 {
251 sum_surface += surface (face);
252 sum_T += surface (face) * mon_Ti (ii, 0);
253 }
254 }
255
256 sum_T = Process::mp_sum (sum_T);
257 sum_surface = Process::mp_sum (sum_surface);
258
259 sum_T = (sum_surface > DMINFLOAT) ? sum_T / sum_surface : 0;
260
261 ready_inject = (sum_T >= pbft->tcl ().tempC_tcl ()) ? true : false;
262 }
263
264 ready_inject = Process::mp_max ((int)ready_inject);
265 }
266
267}
268
270{
272
273 indicatrice_.typer("Champ_front_calc");
274 Champ_front_calc& ch=ref_cast(Champ_front_calc, indicatrice_.valeur());
275
276 Nom nom_bord_=frontiere_dis().frontiere().le_nom();
277 Nom nom_pb = mon_dom_cl_dis->equation ().probleme ().le_nom ();
278
279 int distant=0;
280 // when solving pure condution pb for solid
281 if (sub_type(Conduction,domaine_Cl_dis().equation()))
282 {
283 nom_pb=nom_autre_pb_;
284 nom_bord_=nom_bord_oppose_;
285 distant=1;
286 }
287 // check the coherance and fixer nb of component
288 ch.creer(nom_pb, nom_bord_, nom_champ_indicatrice_);
289 // changer distant = 0; for indicatrice_...
290 // par default, 1;
291 ch.set_distant(distant);
293 ch.completer();
295 ch.fixer_nb_valeurs_temporelles(nb_cases);
296
297 Probleme_base& pb_gen = ref_cast(Probleme_base, Interprete::objet (nom_pb));
298
299 //ONCE phi_ext_lu_ true, will be completer in father classes
300
301 const Probleme_FT_Disc_gen *pbft =
302 dynamic_cast<const Probleme_FT_Disc_gen*> (&pb_gen);
303
304 int nb_faces_raccord1 = frontiere_dis().frontiere().nb_faces ();
305
306 if (pbft->tcl ().is_activated () && phi_ext_lu_ == false)
307 {
308 phi_ext_lu_ = true;
309
310 derivee_phi_ext_.typer ("Champ_front_fonc");
311 derivee_phi_ext_->fixer_nb_comp (1);
312 derivee_phi_ext_->associer_fr_dis_base (frontiere_dis ());
313 derivee_phi_ext_->valeurs ().resize (nb_faces_raccord1, 1);
314
315 phi_ext_.typer ("Champ_front_fonc");
316 phi_ext_->fixer_nb_comp (1);
317 phi_ext_->associer_fr_dis_base (frontiere_dis ());
318 phi_ext_->valeurs ().resize (nb_faces_raccord1, 1);
319 }
320
321
322
323 Ti_wall_.typer ("Champ_front_fonc");
324 Ti_wall_->fixer_nb_comp (1);
325 Ti_wall_->associer_fr_dis_base (frontiere_dis ());
326 Ti_wall_->valeurs().resize (nb_faces_raccord1, 1);
327 Ti_wall_-> fixer_nb_valeurs_temporelles(nb_cases);
328
329}
330
331
332
333/*! @brief Change le i-eme temps futur de la CL.
334 *
335 */
337{
339 indicatrice_->changer_temps_futur(temps,i);
340 Ti_wall_ -> changer_temps_futur(temps,i);
341}
342
343/*! @brief Tourne la roue de la CL
344 *
345 */
347{
348 int ok=Echange_contact_VDF::avancer(temps);
349 ok = ok && indicatrice_->avancer(temps);
350 ok = ok && Ti_wall_ -> avancer(temps);
351 return ok;
352}
353
354/*! @brief Tourne la roue de la CL
355 *
356 */
358{
359 int ok=Echange_contact_VDF::reculer(temps);
360 ok = ok && indicatrice_->reculer(temps);
361 ok = ok && Ti_wall_ -> reculer(temps);
362 return ok;
363}
364
366{
367
368 // T_autre_pb is ALSO created and initialised in the following line
370 return 0;
371
372 DoubleTab& mon_Ti = Ti_wall_->valeurs ();
373
374 int is_pb_fluide = 0;
375 DoubleTab mon_h (mon_Ti);
376 DoubleTab mautre_h (mon_Ti);
377 int opt = 0;
378 calculer_h_autre_pb (mautre_h, 0., opt);
379 // Here, compute h_diffusion in the fluid side
380 calculer_h_mon_pb (mon_h, 0., opt);
381
382 // Use Twalltmp to avoid resize distributed array mon_Ti
383 // when calling calculer_Teta_paroi
384 DoubleTab Twalltmp (mon_Ti);
385 Twalltmp.detach_vect ();
386
387 calculer_Teta_paroi (Twalltmp, mon_h, mautre_h, is_pb_fluide, temps);
388
389 // Echange_contact_VDF initilise T as temp of liq
390 // some pb in initilization of Twall
391 // T_autre_pb().mettre_a_jour(temps);
392
393 int taille = mon_Ti.dimension (0);
394 for (int ii = 0; ii < taille; ii++)
395 {
396 double tempValue = Twalltmp(ii); // Store the result of Twalltmp(ii) in a temporary variable
397 if (tempValue < 0)
398 {
399 mon_Ti(ii, 0) = 0.; // If the value is negative, set mon_Ti(ii, 0) to 0
400 }
401 else
402 {
403 mon_Ti(ii, 0) = tempValue; // Otherwise, use the original value
404 }
405 }
406
407 Champ_front_calc& chbis=ref_cast(Champ_front_calc, indicatrice_.valeur());
408 return chbis.initialiser(temps,domaine_Cl_dis().equation().inconnue());
409}
410
412{
413 if (Ti_wall_)
414 Ti_wall_->set_temps_defaut(temps);
415 if (indicatrice_)
416 indicatrice_->set_temps_defaut(temps);
418}
420{
421
422 if (Ti_wall_->valeurs().size() == 1)
423 return Ti_wall_->valeurs()(0, 0);
424 else if (Ti_wall_->valeurs().dimension(1) == 1)
425 return Ti_wall_->valeurs()(i, 0);
426 else
427 Cerr << "Echange_contact_VDF_FT_Disc::Ti_wall_ erreur" << finl;
429 return 0.;
430}
virtual void associer_fr_dis_base(const Frontiere_dis_base &)
Associe une frontiere discretisee au champ.
virtual DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ.
virtual void mettre_a_jour(double temps)
NE FAIT RIEN, a surcharger.
virtual void completer()
classe Champ_front_calc Classe derivee de Champ_front_var qui represente les
void creer(const Nom &, const Nom &, const Motcle &)
Cree l'objet Champ_front_calc representant la trace d'un champ inconnue sur une frontiere a partir de...
int initialiser(double, const Champ_Inc_base &) override
Initialisation en debut de calcul.
void set_distant(int d)
const Milieu_base & milieu() const
Renvoie le milieu associe a l'equation qui porte le champ inconnue dont on prend la trace.
void fixer_nb_valeurs_temporelles(int nb_cases) override
Surcharge Champ_front_base::fixer_nb_valeurs_temporelles.
Domaine_Cl_dis_base & domaine_Cl_dis()
Renvoie le domaine des conditions aux limites discretisee dont l'objet fait partie.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Renvoie la frontiere discretisee a laquelle les conditions aux limites s'appliquent.
Classe Conduction Cette classe represente l'equation d'evolution.
Definition Conduction.h:41
class Domaine_VF
Definition Domaine_VF.h:44
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
: class Echange_contact_VDF_FT_Disc
virtual double Ti_wall(int num) const
int avancer(double temps) override
Tourne la roue de la CL.
void changer_temps_futur(double temps, int i) override
Change le i-eme temps futur de la CL.
int reculer(double temps) override
Tourne la roue de la CL.
void mettre_a_jour(double) override
Effectue une mise a jour en temps de la condition aux limites.
void set_temps_defaut(double temps) override
Change le i-eme temps futur de la cl.
void completer() override
NE FAIT RIEN A surcharger dans les classes derivees.
int initialiser(double temps) override
Initialisation en debut de calcul.
int reculer(double temps) override
Tourne la roue de la CL.
int initialiser(double temps) override
Initialisation en debut de calcul.
void completer() override
NE FAIT RIEN A surcharger dans les classes derivees.
void changer_temps_futur(double temps, int i) override
Change le i-eme temps futur de la CL.
void calculer_h_autre_pb(DoubleTab &tab, double invhparoi, int opt)
virtual void calculer_Teta_equiv(DoubleTab &Teta_equiv, const DoubleTab &mon_h, const DoubleTab &autre_h, int is_pb_fluide, double temps)
remplit Teta_eq utilise T_autre_pb au temps passe en parametre
int avancer(double temps) override
Tourne la roue de la CL.
virtual void calculer_Teta_paroi(DoubleTab &tab_p, const DoubleTab &mon_h, const DoubleTab &autre_h, int is_pb_fluide, double temps)
remplit Teta_p utilise T_autre_pb au temps passe en parametre
virtual Champ_front_base & T_autre_pb()
void calculer_h_mon_pb(DoubleTab &, double, int)
void set_temps_defaut(double temps) override
Change le i-eme temps futur de la cl.
void mettre_a_jour(double temps) override
Effectue une mise a jour en temps de la condition aux limites.
void fixer_nb_valeurs_temporelles(int nb_cases) override
Appele par Conds_lim::completer Appel cha_front_base::fixer_nb_valeurs_temporelles.
virtual Champ_front_base & T_ext()
Renvoie le champ T_ext de temperature imposee a la frontiere.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Schema_Temps_base & schema_temps()
Renvoie le schema en temps associe a l'equation.
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
virtual int nb_comp() const
Definition Field_base.h:56
int_t num_premiere_face() const
Definition Frontiere.h:67
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Frontiere.h:49
int_t nb_faces() const
Renvoie le nombre de faces de la frontiere.
Definition Frontiere.h:59
const Frontiere & frontiere() const
Renvoie la frontiere geometrique associee.
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
classe Milieu_base Cette classe est la base de la hierarchie des milieux (physiques)
Definition Milieu_base.h:50
virtual const Champ_Don_base & conductivite() const
Renvoie la conductivite du milieu.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const Nom & le_nom() const override
Renvoie *this;.
Definition Nom.cpp:563
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
@ REQUIRED
Definition Param.h:115
const Triple_Line_Model_FT_Disc & tcl() const
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
static double mp_max(double)
Definition Process.cpp:376
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
virtual int nb_valeurs_temporelles() const =0
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size_array() const
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
virtual void detach_vect()
Definition TRUSTVect.h:176
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")