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("TensorMechanicsApp", DisplacementAboutAxis);
14 
16 
17 InputParameters
19 {
20  InputParameters params = DirichletBCBase::validParams();
21  params.addClassDescription("Implements a boundary condition that enforces rotational"
22  "displacement around an axis on a boundary");
24  params.addRequiredParam<int>("component", "The component for the rotational displacement");
25  params.set<bool>("use_displaced_mesh") = true;
26  params.set<bool>("preset") = true;
27  return params;
28 }
29 
30 void
31 addDisplacementAboutAxisParams(InputParameters & params)
32 {
33  MooseEnum units("degrees radians");
34  params.addRequiredParam<FunctionName>("function",
35  "The function providing the angle of rotation.");
36  params.addRequiredParam<MooseEnum>("angle_units",
37  units,
38  "The units of the angle of rotation. Choices are:" +
39  units.getRawNames());
40  params.addRequiredParam<RealVectorValue>("axis_origin", "Origin of the axis of rotation");
41  params.addRequiredParam<RealVectorValue>("axis_direction", "Direction of the axis of rotation");
42 }
43 
44 DisplacementAboutAxis::DisplacementAboutAxis(const InputParameters & parameters)
45  : DirichletBCBase(parameters),
46  _component(getParam<int>("component")),
47  _func(getFunction("function")),
48  _angle_units(getParam<MooseEnum>("angle_units")),
49  _axis_origin(getParam<RealVectorValue>("axis_origin")),
50  _axis_direction(getParam<RealVectorValue>("axis_direction"))
51 {
52  if (_component < 0 || _component > 2)
53  mooseError("Invalid component given for ", name(), ": ", _component, ".");
54 
55  if (_axis_direction.norm() == 0.)
56  mooseError("Please specify a non-zero direction vector for the axis_direction in ", name());
57 }
58 
59 void
61 {
64 }
65 
66 Real
68 {
69  Point p(*_current_node);
70 
71  Real angle(_func.value(_t, *_current_node));
72  if (_angle_units == "degrees")
73  angle = angle * libMesh::pi / 180.0;
74 
75  ColumnMajorMatrix p_old(4, 1);
76  p_old(0, 0) = p(0);
77  p_old(1, 0) = p(1);
78  p_old(2, 0) = p(2);
79  p_old(3, 0) = 1;
80 
81  ColumnMajorMatrix p_new = rotateAroundAxis(p_old, angle);
82 
83  return p_new(_component, 0) - p_old(_component, 0);
84 }
85 
86 ColumnMajorMatrix
87 DisplacementAboutAxis::rotateAroundAxis(const ColumnMajorMatrix & p0, const Real angle)
88 {
89  ColumnMajorMatrix rotate_about_z(4, 4);
90  rotate_about_z(0, 0) = cos(angle);
91  rotate_about_z(0, 1) = -sin(angle);
92  rotate_about_z(0, 2) = 0;
93  rotate_about_z(0, 3) = 0;
94  rotate_about_z(1, 0) = sin(angle);
95  rotate_about_z(1, 1) = cos(angle);
96  rotate_about_z(1, 2) = 0;
97  rotate_about_z(1, 3) = 0;
98  rotate_about_z(2, 0) = 0;
99  rotate_about_z(2, 1) = 0;
100  rotate_about_z(2, 2) = 1;
101  rotate_about_z(2, 3) = 0;
102  rotate_about_z(3, 0) = 0;
103  rotate_about_z(3, 1) = 0;
104  rotate_about_z(3, 2) = 0;
105  rotate_about_z(3, 3) = 1;
106 
107  ColumnMajorMatrix transform =
109  return transform * p0;
110 }
111 
112 void
114 {
115  Real magnitude = _axis_direction.norm();
116  _axis_direction /= magnitude;
117 }
118 
119 void
121 {
122  // These parts of the transformation matrix only depend on the axis of rotation:
123 
124  Real length = _axis_direction.norm_sq();
126 
127  ColumnMajorMatrix transl(4, 4);
128  transl(0, 0) = 1;
129  transl(0, 1) = 0;
130  transl(0, 2) = 0;
131  transl(0, 3) = -_axis_origin(0);
132  transl(1, 0) = 0;
133  transl(1, 1) = 1;
134  transl(1, 2) = 0;
135  transl(1, 3) = -_axis_origin(1);
136  transl(2, 0) = 0;
137  transl(2, 1) = 0;
138  transl(2, 2) = 1;
139  transl(2, 3) = -_axis_origin(2);
140  transl(3, 0) = 0;
141  transl(3, 1) = 0;
142  transl(3, 2) = 0;
143  transl(3, 3) = 1;
144 
145  ColumnMajorMatrix rotate_about_x(4, 4);
146  rotate_about_x(0, 0) = 1;
147  rotate_about_x(0, 1) = 0;
148  rotate_about_x(0, 2) = 0;
149  rotate_about_x(0, 3) = 0;
150  rotate_about_x(1, 0) = 0;
151  rotate_about_x(1, 1) = _axis_direction(2) / v;
152  rotate_about_x(1, 2) = -_axis_direction(1) / v;
153  rotate_about_x(1, 3) = 0;
154  rotate_about_x(2, 0) = 0;
155  rotate_about_x(2, 1) = _axis_direction(1) / v;
156  rotate_about_x(2, 2) = _axis_direction(2) / v;
157  rotate_about_x(2, 3) = 0;
158  rotate_about_x(3, 0) = 0;
159  rotate_about_x(3, 1) = 0;
160  rotate_about_x(3, 2) = 0;
161  rotate_about_x(3, 3) = 1;
162 
163  ColumnMajorMatrix rotate_about_y(4, 4);
164  rotate_about_y(0, 0) = v / length;
165  rotate_about_y(0, 1) = 0;
166  rotate_about_y(0, 2) = -_axis_direction(0) / length;
167  rotate_about_y(0, 3) = 0;
168  rotate_about_y(1, 0) = 0;
169  rotate_about_y(1, 1) = 1;
170  rotate_about_y(1, 2) = 0;
171  rotate_about_y(1, 3) = 0;
172  rotate_about_y(2, 0) = _axis_direction(0) / length;
173  rotate_about_y(2, 1) = 0;
174  rotate_about_y(2, 2) = v / length;
175  rotate_about_y(2, 3) = 0;
176  rotate_about_y(3, 0) = 0;
177  rotate_about_y(3, 1) = 0;
178  rotate_about_y(3, 2) = 0;
179  rotate_about_y(3, 3) = 1;
180 
181  ColumnMajorMatrix transl_inv(4, 4);
182  transl.inverse(transl_inv);
183  ColumnMajorMatrix rotx_inv(4, 4);
184  rotate_about_x.inverse(rotx_inv);
185  ColumnMajorMatrix roty_inv(4, 4);
186  rotate_about_y.inverse(roty_inv);
187 
188  _transformation_matrix = rotate_about_y * rotate_about_x * transl;
189  _transformation_matrix_inv = transl_inv * rotx_inv * roty_inv;
190 }
DisplacementAboutAxis::computeQpValue
virtual Real computeQpValue()
Evaluate the boundary condition at the current quadrature point and timestep.
Definition: DisplacementAboutAxis.C:67
DisplacementAboutAxis::initialSetup
virtual void initialSetup()
Definition: DisplacementAboutAxis.C:60
DisplacementAboutAxis::validParams
static InputParameters validParams()
Definition: DisplacementAboutAxis.C:18
DisplacementAboutAxis::_component
const int _component
Definition: DisplacementAboutAxis.h:53
DisplacementAboutAxis::_angle_units
MooseEnum _angle_units
Definition: DisplacementAboutAxis.h:55
DisplacementAboutAxis::_axis_origin
const Point _axis_origin
Definition: DisplacementAboutAxis.h:56
defineLegacyParams
defineLegacyParams(DisplacementAboutAxis)
DisplacementAboutAxis.h
addDisplacementAboutAxisParams
void addDisplacementAboutAxisParams(InputParameters &params)
Definition: DisplacementAboutAxis.C:31
validParams
InputParameters validParams()
name
const std::string name
Definition: Setup.h:21
DisplacementAboutAxis::_axis_direction
Point _axis_direction
Definition: DisplacementAboutAxis.h:57
DisplacementAboutAxis::DisplacementAboutAxis
DisplacementAboutAxis(const InputParameters &parameters)
Definition: DisplacementAboutAxis.C:44
DisplacementAboutAxis
Implements a boundary condition that enforces rotational displacement around an axis on a boundary.
Definition: DisplacementAboutAxis.h:29
DisplacementAboutAxis::_transformation_matrix
ColumnMajorMatrix _transformation_matrix
Definition: DisplacementAboutAxis.h:59
DisplacementAboutAxis::_transformation_matrix_inv
ColumnMajorMatrix _transformation_matrix_inv
Definition: DisplacementAboutAxis.h:60
DisplacementAboutAxis::_func
const Function & _func
Definition: DisplacementAboutAxis.h:54
registerMooseObject
registerMooseObject("TensorMechanicsApp", DisplacementAboutAxis)
DisplacementAboutAxis::calculateTransformationMatrices
void calculateTransformationMatrices()
Calculate the rotation about the x and y axes based on the provided axis direction vector at the star...
Definition: DisplacementAboutAxis.C:120
DisplacementAboutAxis::rotateAroundAxis
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...
Definition: DisplacementAboutAxis.C:87
DisplacementAboutAxis::calculateUnitDirectionVector
void calculateUnitDirectionVector()
Check if the provided axis direction vector is a unit vector and normalizes the vector if necessary d...
Definition: DisplacementAboutAxis.C:113