Line data Source code
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 "RadialDisplacementSphereAux.h" 11 : #include "MooseMesh.h" 12 : 13 : registerMooseObject("SolidMechanicsApp", RadialDisplacementSphereAux); 14 : 15 : InputParameters 16 38 : RadialDisplacementSphereAux::validParams() 17 : { 18 38 : InputParameters params = AuxKernel::validParams(); 19 38 : params.addClassDescription( 20 : "Compute the radial component of the displacement vector for spherical models."); 21 76 : params.addRequiredCoupledVar( 22 : "displacements", 23 : "The displacements appropriate for the simulation geometry and coordinate system"); 24 76 : params.addParam<RealVectorValue>("origin", 25 : "Sphere origin for 3D Cartesian and 2D axisymmetric models"); 26 38 : params.set<bool>("use_displaced_mesh") = false; 27 : 28 38 : return params; 29 0 : } 30 : 31 20 : RadialDisplacementSphereAux::RadialDisplacementSphereAux(const InputParameters & parameters) 32 : : AuxKernel(parameters), 33 20 : _ndisp(coupledComponents("displacements")), 34 60 : _disp_vals(coupledValues("displacements")) 35 : { 36 20 : const std::set<SubdomainID> & subdomains = _mesh.meshSubdomains(); 37 : const auto & sbd_begin = *subdomains.begin(); 38 40 : for (const auto & sbd : subdomains) 39 : { 40 20 : if (sbd == sbd_begin) 41 20 : _coord_system = _subproblem.getCoordSystem(sbd); 42 0 : else if (_subproblem.getCoordSystem(sbd) != _coord_system) 43 0 : mooseError( 44 : "RadialDisplacementSphereAux requires that all subdomains have the same coordinate type"); 45 : } 46 : 47 20 : if (_ndisp != _mesh.dimension()) 48 0 : mooseError("The number of displacement variables supplied must match the mesh dimension."); 49 : 50 20 : if ((_coord_system == Moose::COORD_XYZ) || (_coord_system == Moose::COORD_RZ)) 51 : { 52 24 : if (isParamValid("origin")) 53 24 : _origin = getParam<RealVectorValue>("origin"); 54 : else 55 0 : mooseError( 56 : "Must specify 'origin' for models with Cartesian or axisymmetric coordinate systems."); 57 : } 58 16 : else if (isParamValid("origin")) 59 2 : mooseError("The 'origin' parameter is only valid for models with Cartesian or axisymmetric " 60 : "coordinate systems."); 61 : 62 18 : if (_coord_system == Moose::COORD_XYZ && _ndisp != 3) 63 0 : mooseError("Cannot compute radial displacement for models with 1D or 2D Cartesian system"); 64 : 65 18 : if (_coord_system == Moose::COORD_RZ && _ndisp != 2) 66 0 : mooseError( 67 : "Can only compute radial displacement for axisymmetric systems if the dimensionality is 2"); 68 : 69 18 : if (!isNodal()) 70 0 : mooseError("Must run on a nodal variable"); 71 18 : } 72 : 73 : Real 74 229596 : RadialDisplacementSphereAux::computeValue() 75 : { 76 : Real rad_disp = 0.0; 77 : 78 229596 : if ((_coord_system == Moose::COORD_XYZ && _ndisp == 3) || 79 : (_coord_system == Moose::COORD_RZ && _ndisp == 2)) 80 : { 81 229056 : Point current_point(*_current_node); 82 : RealVectorValue rad_vec(current_point - _origin); 83 229056 : Real rad = rad_vec.norm(); 84 : const RealVectorValue disp_vec( 85 229056 : (*_disp_vals[0])[_qp], (*_disp_vals[1])[_qp], (_ndisp == 3 ? (*_disp_vals[2])[_qp] : 0.0)); 86 229056 : if (rad > 0.0) 87 : { 88 : rad_vec /= rad; 89 : rad_disp = rad_vec * disp_vec; 90 : } 91 : else 92 632 : rad_disp = disp_vec.norm(); 93 : } 94 540 : else if (_coord_system == Moose::COORD_RSPHERICAL) 95 540 : rad_disp = (*_disp_vals[0])[_qp]; 96 : else 97 0 : mooseError("Unsupported coordinate system"); 98 : 99 229596 : return rad_disp; 100 : }