www.mooseframework.org
RadialDisplacementCylinderAux.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 
11 #include "MooseMesh.h"
12 
14 
16 
17 InputParameters
19 {
20  InputParameters params = AuxKernel::validParams();
21  params.addClassDescription(
22  "Compute the radial component of the displacement vector for cylindrical models.");
23  params.addRequiredCoupledVar(
24  "displacements",
25  "The displacements appropriate for the simulation geometry and coordinate system");
26  params.addParam<RealVectorValue>(
27  "origin", "Origin of cylinder axis of rotation for 2D and 3D Cartesian models");
28  params.addParam<RealVectorValue>(
29  "axis_vector", "Vector defining direction of cylindrical axis (3D Cartesian models)");
30  params.set<bool>("use_displaced_mesh") = false;
31 
32  return params;
33 }
34 
36  : AuxKernel(parameters), _ndisp(coupledComponents("displacements")), _disp_vals(_ndisp)
37 {
38  const std::set<SubdomainID> & subdomains = _mesh.meshSubdomains();
39  const auto & sbd_begin = *subdomains.begin();
40  for (const auto & sbd : subdomains)
41  {
42  if (sbd == sbd_begin)
43  _coord_system = _subproblem.getCoordSystem(sbd);
44  else if (_subproblem.getCoordSystem(sbd) != _coord_system)
45  mooseError("RadialDisplacementCylinderAux requires that all subdomains have the same "
46  "coordinate type");
47  }
48 
49  for (unsigned int i = 0; i < _ndisp; ++i)
50  _disp_vals[i] = &coupledValue("displacements", i);
51 
52  if (_ndisp != _mesh.dimension())
53  mooseError("The number of displacement variables supplied must match the mesh dimension.");
54 
55  if (_coord_system == Moose::COORD_XYZ && _ndisp == 1)
56  mooseError("RadialDisplacmentCylinderAux is not applicable for 1D Cartesian models");
57 
58  else if (!(_coord_system == Moose::COORD_XYZ || _coord_system == Moose::COORD_RZ))
59  mooseError("RadialDisplacementCylinderAux can only be used with Cartesian or axisymmetric "
60  "coordinate systems");
61 
62  if (isParamValid("origin"))
63  {
64  if (_coord_system != Moose::COORD_XYZ)
65  mooseError("The 'origin' parameter is only valid for Cartesian models.");
66 
67  _origin = getParam<RealVectorValue>("origin");
68  }
69  else if (_coord_system == Moose::COORD_XYZ)
70  mooseError("Must specify 'origin' for models with Cartesian coordinate systems.");
71 
72  if (isParamValid("axis_vector"))
73  {
74  if (!(_coord_system == Moose::COORD_XYZ && _ndisp == 3))
75  mooseError("The 'axis_vector' parameter is only valid for 3D Cartesian models.");
76 
77  _axis_vector = getParam<RealVectorValue>("axis_vector");
78  Real vec_len = _axis_vector.norm();
79  if (MooseUtils::absoluteFuzzyEqual(vec_len, 0.0))
80  mooseError("axis_vector must have nonzero length");
81  _axis_vector /= vec_len;
82  }
83  else if (_coord_system == Moose::COORD_XYZ && _ndisp == 3)
84  mooseError("Must specify 'axis_vector' for 3D Cartesian models");
85 
86  if (!isNodal())
87  mooseError("Must run on a nodal variable");
88 }
89 
90 Real
92 {
93  Real rad_disp = 0.0;
94  Point current_point(*_current_node);
95 
96  switch (_coord_system)
97  {
98  case Moose::COORD_XYZ:
99  {
100  RealVectorValue rad_vec;
101  const RealVectorValue disp_vec((*_disp_vals[0])[_qp],
102  (*_disp_vals[1])[_qp],
103  (_ndisp == 3 ? (*_disp_vals[2])[_qp] : 0.0));
104 
105  if (_ndisp == 2)
106  rad_vec = current_point - _origin;
107  else if (_ndisp == 3)
108  {
109  // t is the distance along the axis from point 1 to 2 to the point nearest to the current
110  // point.
111  const RealVectorValue p1pc(current_point - _origin);
112  const Real t = p1pc * _axis_vector;
113 
114  // The nearest point on the cylindrical axis to current_point is p.
115  const RealVectorValue p(_origin + t * _axis_vector);
116  rad_vec = current_point - p;
117  }
118 
119  Real rad = rad_vec.norm();
120  if (rad > 0.0)
121  {
122  rad_vec /= rad;
123  rad_disp = rad_vec * disp_vec;
124  }
125  else
126  rad_disp = disp_vec.norm();
127  break;
128  }
129  case Moose::COORD_RZ:
130  rad_disp = (*_disp_vals[0])[_qp];
131  break;
132  default:
133  mooseError("Unsupported coordinate system");
134  }
135 
136  return rad_disp;
137 }
RadialDisplacementCylinderAux::RadialDisplacementCylinderAux
RadialDisplacementCylinderAux(const InputParameters &parameters)
Definition: RadialDisplacementCylinderAux.C:35
registerMooseObject
registerMooseObject("TensorMechanicsApp", RadialDisplacementCylinderAux)
RadialDisplacementCylinderAux.h
RadialDisplacementCylinderAux::_origin
RealVectorValue _origin
Point used to define the origin of the cylinder axis for Cartesian systems.
Definition: RadialDisplacementCylinderAux.h:49
RadialDisplacementCylinderAux::validParams
static InputParameters validParams()
Definition: RadialDisplacementCylinderAux.C:18
RadialDisplacementCylinderAux
Calculates the radial displacement for cylindrical geometries.
Definition: RadialDisplacementCylinderAux.h:24
validParams
InputParameters validParams()
RadialDisplacementCylinderAux::_disp_vals
std::vector< const VariableValue * > _disp_vals
Coupled variable values of the displacement components.
Definition: RadialDisplacementCylinderAux.h:43
defineLegacyParams
defineLegacyParams(RadialDisplacementCylinderAux)
RadialDisplacementCylinderAux::_coord_system
Moose::CoordinateSystemType _coord_system
Type of coordinate system.
Definition: RadialDisplacementCylinderAux.h:38
RadialDisplacementCylinderAux::computeValue
virtual Real computeValue()
Compute the value of the radial displacement.
Definition: RadialDisplacementCylinderAux.C:91
RadialDisplacementCylinderAux::_axis_vector
RealVectorValue _axis_vector
Axis direction.
Definition: RadialDisplacementCylinderAux.h:46
RadialDisplacementCylinderAux::_ndisp
unsigned int _ndisp
Number of displacment components.
Definition: RadialDisplacementCylinderAux.h:41