11 #include "NonlinearSystem.h"
19 InputParameters params = validParams<NodalUserObject>();
20 params.addRequiredParam<std::string>(
"subspace_name",
21 "FEProblemBase subspace containing rigid body mode vectors");
22 params.addParam<std::vector<unsigned int>>(
24 std::vector<unsigned int>(),
25 "Indices of FEProblemBase subspace vectors containing rigid body modes");
26 params.addParam<std::vector<std::string>>(
"modes",
27 std::vector<std::string>(),
28 "Names of the RigidBody3D modes computed here. Select "
29 "from: trans_x, trans_y, trans_z, rot_x, rot_y, rot_z");
30 params.addRequiredCoupledVar(
"disp_x",
"x-displacement");
31 params.addRequiredCoupledVar(
"disp_y",
"y-displacement");
32 params.addRequiredCoupledVar(
"disp_z",
"z-displacement");
55 : NodalUserObject(parameters),
56 _subspace_name(parameters.get<std::string>(
"subspace_name")),
57 _subspace_indices(parameters.get<std::vector<unsigned int>>(
"subspace_indices")),
58 _modes(parameters.get<std::vector<std::string>>(
"modes").begin(),
59 parameters.get<std::vector<std::string>>(
"modes").end()),
60 _disp_x_i(coupled(
"disp_x")),
61 _disp_y_i(coupled(
"disp_y")),
62 _disp_z_i(coupled(
"disp_z"))
64 const char * all_modes_array[6] = {
"trans_x",
"trans_y",
"trans_z",
"rot_x",
"rot_y",
"rot_z"};
65 std::set<std::string> all_modes(all_modes_array, all_modes_array + 6);
70 std::stringstream err;
71 err <<
"Expected between 0 and 6 rigid body modes, got " <<
_modes.size() <<
" instead\n";
72 mooseError(err.str());
74 for (std::set<std::string>::const_iterator it =
_modes.begin(); it !=
_modes.end(); ++it)
76 if (all_modes.find(*it) == all_modes.end())
78 std::stringstream err;
79 err <<
"Invalid 3D rigid body mode " << *it <<
"; must be one of: ";
80 for (std::set<std::string>::iterator it = all_modes.begin(); it != all_modes.end(); ++it)
82 if (it != all_modes.begin())
87 mooseError(err.str());
94 for (
unsigned int i = 0; i < _fe_problem.subspaceDim(
_subspace_name); ++i)
99 std::stringstream err;
101 <<
" must match the number or rigid body modes " <<
_modes.size() <<
"\n";
102 mooseError(err.str());
107 unsigned int subspace_dim = _fe_problem.subspaceDim(
_subspace_name);
110 std::stringstream err;
112 <<
"; must be < " << _fe_problem.subspaceDim(
_subspace_name) <<
"\n";
113 mooseError(err.str());
123 NonlinearSystemBase & nl = _fe_problem.getNonlinearSystemBase();
124 const Node & node = *_current_node;
127 if (
_modes.count(
"trans_x"))
129 std::stringstream postfix;
131 NumericVector<Number> & mode = nl.getVector(
_subspace_name + postfix.str());
132 unsigned int xdof = node.dof_number(nl.number(),
_disp_x_i, 0);
134 unsigned int ydof = node.dof_number(nl.number(),
_disp_y_i, 0);
136 unsigned int zdof = node.dof_number(nl.number(),
_disp_z_i, 0);
140 if (
_modes.count(
"trans_y"))
142 std::stringstream postfix;
144 NumericVector<Number> & mode = nl.getVector(
_subspace_name + postfix.str());
145 unsigned int xdof = node.dof_number(nl.number(),
_disp_x_i, 0);
147 unsigned int ydof = node.dof_number(nl.number(),
_disp_y_i, 0);
149 unsigned int zdof = node.dof_number(nl.number(),
_disp_z_i, 0);
153 if (
_modes.count(
"trans_z"))
155 std::stringstream postfix;
157 NumericVector<Number> & mode = nl.getVector(
_subspace_name + postfix.str());
158 unsigned int xdof = node.dof_number(nl.number(),
_disp_x_i, 0);
160 unsigned int ydof = node.dof_number(nl.number(),
_disp_y_i, 0);
162 unsigned int zdof = node.dof_number(nl.number(),
_disp_z_i, 0);
166 if (
_modes.count(
"rot_x"))
168 std::stringstream postfix;
170 NumericVector<Number> & mode = nl.getVector(
_subspace_name + postfix.str());
171 Real y = node(1), z = node(2);
172 unsigned int xdof = node.dof_number(nl.number(),
_disp_x_i, 0);
174 unsigned int ydof = node.dof_number(nl.number(),
_disp_y_i, 0);
176 unsigned int zdof = node.dof_number(nl.number(),
_disp_z_i, 0);
180 if (
_modes.count(
"rot_y"))
182 std::stringstream postfix;
184 NumericVector<Number> & mode = nl.getVector(
_subspace_name + postfix.str());
185 Real x = node(0), z = node(2);
186 unsigned int xdof = node.dof_number(nl.number(),
_disp_x_i, 0);
188 unsigned int ydof = node.dof_number(nl.number(),
_disp_y_i, 0);
190 unsigned int zdof = node.dof_number(nl.number(),
_disp_z_i, 0);
194 if (
_modes.count(
"rot_z"))
196 std::stringstream postfix;
198 NumericVector<Number> & mode = nl.getVector(
_subspace_name + postfix.str());
199 Real x = node(0), y = node(1);
200 unsigned int xdof = node.dof_number(nl.number(),
_disp_x_i, 0);
202 unsigned int ydof = node.dof_number(nl.number(),
_disp_y_i, 0);
204 unsigned int zdof = node.dof_number(nl.number(),
_disp_z_i, 0);
213 NonlinearSystemBase & nl = _fe_problem.getNonlinearSystemBase();
216 std::stringstream postfix;
218 NumericVector<Number> & mode = nl.getVector(
_subspace_name + postfix.str());