TrioCFD 1.9.9_beta
TrioCFD documentation
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; //index of the diffusion operator in the other 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 of elements / faces on the other side of the boundary, with offsets */
74{
75 if (f_dist_init_) return; //already done
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); //local/remote positions -> for computing correspondence
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 //closest point in o_fdad for each point of {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++) //fill f_dist: distant face if coincident, -1 otherwise
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}
class Champ_front_calc Derived class of Champ_front_var representing
const Frontiere_dis_base & front_dis() const
Returns the discretized boundary corresponding to the domain on which the trace is taken.
void creer(const Nom &, const Nom &, const Motcle &)
Create the Champ_front_calc object representing the trace of an unknown field on a boundary from name...
const Equation_base & equation() const
Returns the equation associated with the unknown whose trace is taken.
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
int rang_frontiere(const Nom &)
class : Echange_contact_PolyMAC_HFV
Classe Echange_externe_impose: This class represents the special case of the class.
virtual Champ_front_base & T_ext()
Returns the T_ext field of temperature imposed at the boundary.
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 int nombre_d_operateurs() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual const Operateur & operateur(int) const =0
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
class Front_VF
Definition Front_VF.h:36
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const Nom & le_nom() const override
Returns *this.
Definition Nom.cpp:555
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
virtual Operateur_base & l_op_base()=0
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_TYPE_ * addr()