DenseField#

class fields.base.DenseField(grid: GridBase, component: FieldComponent)[source]#

Concrete field class for dense, single-component data on structured grids.

DenseField represents the most common type of geometric field in Pymetric: a uniformly defined scalar, vector, or tensor field backed by a single data buffer and aligned with a structured GridBase. This class is ideal for continuous fields that span the entire domain and share a consistent coordinate and metric context.

Internally, the field is implemented using a single FieldComponent, which encodes both the array data and its spatial alignment. The field supports geometric operations, symbolic dependence tracking, coordinate-aware transformations, and NumPy-style arithmetic and ufuncs.

Typical use cases include:

  • Scalar fields (e.g., temperature, pressure)

  • Vector fields (e.g., velocity, electric field)

  • Tensor fields (e.g., stress, strain)

See also

FieldComponent

Underlying data wrapper used by this class.

DenseTensorField

Tensor-valued field supporting variance-aware operations.

GridBase

Structured grid class supporting coordinate systems and chunking.

Methods

__init__(grid, component)

Initialize a dense, single-component field on a structured grid.

as_array()

Return the underlying buffer as a NumPy array.

as_unyt_array()

Return the underlying buffer as a unyt array with units.

determine_op_dependence(opname, *args, **kwargs)

Infer the symbolic coordinate dependence resulting from a differential operation.

element_wise_laplacian([out, Lterm_field, ...])

Compute the element-wise Laplacian of the field.

element_wise_partial_derivatives([out, ...])

Compute the element-wise partial derivatives of the field.

from_array(*args, **kwargs)

Construct a FieldComponent from an existing array-like object.

from_function(*args, **kwargs)

Construct a FieldComponent by evaluating a function on the grid.

full(*args, **kwargs)

Create a dense field filled with a fill value.

full_like(other, *args, **kwargs)

Create a full-valued component with the same grid, axes, and element shape as another.

ones(*args, **kwargs)

Create a dense field filled with ones.

ones_like(other, *args, **kwargs)

Create a one-filled component with the same grid, axes, and element shape as another.

validate_component(index, component)

Validate a single field component and its index.

validate_components(components)

Validate all components in a dictionary for consistency with the field.

zeros(*args, **kwargs)

Create a dense field filled with zeros.

zeros_like(other, *args, **kwargs)

Create a zero-filled component with the same grid, axes, and element shape as another.

Attributes

axes

The spatial axes along which this field component is defined.

buffer

The internal buffer storing this field’s data.

components

Read-only dictionary of field components.

coordinate_system

The coordinate system (e.g. a subclass of OrthogonalCoordinateSystem) which underlies this grid.

dependence

The symbolic coordinate dependence object for this tensor field.

dtype

The data type of the elements stored in the buffer.

element_ndim

Number of trailing element-wise dimensions (e.g., vector or tensor structure).

element_shape

The shape of the element-wise structure (e.g., vector or tensor components).

element_size

Total number of element-wise components.

grid

The structured grid associated with this field.

is_scalar

Return True if the field has no element-wise structure.

naxes

Number of spatial axes the field is defined over.

ndim

Total number of dimensions in the field buffer.

rank

The rank [number of indices] of the tensor.

shape

The shape of the full data array, including spatial and element dimensions.

size

Total number of elements in the buffer.

spatial_ndim

Number of spatial dimensions (i.e., number of named axes).

spatial_shape

The shape of the field over the spatial axes (grid-aligned dimensions).

spatial_size

Total number of spatial elements (grid cells).

units

Physical units attached to the buffer data, if defined.