www.mooseframework.org
TrussMaterial.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "TrussMaterial.h"
9 
10 // MOOSE includes
11 #include "Material.h"
12 #include "MooseMesh.h"
13 #include "MooseVariable.h"
14 #include "NonlinearSystem.h"
15 
16 #include "libmesh/quadrature.h"
17 
18 template <>
19 InputParameters
21 {
22  InputParameters params = validParams<Material>();
23  params.addParam<std::string>("base_name",
24  "Optional parameter that allows the user to define "
25  "multiple mechanics material systems on the same "
26  "block, i.e. for multiple phases");
27  params.addRequiredParam<std::vector<NonlinearVariableName>>(
28  "displacements",
29  "The displacements appropriate for the simulation geometry and coordinate system");
30  params.addCoupledVar("youngs_modulus", "Variable containing Young's modulus");
31  return params;
32 }
33 
34 TrussMaterial::TrussMaterial(const InputParameters & parameters)
35  : Material(parameters),
36  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
37  _youngs_modulus(coupledValue("youngs_modulus")),
38  _total_stretch(declareProperty<Real>(_base_name + "total_stretch")),
39  _elastic_stretch(declareProperty<Real>(_base_name + "elastic_stretch")),
40  _axial_stress(declareProperty<Real>(_base_name + "axial_stress")),
41  _e_over_l(declareProperty<Real>(_base_name + "e_over_l"))
42 {
43  const std::vector<NonlinearVariableName> & nl_vnames(
44  getParam<std::vector<NonlinearVariableName>>("displacements"));
45  _ndisp = nl_vnames.size();
46 
47  // fetch nonlinear variables
48  for (unsigned int i = 0; i < _ndisp; ++i)
49  _disp_var.push_back(&_fe_problem.getVariable(_tid, nl_vnames[i]));
50 }
51 
52 void
54 {
55  _axial_stress[_qp] = 0.0;
56  _total_stretch[_qp] = 0.0;
57  _elastic_stretch[_qp] = 0.0;
58 }
59 
60 void
62 {
63  // check for consistency of the number of element nodes
64  mooseAssert(_current_elem->n_nodes() == 2, "Truss element needs to have exactly two nodes.");
65 
66  // fetch the two end nodes for _current_elem
67  std::vector<Node *> node;
68  for (unsigned int i = 0; i < 2; ++i)
69  node.push_back(_current_elem->get_node(i));
70 
71  // calculate original length of a truss element
72  RealGradient dxyz;
73  for (unsigned int i = 0; i < _ndisp; ++i)
74  dxyz(i) = (*node[1])(i) - (*node[0])(i);
75  _origin_length = dxyz.norm();
76 
77  // fetch the solution for the two end nodes
78  NonlinearSystemBase & nonlinear_sys = _fe_problem.getNonlinearSystemBase();
79  const NumericVector<Number> & sol = *nonlinear_sys.currentSolution();
80 
81  std::vector<Real> disp0, disp1;
82  for (unsigned int i = 0; i < _ndisp; ++i)
83  {
84  disp0.push_back(sol(node[0]->dof_number(nonlinear_sys.number(), _disp_var[i]->number(), 0)));
85  disp1.push_back(sol(node[1]->dof_number(nonlinear_sys.number(), _disp_var[i]->number(), 0)));
86  }
87 
88  // calculate current length of a truss element
89  for (unsigned int i = 0; i < _ndisp; ++i)
90  dxyz(i) += disp1[i] - disp0[i];
91  _current_length = dxyz.norm();
92 
93  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
94  {
96 
99  }
100 }
Real _current_length
Definition: TrussMaterial.h:43
TrussMaterial(const InputParameters &parameters)
Definition: TrussMaterial.C:34
std::vector< MooseVariable * > _disp_var
Definition: TrussMaterial.h:30
MaterialProperty< Real > & _total_stretch
Definition: TrussMaterial.h:37
const VariableValue & _youngs_modulus
Definition: TrussMaterial.h:35
unsigned int _ndisp
Definition: TrussMaterial.h:34
MaterialProperty< Real > & _elastic_stretch
Definition: TrussMaterial.h:38
virtual void computeQpStrain()=0
MaterialProperty< Real > & _e_over_l
Definition: TrussMaterial.h:40
virtual void computeProperties()
Definition: TrussMaterial.C:61
MaterialProperty< Real > & _axial_stress
Definition: TrussMaterial.h:39
InputParameters validParams< TrussMaterial >()
Definition: TrussMaterial.C:20
virtual void initQpStatefulProperties()
Definition: TrussMaterial.C:53
virtual void computeQpStress()=0