TrioCFD 1.9.9_beta
TrioCFD documentation
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; //index of the diffusion operator in the other 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 of elements / faces on the other side of the boundary, with offsets */
64{
65 if (fs_dist_init_)
66 return; //already done
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; //vertices on each side
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()); //as vectors
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); //local/distant positions -> for correspondence computation
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 //closest point in o_{f,s}dad for each point of {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++) //fill f_dist: distant face if coincident, -1 otherwise
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++) //fill 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}
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.
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
class : Echange_contact_PolyMAC_MPFA
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.
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()
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133