qewton.geometries.continuous.domains_1d package

Module contents

Submodules

qewton.geometries.continuous.domains_1d.interval module

class qewton.geometries.continuous.domains_1d.interval.Interval(variable: Variable, lower_bound, upper_bound, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]

Bases: ContinuousGeometry[TensorType]

Interval class representing a 1D interval domain defined by a lower and upper bound.

Parameters:
  • variable (Variable) – The variable associated with the interval, must be 1D.

  • lower_bound (float) – The lower bound of the interval.

  • upper_bound (float) – The upper bound of the interval.

  • backend (type[ComputingBackend[TensorType]], optional) – What backend the node should use for computations, etc. Defaults to the deep learning backend (DEFAULT_DL_BACKEND).

contains(points)[source]

Check for every point whether it lies inside the geometry.

Parameters:

points (TensorType) – The points to check, shape (n_points, dim).

Returns:

Boolean tensor of shape (n_points, 1), True

where the point lies inside.

Return type:

TensorType

create_mesh(max_vertex_distance: float | None = None, device: Device = CPU())[source]

Mesh this geometry into a mesh geometry.

Parameters:
  • max_vertex_distance – The maximum distance between mesh vertices, which controls how fine the mesh is.

  • device – The device the mesh is created on.

Returns:

The meshed geometry.

Return type:

DiscreteGeometry

Raises:

NotImplementedError – If the geometry does not support meshing.

sample_random_uniform(n_points: int, device: Device | str = CPU()) → TensorType[source]

Sample uniformly distributed random points inside the geometry.

Parameters:
  • n_points – The number of points to sample.

  • device – The device to sample on.

Returns:

The sampled points, shape (n_points, dim).

Return type:

TensorType

sample_grid(n_points: int, device: Device | str = CPU()) → TensorType[source]

Sample grid points inside the geometry.

Parameters:
  • n_points – The number of points to sample.

  • device – The device to sample on.

Returns:

The sampled points, shape (n_points, dim).

Return type:

TensorType

bounding_box()[source]

Compute the axis-aligned bounds of the geometry.

Returns:

Tensor of length 2 * dim of the form

[axis_1_min, axis_1_max, axis_2_min, axis_2_max, ...].

Return type:

TensorType

create_boundary()[source]

Create the boundary of this geometry.

Returns:

A new boundary geometry.

Return type:

BoundaryGeometry

Raises:

NotImplementedError – If the geometry has no boundary implementation.

property boundary_left: IntervalSingleBoundaryPoint

Returns only the left boundary value, useful for the definition of initial conditions.

property boundary_right: IntervalSingleBoundaryPoint

Returns only the right boundary value, useful for the definition of end conditions.

class qewton.geometries.continuous.domains_1d.interval.IntervalBoundary(geometry)[source]

Bases: ContinuousBoundaryGeometry[TensorType]

contains(points)[source]

Check for every point whether it lies inside the geometry.

Parameters:

points (TensorType) – The points to check, shape (n_points, dim).

Returns:

Boolean tensor of shape (n_points, 1), True

where the point lies inside.

Return type:

TensorType

create_mesh(max_vertex_distance: float | None = None, device: Device = CPU())[source]

Mesh this geometry into a mesh geometry.

Parameters:
  • max_vertex_distance – The maximum distance between mesh vertices, which controls how fine the mesh is.

  • device – The device the mesh is created on.

Returns:

The meshed geometry.

Return type:

DiscreteGeometry

Raises:

NotImplementedError – If the geometry does not support meshing.

sample_random_uniform(n_points: int, device: Device | str = CPU(), include_normals: bool = False)[source]

Sample uniformly distributed random points on the boundary.

Parameters:
  • n_points – The number of points to sample.

  • device – The device to sample on.

  • include_normals – Whether to also return the normal vectors at the points.

Returns:

The points, or

(points, normals) if include_normals is True.

Return type:

TensorType or tuple of TensorType

sample_grid(n_points: int, device: Device | str = CPU(), include_normals: bool = False)[source]

Sample grid points on the boundary.

Parameters:
  • n_points – The number of points to sample.

  • device – The device to sample on.

  • include_normals – Whether to also return the normal vectors at the points.

Returns:

The points, or

(points, normals) if include_normals is True.

Return type:

TensorType or tuple of TensorType

normal(points, device: Device | str = CPU()) → TensorType[source]

Compute the outward normal vector at each point.

Parameters:
  • points (TensorType) – The boundary points, shape (n_points, dim).

  • device – The device to compute on.

Returns:

The normal vectors, shape (n_points, dim).

Return type:

TensorType

class qewton.geometries.continuous.domains_1d.interval.IntervalSingleBoundaryPoint(geometry, side, normal_vec=-1)[source]

Bases: ContinuousBoundaryGeometry[TensorType]

contains(points)[source]

Check for every point whether it lies inside the geometry.

Parameters:

points (TensorType) – The points to check, shape (n_points, dim).

Returns:

Boolean tensor of shape (n_points, 1), True

where the point lies inside.

Return type:

TensorType

create_mesh(max_vertex_distance: float | None = None, device: Device = CPU())[source]

Mesh this geometry into a mesh geometry.

Parameters:
  • max_vertex_distance – The maximum distance between mesh vertices, which controls how fine the mesh is.

  • device – The device the mesh is created on.

Returns:

The meshed geometry.

Return type:

DiscreteGeometry

Raises:

NotImplementedError – If the geometry does not support meshing.

sample_random_uniform(n_points: int, device: Device | str = CPU(), include_normals: bool = False)[source]

Sample uniformly distributed random points on the boundary.

Parameters:
  • n_points – The number of points to sample.

  • device – The device to sample on.

  • include_normals – Whether to also return the normal vectors at the points.

Returns:

The points, or

(points, normals) if include_normals is True.

Return type:

TensorType or tuple of TensorType

sample_grid(n_points: int, device: Device | str = CPU(), include_normals: bool = False)[source]

Sample grid points on the boundary.

Parameters:
  • n_points – The number of points to sample.

  • device – The device to sample on.

  • include_normals – Whether to also return the normal vectors at the points.

Returns:

The points, or

(points, normals) if include_normals is True.

Return type:

TensorType or tuple of TensorType

normal(points, device: Device | str = CPU())[source]

Compute the outward normal vector at each point.

Parameters:
  • points (TensorType) – The boundary points, shape (n_points, dim).

  • device – The device to compute on.

Returns:

The normal vectors, shape (n_points, dim).

Return type:

TensorType