Skip to content

Partition Model

Introduction

The PartitionModel handles mesh partitioning and rebalancing across MPI processes. This is important for parallel simulations. The software must distribute the mesh equally to keep good load balancing. After operations such as adaptive refinement, rebalancing can redistribute the mesh to prevent performance degradation. Note that this is only supported for non-conformal meshes.

This model also registers a partition index as a coefficient function to visualize which cells belong to which MPI rank.

Functions

PartitionModel()

The PartitionModel gives mesh partitioning and rebalancing capabilities in the simulation.

rebalance()

Rebalances the mesh across MPI ranks to improve load distribution.

Usually you call it after large mesh changes, for example refinement. It redistributes the elements to balance the number of cells for each rank. This improves solver performance.

Note that this operation is only effective for non-conformal meshes.

Coefficients

The PartitionModel registers the field that follows for visualization or analysis:

Name Field Type Description
Partition Index Scalar The Partition Index provides the MPI rank each cell belongs to. It is useful for debugging load balancing and visualizing mesh distribution across processors.

Example

The example that follows loads a mesh. It then does a repartition with the PartitionModel:

import mufem

sim = mufem.Simulation.New(
    name="My Parallel Case",
    mesh_path="data/geometry.mesh",
    print_only_warnings=True,
)

partition_model = mufem.PartitionModel()

sim.get_model_manager().add_model(partition_model)

# Rebalance the mesh after refinement or load (requires non-conformal mesh)
# partition_model.rebalance()

# Export the partition index field for visualization
field_exporter = sim.get_field_exporter()
field_exporter.add_field_output("Partition Index")
field_exporter.save()