GRINS-0.6.0
elastic_cable_constant_gravity.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_config.h"
30 #include "grins/assembly_context.h"
31 
32 // libMesh
33 #include "libmesh/getpot.h"
34 #include "libmesh/quadrature.h"
35 #include "libmesh/boundary_info.h"
36 #include "libmesh/fem_system.h"
37 
38 namespace GRINS
39 {
41  : ElasticCableBase(physics_name,input),
42  _A(1.0),
43  _rho(1.0)
44  {
45  if( !input.have_variable("Physics/"+physics_name+"/A") )
46  {
47  std::cerr << "Error: Must input area for "+physics_name+"." << std::endl
48  << " Please set Physics/"+physics_name+"/A." << std::endl;
49  libmesh_error();
50  }
51 
52  this->set_parameter
53  (_A, input, "Physics/"+physics_name+"/A", _A );
54 
55  if( !input.have_variable("Physics/"+physics_name+"/rho") )
56  {
57  std::cerr << "Error: Must input density for "+physics_name+"." << std::endl
58  << " Please set Physics/"+physics_name+"/rho." << std::endl;
59  libmesh_error();
60  }
61 
62  this->set_parameter
63  (_rho, input, "Physics/"+physics_name+"/rho", _rho );
64 
65  int num_gravity = input.vector_variable_size("Physics/"+physics_name+"/gravity");
66  if (num_gravity != 3)
67  {
68  std::cerr << "Error: Must input three values for "+physics_name+" gravity." << std::endl
69  << " Please set Physics/"+physics_name+"/gravity." << std::endl;
70  libmesh_error();
71  }
72  for( int i = 0; i < num_gravity; i++ )
73  {
74  _gravity(i)=( input("Physics/"+physics_name+"/gravity", 0.0 , i ) );
75  }
76 
77  return;
78  }
79 
81  {
82  return;
83  }
84 
85 
87  AssemblyContext& context,
88  CachedValues& /*cache*/ )
89  {
90  const unsigned int n_u_dofs = context.get_dof_indices(_disp_vars.u_var()).size();
91 
92  const std::vector<libMesh::Real> &JxW = this->get_fe(context)->get_JxW();
93 
94  const std::vector<std::vector<libMesh::Real> >& u_phi = this->get_fe(context)->get_phi();
95 
96  libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(_disp_vars.u_var());
97  libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(_disp_vars.v_var());
98  libMesh::DenseSubVector<libMesh::Number> &Fw = context.get_elem_residual(_disp_vars.w_var());
99 
100  unsigned int n_qpoints = context.get_element_qrule().n_points();
101 
102  for (unsigned int qp=0; qp != n_qpoints; qp++)
103  {
104  libMesh::Real jac = JxW[qp];
105 
106  for (unsigned int i=0; i != n_u_dofs; i++)
107  {
108  Fu(i) += _gravity(0)*_A*_rho*u_phi[i][qp]*jac;
109 
110  Fv(i) += _gravity(1)*_A*_rho*u_phi[i][qp]*jac;
111 
112  Fw(i) += _gravity(2)*_A*_rho*u_phi[i][qp]*jac;
113  }
114  }
115 
116  return;
117  }
118 } // end 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.
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors.
SolidMechanicsFEVariables _disp_vars
GRINS namespace.
const libMesh::FEGenericBase< libMesh::Real > * get_fe(const AssemblyContext &context)
std::string PhysicsName

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