TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Op_Dift_VDF_Elem_base.cpp
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#include <Op_Dift_VDF_Elem_base.h>
17
18Implemente_base(Op_Dift_VDF_Elem_base,"Op_Dift_VDF_Elem_base",Op_Dift_VDF_base);
19Sortie& Op_Dift_VDF_Elem_base::printOn(Sortie& s ) const { return s << que_suis_je() ; }
21
22/*
23 * Calcul du pas de temps de stabilite : Pour const/var Elem, const/var Multi-inco
24 * La diffusivite laminaire est constante ou variable, La diffusivite turbulente est variable
25 * dt_stab = Min (1/(2*(diff_lam(i)+diff_turb(i))*coeff(elem))
26 * ou
27 * dt_stab = Min (1/(2*(Max(diffu1(i),diffu2(i),....)+diff_turb(i))*coeff(elem))
28 * avec coeff = 1/(dx*dx) + 1/(dy*dy) + 1/(dz*dz) et i decrivant l'ensemble des elements du maillage
29 * diffu1(i),diffu2(i) ...: diffusivites des differents constituants sur l'element
30 */
32{
33 double dt_stab, coef = -1.e10;
34 const Domaine_VDF& domaine_VDF = iter_->domaine();
35 const IntTab& elem_faces = domaine_VDF.elem_faces();
36 const DoubleVect& alpha_t = diffusivite_turbulente().valeurs();
37 bool is_concentration = (equation().que_suis_je().debute_par("Convection_Diffusion_Concentration") || equation().que_suis_je().debute_par("Convection_Diffusion_Espece"));
38
39 ArrOfInt numfa(2*dimension);
40 for (int elem = 0; elem < domaine_VDF.nb_elem(); elem++)
41 {
42 // choix du facteur
43 double rcp = 1.;
44 if (!is_concentration)
45 {
46 const int Ccp = sub_type(Champ_Uniforme, mon_equation->milieu().capacite_calorifique());
47 const int Cr = sub_type(Champ_Uniforme, mon_equation->milieu().masse_volumique());
48 const DoubleTab& tab_Cp = mon_equation->milieu().capacite_calorifique().valeurs(), tab_r = mon_equation->milieu().masse_volumique().valeurs();
49 rcp = tab_r(Cr ? 0 : elem, 0) * tab_Cp(Ccp ? 0 : elem, 0);
50 }
51
52 double moy = 0.;
53 for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i);
54
55 // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart !
56 // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d));
57 for (int d = 0; d < dimension; d++)
58 {
59 const double hd = domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d);
60 moy += 1. / (hd * hd);
61 }
62 const double alpha_local = (alpha_(elem) + alpha_t(elem)) / rcp * moy;
63 coef = std::max(coef, alpha_local);
64 }
65
66 coef = Process::mp_max(coef);
67 dt_stab = 1. / (2. * (coef + DMINFLOAT));
68 return dt_stab;
69}
70
71/*
72 * Calcul du pas de temps de stabilite : Pour const/var Axi, const/var Multi-inco Axi
73 * La diffusivite laminaire est constante ou variable, La diffusivite turbulente est variable
74 * dt_stab = Min (1/(2*(diff_lam(i)+diff_turb(i))*coeff(elem))
75 * ou
76 * dt_stab = Min (1/(2*(Max(diffu1(i),diffu2(i),....)+diff_turb(i))*coeff(elem))
77 * avec coeff = 1/(dx*dx) + 1/(dy*dy) + 1/(dz*dz) et i decrivant l'ensemble des elements du maillage
78 * diffu1(i),diffu2(i) ...: diffusivites des differents constituants sur l'element
79 */
81{
82 double dt_stab, coef = -1.e10;
83 const Domaine_VDF& domaine_VDF = iter_->domaine();
84 const IntTab& elem_faces = domaine_VDF.elem_faces();
85 const DoubleVect& alpha_t = diffusivite_turbulente().valeurs();
86 double alpha_local,h_x,h_y,h_z;
87
88 if (dimension == 2)
89 {
90 int numfa[4];
91 for (int elem=0; elem<domaine_VDF.nb_elem(); elem++)
92 {
93 for (int i=0; i<4; i++) numfa[i] = elem_faces(elem,i);
94 h_x = domaine_VDF.dist_face_axi(numfa[0],numfa[2],0);
95 h_y = domaine_VDF.dist_face_axi(numfa[1],numfa[3],1);
96 alpha_local = (alpha_(elem)+alpha_t(elem)) *(1/(h_x*h_x) + 1/(h_y*h_y));
97 coef = std::max(coef,alpha_local);
98 }
99 }
100 else if (dimension == 3)
101 {
102 int numfa[6];
103 for (int elem=0; elem<domaine_VDF.nb_elem(); elem++)
104 {
105 for (int i=0; i<6; i++) numfa[i] = elem_faces(elem,i);
106 h_x = domaine_VDF.dist_face_axi(numfa[0],numfa[3],0);
107 h_y = domaine_VDF.dist_face_axi(numfa[1],numfa[4],1);
108 h_z = domaine_VDF.dist_face_axi(numfa[2],numfa[5],2);
109 alpha_local = (alpha_(elem)+alpha_t(elem)) *(1/(h_x*h_x) + 1/(h_y*h_y) + 1/(h_z*h_z));
110 coef = std::max(coef,alpha_local);
111 }
112 }
113
114 dt_stab = 1/(2*(coef+DMINFLOAT));
115 return dt_stab;
116}
117
119{
120 double dt_stab, coef = -1.e10;
121 const Domaine_VDF& domaine_VDF = iter_->domaine();
122 const IntTab& elem_faces = domaine_VDF.elem_faces();
123 const DoubleVect& alpha_t = diffusivite_turbulente().valeurs();
124 const int D = dimension;
125
126 IntVect numfa(2 * D);
127 DoubleVect h(D);
128
129 for (int e = 0; e < domaine_VDF.nb_elem(); e++)
130 {
131 for (int i = 0; i < 2 * D; i++)
132 numfa(i) = elem_faces(e, i);
133 for (int d = 0; d < D; d++)
134 h(d) = domaine_VDF.dist_face_axi(numfa(d), numfa(d + D), d);
135 double invh = 0.;
136 for (int d = 0; d < D; d++)
137 invh += 1. / (h(d) * h(d));
138 const double alpha_local = (alpha_(e) + alpha_t(e)) * invh;
139 coef = std::max(coef, alpha_local);
140 }
141
142 dt_stab = 1. / (2. * (coef + DMINFLOAT));
143 return dt_stab;
144}
145
146
147void Op_Dift_VDF_Elem_base::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
148{
149 const std::string& nom_inco = equation().inconnue().le_nom().getString();
150 if (!matrices.count(nom_inco) || semi_impl.count(nom_inco)) return; //semi-implicite ou pas de bloc diagonal -> rien a faire
151
152 Matrice_Morse *mat = matrices.count(nom_inco) ? matrices.at(nom_inco) : nullptr, mat2;
153 Op_VDF_Elem::dimensionner(iter_->domaine(), iter_->domaine_Cl(), mat2, equation().diffusion_multi_scalaire());
154 mat->nb_colonnes() ? *mat += mat2 : *mat = mat2;
155}
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
class Domaine_VDF
Definition Domaine_VDF.h:64
double dist_face(int, int, int k) const
double dist_face_axi(int, int, int k) const
int elem_faces(int i, int j) const
renvoie le numero de le ieme face de la maille num_elem la facon dont ces faces sont numerotees est
Definition Domaine_VF.h:543
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Champ_Inc_base & inconnue() const =0
const Nom & le_nom() const override
Renvoie le nom du champ.
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
virtual int debute_par(const char *const n) const
Definition Nom.cpp:319
const std::string & getString() const
Definition Nom.h:92
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 Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
const Champ_Fonc_base & diffusivite_turbulente() const
double calculer_dt_stab_elem_axi() const
double calculer_dt_stab_elem_var_axi() const
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl) const override
virtual double alpha_(const int) const =0
void dimensionner(const Domaine_VDF &, const Domaine_Cl_VDF &, Matrice_Morse &, const bool) const
static double mp_max(double)
Definition Process.cpp:376
Classe de base des flux de sortie.
Definition Sortie.h:52