ParaView And Others External Tools

Muscat offers some capabilities to communicate with external mesh dedicated tools.

Vtk [1]

If you have a working VTK installation, you can set the module Muscat.Bridges.vtkBridge to convert meshes back and forth to Muscat meshes.

from Muscat.Bridges.vtkBridge import MeshToVtk, VtkToMesh
BTMesh =  #<-- this is my Muscat Mesh
vtkMesh = MeshToVtk(BTMesh, tagsAsFields=True)
# do some work with VTK
vtk MeshII = #<- create a new vtk mesh from the output of a filter
BTMeshII = VtkToMesh(vtkMeshII,FieldsAsTags=True)

ParaView [2]

Conda/Mamba Users Installation

For the moment this functionality is not available on conda environment installation even if the plugin is installed in the path /conda_env_path/ParaViewPlugins/MuscatParaViewBridge.py The reason is the incompatibility of the ParaView python with the conda python. We are working on a solution for this problem

Developer Installation

Some functionalities (like readers, writers) can be added to ParaView as a plugin. The configuration consists in setting the PYTHONPATH environment variable to your Muscat installation

PYTHONPATH=/path/to/Muscat/src

Then you can load the plugin /path/to/Muscat/extras/MuscatParaViewBridge.py using the Tools->Manage Plugins… menu. Also, you can set the PV_PLUGIN_PATH environment variable to indicate to ParaView to load automatically the plugin when starting.

PV_PLUGIN_PATH=/path/to/Muscat/extras

Three types of object are added to ParaView by the plugin:

  • Readers: The Muscat capabilities to read data from different file formats.

  • Writers: The Muscat capabilities to export data to different file formats.

  • Filters: Some of the mesh treatment functionalities of Muscat are exposed as vtk filters.

Be aware that the use of this functionalities involves a format conversion between the vtk and the Muscat internal format. Be aware that your Python installation version may not be compatible with Python version of ParaView.

MeshIO [3]

MeshIO is a library capable of reading and writing to various mesh file formats.

If you have a working MeshIO installation, you can set the module Muscat.Bridges.MeshIOBridge to convert meshes back and forth to Muscat meshes. MeshIO offers some reading and writing capabilities. More informations in Muscat.Bridges.MeshIOBridge.

PyVista [4]

If you have a working PyVista installation, you can set the module Muscat.Bridges.PyVistaBridge to convert meshes back and forth to Muscat meshes.

PyVista offers a very simple interface for the visualisation of 3D meshes. More informations in Muscat.Bridges.PyVistaBridge

MMG [5]

MMG is a remeshing tools that simplify adaptation and optimization of the meshes. An interface is available in Musccat to use the :py:mod:Muscat.Containers.Mesh class directly. This can be done using:

# 2D mesh example
import numpy as np
from Muscat.Containers.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