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