GRINS-0.7.0
List of all members | Public Member Functions | Private Member Functions | Private Attributes
GRINS::HeatTransfer< Conductivity > Class Template Reference

Physics class for Heat Transfer. More...

#include <heat_transfer.h>

Inheritance diagram for GRINS::HeatTransfer< Conductivity >:
Inheritance graph
[legend]
Collaboration diagram for GRINS::HeatTransfer< Conductivity >:
Collaboration graph
[legend]

Public Member Functions

 HeatTransfer (const std::string &physics_name, const GetPot &input)
 
 ~HeatTransfer ()
 
virtual void register_postprocessing_vars (const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
 Register postprocessing variables for HeatTransfer. More...
 
virtual void element_time_derivative (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Time dependent part(s) of physics for element interiors. More...
 
virtual void mass_residual (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part. More...
 
virtual void compute_postprocessed_quantity (unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
 Compute value of postprocessed quantities at libMesh::Point. More...
 
- Public Member Functions inherited from GRINS::HeatTransferBase< Conductivity >
 HeatTransferBase (const std::string &physics_name, const std::string &core_physics_name, const GetPot &input)
 
 ~HeatTransferBase ()
 
virtual void init_variables (libMesh::FEMSystem *system)
 Initialization Heat Transfer variables. More...
 
virtual void set_time_evolving_vars (libMesh::FEMSystem *system)
 Sets velocity variables to be time-evolving. More...
 
virtual void init_context (AssemblyContext &context)
 Initialize context for added physics variables. More...
 
virtual void register_parameter (const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 
- Public Member Functions inherited from GRINS::Physics
 Physics (const GRINS::PhysicsName &physics_name, const GetPot &input)
 
virtual ~Physics ()
 
virtual bool enabled_on_elem (const libMesh::Elem *elem)
 Find if current physics is active on supplied element. More...
 
void set_is_steady (bool is_steady)
 Sets whether this physics is to be solved with a steady solver or not. More...
 
bool is_steady () const
 Returns whether or not this physics is being solved with a steady solver. More...
 
virtual void auxiliary_init (MultiphysicsSystem &system)
 Any auxillary initialization a Physics class may need. More...
 
virtual void side_time_derivative (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Time dependent part(s) of physics for boundaries of elements on the domain boundary. More...
 
virtual void nonlocal_time_derivative (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Time dependent part(s) of physics for scalar variables. More...
 
virtual void element_constraint (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Constraint part(s) of physics for element interiors. More...
 
virtual void side_constraint (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Constraint part(s) of physics for boundaries of elements on the domain boundary. More...
 
virtual void nonlocal_constraint (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Constraint part(s) of physics for scalar variables. More...
 
virtual void damping_residual (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Damping matrix part(s) for element interiors. All boundary terms lie within the time_derivative part. More...
 
virtual void nonlocal_mass_residual (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Mass matrix part(s) for scalar variables. More...
 
void init_ics (libMesh::FEMSystem *system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
 
virtual void compute_element_time_derivative_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_side_time_derivative_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_nonlocal_time_derivative_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_element_constraint_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_side_constraint_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_nonlocal_constraint_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_damping_residual_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_mass_residual_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_nonlocal_mass_residual_cache (const AssemblyContext &context, CachedValues &cache)
 
ICHandlingBaseget_ic_handler ()
 
- Public Member Functions inherited from GRINS::ParameterUser
 ParameterUser (const std::string &user_name)
 
virtual ~ParameterUser ()
 
virtual void set_parameter (libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
 Each subclass can simultaneously read a parameter value from. More...
 
virtual void set_parameter (libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void set_parameter (libMesh::ParsedFEMFunction< libMesh::Number > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void move_parameter (const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &old_func, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFEMFunction< libMesh::Number > &old_func, libMesh::ParsedFEMFunction< libMesh::Number > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 

Private Member Functions

 HeatTransfer ()
 

Private Attributes

unsigned int _k_index
 Index from registering this postprocessed quantity. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from GRINS::Physics
static void set_is_axisymmetric (bool is_axisymmetric)
 Set whether we should treat the problem as axisymmetric. More...
 
static bool is_axisymmetric ()
 
- Static Public Attributes inherited from GRINS::ParameterUser
static std::string zero_vector_function = std::string("{0}")
 A parseable function string with LIBMESH_DIM components, all 0. More...
 
- Protected Member Functions inherited from GRINS::Physics
libMesh::UniquePtr< libMesh::FEGenericBase< libMesh::Real > > build_new_fe (const libMesh::Elem *elem, const libMesh::FEGenericBase< libMesh::Real > *fe, const libMesh::Point p)
 
void parse_enabled_subdomains (const GetPot &input, const std::string &physics_name)
 
- Protected Attributes inherited from GRINS::HeatTransferBase< Conductivity >
unsigned int _dim
 Physical dimension of problem. More...
 
VelocityFEVariables _flow_vars
 
PressureFEVariable _press_var
 
PrimitiveTempFEVariables _temp_vars
 
libMesh::Number _rho
 Material parameters, read from input. More...
 
libMesh::Number _Cp
 
Conductivity _k
 Conductivity. More...
 
- Protected Attributes inherited from GRINS::Physics
const PhysicsName _physics_name
 Name of the physics object. Used for reading physics specific inputs. More...
 
GRINS::ICHandlingBase_ic_handler
 
std::set< libMesh::subdomain_id_type > _enabled_subdomains
 Subdomains on which the current Physics class is enabled. More...
 
- Static Protected Attributes inherited from GRINS::Physics
static bool _is_steady = false
 Caches whether or not the solver that's being used is steady or not. More...
 
static bool _is_axisymmetric = false
 Caches whether we are solving an axisymmetric problem or not. More...
 

Detailed Description

template<class Conductivity>
class GRINS::HeatTransfer< Conductivity >

Physics class for Heat Transfer.

Definition at line 40 of file heat_transfer.h.

Constructor & Destructor Documentation

template<class K >
GRINS::HeatTransfer< K >::HeatTransfer ( const std::string &  physics_name,
const GetPot &  input 
)

Definition at line 45 of file heat_transfer.C.

References GRINS::Physics::_ic_handler.

46  : HeatTransferBase<K>(physics_name, PhysicsNaming::heat_transfer(), input),
47  _k_index(0)
48  {
49  this->_ic_handler = new GenericICHandler( physics_name, input );
50  }
static PhysicsName heat_transfer()
GRINS::ICHandlingBase * _ic_handler
Definition: physics.h:269
unsigned int _k_index
Index from registering this postprocessed quantity.
Definition: heat_transfer.h:76
template<class Conductivity >
GRINS::HeatTransfer< Conductivity >::~HeatTransfer ( )
inline

Definition at line 46 of file heat_transfer.h.

46 {};
template<class Conductivity >
GRINS::HeatTransfer< Conductivity >::HeatTransfer ( )
private

Member Function Documentation

template<class K >
void GRINS::HeatTransfer< K >::compute_postprocessed_quantity ( unsigned int  quantity_index,
const AssemblyContext context,
const libMesh::Point &  point,
libMesh::Real &  value 
)
virtual

Compute value of postprocessed quantities at libMesh::Point.

Reimplemented from GRINS::Physics.

Definition at line 285 of file heat_transfer.C.

289  {
290  if( quantity_index == this->_k_index )
291  {
292  value = this->_k(point, context.get_time());
293  }
294 
295  return;
296  }
unsigned int _k_index
Index from registering this postprocessed quantity.
Definition: heat_transfer.h:76
Conductivity _k
Conductivity.
template<class K >
void GRINS::HeatTransfer< K >::element_time_derivative ( bool  compute_jacobian,
AssemblyContext context,
CachedValues cache 
)
virtual

Time dependent part(s) of physics for element interiors.

Reimplemented from GRINS::Physics.

Definition at line 84 of file heat_transfer.C.

References GRINS::Physics::is_axisymmetric().

87  {
88 #ifdef GRINS_USE_GRVY_TIMERS
89  this->_timer->BeginTimer("HeatTransfer::element_time_derivative");
90 #endif
91 
92  // The number of local degrees of freedom in each variable.
93  const unsigned int n_T_dofs = context.get_dof_indices(this->_temp_vars.T()).size();
94  const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
95 
96  //TODO: check n_T_dofs is same as n_u_dofs, n_v_dofs, n_w_dofs
97 
98  // We get some references to cell-specific data that
99  // will be used to assemble the linear system.
100 
101  // Element Jacobian * quadrature weights for interior integration.
102  const std::vector<libMesh::Real> &JxW =
103  context.get_element_fe(this->_temp_vars.T())->get_JxW();
104 
105  // The temperature shape functions at interior quadrature points.
106  const std::vector<std::vector<libMesh::Real> >& T_phi =
107  context.get_element_fe(this->_temp_vars.T())->get_phi();
108 
109  // The velocity shape functions at interior quadrature points.
110  const std::vector<std::vector<libMesh::Real> >& vel_phi =
111  context.get_element_fe(this->_flow_vars.u())->get_phi();
112 
113  // The temperature shape function gradients (in global coords.)
114  // at interior quadrature points.
115  const std::vector<std::vector<libMesh::RealGradient> >& T_gradphi =
116  context.get_element_fe(this->_temp_vars.T())->get_dphi();
117 
118  const std::vector<libMesh::Point>& u_qpoint =
119  context.get_element_fe(this->_flow_vars.u())->get_xyz();
120 
121  libMesh::DenseSubMatrix<libMesh::Number> &KTT = context.get_elem_jacobian(this->_temp_vars.T(), this->_temp_vars.T()); // R_{T},{T}
122 
123  libMesh::DenseSubMatrix<libMesh::Number> &KTu = context.get_elem_jacobian(this->_temp_vars.T(), this->_flow_vars.u()); // R_{T},{u}
124  libMesh::DenseSubMatrix<libMesh::Number> &KTv = context.get_elem_jacobian(this->_temp_vars.T(), this->_flow_vars.v()); // R_{T},{v}
125  libMesh::DenseSubMatrix<libMesh::Number>* KTw = NULL;
126 
127  libMesh::DenseSubVector<libMesh::Number> &FT = context.get_elem_residual(this->_temp_vars.T()); // R_{T}
128 
129  if( this->_dim == 3 )
130  {
131  KTw = &context.get_elem_jacobian(this->_temp_vars.T(), this->_flow_vars.w()); // R_{T},{w}
132  }
133 
134  // Now we will build the element Jacobian and residual.
135  // Constructing the residual requires the solution and its
136  // gradient from the previous timestep. This must be
137  // calculated at each quadrature point by summing the
138  // solution degree-of-freedom values by the appropriate
139  // weight functions.
140  unsigned int n_qpoints = context.get_element_qrule().n_points();
141 
142  for (unsigned int qp=0; qp != n_qpoints; qp++)
143  {
144  // Compute the solution & its gradient at the old Newton iterate.
145  libMesh::Number u, v;
146  u = context.interior_value(this->_flow_vars.u(), qp);
147  v = context.interior_value(this->_flow_vars.v(), qp);
148 
149  libMesh::Gradient grad_T;
150  grad_T = context.interior_gradient(this->_temp_vars.T(), qp);
151 
152  libMesh::NumberVectorValue U (u,v);
153  if (this->_dim == 3)
154  U(2) = context.interior_value(this->_flow_vars.w(), qp);
155 
156  const libMesh::Number r = u_qpoint[qp](0);
157 
158  libMesh::Real jac = JxW[qp];
159 
160  // Compute the conductivity at this qp
161  libMesh::Real _k_qp = this->_k(context, qp);
162 
164  {
165  jac *= r;
166  }
167 
168  // First, an i-loop over the degrees of freedom.
169  for (unsigned int i=0; i != n_T_dofs; i++)
170  {
171  FT(i) += jac *
172  (-this->_rho*this->_Cp*T_phi[i][qp]*(U*grad_T) // convection term
173  -_k_qp*(T_gradphi[i][qp]*grad_T) ); // diffusion term
174 
175  if (compute_jacobian)
176  {
177  for (unsigned int j=0; j != n_T_dofs; j++)
178  {
179  // TODO: precompute some terms like:
180  // this->_rho*this->_Cp*T_phi[i][qp]*(vel_phi[j][qp]*T_grad_phi[j][qp])
181 
182  KTT(i,j) += jac * context.get_elem_solution_derivative() *
183  (-this->_rho*this->_Cp*T_phi[i][qp]*(U*T_gradphi[j][qp]) // convection term
184  -_k_qp*(T_gradphi[i][qp]*T_gradphi[j][qp])); // diffusion term
185  } // end of the inner dof (j) loop
186 
187  // Matrix contributions for the Tu, Tv and Tw couplings (n_T_dofs same as n_u_dofs, n_v_dofs and n_w_dofs)
188  for (unsigned int j=0; j != n_u_dofs; j++)
189  {
190  KTu(i,j) += jac * context.get_elem_solution_derivative()*(-this->_rho*this->_Cp*T_phi[i][qp]*(vel_phi[j][qp]*grad_T(0)));
191  KTv(i,j) += jac * context.get_elem_solution_derivative()*(-this->_rho*this->_Cp*T_phi[i][qp]*(vel_phi[j][qp]*grad_T(1)));
192  if (this->_dim == 3)
193  (*KTw)(i,j) += jac * context.get_elem_solution_derivative()*(-this->_rho*this->_Cp*T_phi[i][qp]*(vel_phi[j][qp]*grad_T(2)));
194  } // end of the inner dof (j) loop
195 
196  } // end - if (compute_jacobian && context.get_elem_solution_derivative())
197 
198  } // end of the outer dof (i) loop
199  } // end of the quadrature point (qp) loop
200 
201 #ifdef GRINS_USE_GRVY_TIMERS
202  this->_timer->EndTimer("HeatTransfer::element_time_derivative");
203 #endif
204 
205  return;
206  }
static bool is_axisymmetric()
Definition: physics.h:133
libMesh::Number _rho
Material parameters, read from input.
Conductivity _k
Conductivity.
PrimitiveTempFEVariables _temp_vars
VelocityFEVariables _flow_vars
unsigned int _dim
Physical dimension of problem.
template<class K >
void GRINS::HeatTransfer< K >::mass_residual ( bool  compute_jacobian,
AssemblyContext context,
CachedValues cache 
)
virtual

Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part.

Reimplemented from GRINS::Physics.

Definition at line 209 of file heat_transfer.C.

References GRINS::Physics::is_axisymmetric().

212  {
213 #ifdef GRINS_USE_GRVY_TIMERS
214  this->_timer->BeginTimer("HeatTransfer::mass_residual");
215 #endif
216 
217  // First we get some references to cell-specific data that
218  // will be used to assemble the linear system.
219 
220  // Element Jacobian * quadrature weights for interior integration
221  const std::vector<libMesh::Real> &JxW =
222  context.get_element_fe(this->_temp_vars.T())->get_JxW();
223 
224  // The shape functions at interior quadrature points.
225  const std::vector<std::vector<libMesh::Real> >& phi =
226  context.get_element_fe(this->_temp_vars.T())->get_phi();
227 
228  const std::vector<libMesh::Point>& u_qpoint =
229  context.get_element_fe(this->_flow_vars.u())->get_xyz();
230 
231  // The number of local degrees of freedom in each variable
232  const unsigned int n_T_dofs = context.get_dof_indices(this->_temp_vars.T()).size();
233 
234  // The subvectors and submatrices we need to fill:
235  libMesh::DenseSubVector<libMesh::Real> &F = context.get_elem_residual(this->_temp_vars.T());
236 
237  libMesh::DenseSubMatrix<libMesh::Real> &M = context.get_elem_jacobian(this->_temp_vars.T(), this->_temp_vars.T());
238 
239  unsigned int n_qpoints = context.get_element_qrule().n_points();
240 
241  for (unsigned int qp = 0; qp != n_qpoints; ++qp)
242  {
243  // For the mass residual, we need to be a little careful.
244  // The time integrator is handling the time-discretization
245  // for us so we need to supply M(u_fixed)*u' for the residual.
246  // u_fixed will be given by the fixed_interior_value function
247  // while u' will be given by the interior_rate function.
248  libMesh::Real T_dot;
249  context.interior_rate(this->_temp_vars.T(), qp, T_dot);
250 
251  const libMesh::Number r = u_qpoint[qp](0);
252 
253  libMesh::Real jac = JxW[qp];
254 
256  {
257  jac *= r;
258  }
259 
260  for (unsigned int i = 0; i != n_T_dofs; ++i)
261  {
262  F(i) -= this->_rho*this->_Cp*T_dot*phi[i][qp]*jac;
263 
264  if( compute_jacobian )
265  {
266  for (unsigned int j=0; j != n_T_dofs; j++)
267  {
268  // We're assuming rho, cp are constant w.r.t. T here.
269  M(i,j) -= this->_rho*this->_Cp*phi[j][qp]*phi[i][qp]*jac * context.get_elem_solution_rate_derivative();
270  }
271  }// End of check on Jacobian
272 
273  } // End of element dof loop
274 
275  } // End of the quadrature point loop
276 
277 #ifdef GRINS_USE_GRVY_TIMERS
278  this->_timer->EndTimer("HeatTransfer::mass_residual");
279 #endif
280 
281  return;
282  }
static bool is_axisymmetric()
Definition: physics.h:133
libMesh::Number _rho
Material parameters, read from input.
PrimitiveTempFEVariables _temp_vars
VelocityFEVariables _flow_vars
template<class K >
void GRINS::HeatTransfer< K >::register_postprocessing_vars ( const GetPot &  input,
PostProcessedQuantities< libMesh::Real > &  postprocessing 
)
virtual

Register postprocessing variables for HeatTransfer.

Reimplemented from GRINS::Physics.

Definition at line 53 of file heat_transfer.C.

References GRINS::PhysicsNaming::heat_transfer(), and GRINS::PostProcessedQuantities< NumericType >::register_quantity().

55  {
56  std::string section = "Physics/"+PhysicsNaming::heat_transfer()+"/output_vars";
57 
58  if( input.have_variable(section) )
59  {
60  unsigned int n_vars = input.vector_variable_size(section);
61 
62  for( unsigned int v = 0; v < n_vars; v++ )
63  {
64  std::string name = input(section,"DIE!",v);
65 
66  if( name == std::string("k") )
67  {
68  this->_k_index = postprocessing.register_quantity( name );
69  }
70  else
71  {
72  std::cerr << "Error: Invalid output_vars value for "+PhysicsNaming::heat_transfer() << std::endl
73  << " Found " << name << std::endl
74  << " Acceptable values are: k" << std::endl;
75  libmesh_error();
76  }
77  }
78  }
79 
80  return;
81  }
static PhysicsName heat_transfer()
unsigned int _k_index
Index from registering this postprocessed quantity.
Definition: heat_transfer.h:76

Member Data Documentation

template<class Conductivity >
unsigned int GRINS::HeatTransfer< Conductivity >::_k_index
private

Index from registering this postprocessed quantity.

Definition at line 76 of file heat_transfer.h.


The documentation for this class was generated from the following files:

Generated on Thu Jun 2 2016 21:52:31 for GRINS-0.7.0 by  doxygen 1.8.10