GRINS-0.6.0
parsed_source_term.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 // This class
27 
28 // GRINS
29 #include "grins/assembly_context.h"
30 
31 // libMesh
32 #include "libmesh/getpot.h"
33 #include "libmesh/fem_system.h"
34 #include "libmesh/quadrature.h"
35 
36 namespace GRINS
37 {
38  ParsedSourceTerm::ParsedSourceTerm( const std::string& physics_name, const GetPot& input )
39  : SourceTermBase(physics_name,input),
40  _value( input("Physics/"+physics_name+"/Function/value","DIE!") )
41  {
42  if( !input.have_variable("Physics/"+physics_name+"/Function/value") )
43  {
44  libMesh::err << "Error: Must specify value for ParsedSourceTerm." << std::endl
45  << " Please specify Physics/"+physics_name+"/Function/value" << std::endl;
46  libmesh_error();
47  }
48 
49  return;
50  }
51 
53  {
54  return;
55  }
56 
57  void ParsedSourceTerm::element_time_derivative( bool /*compute_jacobian*/,
58  AssemblyContext& context,
59  CachedValues& /*cache*/ )
60  {
61  for( std::vector<VariableIndex>::const_iterator v_it = _vars.begin();
62  v_it != _vars.end(); ++v_it )
63  {
64  VariableIndex var = *v_it;
65 
66  // The number of local degrees of freedom in each variable.
67  const unsigned int n_dofs = context.get_dof_indices(var).size();
68 
69  // Element Jacobian * quadrature weights for interior integration.
70  const std::vector<libMesh::Real> &JxW =
71  context.get_element_fe(var)->get_JxW();
72 
73  // The temperature shape functions at interior quadrature points.
74  const std::vector<std::vector<libMesh::Real> >& phi =
75  context.get_element_fe(var)->get_phi();
76 
77  const std::vector<libMesh::Point>& x_qp = context.get_element_fe(var)->get_xyz();
78 
79  // Get residuals
80  libMesh::DenseSubVector<libMesh::Number> &F_var = context.get_elem_residual(var);
81 
82  libMesh::Real t = context.get_time();
83 
84  // Now we will build the element Jacobian and residual.
85  // Constructing the residual requires the solution and its
86  // gradient from the previous timestep. This must be
87  // calculated at each quadrature point by summing the
88  // solution degree-of-freedom values by the appropriate
89  // weight functions.
90  unsigned int n_qpoints = context.get_element_qrule().n_points();
91 
92  for (unsigned int qp=0; qp != n_qpoints; qp++)
93  {
94  libMesh::Real value = (this->_value)(x_qp[qp],t);
95 
96  for (unsigned int i=0; i != n_dofs; i++)
97  {
98  F_var(i) += value*phi[i][qp]*JxW[qp];
99  }
100  }
101 
102  } // Variable loop
103 
104  return;
105  }
106 
107 } // end namespace GRINS
std::vector< VariableIndex > _vars
unsigned int VariableIndex
More descriptive name of the type used for variable indices.
Definition: var_typedefs.h:40
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors.
libMesh::ParsedFunction< libMesh::Real > _value
GRINS namespace.
Base class for generic source function term, f(x,y,z,t).

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