GRINS-0.6.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-2015 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 //libMesh
30 #include "libmesh/getpot.h"
31 #include "libmesh/system.h"
32 #include "libmesh/mesh.h"
33 
34 namespace GRINS
35 {
36 
38  (const std::string & helper_name,
39  const GetPot& input)
40  : StabilizationHelper(helper_name),
41  _C(1),
42  _tau_factor(0.5),
43  _temp_vars(input),
44  _flow_vars(input)
45  {
46  if (input.have_variable("Stabilization/tau_constant_T"))
47  this->set_parameter
48  (_C, input, "Stabilization/tau_constant_T", _C );
49  else
50  this->set_parameter
51  (_C, input, "Stabilization/tau_constant", _C );
52 
53  if (input.have_variable("Stabilization/tau_factor_T"))
54  this->set_parameter
55  (_tau_factor, input, "Stabilization/tau_factor_T", _tau_factor );
56  else
57  this->set_parameter
58  (_tau_factor, input, "Stabilization/tau_factor", _tau_factor );
59  }
60 
62  {
63  return;
64  }
65 
66  void HeatTransferStabilizationHelper::init( libMesh::FEMSystem& system )
67  {
68  _temp_vars.init(&system);
69  _flow_vars.init(&system);
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_var(), qp);
81  libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T_var(), qp);
82 
83  libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u_var(), qp),
84  rho*Cp*context.fixed_interior_value(this->_flow_vars.v_var(), qp) );
85  if(context.get_system().get_mesh().mesh_dimension() == 3)
86  rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w_var(), 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_var(), qp);
105  libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T_var(), qp);
106 
107  libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u_var(), qp),
108  rho*Cp*context.fixed_interior_value(this->_flow_vars.v_var(), qp) );
109  if(context.get_system().get_mesh().mesh_dimension() == 3)
110  rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w_var(), 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_var(), 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_var(), 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
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
GRINS namespace.
virtual void init(libMesh::FEMSystem *system)
virtual void init(libMesh::FEMSystem *system)
libMesh::Real compute_res_energy_steady(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real Cp, const libMesh::Real k) const
HeatTransferStabilizationHelper(const std::string &helper_name, const GetPot &input)

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1