TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Echange_contact_PolyMAC_HFV.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 <Echange_contact_PolyMAC_HFV.h>
17#include <Schema_Euler_Implicite.h>
18#include <Op_Diff_PolyMAC_HFV_Elem.h>
19#include <Op_Diff_PolyMAC_HFV_Elem.h>
20#include <Champ_Elem_PolyMAC_HFV.h>
21#include <Champ_front_calc.h>
22#include <Champ_Uniforme.h>
23#include <Equation_base.h>
24#include <Probleme_base.h>
25#include <Domaine_PolyMAC_HFV.h>
26#include <Milieu_base.h>
27#include <Operateur.h>
28#include <Front_VF.h>
29#include <cmath>
30
31Implemente_instanciable(Echange_contact_PolyMAC_HFV,"Paroi_Echange_contact_PolyMAC_HFV|Paroi_Echange_contact_PolyMAC_HFV_P1",Echange_externe_impose);
32using namespace MEDCoupling;
33
35{
36 return s << que_suis_je() << finl;
37}
38
40{
41 if (app_domains.size() == 0) app_domains = { Motcle("Thermique"), Motcle("Neutronique"), Motcle("fraction_massique"), Motcle("indetermine") };
42
43 //Nom nom_bord;
44 //Motcle nom_champ;
46 invh_paroi = invh_paroi > 1e8 ? 0 : 1. / invh_paroi;
47 le_champ_front.typer("Ch_front_var_instationnaire_dep");
49 return s;
50}
51
53{
54 if (o_diff) return;
57 fvf = ref_cast(Front_VF, frontiere_dis()), o_fvf = ref_cast(Front_VF, ch.front_dis()); //frontieres
58 const Equation_base& eqn = domaine_Cl_dis().equation(), &o_eqn = ch.equation(); //equations
59 i_fvf = eqn.domaine_dis().rang_frontiere(fvf->le_nom()), i_o_fvf = o_eqn.domaine_dis().rang_frontiere(nom_bord_);
60
61 int i_op = -1, o_i_op = -1, i; //indice de l'operateur de diffusion dans l'autre equation
62 for (i = 0; i < eqn.nombre_d_operateurs(); i++)
63 if (sub_type(Op_Diff_PolyMAC_HFV_Elem, eqn.operateur(i).l_op_base())) i_op = i;
64 if (i_op < 0) Process::exit(le_nom() + " : no diffusion operator found in " + eqn.probleme().le_nom() + " !");
65 for (i = 0; i < o_eqn.nombre_d_operateurs(); i++)
66 if (sub_type(Op_Diff_PolyMAC_HFV_Elem, o_eqn.operateur(i).l_op_base())) o_i_op = i;
67 if (o_i_op < 0) Process::exit(le_nom() + " : no diffusion operator found in " + o_eqn.probleme().le_nom() + " !");
68 diff = ref_cast(Op_Diff_PolyMAC_HFV_Elem, eqn.operateur(i_op).l_op_base());
69 o_diff = ref_cast(Op_Diff_PolyMAC_HFV_Elem, o_eqn.operateur(o_i_op).l_op_base());
70}
71
72/* identification des elements / faces de l'autre cote de la frontiere, avec offsets */
74{
75 if (f_dist_init_) return; //deja fait
76 const Domaine_PolyMAC_HFV& domaine = ref_cast(Domaine_PolyMAC_HFV, fvf->domaine_dis()), &o_domaine = ref_cast(Domaine_PolyMAC_HFV, o_fvf->domaine_dis());
77 const DoubleTab& xv = domaine.xv(), &o_xv = o_domaine.xv();
78
79 int i, f, o_f, nf_tot = fvf->nb_faces_tot(), o_nf_tot = o_fvf->nb_faces_tot(), d, D = dimension;
80 f_dist.resize(nf_tot);
81
82 DoubleTrav xvf(nf_tot, D), o_xvf(o_nf_tot, D); //positions locales/distantes -> pour calcul de correspondance
83 for (i = 0; i < nf_tot; i++)
84 for (d = 0; d < D; d++) xvf(i, d) = xv( fvf->num_face(i), d);
85 for (i = 0; i < o_nf_tot; i++)
86 for (d = 0; d < D; d++) o_xvf(i, d) = o_xv(o_fvf->num_face(i), d);
87
88#ifdef MEDCOUPLING_
89 MCAuto<DataArrayDouble> fdad(DataArrayDouble::New()), o_fdad(DataArrayDouble::New());
90 fdad->useExternalArrayWithRWAccess(xvf.addr(), nf_tot, D), o_fdad->useExternalArrayWithRWAccess(o_xvf.addr(), o_nf_tot, D);
91 //point de o_fdad le plus proche de chaque point de {f,s}dad
92 MCAuto<DataArrayIdType> f_idx(nf_tot && o_nf_tot ? o_fdad->findClosestTupleId(fdad) : nullptr);
93
94 for (i = 0; i < nf_tot; i++) //remplissage de f_dist : face distante si coincidence, -1 sinon
95 {
96 f = fvf->num_face(i), o_f = o_nf_tot ? o_fvf->num_face((int)(f_idx->getIJ(i, 0))) : -1;
97 double d2 = o_f >= 0 ? domaine.dot(&xv(f, 0), &xv(f, 0), &o_xv(o_f, 0), &o_xv(o_f, 0)) : 1e8;
98 if (d2 < 1e-12) f_dist(i) = o_f;
99 else f_dist(i) = -1;
100 if (i < fvf->nb_faces() && d2 >= 1e-12)
101 Process::exit(Nom("Echange_contact_PolyMAC_HFV: missing opposite faces detected between ") + fvf->le_nom() + " and " + o_fvf->le_nom()
102 + " ! Have you used Decouper_multi?");
103 }
104
105#else
106 Process::exit("Echange_contact_PolyMAC_HFV : MEDCoupling is required!");
107#endif
108 f_dist_init_ = 1;
109}
classe Champ_front_calc Classe derivee de Champ_front_var qui represente les
const Frontiere_dis_base & front_dis() const
Renvoie la frontiere discretisee correspondante au domaine sur lequel prend la trace.
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...
const Equation_base & equation() const
Renvoie l'equation associee a l'inconnue dont on prend la trace.
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.
int rang_frontiere(const Nom &)
classe : Echange_contact_PolyMAC_HFV Outre le champ_front representant la temperature de paroi,
Classe Echange_externe_impose: Cette classe represente le cas particulier de la classe.
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
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
virtual int nombre_d_operateurs() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
virtual const Operateur & operateur(int) const =0
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
class Front_VF
Definition Front_VF.h:36
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
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 const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
virtual Operateur_base & l_op_base()=0
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Probleme_U.h:109
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
_TYPE_ * addr()