GRINS-0.6.0
heat_transfer_source.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 // GRINS
30 #include "grins/assembly_context.h"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 #include "libmesh/fem_system.h"
36 #include "libmesh/quadrature.h"
37 
38 namespace GRINS
39 {
40 
41  template< class SourceFunction >
42  HeatTransferSource<SourceFunction>::HeatTransferSource( const std::string& physics_name, const GetPot& input )
43  : Physics(physics_name,input),
44  _source(input),
45  _temp_vars(input,heat_transfer)
46  {
47  return;
48  }
49 
50  template< class SourceFunction >
52  {
53  return;
54  }
55 
56  template< class SourceFunction >
57  void HeatTransferSource<SourceFunction>::init_variables( libMesh::FEMSystem* system )
58  {
59  _temp_vars.init(system);
60 
61  return;
62  }
63 
64  template< class SourceFunction >
66  AssemblyContext& context,
67  CachedValues& /*cache*/ )
68  {
69 #ifdef GRINS_USE_GRVY_TIMERS
70  this->_timer->BeginTimer("HeatTransferSource::element_time_derivative");
71 #endif
72 
73  // The number of local degrees of freedom in each variable.
74  const unsigned int n_T_dofs = context.get_dof_indices(_temp_vars.T_var()).size();
75 
76  // Element Jacobian * quadrature weights for interior integration.
77  const std::vector<libMesh::Real> &JxW =
78  context.get_element_fe(_temp_vars.T_var())->get_JxW();
79 
80  // The temperature shape functions at interior quadrature points.
81  const std::vector<std::vector<libMesh::Real> >& T_phi =
82  context.get_element_fe(_temp_vars.T_var())->get_phi();
83 
84  // Locations of quadrature points
85  const std::vector<libMesh::Point>& x_qp = context.get_element_fe(_temp_vars.T_var())->get_xyz();
86 
87  // Get residuals
88  libMesh::DenseSubVector<libMesh::Number> &FT = context.get_elem_residual(_temp_vars.T_var()); // R_{T}
89 
90  // Now we will build the element Jacobian and residual.
91  // Constructing the residual requires the solution and its
92  // gradient from the previous timestep. This must be
93  // calculated at each quadrature point by summing the
94  // solution degree-of-freedom values by the appropriate
95  // weight functions.
96  unsigned int n_qpoints = context.get_element_qrule().n_points();
97 
98  for (unsigned int qp=0; qp != n_qpoints; qp++)
99  {
100  libMesh::Real q = _source( x_qp[qp] );
101 
102  for (unsigned int i=0; i != n_T_dofs; i++)
103  {
104  FT(i) += q*T_phi[i][qp]*JxW[qp];
105  }
106  }
107 
108 #ifdef GRINS_USE_GRVY_TIMERS
109  this->_timer->EndTimer("HeatTransferSource::element_time_derivative");
110 #endif
111 
112  return;
113  }
114 
115 } // namespace GRINS
116 
117 // Instantiate
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
Definition: physics.h:106
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Source term contribution for HeatTransferSource.
virtual void init_variables(libMesh::FEMSystem *system)
Initialize variables for this physics.
GRINS namespace.
const PhysicsName heat_transfer
Adds generic, spatially dependent source term to HeatTransfer physics.

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