TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Iterateur_Source_Face.h
1/****************************************************************************
2* Copyright (c) 2024, 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#ifndef Iterateur_Source_Face_included
17#define Iterateur_Source_Face_included
18
19#include <Iterateur_Source_base.h>
20#include <Dirichlet_homogene.h>
21#include <Champ_Uniforme.h>
22#include <TRUSTSingle.h>
23#include <Milieu_base.h>
24#include <Dirichlet.h>
25#include <Domaine_VF.h>
26
27template <class _TYPE_>
29{
30 inline unsigned taille_memoire() const override { throw; }
31
32 inline int duplique() const override
33 {
35 if(!xxx) Process::exit("Not enough memory !");
36 return xxx->numero();
37 }
38
39public:
43
44 DoubleTab& ajouter(DoubleTab& ) const override;
45
46 void completer_() override
47 {
48 nb_faces = ref_cast(Domaine_VF,le_dom.valeur()).nb_faces();
49 premiere_face_interne = ref_cast(Domaine_VF,le_dom.valeur()).premiere_face_int();
50 }
51
52 inline Evaluateur_Source& evaluateur() override
53 {
55 return eval;
56 }
57
58protected:
61 mutable DoubleTab coef;
62
63 template <typename Type_Double> DoubleTab& ajouter_faces_internes(const int, DoubleTab& ) const;
64 template <typename Type_Double> DoubleTab& ajouter_faces_bords(const int, DoubleTab& ) const;
65 inline const int& faces_doubles(int num_face) const { return ref_cast(Domaine_VF,le_dom.valeur()).faces_doubles()[num_face]; }
66};
67
68template<class _TYPE_>
69DoubleTab& Iterateur_Source_Face<_TYPE_>::ajouter(DoubleTab& resu) const
70{
71 ((_TYPE_&) (evaluateur_source_face)).mettre_a_jour();
72
73 assert(resu.nb_dim() < 3);
74 const int ncomp = resu.line_size();
75
76 DoubleVect& bilan = so_base->bilan();
77 bilan = 0;
78 const int nb_faces_tot = ref_cast(Domaine_VF,le_dom.valeur()).nb_faces_tot();
79 coef.resize(nb_faces_tot, RESIZE_OPTIONS::NOCOPY_NOINIT);
80 coef = 1;
82 {
83 const Milieu_base& milieu = la_zcl->equation().milieu();
84 const Champ_base& rho = milieu.masse_volumique();
85 if (sub_type(Champ_Uniforme, rho))
86 coef = rho.valeurs()(0, 0);
87 else
88 {
89 const DoubleTab& val_rho = rho.valeurs();
90 const IntTab& face_vois = le_dom->face_voisins();
91 const DoubleVect& volumes = ref_cast(Domaine_VF,le_dom.valeur()).volumes();
92 coef = 0.;
93 for (int fac = 0; fac < nb_faces_tot; fac++)
94 {
95 const int elem1 = face_vois(fac, 0), elem2 = face_vois(fac, 1);
96 double vol = 0.;
97 if (elem1 != -1)
98 {
99 coef(fac) += val_rho(elem1) * volumes(elem1);
100 vol += volumes(elem1);
101 }
102 if (elem2 != -1)
103 {
104 coef(fac) += val_rho(elem2) * volumes(elem2);
105 vol += volumes(elem2);
106 }
107 coef(fac) /= vol;
108 }
109 }
110 }
111
112 if (ncomp == 1)
113 {
116 }
117 else
118 {
121 }
122 return resu;
123}
124
125template<class _TYPE_> template<typename Type_Double>
126DoubleTab& Iterateur_Source_Face<_TYPE_>::ajouter_faces_bords(const int ncomp, DoubleTab& resu) const
127{
128 Type_Double source(ncomp);
129 DoubleVect& bilan = so_base->bilan();
130 for (int num_cl = 0; num_cl < le_dom->nb_front_Cl(); num_cl++)
131 {
132 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
133 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
134 const int ndeb = le_bord.num_premiere_face(), nfin = ndeb + le_bord.nb_faces();
135 if ((sub_type(Dirichlet, la_cl.valeur())) || (sub_type(Dirichlet_homogene, la_cl.valeur()))) { /* Do nothing */ }
136 else
137 for (int num_face = ndeb; num_face < nfin; num_face++)
138 {
139 evaluateur_source_face.calculer_terme_source_bord(num_face, source);
140 for (int k = 0; k < ncomp; k++)
141 {
142 resu(num_face, k) += source[k];
143 double contribution = (faces_doubles(num_face) == 1) ? 0.5 : 1;
144 bilan(k) += contribution * coef(num_face) * source[k];
145 }
146 }
147 }
148 return resu;
149}
150
151template<class _TYPE_> template<typename Type_Double>
152DoubleTab& Iterateur_Source_Face<_TYPE_>::ajouter_faces_internes(const int ncomp, DoubleTab& resu) const
153{
154 Type_Double source(ncomp);
155 DoubleVect& bilan = so_base->bilan();
156 for (int num_face = premiere_face_interne; num_face < nb_faces; num_face++)
157 {
158 evaluateur_source_face.calculer_terme_source(num_face, source);
159 for (int k = 0; k < ncomp; k++)
160 {
161 resu(num_face, k) += source[k];
162 double contribution = (faces_doubles(num_face) == 1) ? 0.5 : 1;
163 bilan(k) += contribution * coef(num_face) * source[k];
164 }
165 }
166 return resu;
167}
168
169#endif /* Iterateur_Source_Face_included */
virtual DoubleTab & valeurs()=0
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
Classe Dirichlet_homogene Cette classe est la classe de base de la hierarchie des conditions aux limi...
classe Dirichlet Cette classe est la classe de base de la hierarchie des conditions aux limites de ty...
Definition Dirichlet.h:31
class Domaine_VF
Definition Domaine_VF.h:44
virtual const Milieu_base & milieu() const =0
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
DoubleTab & ajouter_faces_internes(const int, DoubleTab &) const
Evaluateur_Source & evaluateur() override
const int & faces_doubles(int num_face) const
DoubleTab & ajouter(DoubleTab &) const override
Iterateur_Source_Face(const Iterateur_Source_Face< _TYPE_ > &iter)
DoubleTab & ajouter_faces_bords(const int, DoubleTab &) const
classe Milieu_base Cette classe est la base de la hierarchie des milieux (physiques)
Definition Milieu_base.h:50
virtual const Equation_base & equation(const std::string &nom_inc) const
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
virtual int duplique() const =0
virtual unsigned taille_memoire() const =0
int numero() const
Renvoie l'indice de l'objet dans Memoire::data.
Definition Objet_U.cpp:268
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
int nb_dim() const
Definition TRUSTTab.h:199
int line_size() const
Definition TRUSTVect.tpp:67