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 "NearestPositionsDivision.h" 11 : #include "MooseMesh.h" 12 : #include "Positions.h" 13 : 14 : #include "libmesh/mesh_base.h" 15 : #include "libmesh/elem.h" 16 : 17 : registerMooseObject("MooseApp", NearestPositionsDivision); 18 : 19 : InputParameters 20 14290 : NearestPositionsDivision::validParams() 21 : { 22 14290 : InputParameters params = MeshDivision::validParams(); 23 14290 : params.addClassDescription("Divide the mesh using a nearest-point / voronoi algorithm, with the " 24 : "points coming from a Positions object"); 25 14290 : params.addRequiredParam<PositionsName>( 26 : "positions", "The name of the Positions object to form the nearest-neighbor division with"); 27 14290 : return params; 28 0 : } 29 : 30 13 : NearestPositionsDivision::NearestPositionsDivision(const InputParameters & parameters) 31 : : MeshDivision(parameters), 32 13 : _nearest_positions_obj(&_fe_problem->getPositionsObject(getParam<PositionsName>("positions"))) 33 : { 34 13 : NearestPositionsDivision::initialize(); 35 13 : _mesh_fully_indexed = true; 36 13 : } 37 : 38 : void 39 13 : NearestPositionsDivision::initialize() 40 : { 41 13 : setNumDivisions(_nearest_positions_obj->getNumPositions()); 42 13 : } 43 : 44 : unsigned int 45 640 : NearestPositionsDivision::divisionIndex(const Elem & elem) const 46 : { 47 640 : const bool initial = _fe_problem->getCurrentExecuteOnFlag() == EXEC_INITIAL; 48 640 : return _nearest_positions_obj->getNearestPositionIndex(elem.vertex_average(), initial); 49 : } 50 : 51 : unsigned int 52 0 : NearestPositionsDivision::divisionIndex(const Point & pt) const 53 : { 54 0 : const bool initial = _fe_problem->getCurrentExecuteOnFlag() == EXEC_INITIAL; 55 0 : return _nearest_positions_obj->getNearestPositionIndex(pt, initial); 56 : }