TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Echange_contact_PolyMAC_MPFA.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_MPFA.h>
17#include <Op_Diff_PolyMAC_MPFA_Elem.h>
18#include <Schema_Euler_Implicite.h>
19#include <Champ_Elem_PolyMAC_MPFA.h>
20#include <Domaine_PolyMAC_MPFA.h>
21#include <Champ_front_calc.h>
22#include <Champ_Uniforme.h>
23#include <Probleme_base.h>
24#include <Equation_base.h>
25#include <Milieu_base.h>
26#include <Operateur.h>
27#include <Front_VF.h>
28
29Implemente_instanciable(Echange_contact_PolyMAC_MPFA, "Paroi_Echange_contact_PolyMAC_MPFA", Echange_contact_PolyMAC_HFV);
30using namespace MEDCoupling;
31
32Sortie& Echange_contact_PolyMAC_MPFA::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
33
35
37{
38 if (o_diff)
39 return;
42 fvf = ref_cast(Front_VF, frontiere_dis()), o_fvf = ref_cast(Front_VF, ch.front_dis()); //frontieres
43 const Equation_base& eqn = domaine_Cl_dis().equation(), &o_eqn = ch.equation(); //equations
44 i_fvf = eqn.domaine_dis().rang_frontiere(fvf->le_nom()), i_o_fvf = o_eqn.domaine_dis().rang_frontiere(nom_bord_);
45
46 int i_op = -1, o_i_op = -1, i; //indice de l'operateur de diffusion dans l'autre equation
47 for (i = 0; i < eqn.nombre_d_operateurs(); i++)
48 if (sub_type(Op_Diff_PolyMAC_MPFA_Elem, eqn.operateur(i).l_op_base()))
49 i_op = i;
50 if (i_op < 0)
51 Process::exit(le_nom() + " : no diffusion operator found in " + eqn.probleme().le_nom() + " !");
52 for (i = 0; i < o_eqn.nombre_d_operateurs(); i++)
53 if (sub_type(Op_Diff_PolyMAC_MPFA_Elem, o_eqn.operateur(i).l_op_base()))
54 o_i_op = i;
55 if (o_i_op < 0)
56 Process::exit(le_nom() + " : no diffusion operator found in " + o_eqn.probleme().le_nom() + " !");
57 diff = ref_cast(Op_Diff_PolyMAC_MPFA_Elem, eqn.operateur(i_op).l_op_base());
58 o_diff = ref_cast(Op_Diff_PolyMAC_MPFA_Elem, o_eqn.operateur(o_i_op).l_op_base());
59
60}
61
62/* identification des elements / faces de l'autre cote de la frontiere, avec offsets */
64{
65 if (fs_dist_init_)
66 return; //deja fait
67 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, fvf->domaine_dis()), &o_domaine = ref_cast(Domaine_PolyMAC_MPFA, o_fvf->domaine_dis());
68 const DoubleTab& xv = domaine.xv(), &o_xv = o_domaine.xv(), &xs = domaine.domaine().coord_sommets(), &o_xs = o_domaine.domaine().coord_sommets();
69 const IntTab& f_s = domaine.face_sommets(), &o_f_s = o_domaine.face_sommets();
70
71 int i, j, f, o_f, s, o_s, nf_tot = fvf->nb_faces_tot(), o_nf_tot = o_fvf->nb_faces_tot(), d, D = dimension;
72 f_dist.resize(nf_tot);
73
74 std::set<int> s_som, s_o_som; //sommets de chaque cote
75 for (i = 0; i < nf_tot; i++)
76 for (f = fvf->num_face(i), j = 0; j < f_s.dimension(1) && (s = f_s(f, j)) >= 0; j++)
77 s_som.insert(s);
78 for (i = 0; i < o_nf_tot; i++)
79 for (f = o_fvf->num_face(i), j = 0; j < o_f_s.dimension(1) && (s = o_f_s(f, j)) >= 0; j++)
80 s_o_som.insert(s);
81 std::vector<int> som(s_som.begin(), s_som.end()), o_som(s_o_som.begin(), s_o_som.end()); //en vecteur
82 int ns_tot = (int) som.size(), o_ns_tot = (int) o_som.size();
83
84 DoubleTrav xvf(nf_tot, D), o_xvf(o_nf_tot, D), xsf(ns_tot, D), o_xsf(o_ns_tot, D); //positions locales/distantes -> pour calcul de correspondance
85 for (i = 0; i < nf_tot; i++)
86 for (d = 0; d < D; d++)
87 xvf(i, d) = xv(fvf->num_face(i), d);
88 for (i = 0; i < o_nf_tot; i++)
89 for (d = 0; d < D; d++)
90 o_xvf(i, d) = o_xv(o_fvf->num_face(i), d);
91 for (i = 0; i < ns_tot; i++)
92 for (d = 0; d < D; d++)
93 xsf(i, d) = xs(som[i], d);
94 for (i = 0; i < o_ns_tot; i++)
95 for (d = 0; d < D; d++)
96 o_xsf(i, d) = o_xs(o_som[i], d);
97
98#ifdef MEDCOUPLING_
99 MCAuto<DataArrayDouble> fdad(DataArrayDouble::New()), o_fdad(DataArrayDouble::New()), sdad(DataArrayDouble::New()), o_sdad(DataArrayDouble::New());
100 fdad->useExternalArrayWithRWAccess(xvf.addr(), nf_tot, D), o_fdad->useExternalArrayWithRWAccess(o_xvf.addr(), o_nf_tot, D);
101 sdad->useExternalArrayWithRWAccess(xsf.addr(), ns_tot, D), o_sdad->useExternalArrayWithRWAccess(o_xsf.addr(), o_ns_tot, D);
102 //point de o_{f,s}dad le plus proche de chaque point de {f,s}dad
103 MCAuto<DataArrayIdType> f_idx(nf_tot && o_nf_tot ? o_fdad->findClosestTupleId(fdad) : nullptr), s_idx(ns_tot && o_ns_tot ? o_sdad->findClosestTupleId(sdad) : nullptr);
104
105 for (i = 0; i < nf_tot; i++) //remplissage de f_dist : face distante si coincidence, -1 sinon
106 {
107 f = fvf->num_face(i), o_f = o_nf_tot ? o_fvf->num_face((int)(f_idx->getIJ(i, 0))) : -1;
108 double d2 = o_f >= 0 ? domaine.dot(&xv(f, 0), &xv(f, 0), &o_xv(o_f, 0), &o_xv(o_f, 0)) : 1e8;
109 if (d2 < 1e-12)
110 f_dist(i) = o_f;
111 else
112 f_dist(i) = -1;
113 if (i < fvf->nb_faces() && d2 >= 1e-12)
114 Process::exit(Nom("Echange_contact_PolyMAC_MPFA: missing opposite faces detected between ") + fvf->le_nom() + " and " + o_fvf->le_nom() + " ! Have you used Decouper_multi?");
115 }
116 for (i = 0; i < ns_tot; i++) //remplissage de s_dist
117 {
118 s = som[i], o_s = o_ns_tot ? o_som[s_idx->getIJ(i, 0)] : -1;
119 if (o_s >= 0 && domaine.dot(&xs(s, 0), &xs(s, 0), &o_xs(o_s, 0), &o_xs(o_s, 0)) < 1e-12)
120 s_dist[s] = o_s;
121 }
122
123#else
124 Process::exit("Echange_contact_PolyMAC_MPFA : MEDCoupling is required!");
125#endif
126 fs_dist_init_ = 1;
127}
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.
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_contact_PolyMAC_MPFA Outre le champ_front representant la temperature de paroi,
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.
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()
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133