14 #include "MooseMesh.h"
15 #include "MooseVariable.h"
16 #include "NonlinearSystem.h"
18 #include "libmesh/quadrature.h"
26 params.addParam<std::string>(
"base_name",
27 "Optional parameter that allows the user to define "
28 "multiple mechanics material systems on the same "
29 "block, i.e. for multiple phases");
30 params.addRequiredParam<std::vector<VariableName>>(
32 "The displacements appropriate for the simulation geometry and coordinate system");
33 params.addCoupledVar(
"youngs_modulus",
"Variable containing Young's modulus");
38 : Material(parameters),
39 _base_name(isParamValid(
"base_name") ? getParam<std::string>(
"base_name") +
"_" :
""),
40 _youngs_modulus(coupledValue(
"youngs_modulus")),
41 _total_stretch(declareProperty<Real>(_base_name +
"total_stretch")),
42 _elastic_stretch(declareProperty<Real>(_base_name +
"elastic_stretch")),
43 _axial_stress(declareProperty<Real>(_base_name +
"axial_stress")),
44 _e_over_l(declareProperty<Real>(_base_name +
"e_over_l"))
46 const std::vector<VariableName> & nl_vnames(getParam<std::vector<VariableName>>(
"displacements"));
50 for (
unsigned int i = 0; i <
_ndisp; ++i)
51 _disp_var.push_back(&_fe_problem.getStandardVariable(_tid, nl_vnames[i]));
66 mooseAssert(_current_elem->n_nodes() == 2,
"Truss element needs to have exactly two nodes.");
69 std::vector<const Node *> node;
70 for (
unsigned int i = 0; i < 2; ++i)
71 node.push_back(_current_elem->node_ptr(i));
75 for (
unsigned int i = 0; i <
_ndisp; ++i)
76 dxyz(i) = (*node[1])(i) - (*node[0])(i);
80 NonlinearSystemBase & nonlinear_sys = _fe_problem.getNonlinearSystemBase();
81 const NumericVector<Number> & sol = *nonlinear_sys.currentSolution();
83 std::vector<Real> disp0, disp1;
84 for (
unsigned int i = 0; i <
_ndisp; ++i)
86 disp0.push_back(sol(node[0]->dof_number(nonlinear_sys.number(),
_disp_var[i]->number(), 0)));
87 disp1.push_back(sol(node[1]->dof_number(nonlinear_sys.number(),
_disp_var[i]->number(), 0)));
91 for (
unsigned int i = 0; i <
_ndisp; ++i)
92 dxyz(i) += disp1[i] - disp0[i];
95 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)