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 structuredGridBase
. 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.
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
The spatial axes along which this field component is defined.
The internal buffer storing this field’s data.
Read-only dictionary of field components.
The coordinate system (e.g. a subclass of
OrthogonalCoordinateSystem
) which underlies this grid.The symbolic coordinate dependence object for this tensor field.
The data type of the elements stored in the buffer.
Number of trailing element-wise dimensions (e.g., vector or tensor structure).
The shape of the element-wise structure (e.g., vector or tensor components).
Total number of element-wise components.
The structured grid associated with this field.
Return True if the field has no element-wise structure.
Number of spatial axes the field is defined over.
Total number of dimensions in the field buffer.
The rank [number of indices] of the tensor.
The shape of the full data array, including spatial and element dimensions.
Total number of elements in the buffer.
Number of spatial dimensions (i.e., number of named axes).
The shape of the field over the spatial axes (grid-aligned dimensions).
Total number of spatial elements (grid cells).
Physical units attached to the buffer data, if defined.