Class pylset_grid¶
Provides the fixed Cartesian grid in 2D or 3D and the boundary conditions along each axis.
Methods:¶
__init__ ¶
__init__(domain_size: Union[List[float], ndarray], ndiv: Union[List[int], ndarray], bc: Sequence[str] = ('Periodic', 'Periodic', 'Periodic')) -> None
Initialize a fixed Cartesian grid in 2D or 3D.
The dimensionality is set by the length of ndiv (2 or 3). Level set values
are stored at cell centers, so grid point i along an axis sits at
x_i = (i + 0.5)*dx, and interfaces taken from voxel data lie on cell faces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain_size
|
array_like of float, shape (ndim,)
|
Physical size of the domain along each axis, [Lx, Ly] or [Lx, Ly, Lz]. |
required |
ndiv
|
array_like of int, shape (ndim,)
|
Number of grid points (cells) along each axis, [nx, ny] or [nx, ny, nz]. |
required |
bc
|
sequence of str
|
Boundary condition along each axis, 'Periodic' or 'Mirror'. Only the
first |
('Periodic', 'Periodic', 'Periodic')
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dimensionality is not 2 or 3, if |
get_bc ¶
Get the boundary conditions along each axis.
Returns:
| Name | Type | Description |
|---|---|---|
bc |
list of str
|
'PERIODIC' or 'MIRROR' for each axis. |
get_coordinates ¶
Get the cell center coordinates along one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
int
|
Axis index, 0 for x, 1 for y and 2 for z. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
x |
ndarray of float, shape (ndiv[axis],)
|
Coordinates |
get_ddiv ¶
Get the grid spacing along each axis.
Returns:
| Name | Type | Description |
|---|---|---|
ddiv |
ndarray of float, shape (ndim,)
|
Grid spacing along each axis. |
get_domain_size ¶
Get the physical size of the domain.
Returns:
| Name | Type | Description |
|---|---|---|
domain_size |
ndarray of float, shape (ndim,)
|
Size of the domain along each axis. |
get_meshgrid ¶
Get cell center coordinate arrays for the full grid.
Returns:
| Name | Type | Description |
|---|---|---|
coords |
list of ndarray
|
One array of shape |
get_ndim ¶
Get the dimensionality of the grid.
Returns:
| Name | Type | Description |
|---|---|---|
ndim |
int
|
2 or 3. |
get_ndiv ¶
Get the number of grid points along each axis.
Returns:
| Name | Type | Description |
|---|---|---|
ndiv |
ndarray of int, shape (ndim,)
|
Number of grid points along each axis. |
get_periodic ¶
Get a flag for each axis telling whether the axis is periodic.
Returns:
| Name | Type | Description |
|---|---|---|
periodic |
list of bool
|
True for periodic axes. |
set_bc ¶
Set the boundary conditions along each axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bc
|
sequence of str
|
Boundary condition along each axis, 'Periodic' or 'Mirror' (case
insensitive). At least |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If too few entries are given or a boundary condition is not recognized. |
set_ndiv ¶
Set the number of grid points along each axis, keeping the domain size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ndiv
|
array_like of int, shape (ndim,)
|
Number of grid points along each axis. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of entries differs from the current dimensionality. |