grids.core.GenericGrid.__init__#
- GenericGrid.__init__(coordinate_system: _CoordinateSystemBase, coordinates: Sequence[ndarray], /, ghost_zones: Sequence[Sequence[float]] | None = None, chunk_size: Sequence[int] | None = None, *args, units: Dict[str, str | Unit] | None = None, center: Literal['vertex', 'cell'] = 'vertex', bbox: BoundingBox | None = None, **kwargs)[source]#
Construct a generic grid on a particular coordinate system.
This method uses the coordinates and coordinate_system arguments to construct the coordinate grid.
- Parameters:
coordinate_system (
CurvilinearCoordinateSystem
) –An instance of a coordinate system subclass (e.g.,
CartesianCoordinateSystem3D
,CylindricalCoordinateSystem
, orSphericalCoordinateSystem
), which defines the geometry and dimensionality of the grid. This object determines:The number of spatial dimensions spanned by the
GenericGrid
(ndim
)The axis names (
axes
. e.g.,["x", "y", "z"]
or["r", "theta", "phi"]
)The behavior of differential operations such as gradient and divergence
Note
The number of coordinate arrays provided in
coordinates
must match the dimensionality defined by this coordinate system.coordinates (
list
ofnumpy.ndarray
) – The coordinate positions of each of the cells along each coordinate axis. Ifcenter='vertex'
, then these are interpreted as the vertex coordinates and there will be N-1 cells along each axis. Ifcenter='cell'
, then the coordinates will be interpreted as the cell coordinates.ghost_zones (
numpy.ndarray
, optional) –The number of ghost cells to include on each side of every axis. Should be a 2D array-like object of shape
(2, ndim)
, where:The first row specifies the number of ghost cells on the lower side of each axis.
The second row specifies the number on the upper side.
If not provided, defaults to no ghost cells (i.e., zeros on all boundaries).
Hint
Including
ghost_zones
is generally good practice because most numerical schemes for computing differential operations can obtain \(\mathcal{O}(\delta x^2)\) precision in the center of the grid but may lose accuracy at edges. Thus, ghost zones can be configured to ensure that these low accuracy areas are outside of the desired physical domain.chunk_size (
list
ofint
, optional) – A sequence of integers specifying the number of grid points per chunk along each axis. If specified, enables chunking support for domain decomposition, which can be useful for parallel processing or memory-constrained workflows. Each chunk size must evenly divide the non-ghost extent of the corresponding axis. If not specified, chunking is disabled.args – Positional arguments passed through to initialization hooks. These are forwarded to
__configure_domain__
and__configure_boundary__
.units (
dict
ofstr
orUnit
, optional) – A dictionary mapping base physical dimensions (e.g., “length”, “time”, “mass”, “angle”) to their corresponding units, either as strings (e.g., “cm”, “s”) or asUnit
instances. If not provided, the grid defaults to the CGS (centimeter–gram–second) unit system. This unit system is used for interpreting coordinate values and for scaling differential geometry operations.kwargs – Additional keyword arguments forwarded to subclass initialization routines, such as boundary condition configuration or field metadata.
- Raises:
GridInitializationError – If the coordinate arrays are invalid (e.g., wrong shape, not increasing), or if chunking/ghost zone settings are inconsistent with the domain.
Notes
This constructor calls the base class
grids.base.GridBase.__init__()
, which delegates setup to:__configure_coordinate_system__
__configure_unit_system__
__configure_domain__
__configure_boundary__
All coordinate arrays are stored internally and used for geometric evaluation, boundary layout, and interpolation logic.