Python API

class pcms.BoundCoordinateMap

A CoordinateMap bound to one set of query points

mapped_points(self: object) → pcms.CoordinateView

The query points in the map’s target coordinate system, read-only

num_points(self: pcms.BoundCoordinateMap) → int
output_basis(self: pcms.BoundCoordinateMap, stored: pcms.ValueBasis) → pcms.ValueBasis

The basis values stored in stored are re-expressed in

transform_values(self: pcms.BoundCoordinateMap, values: pcms.ValueView) → pcms.ValueView

Re-express values (one row per query point, over a writeable C-contiguous float64 array) in place, and return a ValueView of the same array tagged with the new basis

class pcms.CartesianToCylindrical
class pcms.ComponentScaling

How components are scaled relative to the coordinate-induced basis

Members:

Physical : Components on the unit basis; all have the same units

Natural : Components on the unscaled coordinate basis

Natural = <ComponentScaling.Natural: 1>
Physical = <ComponentScaling.Physical: 0>
ComponentScaling.name -> str
property value
class pcms.CoordinateMap

Maps points from a source to a target coordinate system; values are re-expressed the other way

bind(self: pcms.CoordinateMap, query_points: pcms.CoordinateView) → pcms.BoundCoordinateMap

Do every per-point computation for points in the source coordinate system

get_source_coordinate_system(self: pcms.CoordinateMap) → pcms.CoordinateSystem
get_target_coordinate_system(self: pcms.CoordinateMap) → pcms.CoordinateSystem
class pcms.CoordinateSystem

What coordinate numbers mean. Create one through the classes in pcms.csys.

dimension(self: pcms.CoordinateSystem) → int

Number of coordinate columns

has_orthogonal_basis(self: pcms.CoordinateSystem) → bool
has_unit_scale_factors(self: pcms.CoordinateSystem) → bool
kind(self: pcms.CoordinateSystem) → str

Family label, e.g. ‘cartesian’

class pcms.CoordinateView

Coordinates tagged with their coordinate system

get_coordinate_system(self: pcms.CoordinateView) → pcms.CoordinateSystem
get_values(self: pcms.CoordinateView) → numpy.ndarray[numpy.float64]

The coordinates as a read-only 2D array (num_points × dim)

class pcms.Copy
class pcms.CylindricalToCartesian
class pcms.EvaluationRequest
property coords
static from_coordinates(coordinates: pcms.CoordinateView, policy: pcms.OutOfBoundsPolicy = <pcms.OutOfBoundsPolicy object at 0x7f6af81df4b0>) → pcms.EvaluationRequest

Request evaluation at the given CoordinateView’s points

static from_function_space(function_space: pcms::FunctionSpace, policy: pcms.OutOfBoundsPolicy = <pcms.OutOfBoundsPolicy object at 0x7f6af81df730>) → pcms.EvaluationRequest

Request evaluation at a FunctionSpace’s DOF-holder coordinates

property policy
class pcms.Field

DOF-holder values together with the layout that orders them

get_data(self: pcms.Field) → pcms.FieldData
get_dof_holder_data(self: object) → pcms.ValueView

The DOF-holder values (num_dof_holders × num_components) as a ValueView whose array is read-only. When the field’s data is in host memory the array shares it, so it reflects later writes; otherwise it is a copy.

get_layout(self: pcms.Field) → pcms.FieldLayout
get_name(self: pcms.Field) → str
set_dof_holder_data(*args, **kwargs)

Overloaded function.

  1. set_dof_holder_data(self: pcms.Field, data: pcms.ValueView) -> None

Set the DOF-holder values from a ValueView (num_dof_holders × num_components) whose basis must match the field’s

  1. set_dof_holder_data(self: pcms.Field, data: numpy.ndarray[numpy.float64]) -> None

Set a scalar field’s DOF-holder values from a plain 2D array (num_dof_holders × num_components). A 1D array (num_dof_holders,) is accepted when the field has one component.

set_dof_holder_data_unchecked(self: pcms.Field, data: numpy.ndarray[numpy.float64]) → None

Set the DOF-holder values without checking their basis (the shape is still checked). A 1D array (num_dof_holders,) is accepted when the field has one component.

class pcms.FieldData

A field’s stored values

get_value_basis(self: pcms.FieldData) → pcms.ValueBasis

The basis the stored components are in

get_value_type(self: pcms.FieldData) → pcms.FieldValueType
class pcms.FieldLayout

How a field’s DOF holders are laid out

get_coordinate_system(self: pcms.FieldLayout) → pcms.CoordinateSystem

What this layout’s DOF-holder coordinates mean

get_dimension(self: pcms.FieldLayout) → int
get_dof_holder_coordinates(self: object) → pcms.CoordinateView

The DOF-holder coordinates (num_dof_holders × dim), read-only

get_num_components(self: pcms.FieldLayout) → int
get_num_global_dof_holder(self: pcms.FieldLayout) → int
get_num_owned_dof_holder(self: pcms.FieldLayout) → int
is_distributed(self: pcms.FieldLayout) → bool
class pcms.FieldValueType

Members:

Scalar

Vector

Tensor

Scalar = <FieldValueType.Scalar: 0>
Tensor = <FieldValueType.Tensor: 2>
Vector = <FieldValueType.Vector: 1>
FieldValueType.name -> str
property value
class pcms.Function

A Field that knows its FunctionSpace

get_space(self: pcms.Function) → pcms::FunctionSpace
class pcms.FunctionSpace
create_function(self: pcms.FunctionSpace, name: str = '', variance: pcms.VarianceSignature = <pcms.VarianceSignature []>, system: pcms.CoordinateSystem = None, scaling: pcms.ComponentScaling | None = None) → pcms.Function

Create a Function in this space. Vector and tensor values are in system’s basis (default: this space’s coordinate system), with scaling required when that system admits both scalings.

get_layout(self: pcms.FunctionSpace) → pcms.FieldLayout
mesh(self: pcms.FunctionSpace) → Omega_h::Mesh

The Omega_h mesh this function space is defined on (Omega_h backend only).

class pcms.Interpolator
class pcms.LagrangeFunctionSpace
class Backend

Members:

MeshFields : MeshFields-backed layout (default when MeshFields is enabled)

OmegaH : Native Omega_h Lagrange layout (required by the conservative and Monte Carlo projection transfer operators)

MeshFields = <Backend.MeshFields: 0>
OmegaH = <Backend.OmegaH: 1>
LagrangeFunctionSpace.Backend.name -> str
property value
MeshFields = <Backend.MeshFields: 0>
OmegaH = <Backend.OmegaH: 1>
static from_mesh(mesh: Omega_h::Mesh, order: int, num_components: int, mesh_coordinate_system: pcms.CoordinateSystem = None, global_id_name: str = 'global', backend: pcms.LagrangeFunctionSpace.Backend = <Backend.MeshFields: 0>) → pcms.LagrangeFunctionSpace

Create a LagrangeFunctionSpace from an Omega_h mesh. The coordinate system defaults to Cartesian.

static from_uniform_grid(*args, **kwargs)

Overloaded function.

  1. from_uniform_grid(grid: pcms.UniformGrid2D, num_components: int, mesh_coordinate_system: pcms.CoordinateSystem = None, order: int = 1) -> pcms.LagrangeFunctionSpace

Create a LagrangeFunctionSpace from a 2D uniform grid. The coordinate system defaults to Cartesian.

  1. from_uniform_grid(grid: pcms.UniformGrid3D, num_components: int, mesh_coordinate_system: pcms.CoordinateSystem = None, order: int = 1) -> pcms.LagrangeFunctionSpace

Create a LagrangeFunctionSpace from a 3D uniform grid. The coordinate system defaults to Cartesian.

class pcms.MLSOptions
property adapt_radius
property basis
property decay_factor
property degree
property lambda_reg
property min_req_supports
property radius
property tol
class pcms.MassMatrixType

Members:

Consistent : Full Galerkin mass matrix

Lumped : Row-sum lumped diagonal mass matrix (exact diagonal solve; conserves the integral but adds lumping error)

Consistent = <MassMatrixType.Consistent: 0>
Lumped = <MassMatrixType.Lumped: 1>
MassMatrixType.name -> str
property value
class pcms.MonteCarloSampling

Members:

UniformRandom : Independent pseudo-random uniform draws per element

UniformRandom = <MonteCarloSampling.UniformRandom: 0>
MonteCarloSampling.name -> str
property value
class pcms.OmegaHConservativeProjection
class pcms.OmegaHControlVariateProjection
class pcms.OutOfBoundsMode

Members:

ERROR : Raise error when points are out of bounds

FILL : Fill with a specified value when points are out of bounds

NEAREST_BOUNDARY : Clamp to nearest boundary cell (extrapolate)

ERROR = <OutOfBoundsMode.ERROR: 0>
FILL = <OutOfBoundsMode.FILL: 1>
NEAREST_BOUNDARY = <OutOfBoundsMode.NEAREST_BOUNDARY: 2>
OutOfBoundsMode.name -> str
property value
class pcms.OutOfBoundsPolicy
property fill_value

Fill value (used only when mode == FILL)

property mode

Out-of-bounds handling mode

class pcms.PointEvaluator

Evaluates fields at the query points it was created for

evaluate(*args, **kwargs)

Overloaded function.

  1. evaluate(self: pcms.PointEvaluator, field: pcms.Field, output: pcms.ValueView) -> None

Evaluate the field into output, a ValueView over a writeable C-contiguous float64 array (num_points × num_components) whose basis must be output_basis() of the field’s stored basis

  1. evaluate(self: pcms.PointEvaluator, field: pcms.Field, output: numpy.ndarray) -> None

Evaluate a scalar field into a writeable C-contiguous float64 array (num_points × num_components). A 1D array (num_points,) is accepted when the output has one component.

filled_points(self: object) → numpy.ndarray[numpy.int32]

Indices of the query points that get the out-of-bounds fill value, read-only

num_points(self: pcms.PointEvaluator) → int
output_basis(self: pcms.PointEvaluator, stored: pcms.ValueBasis) → pcms.ValueBasis

The basis this evaluator writes for a field stored in stored

class pcms.PointEvaluatorFactory

Creates evaluators bound to query points

create_point_evaluator(self: pcms.PointEvaluatorFactory, request: pcms.EvaluationRequest) → pcms::PointEvaluator<double, Kokkos::layout_right>

Create a reusable point evaluator for the request’s points

get_coordinate_system(self: pcms.PointEvaluatorFactory) → pcms.CoordinateSystem

The coordinate system query points must be expressed in

class pcms.PolynomialReconstructionFunctionSpace
static create(coords: pcms.CoordinateView, options: pcms.MLSOptions = <pcms.MLSOptions object at 0x7f6af81e58b0>) → pcms.PolynomialReconstructionFunctionSpace

Create a PolynomialReconstructionFunctionSpace over the source points of a CoordinateView

static from_mesh(mesh: Omega_h::Mesh, source_entity_dim: int, coordinate_system: pcms.CoordinateSystem = None, options: pcms.MLSOptions = <pcms.MLSOptions object at 0x7f6af81e59b0>) → pcms.PolynomialReconstructionFunctionSpace

Create a PolynomialReconstructionFunctionSpace from mesh entity coordinates.

class pcms.RadialBasisFunction

Members:

RBF_GAUSSIAN

RBF_C4

RBF_CONST

NO_OP

NO_OP = <RadialBasisFunction.NO_OP: 3>
RBF_C4 = <RadialBasisFunction.RBF_C4: 1>
RBF_CONST = <RadialBasisFunction.RBF_CONST: 2>
RBF_GAUSSIAN = <RadialBasisFunction.RBF_GAUSSIAN: 0>
RadialBasisFunction.name -> str
property value
class pcms.TransferOperator
apply(self: pcms.TransferOperator, source: pcms.Field, target: pcms.Field) → None

Transfer the source field onto the target

class pcms.TransformedSource

Presents a PointEvaluatorFactory as one in another coordinate system

class pcms.UniformGrid2D
property bot_left

Bottom-left corner coordinates

closest_cell_id(self: pcms.UniformGrid2D, point: numpy.ndarray[numpy.float64]) → int

Get the cell ID that contains or is closest to the given point

property divisions

Number of divisions in each dimension

property edge_length

Edge length in each dimension

get_cell_bbox(self: pcms.UniformGrid2D, cell_index: int) → pcms::AABBox<2>

Get the bounding box of a cell

get_num_cells(self: pcms.UniformGrid2D) → int

Get the total number of cells in the grid

class pcms.UniformGrid3D
property bot_left

Bottom-left corner coordinates

closest_cell_id(self: pcms.UniformGrid3D, point: numpy.ndarray[numpy.float64]) → int

Get the cell ID that contains or is closest to the given point

property divisions

Number of divisions in each dimension

property edge_length

Edge length in each dimension

get_cell_bbox(self: pcms.UniformGrid3D, cell_index: int) → pcms::AABBox<3>

Get the bounding box of a cell

get_num_cells(self: pcms.UniformGrid3D) → int

Get the total number of cells in the grid

class pcms.ValueBasis

The basis a value’s components are expressed in. The default is the scalar basis.

rank(self: pcms.ValueBasis) → int
property scaling
property system
property variance
class pcms.ValueView

Values (num_points × num_components) tagged with the basis their components are in

extent(self: pcms.ValueView, r: int) → int
get_basis(self: pcms.ValueView) → pcms.ValueBasis
get_value_type(self: pcms.ValueView) → pcms.FieldValueType
get_values(self: pcms.ValueView) → numpy.ndarray
rank(self: pcms.ValueView) → int
size(self: pcms.ValueView) → int
class pcms.Variance

Index variance: Contravariant components are on the basis dx/dq^i, Covariant on the dual grad q^i

Members:

Contravariant

Covariant

Contravariant = <Variance.Contravariant: 0>
Covariant = <Variance.Covariant: 1>
Variance.name -> str
property value
class pcms.VarianceSignature

The variance of each index of a value

rank(self: pcms.VarianceSignature) → int
pcms.compute_entity_centroids(mesh: Omega_h::Mesh, entity_dim: int) → numpy.ndarray

Compute centroids of mesh entities (faces or elements). Returns an array of shape (nentities, dim).

pcms.compute_entity_centroids_few(mesh: Omega_h::Mesh, entity_dim: int) → numpy.ndarray

Compute entity centroids using gather_verts/gather_vectors/average. Returns an array of shape (nentities, dim). Note: This is an alias for compute_entity_centroids.

pcms.create_uniform_grid_binary_field(mesh: Omega_h::Mesh, divisions: Annotated[List[int], FixedSize(2)]) → pcms.Field

Create a 2D vertex mask field indicating inside/outside mesh

pcms.create_uniform_grid_from_mesh(*args, **kwargs)

Overloaded function.

  1. create_uniform_grid_from_mesh(mesh: Omega_h::Mesh, divisions: Annotated[List[int], FixedSize(2)]) -> pcms.UniformGrid2D

Create a 2D uniform grid from an Omega_h mesh

  1. create_uniform_grid_from_mesh(mesh: Omega_h::Mesh, divisions: Annotated[List[int], FixedSize(3)]) -> pcms.UniformGrid3D

Create a 3D uniform grid from an Omega_h mesh

pcms.has_identity_metric(system: pcms.CoordinateSystem) → bool
pcms.map_entity_field_to_vertices_average(mesh: Omega_h::Mesh, entity_field_values: numpy.ndarray[numpy.float64], entity_dim: int) → numpy.ndarray

Map field values defined on mesh entities (faces/elements) to vertices by simple averaging. Each vertex value is the average of all adjacent entity values.

Parameters:

mesh: OmegaHMesh object entity_field_values: numpy array of field values at entities (shape: (nentities,) or (nentities, ncomps)) entity_dim: dimension of entities (2 for faces, 3 for elements)

Returns:

numpy array of field values at vertices (shape: (nverts,) or (nverts, ncomps), matching entity_field_values)

pcms.map_entity_field_to_vertices_mls(mesh: Omega_h::Mesh, entity_field_values: numpy.ndarray[numpy.float64], entity_dim: int, interp_degree: int = 1, min_support: int = -1, lambda_reg: float = 1e-05) → numpy.ndarray

Map field values defined on mesh entities (faces/elements) to vertices using Moving Least Squares (MLS) interpolation. This provides smoother and more accurate interpolation than simple averaging.

Parameters:

mesh: OmegaHMesh object entity_field_values: numpy array of field values at entities (shape: (nentities,) or (nentities, ncomps)) entity_dim: dimension of entities (2 for faces, 3 for elements) interp_degree: polynomial degree for MLS (default: 1) min_support: minimum patch size, auto-selected if < 0 (default: -1) lambda_reg: regularization parameter (default: 1e-5)

Returns:

numpy array of field values at vertices (shape: (nverts,) or (nverts, ncomps), matching entity_field_values)

pcms.patch_size_for_degree(interp_degree: int) → int

Get recommended minimum patch size for given MLS interpolation degree. Returns 4 for degree 1, 10 for degree 2, and 12 for degree 3.

pcms.same_coordinate_system(a: pcms.CoordinateSystem, b: pcms.CoordinateSystem) → bool
pcms.same_value_basis(a: pcms.ValueBasis, b: pcms.ValueBasis) → bool