TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Op_Diff_EF.h
1/****************************************************************************
2* Copyright (c) 2025, 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
17#ifndef Op_Diff_EF_included
18#define Op_Diff_EF_included
19
20#include <Op_Diff_EF_base.h>
21#include <Op_EF_base.h>
22#include <TRUST_Ref.h>
23
24
25class Domaine_Cl_EF;
26class Domaine_EF;
27class Matrice_Morse;
28
29/*! @brief class Op_Diff_EF Cette classe represente l'operateur de diffusion
30 *
31 * La discretisation est EF
32 * Le champ diffuse est scalaire
33 * Le champ de diffusivite est uniforme
34 *
35 */
37{
38 Declare_instanciable(Op_Diff_EF);
39public:
40 void associer_diffusivite(const Champ_base& ) override;
41 void associer_diffusivite_volumique(const Champ_base& ) override;
42 void completer() override;
43 const Champ_base& diffusivite() const override;
44 const Champ_base& diffusivite_volumique() const;
45
46 DoubleTab& ajouter(const DoubleTab& , DoubleTab& ) const override;
47 DoubleTab& ajouter_new(const DoubleTab& , DoubleTab& ) const;
48 DoubleTab& calculer(const DoubleTab& , DoubleTab& ) const override;
49 void verifier() const;
50 void remplir_nu(DoubleTab&) const override;
51 void remplir_lambda(DoubleTab&) const;
52 void calculer_von_mises(const DoubleTab& deplacement, DoubleTab& deformation, DoubleTab& contraintes, DoubleTab& von_mises) const override;
53
54 // Methodes pour l implicite.
55 inline void dimensionner(Matrice_Morse& matrice) const override { Op_EF_base::dimensionner(le_dom_EF.valeur(), la_zcl_EF.valeur(), matrice); }
56 inline void modifier_pour_Cl(Matrice_Morse& matrice, DoubleTab& secmem) const override { Op_EF_base::modifier_pour_Cl(le_dom_EF.valeur(),la_zcl_EF.valeur(), matrice, secmem); }
57 inline void contribuer_a_avec(const DoubleTab& inco, Matrice_Morse& matrice) const override { ajouter_contribution(inco, matrice); }
58
59 void contribuer_au_second_membre(DoubleTab& ) const override;
60 void ajouter_bords(const DoubleTab&, DoubleTab& ,int contrib_interne=1) const;
61 void ajouter_contribution(const DoubleTab&, Matrice_Morse& ) const;
62 void ajouter_contributions_bords(Matrice_Morse& matrice ) const;
63 void ajouter_contribution_new(const DoubleTab&, Matrice_Morse& ) const;
64 void ajouter_cas_scalaire(const DoubleTab& inconnue, DoubleTab& resu, DoubleTab& flux_bords, DoubleTab& nu, const Domaine_Cl_EF& domaine_Cl_EF, const Domaine_EF& domaine_EF) const;
65 void ajouter_cas_vectoriel(const DoubleTab& inconnue, DoubleTab& resu, DoubleTab& flux_bords, DoubleTab& nu, const Domaine_Cl_EF& domaine_Cl_EF, const Domaine_EF& domaine_EF, int nb_comp) const;
66
67protected :
68 int transpose_; // vaurt zero si on ne veut pas calculer grad u transpose
69 int transpose_partout_ ; // vaut 1 si on veut calculer grad_u_transpose meme au bord
71 OBS_PTR(Champ_base) diffusivite_;
72 OBS_PTR(Champ_base) diffusivite_volumique_;
73
74 DoubleTab& ajouter_scalaire_dim3_nbn_8(const DoubleTab&, DoubleTab&) const;
75 DoubleTab& ajouter_scalaire_dim2_nbn_4(const DoubleTab&, DoubleTab&) const;
76 DoubleTab& ajouter_scalaire_gen(const DoubleTab&, DoubleTab&) const;
77
78 template<AJOUTE_SCAL _T_>
79 DoubleTab& ajouter_scalaire_template(const DoubleTab&, DoubleTab&) const;
80
81 DoubleTab& ajouter_vectoriel_dim3_nbn_8(const DoubleTab&, DoubleTab&) const;
82 DoubleTab& ajouter_vectoriel_dim2_nbn_4(const DoubleTab&, DoubleTab&) const;
83 DoubleTab& ajouter_vectoriel_gen(const DoubleTab&, DoubleTab&) const;
84
85 template<AJOUTE_VECT _T_>
86 DoubleTab& ajouter_vectoriel_template(const DoubleTab&, DoubleTab&) const;
87
88 mutable DoubleTab lambda_;
89
90private:
91 void ajouter_contribution_diffusivite_volumique(int N, Matrice_Morse& matrice) const;
92 void ajouter_contribution_axisymetrique(int N, Matrice_Morse& matrice) const;
93};
94
96{
97 Declare_instanciable(Op_Diff_option_EF);
98};
99
100template<AJOUTE_SCAL _T_>
101DoubleTab& Op_Diff_EF::ajouter_scalaire_template(const DoubleTab& tab_inconnue, DoubleTab& resu) const
102{
103 static constexpr bool IS_GEN = (_T_ == AJOUTE_SCAL::GEN), IS_D3_8 = (_T_ == AJOUTE_SCAL::D3_8), IS_D2_4 = (_T_ == AJOUTE_SCAL::D2_4);
104
105 const Domaine_EF& domaine_ef = ref_cast(Domaine_EF, equation().domaine_dis());
106
107 const int N = IS_GEN ? resu.line_size() : 1;
108 const int nb_som_elem = IS_D3_8 ? 8 : ( IS_D2_4 ? 4 : domaine_ef.domaine().nb_som_elem() /* IS_GEN */);
109 const int const_dimension = IS_D3_8 ? 3 : ( IS_D2_4 ? 2 : Objet_U::dimension /* IS_GEN */);
110 const int dim_fois_nbn = nb_som_elem * const_dimension;
111
112 const DoubleVect& volumes_thilde = domaine_ef.volumes_thilde(), &volumes = domaine_ef.volumes();
113
114 const DoubleTab& bij = domaine_ef.Bij();
115 int nb_elem_tot = domaine_ef.domaine().nb_elem_tot();
116 const IntTab& elems = domaine_ef.domaine().les_elems();
117
118 const double *bij_ptr = bij.addr();
119 const double *inco_ptr = tab_inconnue.addr();
120
121#define bij_(elem,i,j) bij_ptr[elem*dim_fois_nbn+i*const_dimension+j]
122#define inconnue_(som,a) inco_ptr[som * N + a]
123#define resu_(som,a) resu_ptr[som * N + a]
124
125 ArrOfDouble pr(N);
126 for (int elem = 0; elem < nb_elem_tot; elem++)
127 if (elem_contribue(elem))
128 {
129 double pond = volumes_thilde(elem) / volumes(elem) / volumes(elem) * nu_(elem);
130
131 for (int i1 = 0; i1 < nb_som_elem; i1++)
132 {
133 int glob = elems(elem, i1);
134 for (int yy = 0; yy < N; yy++)
135 pr[yy] = 0;
136 for (int i2 = 0; i2 < nb_som_elem; i2++)
137 {
138 int glob2 = elems(elem, i2);
139
140 {
141 double prod = 0;
142 for (int b = 0; b < const_dimension; b++)
143 {
144 prod += bij_(elem,i1,b)*bij_(elem,i2,b);
145 }
146 for (int n = 0; n < N; n++) pr[n] += prod * inconnue_(glob2, n);
147 }
148 }
149 resu(glob) -= pr[0] * pond;
150 }
151 }
152
153 // on ajoute la contribution des bords
154 ajouter_bords(tab_inconnue, resu);
155 return resu;
156
157#undef bij_
158#undef inconnue_
159#undef resu_
160}
161
162template<AJOUTE_VECT _T_>
163DoubleTab& Op_Diff_EF::ajouter_vectoriel_template(const DoubleTab& tab_inconnue, DoubleTab& resu) const
164{
165 static constexpr bool IS_GEN = (_T_ == AJOUTE_VECT::GEN), IS_D3_8 = (_T_ == AJOUTE_VECT::D3_8), IS_D2_4 = (_T_ == AJOUTE_VECT::D2_4);
166
167 const Domaine_EF& domaine_ef = ref_cast(Domaine_EF, equation().domaine_dis());
168
169 const int N = IS_D3_8 ? 3 : (IS_D2_4 ? 2 : resu.line_size() /* IS_GEN */);
170 const int const_dimension = IS_GEN ? Objet_U::dimension : N;
171 const int nb_som_elem = IS_D3_8 ? 8 : (IS_D2_4 ? 4 : domaine_ef.domaine().nb_som_elem() /* IS_GEN */);
172 const int dim_fois_nbn = nb_som_elem * const_dimension;
173
174 ArrOfInt marqueur_neuman;
175 remplir_marqueur_sommet_neumann(marqueur_neuman, domaine_ef, la_zcl_EF.valeur(), transpose_partout_);
176
177 const DoubleVect& volumes_thilde = domaine_ef.volumes_thilde(), &volumes = domaine_ef.volumes();
178
179 const DoubleTab& bij = domaine_ef.Bij();
180 int nb_elem_tot = domaine_ef.domaine().nb_elem_tot();
181 const IntTab& elems = domaine_ef.domaine().les_elems();
182
183 const double *bij_ptr = bij.addr();
184 const double *inco_ptr = tab_inconnue.addr();
185 double *resu_ptr = resu.addr();
186
187#define bij_(elem,i,j) bij_ptr[elem*dim_fois_nbn+i*const_dimension+j]
188#define inconnue_(som,a) inco_ptr[som * N + a]
189#define resu_(som,a) resu_ptr[som * N + a]
190
191 ArrOfDouble pr(N);
192
193 for (int elem = 0; elem < nb_elem_tot; elem++)
194 if (elem_contribue(elem))
195 {
196 double pond = volumes_thilde(elem) / volumes(elem) / volumes(elem) * nu_(elem);
197
198 for (int i1 = 0; i1 < nb_som_elem; i1++)
199 {
200 int glob = elems(elem, i1);
201 for (int yy = 0; yy < N; yy++)
202 pr[yy] = 0;
203 int transpose = (marqueur_neuman[glob] == 1 || N == 1) ? 0 : transpose_;
204 for (int i2 = 0; i2 < nb_som_elem; i2++)
205 {
206 int glob2 = elems(elem, i2);
207
208 {
209 double prod = 0;
210 double prod2 = 0;
211 for (int b = 0; b < const_dimension; b++)
212 {
213 prod += bij_(elem,i1,b)*bij_(elem,i2,b);
214 if (transpose)
215 prod2+=bij_(elem,i1,b)*inconnue_(glob2,b);
216 }
217 for (int n = 0; n < N; n++) pr[n] += prod * inconnue_(glob2, n) + prod2 * bij_(elem, i2, n);
218 }
219 }
220 for (int n = 0; n < N; n++) resu_(glob, n)-= pr[n] * pond;
221 }
222 }
223
224 // on ajoute la contribution des bords
225 ajouter_bords(tab_inconnue, resu);
226 return resu;
227
228#undef bij_
229#undef inconnue_
230#undef resu_
231}
232
233#endif
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
int_t nb_elem_tot() const
Definition Domaine.h:132
IntTab_t & les_elems()
Definition Domaine.h:129
class Domaine_EF
Definition Domaine_EF.h:59
const DoubleTab & Bij() const
Definition Domaine_EF.h:92
const DoubleVect & volumes_thilde() const
Definition Domaine_EF.h:85
double volumes(int i) const
Definition Domaine_VF.h:113
const Domaine & domaine() const
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
static int dimension
Definition Objet_U.h:99
class Op_Diff_EF_base Classe de base des operateurs de diffusion EF
class Op_Diff_EF Cette classe represente l'operateur de diffusion
Definition Op_Diff_EF.h:37
DoubleTab lambda_
Definition Op_Diff_EF.h:88
void ajouter_contribution_new(const DoubleTab &, Matrice_Morse &) const
void contribuer_a_avec(const DoubleTab &inco, Matrice_Morse &matrice) const override
DOES NOTHING - to override in derived classes.
Definition Op_Diff_EF.h:57
void verifier() const
void modifier_pour_Cl(Matrice_Morse &matrice, DoubleTab &secmem) const override
DOES NOTHING - to override in derived classes.
Definition Op_Diff_EF.h:56
OBS_PTR(Champ_base) diffusivite_volumique_
DoubleTab & ajouter_vectoriel_dim3_nbn_8(const DoubleTab &, DoubleTab &) const
OBS_PTR(Champ_base) diffusivite_
DoubleTab & ajouter_scalaire_template(const DoubleTab &, DoubleTab &) const
Definition Op_Diff_EF.h:101
DoubleTab & ajouter_vectoriel_gen(const DoubleTab &, DoubleTab &) const
DoubleTab & ajouter_vectoriel_dim2_nbn_4(const DoubleTab &, DoubleTab &) const
const Champ_base & diffusivite() const override
void remplir_lambda(DoubleTab &) const
DoubleTab & ajouter_new(const DoubleTab &, DoubleTab &) const
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
int nouvelle_expression_
Definition Op_Diff_EF.h:70
DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const override
void contribuer_au_second_membre(DoubleTab &) const override
DOES NOTHING - to override in derived classes.
int transpose_
Definition Op_Diff_EF.h:68
DoubleTab & ajouter_scalaire_gen(const DoubleTab &, DoubleTab &) const
void remplir_nu(DoubleTab &) const override
void ajouter_cas_vectoriel(const DoubleTab &inconnue, DoubleTab &resu, DoubleTab &flux_bords, DoubleTab &nu, const Domaine_Cl_EF &domaine_Cl_EF, const Domaine_EF &domaine_EF, int nb_comp) const
void dimensionner(Matrice_Morse &matrice) const override
DOES NOTHING - to override in derived classes.
Definition Op_Diff_EF.h:55
void completer() override
Associe l'operateur au domaine_dis, le domaine_Cl_dis, et a l'inconnue de son equation.
int transpose_partout_
Definition Op_Diff_EF.h:69
void ajouter_contribution(const DoubleTab &, Matrice_Morse &) const
void ajouter_cas_scalaire(const DoubleTab &inconnue, DoubleTab &resu, DoubleTab &flux_bords, DoubleTab &nu, const Domaine_Cl_EF &domaine_Cl_EF, const Domaine_EF &domaine_EF) const
void ajouter_bords(const DoubleTab &, DoubleTab &, int contrib_interne=1) const
DoubleTab & ajouter_scalaire_dim3_nbn_8(const DoubleTab &, DoubleTab &) const
void associer_diffusivite_volumique(const Champ_base &) override
void associer_diffusivite(const Champ_base &) override
associe le champ de diffusivite
const Champ_base & diffusivite_volumique() const
DoubleTab & ajouter_vectoriel_template(const DoubleTab &, DoubleTab &) const
Definition Op_Diff_EF.h:163
DoubleTab & ajouter_scalaire_dim2_nbn_4(const DoubleTab &, DoubleTab &) const
void calculer_von_mises(const DoubleTab &deplacement, DoubleTab &deformation, DoubleTab &contraintes, DoubleTab &von_mises) const override
void ajouter_contributions_bords(Matrice_Morse &matrice) const
void dimensionner(const Domaine_EF &, const Domaine_Cl_EF &, Matrice_Morse &) const
Dimensionnement de la matrice qui devra recevoir les coefficients provenant de la convection,...
int elem_contribue(const int elem) const
void modifier_pour_Cl(const Domaine_EF &, const Domaine_Cl_EF &, Matrice_Morse &, DoubleTab &) const
Modification des coef de la matrice et du second membre pour les conditions de Dirichlet.
DoubleTab & flux_bords()
_TYPE_ * addr()
int line_size() const
Definition TRUSTVect.tpp:67