https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12registerMooseObject("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
34 _direction /= _direction.norm();
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
47Real
49{
50 // displacement vector
51 RealVectorValue delta;
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.
56 RealVectorValue dr1 = *_current_node - _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::atan2(dr1.cross(dr2) * _direction, dr1 * dr2);
69 else
70 return 0.0;
71}
registerMooseObject("SolidMechanicsApp", RotationAngle)
const Node *const & _current_node
static InputParameters validParams()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void paramError(const std::string &param, Args... args) const
Compute the field of angular rotations of points around an axis defined by an origin point and a dire...
static InputParameters validParams()
std::vector< const VariableValue * > _disp
displacement variables
RealVectorValue _direction
compute angles in the plane defined by this vector
Real computeValue() override
const Point _origin
origin point to determine the angle w.r.t.
RotationAngle(const InputParameters &parameters)
static constexpr Real TOLERANCE