14 #include "libmesh/elem.h" 24 "block",
"The list of block ids (SubdomainID) that this object will be applied");
27 "weight",
"The list of weights (integer) that specify how heavy each block is");
29 params.
set<
bool>(
"apply_element_weight") =
true;
38 _blocks(getParam<
std::vector<SubdomainName>>(
"block")),
45 " does not match with the number of blocks ",
49 std::unique_ptr<Partitioner>
62 std::set<subdomain_id_type> mesh_block_ids;
63 mesh.subdomain_ids(mesh_block_ids);
64 for (
const auto block_id : block_ids)
65 if (!mesh_block_ids.count(block_id))
66 paramError(
"block",
"The block ", block_id,
" was not found on the mesh");
70 for (MooseIndex(block_ids.size()) i = 0; i < block_ids.size(); i++)
77 mooseAssert(
_blocks_to_weights.count(elem.subdomain_id()),
"Missing weight for block");
std::unordered_map< SubdomainID, dof_id_type > _blocks_to_weights
A map from subdomain to weight.
const std::vector< dof_id_type > & _weights
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
const std::vector< SubdomainName > & _blocks
Vector the block names supplied by the user via the input file.
static InputParameters validParams()
registerMooseObject("MooseApp", BlockWeightedPartitioner)
virtual std::unique_ptr< Partitioner > clone() const override
std::vector< subdomain_id_type > getSubdomainIDs(const libMesh::MeshBase &mesh, const std::vector< SubdomainName > &subdomain_name)
Get the associated subdomainIDs for the subdomain names that are passed in.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
void initialize(MeshBase &mesh) override
Fills _blocks_to_weights before performing the partition.
BlockWeightedPartitioner(const InputParameters ¶ms)
MooseApp & _app
The MOOSE application this is associated with.
Partition a mesh by weighting blocks.
virtual dof_id_type computeElementWeight(Elem &elm) override
static InputParameters validParams()
std::unique_ptr< T > clone(const T &object)
Clones the object object.
Partitions a mesh using external petsc partitioners such as parmetis, ptscotch, chaco, party, etc.