https://mooseframework.inl.gov
RotationAngle.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 "RotationAngle.h"
11 
12 registerMooseObject("SolidMechanicsApp", RotationAngle);
13 
16 {
18  params.addRequiredParam<Point>("origin", "Axis origin");
19  params.addRequiredParam<RealVectorValue>("direction", "Axis direction");
20  params.addClassDescription("Compute the field of angular rotations of points around an axis "
21  "defined by an origin point and a direction vector");
22  params.addRequiredCoupledVar("displacements", "The displacements");
23  params.set<bool>("use_displaced_mesh") = false;
24  return params;
25 }
26 
28  : AuxKernel(parameters),
29  _origin(getParam<Point>("origin")),
30  _direction(getParam<RealVectorValue>("direction")),
31  _disp(coupledValues("displacements"))
32 {
33  // normalize direction
35 
36  // sanity checks
37  if (getParam<bool>("use_displaced_mesh"))
38  paramError("use_displaced_mesh", "This AuxKernel must be run on the undisplaced mesh");
39  if (!isNodal())
40  paramError("variable", "This AuxKernel must operate on a nodal variable");
41  if (_disp.size() > LIBMESH_DIM)
42  paramError("displacements",
43  "Too many displacement variables were specified. The max is LIBMESH_DIM, which is ",
44  LIBMESH_DIM);
45 }
46 
47 Real
49 {
50  // displacement vector
52  for (unsigned int i = 0; i < _disp.size(); ++i)
53  delta(i) = (*_disp[i])[_qp];
54 
55  // undisplaced and displaced locations relative to the origin.
57  RealVectorValue dr2 = dr1 + delta;
58 
59  // subtract out of plane projections
60  dr1 -= _direction * (_direction * dr1);
61  dr2 -= _direction * (_direction * dr2);
62 
63  // product of the lengths
64  auto norms = std::sqrt(dr1.norm_sq() * dr2.norm_sq());
65 
66  // angle between dr1 and dr2
67  if (norms > libMesh::TOLERANCE)
68  return std::acos((dr1 * dr2) / norms) * ((dr1.cross(dr2) * _direction) > 0 ? 1.0 : -1.0);
69  else
70  return 0.0;
71 }
std::vector< const VariableValue * > _disp
displacement variables
Definition: RotationAngle.h:35
Compute the field of angular rotations of points around an axis defined by an origin point and a dire...
Definition: RotationAngle.h:18
auto norm() const -> decltype(std::norm(Real()))
const Point _origin
origin point to determine the angle w.r.t.
Definition: RotationAngle.h:29
static constexpr Real TOLERANCE
static InputParameters validParams()
Definition: RotationAngle.C:15
const Node *const & _current_node
T & set(const std::string &name, bool quiet_mode=false)
int delta(unsigned int i, unsigned int j)
Delta function, which returns zero if $i j$ and unity if $i=j$.
registerMooseObject("SolidMechanicsApp", RotationAngle)
void addRequiredParam(const std::string &name, const std::string &doc_string)
auto norm_sq() const -> decltype(std::norm(Real()))
void paramError(const std::string &param, Args... args) const
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
RealVectorValue _direction
compute angles in the plane defined by this vector
Definition: RotationAngle.h:32
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
RotationAngle(const InputParameters &parameters)
Definition: RotationAngle.C:27
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real computeValue() override
Definition: RotationAngle.C:48
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()