https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RadialDisplacementSphereAux.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
11#include "MooseMesh.h"
12
14
17{
20 "Compute the radial component of the displacement vector for spherical models.");
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)
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
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
63 mooseError("Cannot compute radial displacement for models with 1D or 2D Cartesian system");
64
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
73Real
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}
registerMooseObject("SolidMechanicsApp", RadialDisplacementSphereAux)
SubProblem & _subproblem
const Node *const & _current_node
static InputParameters validParams()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
virtual unsigned int dimension() const
const std::set< SubdomainID > & meshSubdomains() const
Calculates the radial displacement for spherical geometries.
RadialDisplacementSphereAux(const InputParameters &parameters)
RealVectorValue _origin
Point used to define an origin for 2D axisymmetric or 3D Cartesian systems.
const std::vector< const VariableValue * > _disp_vals
Coupled variable values of the displacement components.
virtual Real computeValue()
Compute the value of the radial displacement.
const unsigned int _ndisp
Number of displacment components.
Moose::CoordinateSystemType _coord_system
Type of coordinate system.
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
COORD_RSPHERICAL