https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SingleRankPartitioner.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
12#include "MooseApp.h"
13
14#include "libmesh/elem.h"
15
17
20{
22
23 params.addParam<processor_id_type>("rank", 0, "The MPI rank to assign all elements to.");
24
25 params.addClassDescription("Assigns element processor ids to a single MPI rank.");
26
27 return params;
28}
29
31 : MoosePartitioner(params), _rank(getParam<processor_id_type>("rank"))
32{
33 if (_rank >= _communicator.size())
34 paramError("rank", "Cannot be larger than the available number of MPI ranks");
35}
36
37std::unique_ptr<Partitioner>
39{
40 return _app.getFactory().clone(*this);
41}
42
43void
44SingleRankPartitioner::_do_partition(MeshBase & mesh, const unsigned int /*n*/)
45{
46 for (auto & elem_ptr : mesh.active_element_ptr_range())
47 elem_ptr->processor_id() = _rank;
48}
registerMooseObject("MooseApp", SingleRankPartitioner)
std::unique_ptr< T > clone(const T &object)
Clones the object object.
Definition Factory.h:323
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition MooseApp.h:407
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
Base class for MOOSE partitioner.
static InputParameters validParams()
Partitions a mesh to one MPI rank.
static InputParameters validParams()
const processor_id_type _rank
Rank to assign every element to.
SingleRankPartitioner(const InputParameters &params)
virtual std::unique_ptr< Partitioner > clone() const override
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
processor_id_type size() const
const Parallel::Communicator & _communicator
MeshBase & mesh