TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_WC_Chaleur_VEF.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_VEF.h>
18#include <Neumann_sortie_libre.h>
19#include <Navier_Stokes_WC.h>
20#include <Probleme_base.h>
21#include <Milieu_base.h>
22#include <Domaine_VF.h>
23
24Implemente_instanciable(Source_WC_Chaleur_VEF,"Source_WC_Chaleur_VEF",Source_WC_Chaleur);
25
27{
28 os <<que_suis_je()<< finl;
29 return os;
30}
31
33
39
40void Source_WC_Chaleur_VEF::compute_interpolate_gradP(DoubleTab& UgradP_face, const DoubleTab& Ptot) const
41{
42 /*
43 * NOTE:
44 * P_EOS is discretized with a 'temperature' directive, giving in VEF:
45 * Ptot => on faces
46 * la_vitesse => on faces (VEF)
47 * grad_Ptot => on elements
48 *
49 * The equation is a scalar equation => on faces (VEF)
50 * d P_tot / d t = del P / del t + u.grad(P_tot)
51 *
52 * del P / del t => on faces
53 * u.grad(P_tot) !!! grad(P_tot) must be interpolated to faces
54 */
55
56 const Navier_Stokes_WC& eqHyd = ref_cast(Navier_Stokes_WC,mon_equation->probleme().equation(0));
57 const DoubleTab& la_vitesse = eqHyd.vitesse().valeurs();
58
59 // grad_Ptot is an element field => think of conductivity (element field in VEF!!)
60 DoubleTab grad_Ptot;
61 const DoubleTab& lambda = eqHyd.milieu().conductivite().valeurs();
62 const int nb = lambda.size_totale(), nbcomp = la_vitesse.line_size();
63 assert (nb == lambda.dimension_tot(0) && lambda.line_size() == 1);
64 grad_Ptot.resize(nb,nbcomp);
65
66 const Convection_Diffusion_Chaleur_WC& eq_chal = ref_cast(Convection_Diffusion_Chaleur_WC,mon_equation.valeur());
67 const Operateur_Grad& Op_Grad = eq_chal.operateur_gradient_WC();
68 Op_Grad.calculer(Ptot,grad_Ptot); // compute grad(P_tot)
69
70 const Domaine_dis_base& domaine_dis = mon_equation->inconnue().domaine_dis_base();
71 const Domaine_VF& domaine = ref_cast(Domaine_VF, domaine_dis);
72 assert (domaine_dis.que_suis_je() == "Domaine_VEF");
73
74 // grad should be zero at boundary
75 correct_grad_boundary(domaine,grad_Ptot);
76
77 // We compute u*grad(P_tot) on each face
78 DoubleTab grad_Ptot_face(la_vitesse); // face fields
79
80 // get grad_Ptot on faces
81 elem_to_face(domaine,grad_Ptot,grad_Ptot_face);
82
83 const int n = la_vitesse.dimension_tot(0);
84 assert (UgradP_face.dimension_tot(0) == n && grad_Ptot_face.dimension_tot(0) == n);
85 assert (UgradP_face.line_size() == 1 && n == domaine.nb_faces_tot());
86 for (int i=0 ; i <n ; i++)
87 {
88 UgradP_face(i,0) = 0.;
89 for (int j=0 ; j <nbcomp ; j++) UgradP_face(i,0) += la_vitesse(i,j) * grad_Ptot_face(i,j);
90 }
91}
92
93// Static methods of Discretisation_tools could be used here... but it requires creating a Champ_base ...
94void Source_WC_Chaleur_VEF::elem_to_face(const Domaine_VF& domaine, const DoubleTab& grad_Ptot,DoubleTab& grad_Ptot_face) const
95{
96 const DoubleVect& vol = domaine.volumes();
97 const IntTab& elem_faces = domaine.elem_faces();
98 const int nb_face_elem = elem_faces.line_size(), nb_elem_tot = domaine.nb_elem_tot(), nb_comp = grad_Ptot_face.line_size();
99 assert (grad_Ptot.dimension_tot(0) == nb_elem_tot && grad_Ptot_face.dimension_tot(0) == domaine.nb_faces_tot());
100 assert (grad_Ptot.line_size() == nb_comp);
101
102 grad_Ptot_face = 0.;
103 for (int ele = 0; ele < nb_elem_tot; ele++)
104 for (int s = 0; s < nb_face_elem; s++)
105 {
106 const int face = elem_faces(ele,s);
107 for (int comp = 0; comp < nb_comp; comp++) grad_Ptot_face(face,comp) += grad_Ptot(ele,comp)*vol(ele);
108 }
109
110 for (int f=0; f<domaine.nb_faces_tot(); f++)
111 for (int comp=0; comp<nb_comp; comp++) grad_Ptot_face(f,comp) /= volumes(f)*nb_face_elem;
112}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
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
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
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual const Champ_Don_base & conductivite() const
Returns the conductivity of the medium (const version).
Carries the terms of the momentum equation for a weakly compressible fluid without turbulence modelli...
const Milieu_base & milieu() const override
Returns the physical medium of the equation (Fluide_base upcast to Milieu_base).
virtual const Champ_Inc_base & vitesse() const
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
Base class for output streams.
Definition Sortie.h:52
void associer_domaines_impl(const Domaine_dis_base &domaine, const Domaine_Cl_dis_base &domaine_cl)
void associer_volume_porosite_impl(const Domaine_dis_base &domaine, DoubleVect &volumes, DoubleVect &porosites)
class Source_WC_Chaleur_VEF
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void compute_interpolate_gradP(DoubleTab &UgradP_face, const DoubleTab &Ptot) const override
class Source_WC_Chaleur
const DoubleTab & correct_grad_boundary(const Domaine_VF &domaine, DoubleTab &grad_Ptot) const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
int line_size() const
Definition TRUSTVect.tpp:67