GRINS-0.6.0
axisym_boussinesq_buoyancy.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"
31 #include "grins/grins_enums.h"
32 
33 // libMesh
34 #include "libmesh/utility.h"
35 #include "libmesh/string_to_enum.h"
36 #include "libmesh/getpot.h"
37 #include "libmesh/fem_system.h"
38 #include "libmesh/quadrature.h"
39 
40 namespace GRINS
41 {
42 
44  const GetPot& input )
45  : Physics(physics_name, input)
46  {
47  this->read_input_options(input);
48  return;
49  }
50 
52  {
53  return;
54  }
55 
57  {
58  this->_T_FE_family =
59  libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>( input("Physics/"+axisymmetric_heat_transfer+"/FE_family", "LAGRANGE") );
60 
61  this->_T_order =
62  libMesh::Utility::string_to_enum<GRINSEnums::Order>( input("Physics/"+axisymmetric_heat_transfer+"/T_order", "SECOND") );
63 
64  this->_V_FE_family =
65  libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>( input("Physics/"+incompressible_navier_stokes+"/FE_family", "LAGRANGE") );
66 
67  this->_V_order =
68  libMesh::Utility::string_to_enum<GRINSEnums::Order>( input("Physics/"+incompressible_navier_stokes+"/V_order", "SECOND") );
69 
70  // Read variable naming info
71  this->_u_r_var_name = input("Physics/VariableNames/r_velocity", u_r_var_name_default );
72  this->_u_z_var_name = input("Physics/VariableNames/z_velocity", u_z_var_name_default );
73  this->_T_var_name = input("Physics/VariableNames/Temperature", T_var_name_default );
74 
75  this->set_parameter
76  (_rho_ref, input,
77  "Physics/"+axisymmetric_boussinesq_buoyancy+"/rho_ref", 1.0);
78 
79  this->set_parameter
80  (_T_ref, input, "Physics/"+axisymmetric_boussinesq_buoyancy+"/T_ref", 1.0);
81 
82  this->set_parameter
83  (_beta_T, input, "Physics/"+axisymmetric_boussinesq_buoyancy+"/beta_T", 1.0);
84 
85  _g(0) = input("Physics/"+axisymmetric_boussinesq_buoyancy+"/g", 0.0, 0 );
86  _g(1) = input("Physics/"+axisymmetric_boussinesq_buoyancy+"/g", 0.0, 1 );
87 
88  return;
89  }
90 
91  void AxisymmetricBoussinesqBuoyancy::init_variables( libMesh::FEMSystem* system )
92  {
93  this->_dim = system->get_mesh().mesh_dimension();
94 
95  _u_r_var = system->add_variable(_u_r_var_name, _V_order, _V_FE_family);
96  _u_z_var = system->add_variable(_u_z_var_name, _V_order, _V_FE_family);
97  _T_var = system->add_variable(_T_var_name, _T_order, _T_FE_family);
98  return;
99  }
100 
102  AssemblyContext& context,
103  CachedValues& /*cache*/ )
104  {
105 #ifdef GRINS_USE_GRVY_TIMERS
106  this->_timer->BeginTimer("AxisymmetricBoussinesqBuoyancy::element_time_derivative");
107 #endif
108 
109  // The number of local degrees of freedom in each variable.
110  const unsigned int n_u_dofs = context.get_dof_indices(_u_r_var).size();
111  const unsigned int n_T_dofs = context.get_dof_indices(_T_var).size();
112 
113  // Element Jacobian * quadrature weights for interior integration.
114  const std::vector<libMesh::Real> &JxW =
115  context.get_element_fe(_u_r_var)->get_JxW();
116 
117  // The velocity shape functions at interior quadrature points.
118  const std::vector<std::vector<libMesh::Real> >& vel_phi =
119  context.get_element_fe(_u_r_var)->get_phi();
120 
121  // The temperature shape functions at interior quadrature points.
122  const std::vector<std::vector<libMesh::Real> >& T_phi =
123  context.get_element_fe(_T_var)->get_phi();
124 
125  // Physical location of the quadrature points
126  const std::vector<libMesh::Point>& u_qpoint =
127  context.get_element_fe(_u_r_var)->get_xyz();
128 
129  // Get residuals
130  libMesh::DenseSubVector<libMesh::Number> &Fr = context.get_elem_residual(_u_r_var); // R_{r}
131  libMesh::DenseSubVector<libMesh::Number> &Fz = context.get_elem_residual(_u_z_var); // R_{z}
132 
133  // Get Jacobians
134  libMesh::DenseSubMatrix<libMesh::Number> &KrT = context.get_elem_jacobian(_u_r_var, _T_var); // R_{r},{T}
135  libMesh::DenseSubMatrix<libMesh::Number> &KzT = context.get_elem_jacobian(_u_z_var, _T_var); // R_{z},{T}
136 
137  // Now we will build the element Jacobian and residual.
138  // Constructing the residual requires the solution and its
139  // gradient from the previous timestep. This must be
140  // calculated at each quadrature point by summing the
141  // solution degree-of-freedom values by the appropriate
142  // weight functions.
143  unsigned int n_qpoints = context.get_element_qrule().n_points();
144 
145  for (unsigned int qp=0; qp != n_qpoints; qp++)
146  {
147  const libMesh::Number r = u_qpoint[qp](0);
148 
149  // Compute the solution & its gradient at the old Newton iterate.
150  libMesh::Number T;
151  T = context.interior_value(_T_var, qp);
152 
153  // First, an i-loop over the velocity degrees of freedom.
154  // We know that n_u_dofs == n_v_dofs so we can compute contributions
155  // for both at the same time.
156  for (unsigned int i=0; i != n_u_dofs; i++)
157  {
158  Fr(i) += -_rho_ref*_beta_T*(T - _T_ref)*_g(0)*vel_phi[i][qp]*r*JxW[qp];
159  Fz(i) += -_rho_ref*_beta_T*(T - _T_ref)*_g(1)*vel_phi[i][qp]*r*JxW[qp];
160 
161  if (compute_jacobian && context.get_elem_solution_derivative())
162  {
163  for (unsigned int j=0; j != n_T_dofs; j++)
164  {
165  const libMesh::Number val =
166  -_rho_ref*_beta_T*vel_phi[i][qp]*T_phi[j][qp]*r*JxW[qp]
167  * context.get_elem_solution_derivative();
168  KrT(i,j) += val*_g(0);
169  KzT(i,j) += val*_g(1);
170  } // End j dof loop
171  } // End compute_jacobian check
172 
173  } // End i dof loop
174  } // End quadrature loop
175 
176 #ifdef GRINS_USE_GRVY_TIMERS
177  this->_timer->EndTimer("AxisymmetricBoussinesqBuoyancy::element_time_derivative");
178 #endif
179 
180  return;
181  }
182 
183 } // namespace GRINS
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.
const PhysicsName incompressible_navier_stokes
GRINSEnums::Order _T_order
Temperature element order, read from input.
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
Definition: physics.h:106
const PhysicsName axisymmetric_heat_transfer
std::string _u_r_var_name
Name of r-velocity.
libMesh::Number _rho_ref
reference density
virtual void read_input_options(const GetPot &input)
Read options from GetPot input file.
GRINS namespace.
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Source term contribution for AxisymmetricBoussinesqBuoyancy.
VariableIndex _T_var
Index for temperature field.
const std::string T_var_name_default
temperature
VariableIndex _u_z_var
Index for z-velocity field.
virtual void init_variables(libMesh::FEMSystem *system)
Initialization of AxisymmetricBoussinesqBuoyancy variables.
std::string _T_var_name
Name of temperature.
VariableIndex _u_r_var
Index for r-velocity field.
libMesh::Point _g
Gravitational vector.
const std::string u_z_var_name_default
z-velocity (axisymmetric case)
libMesh::Number _T_ref
reference temperature
const PhysicsName axisymmetric_boussinesq_buoyancy
std::string _u_z_var_name
Name of z-velocity.
libMesh::Number _beta_T
coefficient of thermal expansion
unsigned int _dim
Physical dimension of problem.
const std::string u_r_var_name_default
r-velocity (axisymmetric case)
GRINSEnums::FEFamily _T_FE_family
Element type, read from input.

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