Skip to content

Refinement Model

Introduction

The RefinementModel coordinates adaptive mesh refinement (h-refinement) within a simulation. It registers geometric and topological coefficient functions useful for visualization, reporting, and refinement criteria. It also interacts with other models that implement refinement logic by querying them before modifying the mesh.

Functions

RefinementModel()

The RefinementModel provides mesh refinement capabilities in the simulation.

refine_mesh()

Refines the mesh based on refinement suggestions from other models.

All models that implement the refinement interface are queried to mark which cells should be refined. The marked cells are then refined in parallel using MFEM's nonconforming mesh support.

uniform_refinement()

Performs uniform refinement of the entire mesh.

This subdivides all cells uniformly without checking any refinement criteria. Useful for debugging, convergence studies, or testing.

refine_order()

Performs p-refinement based on model-specific criteria.

Models implementing the p-refinement interface are queried to mark cells whose polynomial order should be increased.

equilibrate_refinement(max_refinement_contrast=1)

Equilibrates refinement levels across the mesh so that neighboring cells differ by at most max_refinement_contrast levels.

Coefficients

The RefinementModel registers the following coefficient:

Name Field Type Description
Refinement Level Scalar The Refinement Level provides the current refinement depth of each cell. It is incremented each time a cell is refined.

General mesh coefficients such as Cell Volume, Element Type, Position, and Global Cell Index are not added by this model — they are always available as Built-in Coefficients.

Example

In this example, we load a mesh, perform uniform refinement, and visualize the coefficient functions using the Field Exporter and ParaView:

import mufem

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

refinement_model = mufem.RefinementModel()

sim.get_model_manager().add_model(refinement_model)

refinement_model.uniform_refinement()

field_exporter = sim.get_field_exporter()

field_exporter.add_field_output("Cell Volume")
field_exporter.add_field_output("Element Type")
field_exporter.add_field_output("Position")
field_exporter.add_field_output("Refinement Level")
field_exporter.add_field_output("Global Cell Index")

field_exporter.save()