Pacman Interface¶
Muscat provides an optional bridge to Pacman for accelerated field-transfer
operations. The bridge is implemented in Muscat.Bridges.PacmanBridge and
can be used when the pacman Python module is available in the active Python
environment.
Pacman is not a mandatory dependency of Muscat. If it is not installed, calling
the bridge raises a RuntimeError asking the user to install Pacman first.
Available transfers¶
The Pacman bridge exposes three families of transfer routines:
GetFieldTransferPacmanFE: finite-element interpolation on supported Muscat element types.GetFieldTransferPacmanMLS: Moving Least Squares interpolation from mesh nodes to target points.GetFieldTransferPacmanRBF: Radial Basis Function interpolation from mesh nodes to target points.
The input can be either a FEField or a Mesh. A Mesh can be passed
with the inputMesh keyword or, for convenience, as the first positional
argument. When a Mesh is used, values are read from mesh.nodeFields.
For finite-element transfer, one or more nodal fields can be provided and the
result is reconstructed as a dictionary keyed by the original field names.
Finite-element transfer¶
GetFieldTransferPacmanFE returns both interpolated values and a status
array:
from Muscat.Bridges.PacmanBridge import GetFieldTransferPacmanFE
values, status = GetFieldTransferPacmanFE(
inputField,
targetPoints=targetPoints,
method="Interp/Clamp",
)
mesh_values, mesh_status = GetFieldTransferPacmanFE(
inputMesh=mesh,
targetPoints=targetPoints,
method="Interp/Clamp",
)
Supported FE methods are:
"Nearest/Nearest""Interp/Clamp""Interp/Nearest""Interp/ZeroFill""Interp/Extrap"None: equivalent to"Interp/Clamp"
The returned status values use Muscat’s field-transfer convention:
0: nearest1: interpolation2: extrapolation3: clamp4: zero fill
When inputMesh is used, all nodal fields in mesh.nodeFields are packed
before the Pacman call and unpacked afterwards. The returned values are a
dictionary with the same keys as mesh.nodeFields. For example, if
mesh.nodeFields contains "temperature" and "displacement", then
mesh_values["temperature"] and mesh_values["displacement"] contain the
corresponding transferred arrays.
The FE bridge supports the following Muscat element types:
Point_1Bar_2andBar_3Triangle_3andTriangle_6Quadrangle_4andQuadrangle_8Tetrahedron_4andTetrahedron_10Hexahedron_8andHexahedron_20Wedge_6andWedge_15Pyramid_5andPyramid_13
MLS and RBF transfers¶
The MLS and RBF helpers return the transferred values directly:
from Muscat.Bridges.PacmanBridge import (
GetFieldTransferPacmanMLS,
GetFieldTransferPacmanRBF,
)
mls_values = GetFieldTransferPacmanMLS(inputField, targetPoints)
rbf_values = GetFieldTransferPacmanRBF(
inputField,
targetPoints,
method="WENDLANDC2",
)
MLS and RBF transfers require scalar nodal values. With inputMesh, this
means mesh.nodeFields must describe a single scalar nodal quantity; the
returned value is reconstructed as a dictionary keyed by the nodal-field name.
Supported RBF functions are:
"WENDLANDC0""WENDLANDC2""WENDLANDC4""WENDLANDC6""WENDLANDC8"
Execution space selection¶
Pacman execution spaces are selected automatically by
GetPacmanExecSpace(). The first available execution space is chosen in this
order:
CUDAHIPOPENMPSERIAL
The selected execution-space name is cached after the first successful lookup. This means that a Python process normally uses a consistent Pacman execution space for all subsequent bridge calls.
Dependencies and compilation¶
Pacman must be compiled against a dependency stack compatible with the one used by Muscat. In practice, this stack includes:
Kokkos
Kokkos-Kernels
ArborX
Pacman
Muscat
For source-build instructions for Muscat and this external stack, see Installing Muscat.