TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Th_TdivU_VEF_Face.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 <Terme_Source_Th_TdivU_VEF_Face.h>
17#include <Convection_Diffusion_std.h>
18#include <Op_Conv_Muscl_VEF_Face.h>
19#include <Echange_impose_base.h>
20#include <Domaine_Cl_dis_base.h>
21#include <Dirichlet_homogene.h>
22#include <Navier_Stokes_std.h>
23#include <Neumann_homogene.h>
24#include <Neumann_val_ext.h>
25#include <Probleme_base.h>
26#include <Milieu_base.h>
27#include <Periodique.h>
28#include <Symetrie.h>
29#include <Neumann.h>
30#include <EChaine.h>
31
32Implemente_instanciable(Terme_Source_Th_TdivU_VEF_Face,"Source_Th_TdivU_VEF_P1NC",Source_base);
33// XD source_th_tdivu source_base source_th_tdivu NO_BRACE This term source is dedicated for any scalar (called T)
34// XD_CONT transport. Coupled with upwind (amont) or muscl scheme, this term gives for final expression of convection :
35// XD_CONT div(U.T)-T.div (U)=U.grad(T) This ensures, in incompressible flow when divergence free is badly resolved, to
36// XD_CONT stay in a better way in the physical boundaries. NL2 Warning: Only available in VEF discretization.
37
39{
40 return s << que_suis_je() ;
41}
42
44{
45 return s ;
46}
47
49{
50 int nb_eqn = pb.nombre_d_equations();
51 int ok_vit=0;
52 int ok_temp=0;
53 for (int i=0; i<nb_eqn; i++)
54 {
55 const Equation_base& eqn = pb.equation(i);
56 if (sub_type(Navier_Stokes_std,eqn))
57 {
58 ok_vit = 1;
59 }
60 if (sub_type(Convection_Diffusion_std,eqn))
61 {
62 ok_temp = 1;
63 }
64 }
65
66 if (!ok_vit)
67 {
68 Cerr << "Error TRUST in " << que_suis_je() << finl;
69 Cerr << "Hydraulic equation not found" << finl;
70 exit();
71 }
72 if (!ok_temp)
73 {
74 Cerr << "Error TRUST in " << que_suis_je() << finl;
75 Cerr << "Thermal equation not found" << finl;
76 exit();
77 }
78}
83
85 const Domaine_Cl_dis_base& domaine_Cl_dis)
86{
87}
88
94
96{
97 if (domaine_cl_mod_) return;
99 mon_domcl_=eqn_t->domaine_Cl_dis();
100 domainecl_sa=eqn_t->domaine_Cl_dis();
101 Conds_lim& condlims=mon_domcl_->les_conditions_limites();
102 Conds_lim& condlims_sa=domainecl_sa->les_conditions_limites();
103 int nb=condlims.size();
104
105 for (int i=0; i<nb*0; i++)
106 {
107 condlims[i]= condlims_sa[i];
108 //Cerr<<(int)( &condlims[i].valeur())<<" addr "<<(int) &condlims_sa[i].valeur()<<finl;
109 }
110 for (int i=0; i<nb; i++)
111 {
112 Cond_lim_base& la_cl=condlims_sa[i].valeur();
113 int modif=0;
114 Nom new_cl;
115 if (sub_type(Periodique,la_cl)||sub_type(Symetrie,la_cl))
116 {
117 ;
118 }
119 else if (sub_type(Neumann_homogene,la_cl)||sub_type(Neumann,la_cl)||sub_type(Neumann_val_ext,la_cl)||sub_type(Echange_impose_base,la_cl))
120 {
121 modif=1;
122 new_cl="Frontiere_ouverte T_ext Champ_front_uniforme 1 1";
123 }
124 else if (sub_type(Dirichlet_homogene,la_cl)||sub_type(Dirichlet,la_cl))
125 {
126 modif=1;
127 new_cl="Frontiere_ouverte_temperature_imposee Champ_front_uniforme 1 1";
128 }
129 else
130 {
131 Cerr<<"override of boundary condition "<<la_cl.que_suis_je()<<" not coded in "<<__FILE__<<finl;
132 exit();
133 }
134 if (modif)
135 {
136 EChaine cons("Frontiere_ouverte T_ext Champ_front_uniforme 1 1");
137 //EChaine cons("symetrie");
138 Frontiere_dis_base& frdis=condlims[i]->frontiere_dis();
139 cons>>condlims[i];
140 Cond_lim_base& cl_m=condlims[i].valeur();
141
142 cl_m.associer_fr_dis_base(frdis);
143 cl_m.completer();
144
145 }
146
147 }
148}
149
150DoubleTab& Terme_Source_Th_TdivU_VEF_Face::ajouter(DoubleTab& resu) const
151{
152 Terme_Source_Th_TdivU_VEF_Face& me_non_const=ref_cast_non_const(Terme_Source_Th_TdivU_VEF_Face,*this);
153 me_non_const.modifier_domaine_cl();
154 if(resu.line_size() > 1)
155 {
156 Cerr << "Error in " << que_suis_je() << finl;
157 Cerr << "The source term Source_Th_TdivU_VEF_P1NC is only dedicated to thermal equation" << finl;
158 exit();
159 }
160 const DoubleTab& temperature=equation().inconnue().valeurs();
161 const int nb_faces = temperature.dimension_tot(0);
162
163 // Compute TdivU according to the convection scheme
164 DoubleTab temp(temperature);
165 DoubleTab TdivU(resu);
166 TdivU=0.;
167 temp=1.;
168 const Operateur& Op_conv=equation().operateur(1);
169 Operateur_base& optype=ref_cast_non_const(Operateur_base,Op_conv.l_op_base());
170 // We save the boundary fluxes:
171 DoubleTab flux_bords_backup = optype.flux_bords();
172 optype.associer_domaine_cl_dis(mon_domcl_.valeur());
173 Op_conv.ajouter(temp,TdivU);
174 for(int face=0; face<nb_faces; face++)
175 {
176 TdivU[face]*=temperature(face);
177 }
178 if (mp_max_vect(TdivU)==0)
179 {
180 Cerr << finl;
181 Cerr << "******* Warning *******" << finl;
182 Cerr << "You are using source term TdivU into one transport equation." << finl;
183 Cerr << "It seems useless cause TdivU=0" << finl;
184 Cerr << "May be the advection operator is calculated with the non-conservative formulation." << finl;
185 }
186
187 // the TdivU part is a piece of the convection operator -> it must be multiplied by rhoCp
188 const double rhoCp = equation().milieu().capacite_calorifique().valeurs()(0, 0) * equation().milieu().masse_volumique().valeurs()(0, 0);
189 TdivU *= rhoCp;
190 resu-=TdivU;
191 // restore the correct domaine_cl_dis
192 optype.associer_domaine_cl_dis(domainecl_sa.valeur());
193 // We reset flux_bords
194 optype.flux_bords() = flux_bords_backup;
195 return resu;
196}
197
198DoubleTab& Terme_Source_Th_TdivU_VEF_Face::calculer(DoubleTab& resu) const
199{
200 resu = 0.;
201 return ajouter(resu);
202}
203
205{
206 ;
207}
208
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.
virtual DoubleTab & valeurs()=0
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
virtual void associer_fr_dis_base(const Frontiere_dis_base &)
Associates the boundary with the object.
virtual void completer()
DOES NOTHING must be overridden in derived classes.
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
Convection_Diffusion_std This class is the base for equations modelling the transport.
Classe Dirichlet_homogene This class is the base class of the hierarchy of homogeneous Dirichlet-type...
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
An input stream whose source is a character string.
Definition EChaine.h:31
Echange_impose_base: This boundary condition is used only for the energy equation.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
virtual const Operateur & operateur(int) const =0
class Frontiere_dis_base Class representing a discretized boundary.
virtual const Champ_Don_base & capacite_calorifique() const
Returns the heat capacity of the medium (const version).
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Navier_Stokes_std This class carries the terms of the momentum equation.
Classe Neumann_homogene This class is the base class of the hierarchy of homogeneous Neumann-type bou...
Classe Neumann_val_ext This class is the base class of the hierarchy of.
Classe Neumann This class is the base class of the hierarchy of Neumann-type boundary conditions.
Definition Neumann.h:31
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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
class Operateur_base This class is the base of the hierarchy of objects representing an
virtual void associer_domaine_cl_dis(const Domaine_Cl_dis_base &)
DoubleTab & flux_bords()
class Operateur Generic class of the operator hierarchy.
Definition Operateur.h:39
virtual Operateur_base & l_op_base()=0
virtual DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const =0
class Periodique This class represents a periodic boundary condition.
Definition Periodique.h:31
class Probleme_base It is a Probleme_U that is not a coupling.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
virtual void completer()
Updates internal references of the Source_base object.
Symetrie On symmetry faces, the following properties hold:
Definition Symetrie.h:37
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67
class Terme_Source_Th_TdivU_VEF_Face
DoubleTab & ajouter(DoubleTab &) const override
void completer() override
Updates internal references of the Source_base object.
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
DoubleTab & calculer(DoubleTab &) const override
void associer_pb(const Probleme_base &) override