GRINS-0.8.0
heat_transfer_stab_helper.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // This class
28 
29 // GRINS
33 #include "grins/single_variable.h"
34 #include "grins/physics_naming.h"
35 
36 //libMesh
37 #include "libmesh/getpot.h"
38 #include "libmesh/system.h"
39 #include "libmesh/mesh.h"
40 
41 namespace GRINS
42 {
43 
45  (const std::string & helper_name,
46  const GetPot& input)
47  : StabilizationHelper(helper_name),
48  _C(1),
49  _tau_factor(0.5),
50  _temp_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<PrimitiveTempFEVariables>(VariablesParsing::temp_variable_name(input,PhysicsNaming::heat_transfer(),VariablesParsing::PHYSICS))),
51  _flow_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<VelocityVariable>(VariablesParsing::velocity_variable_name(input,PhysicsNaming::heat_transfer(),VariablesParsing::PHYSICS))),
52  _press_var(GRINSPrivate::VariableWarehouse::get_variable_subclass<PressureFEVariable>(VariablesParsing::press_variable_name(input,PhysicsNaming::heat_transfer(),VariablesParsing::PHYSICS)))
53  {
54  if (input.have_variable("Stabilization/tau_constant_T"))
55  this->set_parameter
56  (_C, input, "Stabilization/tau_constant_T", _C );
57  else
58  this->set_parameter
59  (_C, input, "Stabilization/tau_constant", _C );
60 
61  if (input.have_variable("Stabilization/tau_factor_T"))
62  this->set_parameter
63  (_tau_factor, input, "Stabilization/tau_factor_T", _tau_factor );
64  else
65  this->set_parameter
66  (_tau_factor, input, "Stabilization/tau_factor", _tau_factor );
67  }
68 
70  {
71  return;
72  }
73 
75  unsigned int qp,
76  const libMesh::Real rho,
77  const libMesh::Real Cp,
78  const libMesh::Real k ) const
79  {
80  libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);
81  libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T(), qp);
82 
83  libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u(), qp),
84  rho*Cp*context.fixed_interior_value(this->_flow_vars.v(), qp) );
85  if(this->_flow_vars.dim() == 3)
86  rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w(), qp);
87 
88  return rhocpU*grad_T - k*(hess_T(0,0) + hess_T(1,1) + hess_T(2,2));
89  }
90 
92  ( AssemblyContext& context,
93  unsigned int qp,
94  const libMesh::Real rho,
95  const libMesh::Real Cp,
96  const libMesh::Real k,
97  libMesh::Real &res,
98  libMesh::Real &d_res_dT,
99  libMesh::Gradient &d_res_dgradT,
100  libMesh::Tensor &d_res_dhessT,
101  libMesh::Gradient &d_res_dU
102  ) const
103  {
104  libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);
105  libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T(), qp);
106 
107  libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u(), qp),
108  rho*Cp*context.fixed_interior_value(this->_flow_vars.v(), qp) );
109  if(this->_flow_vars.dim() == 3)
110  rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w(), qp);
111 
112  res = rhocpU*grad_T - k*(hess_T(0,0) + hess_T(1,1) + hess_T(2,2));
113  d_res_dT = 0;
114  d_res_dgradT = rhocpU;
115  d_res_dhessT = 0;
116  d_res_dhessT(0,0) = -k;
117  d_res_dhessT(1,1) = -k;
118  d_res_dhessT(2,2) = -k;
119  d_res_dU = rho * Cp * grad_T;
120  }
121 
122 
124  unsigned int qp,
125  const libMesh::Real rho,
126  const libMesh::Real Cp ) const
127  {
128  libMesh::Real T_dot;
129  context.interior_rate(this->_temp_vars.T(), qp, T_dot);
130 
131  return rho*Cp*T_dot;
132  }
133 
134 
136  ( AssemblyContext& context,
137  unsigned int qp,
138  const libMesh::Real rho,
139  const libMesh::Real Cp,
140  libMesh::Real &res,
141  libMesh::Real &d_res_dTdot
142  ) const
143  {
144  libMesh::Real T_dot;
145  context.interior_rate(this->_temp_vars.T(), qp, T_dot);
146 
147  res = rho*Cp*T_dot;
148  d_res_dTdot = rho*Cp;
149  }
150 
151 } // namespace GRINS
libMesh::Real compute_res_energy_transient(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real Cp) const
static PhysicsName heat_transfer()
VariableIndex T() const
void compute_res_energy_transient_and_derivs(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real Cp, libMesh::Real &res, libMesh::Real &d_res_dTdot) const
void compute_res_energy_steady_and_derivs(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real Cp, const libMesh::Real k, libMesh::Real &res, libMesh::Real &d_res_dT, libMesh::Gradient &d_res_dgradT, libMesh::Tensor &d_res_dhessT, libMesh::Gradient &d_res_dU) const
static std::string velocity_variable_name(const GetPot &input, const std::string &subsection_name, const SECTION_TYPE section_type)
const PrimitiveTempFEVariables & _temp_vars
static std::string press_variable_name(const GetPot &input, const std::string &subsection_name, const SECTION_TYPE section_type)
GRINS namespace.
static std::string temp_variable_name(const GetPot &input, const std::string &subsection_name, const SECTION_TYPE section_type)
libMesh::Real compute_res_energy_steady(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real Cp, const libMesh::Real k) const
unsigned int dim() const
Number of components.
HeatTransferStabilizationHelper(const std::string &helper_name, const GetPot &input)

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1