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 works with other models that do refinement logic. It queries these
models before it changes the mesh.
Functions¶
RefinementModel()
The RefinementModel gives mesh refinement capabilities in the simulation.
refine_mesh()
Refines the mesh based on refinement suggestions from other models.
The software queries all models that implement the refinement interface. These models mark the cells to refine. The software then refines the marked cells in parallel with MFEM's nonconforming mesh support.
uniform_refinement()
Does uniform refinement of the entire mesh.
This subdivides all cells uniformly. It does not check any refinement criteria. You can use it for debugging, convergence studies, or testing.
refine_order()
Does p-refinement based on model-specific criteria.
The software queries the models that implement the p-refinement interface. These models mark the cells that need a higher polynomial order.
refine_along_interface(phi, sample_ir_order=2, max_refinement_contrast=1)
Refines the cells crossed by the zero level set of the scalar coefficient
phi.
The software samples each cell with an integration rule of order
sample_ir_order. It marks a cell for refinement when phi changes sign
between the sample points.
You can use it to resolve material interfaces that are defined implicitly, for
example with the
Implicit Geometry Material:
for _ in range(5):
refinement_model.refine_along_interface(phi=cff_phi, sample_ir_order=8)
refinement_model.equilibrate_refinement()
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.
|
This model does not add general mesh coefficients such as Cell Volume,
Element Type, Position, and Global Cell Index. They are always
available as
Built-in Coefficients.
Example¶
In this example you load a mesh and do uniform refinement. Then you show the coefficient functions with 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()