GRINS-0.7.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-2016 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  : ElasticCableAbstract(physics_name,input)
42  {
43  int num_gravity = input.vector_variable_size("Physics/"+physics_name+"/gravity");
44  if (num_gravity != 3)
45  {
46  std::cerr << "Error: Must input three values for "+physics_name+" gravity." << std::endl
47  << " Please set Physics/"+physics_name+"/gravity." << std::endl;
48  libmesh_error();
49  }
50  for( int i = 0; i < num_gravity; i++ )
51  {
52  _gravity(i)=( input("Physics/"+physics_name+"/gravity", 0.0 , i ) );
53  }
54 
55  return;
56  }
57 
59  {
60  return;
61  }
62 
63 
65  AssemblyContext& context,
66  CachedValues& /*cache*/ )
67  {
68  const unsigned int n_u_dofs = context.get_dof_indices(_disp_vars.u()).size();
69 
70  const std::vector<libMesh::Real> &JxW = this->get_fe(context)->get_JxW();
71 
72  const std::vector<std::vector<libMesh::Real> >& u_phi = this->get_fe(context)->get_phi();
73 
74  libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(_disp_vars.u());
75  libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(_disp_vars.v());
76  libMesh::DenseSubVector<libMesh::Number> &Fw = context.get_elem_residual(_disp_vars.w());
77 
78  unsigned int n_qpoints = context.get_element_qrule().n_points();
79 
80  for (unsigned int qp=0; qp != n_qpoints; qp++)
81  {
82  libMesh::Real jac = JxW[qp];
83 
84  for (unsigned int i=0; i != n_u_dofs; i++)
85  {
86  Fu(i) -= _gravity(0)*_A*_rho*u_phi[i][qp]*jac;
87 
88  Fv(i) -= _gravity(1)*_A*_rho*u_phi[i][qp]*jac;
89 
90  Fw(i) -= _gravity(2)*_A*_rho*u_phi[i][qp]*jac;
91  }
92  }
93 
94  return;
95  }
96 } // end namespace GRINS
libMesh::Real _rho
Cable density.
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors.
GRINS namespace.
std::string PhysicsName
libMesh::Real _A
Cross-sectional area of the cable.
const libMesh::FEGenericBase< libMesh::Real > * get_fe(const AssemblyContext &context)

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