qewton.geometries.continuous.domain_operations package

Module contents

Submodules

qewton.geometries.continuous.domain_operations.cut module

class qewton.geometries.continuous.domain_operations.cut.CutGeometry(geometry_a: ContinuousGeometry, geometry_b: ContinuousGeometry, contained=False)[source]

Bases: ContinuousGeometry[TensorType]

Implements the logical cut of two geometries. The cut is implemented via “on time sampling” and does not have an explicit representation. When points are sampled they are filtered using logical operations.

Parameters:
  • geometry_a (ContinuousGeometry) – The first geometry.

  • geometry_b (ContinuousGeometry) – The second geometry.

  • contained (bool) – Whether geometry_b is fully contained within geometry_a.

  • 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

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

sample_random_uniform(n_points: int, device: Device = CPU())[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 = CPU())[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

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.

class qewton.geometries.continuous.domain_operations.cut.CutBoundaryGeometry(geometry: CutGeometry)[source]

Bases: ContinuousBoundaryGeometry

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

sample_random_uniform(n_points: int, device: Device = 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 = 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 = 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

qewton.geometries.continuous.domain_operations.intersection module

class qewton.geometries.continuous.domain_operations.intersection.IntersectionGeometry(geometry_a: ContinuousGeometry, geometry_b: ContinuousGeometry)[source]

Bases: ContinuousGeometry[TensorType]

Implements the logical intersection of two geometries. The intersection is implemented via “on time sampling” and does not have an explicit representation. When points are sampled they are filtered using logical operations.

Parameters:
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

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

sample_random_uniform(n_points: int, device: Device = CPU())[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 = CPU())[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

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.

class qewton.geometries.continuous.domain_operations.intersection.IntersectionBoundaryGeometry(geometry: IntersectionGeometry)[source]

Bases: ContinuousBoundaryGeometry

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

sample_random_uniform(n_points: int, device: Device = 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 = 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 = 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

qewton.geometries.continuous.domain_operations.sampler_helper module

This file contains some sample functions for the domain operations. Since Union/Cut/Intersection follow the same idea for sampling for a given number of points.

qewton.geometries.continuous.domain_operations.union module

class qewton.geometries.continuous.domain_operations.union.UnionGeometry(geometry_a: ContinuousGeometry, geometry_b: ContinuousGeometry)[source]

Bases: ContinuousGeometry[TensorType]

Implements the logical union of two geometries. The union is implemented via “on time sampling” and does not have an explicit representation. When points are sampled they are filtered using logical operations.

Parameters:
  • geometry_a (ContinuousGeometry) – The first geometry.

  • geometry_b (ContinuousGeometry) – The second geometry.

  • contained (bool) – Whether geometry_b is fully contained within geometry_a.

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

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

sample_random_uniform(n_points: int, device: Device = CPU())[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 = CPU())[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

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.

class qewton.geometries.continuous.domain_operations.union.UnionBoundaryDomain(geometry: UnionGeometry)[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

sample_random_uniform(n_points: int, device: Device = 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 = 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 = 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