www.mooseframework.org
RadialDisplacementSphereAux.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 
17 {
19  params.addClassDescription(
20  "Compute the radial component of the displacement vector for spherical models.");
21  params.addRequiredCoupledVar(
22  "displacements",
23  "The displacements appropriate for the simulation geometry and coordinate system");
24  params.addParam<RealVectorValue>("origin",
25  "Sphere origin for 3D Cartesian and 2D axisymmetric models");
26  params.set<bool>("use_displaced_mesh") = false;
27 
28  return params;
29 }
30 
32  : AuxKernel(parameters),
33  _ndisp(coupledComponents("displacements")),
34  _disp_vals(coupledValues("displacements"))
35 {
36  const std::set<SubdomainID> & subdomains = _mesh.meshSubdomains();
37  const auto & sbd_begin = *subdomains.begin();
38  for (const auto & sbd : subdomains)
39  {
40  if (sbd == sbd_begin)
42  else if (_subproblem.getCoordSystem(sbd) != _coord_system)
43  mooseError(
44  "RadialDisplacementSphereAux requires that all subdomains have the same coordinate type");
45  }
46 
47  if (_ndisp != _mesh.dimension())
48  mooseError("The number of displacement variables supplied must match the mesh dimension.");
49 
51  {
52  if (isParamValid("origin"))
53  _origin = getParam<RealVectorValue>("origin");
54  else
55  mooseError(
56  "Must specify 'origin' for models with Cartesian or axisymmetric coordinate systems.");
57  }
58  else if (isParamValid("origin"))
59  mooseError("The 'origin' parameter is only valid for models with Cartesian or axisymmetric "
60  "coordinate systems.");
61 
62  if (_coord_system == Moose::COORD_XYZ && _ndisp != 3)
63  mooseError("Cannot compute radial displacement for models with 1D or 2D Cartesian system");
64 
65  if (_coord_system == Moose::COORD_RZ && _ndisp != 2)
66  mooseError(
67  "Can only compute radial displacement for axisymmetric systems if the dimensionality is 2");
68 
69  if (!isNodal())
70  mooseError("Must run on a nodal variable");
71 }
72 
73 Real
75 {
76  Real rad_disp = 0.0;
77 
78  if ((_coord_system == Moose::COORD_XYZ && _ndisp == 3) ||
80  {
81  Point current_point(*_current_node);
82  RealVectorValue rad_vec(current_point - _origin);
83  Real rad = rad_vec.norm();
84  const RealVectorValue disp_vec(
85  (*_disp_vals[0])[_qp], (*_disp_vals[1])[_qp], (_ndisp == 3 ? (*_disp_vals[2])[_qp] : 0.0));
86  if (rad > 0.0)
87  {
88  rad_vec /= rad;
89  rad_disp = rad_vec * disp_vec;
90  }
91  else
92  rad_disp = disp_vec.norm();
93  }
95  rad_disp = (*_disp_vals[0])[_qp];
96  else
97  mooseError("Unsupported coordinate system");
98 
99  return rad_disp;
100 }
Calculates the radial displacement for spherical geometries.
auto norm() const -> decltype(std::norm(Real()))
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Node *const & _current_node
T & set(const std::string &name, bool quiet_mode=false)
RealVectorValue _origin
Point used to define an origin for 2D axisymmetric or 3D Cartesian systems.
const unsigned int _ndisp
Number of displacment components.
COORD_RSPHERICAL
RadialDisplacementSphereAux(const InputParameters &parameters)
bool isParamValid(const std::string &name) const
virtual Real computeValue()
Compute the value of the radial displacement.
virtual unsigned int dimension() const
const std::vector< const VariableValue * > _disp_vals
Coupled variable values of the displacement components.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
registerMooseObject("SolidMechanicsApp", RadialDisplacementSphereAux)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SubProblem & _subproblem
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Moose::CoordinateSystemType _coord_system
Type of coordinate system.
const std::set< SubdomainID > & meshSubdomains() const