15 #include "MooseVariable.h"
16 #include "SystemBase.h"
26 params.addClassDescription(
"Kernel for truss element");
27 params.addRequiredParam<
unsigned int>(
"component",
28 "An integer corresponding to the direction "
29 "the variable this kernel acts in. (0 for x, "
31 params.addCoupledVar(
"displacements",
32 "The string of displacements suitable for the problem statement");
33 params.addCoupledVar(
"temperature",
"The temperature");
34 params.addCoupledVar(
"area",
"Cross-sectional area of truss element");
35 params.addParam<std::string>(
"base_name",
"Material property base name");
36 params.set<
bool>(
"use_displaced_mesh") =
true;
42 _base_name(isParamValid(
"base_name") ? getParam<std::string>(
"base_name") +
"_" :
""),
43 _axial_stress(getMaterialPropertyByName<Real>(_base_name +
"axial_stress")),
44 _e_over_l(getMaterialPropertyByName<Real>(_base_name +
"e_over_l")),
45 _component(getParam<unsigned int>(
"component")),
46 _ndisp(coupledComponents(
"displacements")),
47 _temp_coupled(isCoupled(
"temperature")),
48 _temp_var(_temp_coupled ? coupled(
"temperature") : 0),
49 _area(coupledValue(
"area")),
52 for (
unsigned int i = 0; i <
_ndisp; ++i)
53 _disp_var.push_back(coupled(
"displacements", i));
59 _orientation = &_subproblem.assembly(_tid).getFE(FEType(), 1)->get_dxyzdxi();
65 prepareVectorTag(_assembly, _var.number());
67 mooseAssert(_local_re.size() == 2,
"Truss element has and only has two nodes.");
70 orientation /= orientation.norm();
75 _local_re(1) = -_local_re(0);
77 accumulateTaggedLocalResidual();
81 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
82 for (
unsigned int i = 0; i < _save_in.size(); ++i)
83 _save_in[i]->sys().solution().add_vector(_local_re, _save_in[i]->dofIndices());
91 orientation /= orientation.norm();
99 prepareMatrixTag(_assembly, _var.number(), _var.number());
101 for (
unsigned int i = 0; i < _test.size(); ++i)
102 for (
unsigned int j = 0; j < _phi.size(); ++j)
105 accumulateTaggedLocalMatrix();
107 if (_has_diag_save_in)
109 unsigned int rows = _local_ke.m();
110 DenseVector<Number> diag(rows);
111 for (
unsigned int i = 0; i < rows; ++i)
112 diag(i) = _local_ke(i, i);
114 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
115 for (
unsigned int i = 0; i < _diag_save_in.size(); ++i)
116 _diag_save_in[i]->sys().solution().add_vector(diag, _diag_save_in[i]->dofIndices());
123 size_t jvar_num = jvar.number();
124 if (jvar_num == _var.number())
130 auto phi_size = _sys.getVariable(_tid, jvar.number()).dofIndices().size();
132 unsigned int coupled_component = 0;
133 bool disp_coupled =
false;
135 for (
unsigned int i = 0; i <
_ndisp; ++i)
138 coupled_component = i;
145 prepareMatrixTag(_assembly, _var.number(), jvar_num);
147 for (
unsigned int i = 0; i < _test.size(); ++i)
148 for (
unsigned int j = 0; j < phi_size; ++j)
151 accumulateTaggedLocalMatrix();