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 "SingleRankPartitioner.h" 11 : 12 : #include "MooseApp.h" 13 : 14 : #include "libmesh/elem.h" 15 : 16 : registerMooseObject("MooseApp", SingleRankPartitioner); 17 : 18 : InputParameters 19 14416 : SingleRankPartitioner::validParams() 20 : { 21 14416 : InputParameters params = MoosePartitioner::validParams(); 22 : 23 14416 : params.addParam<processor_id_type>("rank", 0, "The MPI rank to assign all elements to."); 24 : 25 14416 : params.addClassDescription("Assigns element processor ids to a single MPI rank."); 26 : 27 14416 : return params; 28 0 : } 29 : 30 115 : SingleRankPartitioner::SingleRankPartitioner(const InputParameters & params) 31 115 : : MoosePartitioner(params), _rank(getParam<processor_id_type>("rank")) 32 : { 33 115 : if (_rank >= _communicator.size()) 34 7 : paramError("rank", "Cannot be larger than the available number of MPI ranks"); 35 108 : } 36 : 37 : std::unique_ptr<Partitioner> 38 72 : SingleRankPartitioner::clone() const 39 : { 40 72 : return _app.getFactory().clone(*this); 41 : } 42 : 43 : void 44 32 : SingleRankPartitioner::_do_partition(MeshBase & mesh, const unsigned int /*n*/) 45 : { 46 3232 : for (auto & elem_ptr : mesh.active_element_ptr_range()) 47 3232 : elem_ptr->processor_id() = _rank; 48 32 : }