TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_WC_Chaleur_VDF.cpp
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#include <Convection_Diffusion_Chaleur_WC.h>
17#include <Source_WC_Chaleur_VDF.h>
18#include <Neumann_sortie_libre.h>
19#include <Domaine_Cl_dis_base.h>
20#include <Navier_Stokes_WC.h>
21#include <Probleme_base.h>
22#include <Domaine_VF.h>
23
24Implemente_instanciable(Source_WC_Chaleur_VDF,"Source_WC_Chaleur_VDF",Source_WC_Chaleur);
25
27{
28 os <<que_suis_je()<< finl;
29 return os;
30}
31
33
39
40void Source_WC_Chaleur_VDF::compute_interpolate_gradP(DoubleTab& UgradP_elem, const DoubleTab& Ptot) const
41{
42 /*
43 * NOTA BENE :
44 * On a discretise P_EOS avec une directive = temperature qui donne en VDF :
45 * Ptot => aux elems
46 * la_vitesse => faces car vdf
47 * grad_Ptot => faces car vdf
48 *
49 * Donc u*grad(P_tot) => faces
50 * L'equation est une equation de scalaire => aux elems car vdf
51 * On a d P_tot / d t = del P / del t + u.grad(P_tot)
52 *
53 * del P / del t => aux elem
54 * u.grad(P_tot) !!! faut l'interpoler aux elems
55 */
56
57 const Navier_Stokes_WC& eqHyd = ref_cast(Navier_Stokes_WC,mon_equation->probleme().equation(0));
58 const DoubleTab& la_vitesse = eqHyd.vitesse().valeurs();
59 DoubleTab grad_Ptot(eqHyd.grad_P().valeurs()); // initialized with grad(P) because face-based
60 const Convection_Diffusion_Chaleur_WC& eq_chal = ref_cast(Convection_Diffusion_Chaleur_WC,mon_equation.valeur());
61 const Operateur_Grad& Op_Grad = eq_chal.operateur_gradient_WC();
62 Op_Grad.calculer(Ptot,grad_Ptot); // compute grad(P_tot)
63
64 const Domaine_dis_base& domaine_dis = mon_equation->inconnue().domaine_dis_base();
65 const Domaine_VF& domaine = ref_cast(Domaine_VF, domaine_dis);
66 assert (domaine_dis.que_suis_je() == "Domaine_VDF");
67
68 // grad should be zero at boundary
69 correct_grad_boundary(domaine,grad_Ptot);
70
71 // We compute u*grad(P_tot) on each face
72 DoubleTab UgradP(grad_Ptot); // field on faces
73 const int n = la_vitesse.dimension_tot(0);
74 assert ( n == domaine.nb_faces_tot() && la_vitesse.line_size() == 1);
75 assert ( Ptot.dimension_tot(0) == domaine.nb_elem_tot() );
76
77 for (int i=0 ; i <n ; i++) UgradP(i,0) = la_vitesse(i,0) * grad_Ptot(i,0);
78 face_to_elem(domaine,UgradP,UgradP_elem);
79}
80
81// Could use the static methods of Discretisation_tools... but a Champ_base needs to be created ...
82void Source_WC_Chaleur_VDF::face_to_elem(const Domaine_VF& domaine, const DoubleTab& UgradP,DoubleTab& UgradP_elem) const
83{
84 const IntTab& elem_faces = domaine.elem_faces();
85 const int nb_face_elem = elem_faces.line_size(), nb_elem_tot= domaine.nb_elem_tot();
86 assert (UgradP_elem.dimension_tot(0) == nb_elem_tot && UgradP.dimension_tot(0) == domaine.nb_faces_tot());
87
88 UgradP_elem = 0.;
89 for (int ele=0; ele<nb_elem_tot; ele++)
90 for (int s=0; s<nb_face_elem; s++) UgradP_elem(ele,0) += UgradP(elem_faces(ele,s),0);
91
92 UgradP_elem *= 0.5;
93}
94
95// works well but not suitable for vef ... P in vef is everywhere, grad on faces but not suitable for us
96void Source_WC_Chaleur_VDF::compute_interpolate_gradP_old(DoubleTab& UgradP_elem, const DoubleTab& Ptot) const
97{
98 // compute the grad
99 const Navier_Stokes_WC& eqHyd = ref_cast(Navier_Stokes_WC,mon_equation->probleme().equation(0));
100 const DoubleTab& la_vitesse = eqHyd.vitesse().valeurs();
101 DoubleTab grad_Ptot(eqHyd.grad_P().valeurs()); // initialized with grad(P) because face-based
102 const Operateur_Grad& gradient = eqHyd.operateur_gradient(); // retrieve the NS gradient operator
103 gradient.calculer(Ptot,grad_Ptot); // compute grad(P_tot)
104
105 // XXX : very important : otherwise we have values * V !
106 eqHyd.solv_masse().appliquer(grad_Ptot);
107
108 /*
109 * XXX XXX XXX
110 * READ CAREFULLY : We use the grad operator from Navier_Stokes_std
111 * => created for the pressure normally
112 * There is a special treatement for Neumann bc (Neumann_sortie_libre)
113 * because we use explicitly the prescribed pressure.
114 * So if we calculate the grad of Ptot or rho for example, we will use
115 * P_ext defined in data file which is wrong !
116 *
117 * Now we do the following : we assume open bd as a wall => null gradient
118 */
119
120 // We use that of NS because we test the CL too (attention mon_equation is Chaleur...)
121 const Domaine_dis_base& domaine_dis = eqHyd.inconnue().domaine_dis_base();
122 const Domaine_VF& domaine = ref_cast(Domaine_VF, domaine_dis);
123 const Domaine_Cl_dis_base& domaine_cl = eqHyd.domaine_Cl_dis();
124 assert (domaine_dis.que_suis_je() == "Domaine_VDF");
125
126 for (int n_bord=0; n_bord<domaine.nb_front_Cl(); n_bord++)
127 {
128 const Cond_lim& la_cl = domaine_cl.les_conditions_limites(n_bord);
129 // corrige si Neumann_sortie_libre
130 if ( sub_type(Neumann_sortie_libre,la_cl.valeur()) )
131 {
132 // retrieve face and replace gradient by 0
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
136 for (int num_face=ndeb; num_face<nfin; num_face++) grad_Ptot(num_face,0) = 0.;
137 }
138 }
139
140 // We compute u*grad(P_tot) on each face
141 DoubleTab UgradP(grad_Ptot); // field on faces
142 const int n = la_vitesse.dimension(0);
143 assert ( n == domaine.nb_faces() );
144 assert ( Ptot.dimension(0) == domaine.nb_elem() );
145 for (int i=0 ; i <n ; i++) UgradP(i,0) = la_vitesse(i,0) * grad_Ptot(i,0);
146 face_to_elem(domaine,UgradP,UgradP_elem);
147}
const Domaine_dis_base & domaine_dis_base() const override
DoubleTab & valeurs() override
Returns the array of field values at the current time.
Particular case of Convection_Diffusion_Chaleur_Fluide_Dilatable_base for a weakly compressible fluid...
const Operateur_Grad & operateur_gradient_WC() const
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VF
Definition Domaine_VF.h:44
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Solveur_Masse_base & solv_masse()
Returns the mass solver associated with the equation.
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
Carries the terms of the momentum equation for a weakly compressible fluid without turbulence modelli...
const Champ_Inc_base & inconnue() const override
Returns the velocity (unknown field of the equation) (const version).
virtual const Champ_Inc_base & vitesse() const
Operateur_Grad & operateur_gradient()
Returns the gradient operator associated with the equation.
Champ_Inc_base & grad_P()
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 Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Classe Operateur_Grad Generic class of the hierarchy of operators computing the gradient.
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
Initializes the array passed as parameter with the contribution of the operator.
virtual const Equation_base & equation(int) const =0
virtual DoubleTab & appliquer(DoubleTab &) const
Returns appliquer_impl(x/temporal_coefficient) if a temporal coefficient is set, otherwise returns ap...
Base class for output streams.
Definition Sortie.h:52
void associer_volume_porosite_impl(const Domaine_dis_base &domaine, DoubleVect &volumes, DoubleVect &porosites)
void associer_domaines_impl(const Domaine_dis_base &domaine, const Domaine_Cl_dis_base &domaine_cl)
class Source_WC_Chaleur_VDF
void compute_interpolate_gradP(DoubleTab &gradP, const DoubleTab &Ptot) const override
void associer_domaines(const Domaine_dis_base &domaine, const Domaine_Cl_dis_base &zcl) override
class Source_WC_Chaleur
const DoubleTab & correct_grad_boundary(const Domaine_VF &domaine, DoubleTab &grad_Ptot) const
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67