Coordinate System Module#

class CoordinateSystem(nx: int, ny: int, min_x: float, max_x: float, min_y: float, max_y: float)[source]#

Bases: object

Represents a 2D coordinate system defined by grid points and boundaries.

Parameters:
  • nx (int) – The number of grid points along the x-axis.

  • ny (int) – The number of grid points along the y-axis.

  • min_x (float) – The minimum x-coordinate boundary.

  • max_x (float) – The maximum x-coordinate boundary.

  • min_y (float) – The minimum y-coordinate boundary.

  • max_y (float) – The maximum y-coordinate boundary.

The CoordinateSystem class manages the coordinate grid for rendering and evaluating the mesh construction. It includes methods for centering, padding, and scaling boundaries, enabling flexible and precise geometry visualization.

nx: int#
ny: int#
min_x: float#
max_x: float#
min_y: float#
max_y: float#
property shape: Tuple[int, int]#
to_unstructured_coordinate() ndarray[source]#

Get an unstructured coordinate representation of the grid.

Returns:

An unstructured array of coordinates.

Return type:

numpy.ndarray

ensure_odd(attribute: str) None[source]#

Ensure the specified grid attribute (nx or ny) is odd.

Parameters:

attribute (str) – The attribute to update (‘nx’ or ‘ny’).

Raises:

ValueError – If the attribute is not ‘nx’ or ‘ny’.

y_centering(zero_included: bool = False) None[source]#

Center the y-axis coordinate system around zero.

Parameters:

zero_included (bool, optional) – If True, adjusts grid points to include zero. Default is True.

x_centering(zero_included: bool = False) None[source]#

Center the x-axis coordinate system around zero.

Parameters:

zero_included (bool, optional) – If True, adjusts grid points to include zero. Default is True.

center(factor: float = 1.0, zero_included: bool = False) None[source]#

Center the coordinate system by scaling the boundaries.

Parameters:
  • factor (float, optional) – Scaling factor for the boundaries. Must be greater than 0. Default is 1.2.

  • zero_included (bool, optional) – If True, adjust grid points to include zero. Default is True.

Raises:

ValueError – If the scaling factor is not positive.

add_padding(padding_factor: float) None[source]#

Add padding space around the coordinate boundaries.

Parameters:

padding_factor (float) – Factor by which to pad the boundaries. Must be greater than 0.

Raises:

ValueError – If the padding factor is not positive.

update(**kwargs) None[source]#

Update the coordinate system attributes and recompute parameters.

Parameters:

**kwargs (dict) – Attribute-value pairs to update in the coordinate system.

Raises:

ValueError – If an invalid attribute is passed.

property dx: float#
property dy: float#
property x_bounds: Tuple#
property y_bounds: Tuple#
property x_vector: ndarray#
property y_vector: ndarray#
property x_mesh: ndarray#
property y_mesh: ndarray#
set_right() None[source]#

Set the coordinate system boundaries to align the grid to the left.

set_left() None[source]#

Set the coordinate system boundaries to align the grid to the right.

set_top() None[source]#

Set the coordinate system boundaries to align the grid to the top.

set_bottom() None[source]#

Set the coordinate system boundaries to align the grid to the bottom.