TrioCFD 1.9.8
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 * NOTA BENE :
44 * On a discretise P_EOS avec une directive = temperature qui donne en VEF :
45 * Ptot => aux faces
46 * la_vitesse => faces car vef
47 * grad_Ptot => elem
48 *
49 * L'equation est une equation de scalaire => aux faces car vef
50 * On a d P_tot / d t = del P / del t + u.grad(P_tot)
51 *
52 * del P / del t => aux faces
53 * u.grad(P_tot) !!! faut interpoler grad(P_tot) aux 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 // On sait que grad_Ptot est un champ elem => on pense a la conductivite (elem en 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); // champs sur les faces
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// On peut utiliser les methodes statics de Discretisation_tools... mais faut creer de 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
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
classe Convection_Diffusion_Chaleur_WC Cas particulier de Convection_Diffusion_Chaleur_Fluide_Dilatab...
const Operateur_Grad & operateur_gradient_WC() const
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
class Domaine_VF
Definition Domaine_VF.h:44
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
virtual const Champ_Don_base & conductivite() const
Renvoie la conductivite du milieu.
classe Navier_Stokes_WC Cette classe porte les termes de l'equation de la dynamique
const Milieu_base & milieu() const override
Renvoie le milieu physique de l'equation (le Fluide_base upcaste en Milieu_base).
virtual const Champ_Inc_base & vitesse() const
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
Classe Operateur_Grad Classe generique de la hierarchie des operateurs calculant le gradient.
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
Initialise le tableau passe en parametre avec la contribution de l'operateur.
virtual const Equation_base & equation(int) const =0
Classe de base des flux de sortie.
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