www.mooseframework.org
DisplacementAboutAxis.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "DisplacementAboutAxis.h"
11 #include "Function.h"
12 
13 registerMooseObject("SolidMechanicsApp", DisplacementAboutAxis);
14 
17 {
19  params.addClassDescription("Implements a boundary condition that enforces rotational"
20  "displacement around an axis on a boundary");
22  params.addRequiredParam<int>("component", "The component for the rotational displacement");
23  params.set<bool>("use_displaced_mesh") = false;
24  params.set<bool>("preset") = true;
25  return params;
26 }
27 
28 void
30 {
31  MooseEnum units("degrees radians");
32  params.addRequiredParam<FunctionName>(
33  "function", "The function providing the total angle of rotation or the angular velocity.");
34  params.addRequiredParam<MooseEnum>("angle_units",
35  units,
36  "The units of the angle of rotation. Choices are:" +
37  units.getRawNames());
38  params.addRequiredParam<RealVectorValue>("axis_origin", "Origin of the axis of rotation");
39  params.addRequiredParam<RealVectorValue>("axis_direction", "Direction of the axis of rotation");
40  params.addParam<bool>(
41  "angular_velocity", false, "If true interprets the function value as an angular velocity");
42  params.addRequiredCoupledVar("displacements",
43  "The string of displacements suitable for the problem statement");
44 }
45 
47  : DirichletBCBase(parameters),
48  _component(getParam<int>("component")),
49  _func(getFunction("function")),
50  _angle_units(getParam<MooseEnum>("angle_units")),
51  _axis_origin(getParam<RealVectorValue>("axis_origin")),
52  _axis_direction(getParam<RealVectorValue>("axis_direction")),
53  _ndisp(coupledComponents("displacements")),
54  _disp_old(_ndisp),
55  _angular_velocity(getParam<bool>("angular_velocity"))
56 {
57  if (_component < 0 || _component > 2)
58  mooseError("Invalid component given for ", name(), ": ", _component, ".");
59 
60  if (_axis_direction.norm() == 0.)
61  mooseError("Please specify a non-zero direction vector for the axis_direction in ", name());
62 }
63 
64 void
66 {
69 
71  for (unsigned int i = 0; i < _ndisp; ++i)
72  _disp_old[i] = &coupledDofValuesOld("displacements", i);
73  else
74  for (unsigned int i = 0; i < _ndisp; ++i)
75  _disp_old[i] = nullptr;
76 }
77 
78 Real
80 {
81  Point p(*_current_node);
82 
83  Real angle(_func.value(_t, *_current_node));
84  if (_angle_units == "degrees")
85  angle = angle * libMesh::pi / 180.0;
86 
88  angle *= _dt;
89 
90  ColumnMajorMatrix p_old(4, 1);
91  p_old(0, 0) = p(0);
92  p_old(1, 0) = p(1);
93  p_old(2, 0) = p(2);
94  p_old(3, 0) = 1;
95 
97  for (unsigned int i = 0; i < _ndisp; i++)
98  p_old(i, 0) += (*_disp_old[i])[_qp];
99 
100  ColumnMajorMatrix p_new = rotateAroundAxis(p_old, angle);
101 
102  return p_new(_component, 0) - p(_component);
103 }
104 
107 {
108  ColumnMajorMatrix rotate_about_z(4, 4);
109  rotate_about_z(0, 0) = cos(angle);
110  rotate_about_z(0, 1) = -sin(angle);
111  rotate_about_z(0, 2) = 0;
112  rotate_about_z(0, 3) = 0;
113  rotate_about_z(1, 0) = sin(angle);
114  rotate_about_z(1, 1) = cos(angle);
115  rotate_about_z(1, 2) = 0;
116  rotate_about_z(1, 3) = 0;
117  rotate_about_z(2, 0) = 0;
118  rotate_about_z(2, 1) = 0;
119  rotate_about_z(2, 2) = 1;
120  rotate_about_z(2, 3) = 0;
121  rotate_about_z(3, 0) = 0;
122  rotate_about_z(3, 1) = 0;
123  rotate_about_z(3, 2) = 0;
124  rotate_about_z(3, 3) = 1;
125 
126  ColumnMajorMatrix transform =
128  return transform * p0;
129 }
130 
131 void
133 {
134  Real magnitude = _axis_direction.norm();
135  _axis_direction /= magnitude;
136 }
137 
138 void
140 {
141  // These parts of the transformation matrix only depend on the axis of rotation:
142 
143  Real length = _axis_direction.norm_sq();
145 
146  ColumnMajorMatrix transl(4, 4);
147  transl(0, 0) = 1;
148  transl(0, 1) = 0;
149  transl(0, 2) = 0;
150  transl(0, 3) = -_axis_origin(0);
151  transl(1, 0) = 0;
152  transl(1, 1) = 1;
153  transl(1, 2) = 0;
154  transl(1, 3) = -_axis_origin(1);
155  transl(2, 0) = 0;
156  transl(2, 1) = 0;
157  transl(2, 2) = 1;
158  transl(2, 3) = -_axis_origin(2);
159  transl(3, 0) = 0;
160  transl(3, 1) = 0;
161  transl(3, 2) = 0;
162  transl(3, 3) = 1;
163 
164  ColumnMajorMatrix rotate_about_x(4, 4);
165  rotate_about_x(0, 0) = 1;
166  rotate_about_x(0, 1) = 0;
167  rotate_about_x(0, 2) = 0;
168  rotate_about_x(0, 3) = 0;
169  rotate_about_x(1, 0) = 0;
170  rotate_about_x(1, 1) = _axis_direction(2) / v;
171  rotate_about_x(1, 2) = -_axis_direction(1) / v;
172  rotate_about_x(1, 3) = 0;
173  rotate_about_x(2, 0) = 0;
174  rotate_about_x(2, 1) = _axis_direction(1) / v;
175  rotate_about_x(2, 2) = _axis_direction(2) / v;
176  rotate_about_x(2, 3) = 0;
177  rotate_about_x(3, 0) = 0;
178  rotate_about_x(3, 1) = 0;
179  rotate_about_x(3, 2) = 0;
180  rotate_about_x(3, 3) = 1;
181 
182  ColumnMajorMatrix rotate_about_y(4, 4);
183  rotate_about_y(0, 0) = v / length;
184  rotate_about_y(0, 1) = 0;
185  rotate_about_y(0, 2) = -_axis_direction(0) / length;
186  rotate_about_y(0, 3) = 0;
187  rotate_about_y(1, 0) = 0;
188  rotate_about_y(1, 1) = 1;
189  rotate_about_y(1, 2) = 0;
190  rotate_about_y(1, 3) = 0;
191  rotate_about_y(2, 0) = _axis_direction(0) / length;
192  rotate_about_y(2, 1) = 0;
193  rotate_about_y(2, 2) = v / length;
194  rotate_about_y(2, 3) = 0;
195  rotate_about_y(3, 0) = 0;
196  rotate_about_y(3, 1) = 0;
197  rotate_about_y(3, 2) = 0;
198  rotate_about_y(3, 3) = 1;
199 
200  ColumnMajorMatrix transl_inv(4, 4);
201  transl.inverse(transl_inv);
202  ColumnMajorMatrix rotx_inv(4, 4);
203  rotate_about_x.inverse(rotx_inv);
204  ColumnMajorMatrix roty_inv(4, 4);
205  rotate_about_y.inverse(roty_inv);
206 
207  _transformation_matrix = rotate_about_y * rotate_about_x * transl;
208  _transformation_matrix_inv = transl_inv * rotx_inv * roty_inv;
209 }
void inverse(ColumnMajorMatrixTempl< Real > &invA) const
const unsigned int _ndisp
number of displacement components
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
virtual Real computeQpValue()
Evaluate the boundary condition at the current quadrature point and timestep.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const bool _angular_velocity
flag for incremental formulation
DisplacementAboutAxis(const InputParameters &parameters)
virtual const VariableValue & coupledDofValuesOld(const std::string &var_name, unsigned int comp=0) const
const Node *const & _current_node
T & set(const std::string &name, bool quiet_mode=false)
ColumnMajorMatrix _transformation_matrix
std::string getRawNames() const
const unsigned int _qp
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
std::vector< const VariableValue * > _disp_old
the old displacement value
void calculateTransformationMatrices()
Calculate the rotation about the x and y axes based on the provided axis direction vector at the star...
static InputParameters validParams()
void calculateUnitDirectionVector()
Check if the provided axis direction vector is a unit vector and normalizes the vector if necessary d...
void addDisplacementAboutAxisParams(InputParameters &params)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
ColumnMajorMatrix _transformation_matrix_inv
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Implements a boundary condition that enforces rotational displacement around an axis on a boundary...
static const std::string v
Definition: NS.h:82
void mooseError(Args &&... args) const
registerMooseObject("SolidMechanicsApp", DisplacementAboutAxis)
void addClassDescription(const std::string &doc_string)
virtual Real value(Real t, const Point &p) const
ColumnMajorMatrix rotateAroundAxis(const ColumnMajorMatrix &p0, const Real angle)
Calculate the tranformation matrix to rotate in x, y, and z depends on the prescribed BC angle and th...
void ErrorVector unsigned int
const Real pi