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 "RZSymmetry.h" 11 : #include "BlockRestrictable.h" 12 : #include "BoundaryRestrictable.h" 13 : #include "FEProblemBase.h" 14 : #include "libmesh/point.h" 15 : 16 : InputParameters 17 8603 : RZSymmetry::validParams() 18 : { 19 8603 : InputParameters params = emptyInputParameters(); 20 17206 : params.addRequiredParam<Point>("axis_point", "A point on the axis of RZ symmetry."); 21 17206 : params.addRequiredParam<RealVectorValue>("axis_dir", "The direction of the axis of RZ symmetry."); 22 17206 : params.addParam<Real>("offset", 0., "Radial offset of the axis of RZ symmetry."); 23 8603 : return params; 24 0 : } 25 : 26 4463 : RZSymmetry::RZSymmetry(const MooseObject * moose_object, const InputParameters & parameters) 27 : : _axis_point(0., 0., 0.), 28 4463 : _axis_dir(parameters.get<RealVectorValue>("axis_dir")), 29 4463 : _offset(parameters.get<Real>("offset")) 30 : { 31 : const FEProblemBase * fe_problem = 32 4463 : moose_object->isParamValid("_fe_problem_base") 33 13389 : ? moose_object->getParam<FEProblemBase *>("_fe_problem_base") 34 : : nullptr; 35 4463 : if (fe_problem != nullptr) 36 : { 37 4463 : const MooseMesh & mesh = fe_problem->mesh(); 38 : 39 4463 : const BlockRestrictable * blk_restr = dynamic_cast<const BlockRestrictable *>(moose_object); 40 : const BoundaryRestrictable * bnd_restr = 41 4463 : dynamic_cast<const BoundaryRestrictable *>(moose_object); 42 : 43 4463 : if (blk_restr != nullptr) 44 : { 45 3748 : const std::set<SubdomainID> & blks = blk_restr->meshBlockIDs(); 46 : 47 16467 : for (auto & b : blks) 48 : { 49 12721 : if (fe_problem->getCoordSystem(b) != Moose::COORD_XYZ) 50 2 : mooseError( 51 2 : moose_object->name(), 52 : ": This is a THM-specific object can be applied only on subdomains with Cartesian " 53 : "coordinate system. If your domain has RZ cooridnate system associated with it, you " 54 : "need to use the object without the RZ suffix to obtain the desired result."); 55 : } 56 : } 57 4461 : if (bnd_restr != nullptr) 58 : { 59 : std::set<SubdomainID> blks; 60 715 : const std::set<BoundaryID> & bnds = bnd_restr->boundaryIDs(); 61 1430 : for (auto & bid : bnds) 62 : { 63 715 : std::set<SubdomainID> conn_blks = mesh.getBoundaryConnectedBlocks(bid); 64 1430 : for (auto & cb : conn_blks) 65 715 : blks.insert(cb); 66 : } 67 : 68 1428 : for (auto & b : blks) 69 : { 70 715 : if (fe_problem->getCoordSystem(b) != Moose::COORD_XYZ) 71 2 : mooseError( 72 2 : moose_object->name(), 73 : ": This is a THM-specific object can be applied only on subdomains with Cartesian " 74 : "coordinate system. If your domain has RZ cooridnate system associated with it, you " 75 : "need to use the object without the RZ suffix to obtain the desired result."); 76 : } 77 : } 78 : } 79 : 80 4459 : const Point pt = parameters.get<Point>("axis_point"); 81 4459 : _axis_point = Point(pt(0), pt(1), pt(2)); 82 4459 : } 83 : 84 : Real 85 37455207 : RZSymmetry::computeCircumference(const RealVectorValue & pt) 86 : { 87 : RealVectorValue v = (pt - _axis_point); 88 37455207 : const Real r = v.cross(_axis_dir).norm() / _axis_dir.norm(); 89 37455207 : return 2 * libMesh::pi * (r + _offset); 90 : }