MMG [1]ΒΆ

MMG is a remeshing tool for mesh adaptation and optimization. An interface is available in Muscat to use the :py:mod:Muscat.MeshContainers.Mesh class directly. This can be done using:

# 2D mesh example
import numpy as np
from Muscat.MeshTools.MeshCreationTools import CreateMeshOfTriangles, CreateCube
from Muscat.MeshTools.Remesh import Remesh
from Muscat.Simple import PlotMesh

nodes = np.array([[0.0,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0]])
tris = np.array([[0,1,3],[1,2,3]])
mesh2D = CreateMeshOfTriangles(nodes, tris)
PlotMesh(mesh2D)

new2Dmesh = Remesh(mesh2D, remesher_options={"hmin":0.05, "hmax":0.5}) # can take float value
PlotMesh(new2Dmesh)

new2Dmesh = Remesh(mesh2D, metric=np.full(mesh2D.GetNumberOfNodes(), 0.05)) # cat take a scalar metric field
PlotMesh(new2Dmesh)

# 3D mesh example
mesh3D = CreateCube([2,2,2], [0,0,0], [1,1,1], True) # Create cube in [0,0,0] with [2,2,2] points with spacing [1,1,1]
new3Dmesh = Remesh(mesh3D, remesher_options={"hmin":0.05, "hmax":0.5}) # cat take a scalar metric field
PlotMesh(new3Dmesh)

Footnotes