qewton.geometries.continuous.domains_3d package

Module contents

Submodules

qewton.geometries.continuous.domains_3d.box module

class qewton.geometries.continuous.domains_3d.box.Box(variable: ~qewton.config.variables.Variable, origin: ~qewton.backends.base.TensorType | list[float] | tuple[float, float, float], width: float, height: float, depth: float, backend: type[~qewton.backends.base.ComputingBackend[~qewton.backends.base.TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]

Bases: ContinuousGeometry[TensorType]

Class for three-dimensional boxes.

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

  • origin (TensorType | list[float] | tuple[float, float, float]) – The origin of the box (one corner).

  • width (float) – The width of the box.

  • height (float) – The height of the box.

  • depth (float) – The depth of the box.

  • 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.

create_mesh(max_vertex_distance: float | None = None, device: Device = CPU()) → MeshGeometry[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.

class qewton.geometries.continuous.domains_3d.box.BoxBoundary(geometry: Box)[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.domains_3d.cylinder module

class qewton.geometries.continuous.domains_3d.cylinder.Cylinder(variable: ~qewton.config.variables.Variable, center: ~qewton.backends.base.TensorType | list[float] | tuple[float, float, float], radius: float, height: float, backend: type[~qewton.backends.base.ComputingBackend[~qewton.backends.base.TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]

Bases: ContinuousGeometry[TensorType]

Class for cylinders.

The cylinder is axis-aligned along the upwards direction.

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

  • center (TensorType) | list[float] | tuple[float, float, float]) – The center of the cylinder, e.g. [0, 0, 0].

  • radius (float) – The radius of the cylinder.

  • height (float) – The height of the cylinder.

  • 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.

create_mesh(max_vertex_distance: float | None = None, device: Device = CPU()) → MeshGeometry[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.

ordering_vertices(vertices, a_original, b_original, c_original)[source]
class qewton.geometries.continuous.domains_3d.cylinder.CylinderBoundary(geometry: Cylinder)[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 from all surfaces (side + bottom + top).

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

Sample on a grid from all surfaces.

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

Compute outward normal vectors at boundary points.

qewton.geometries.continuous.domains_3d.sphere module

class qewton.geometries.continuous.domains_3d.sphere.Sphere(variable: ~qewton.config.variables.Variable, center: ~qewton.backends.base.TensorType | list[float] | tuple[float, float, float], radius: float, backend: type[~qewton.backends.base.ComputingBackend[~qewton.backends.base.TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]

Bases: ContinuousGeometry[TensorType]

Class for spheres.

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

  • center (TensorType | list[float] | tuple[float, float, float]) – The center of the sphere, e.g. [0, 0, 0].

  • radius (float) – The radius of the sphere.

  • 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.domains_3d.sphere.SphereBoundary(geometry: Sphere)[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: TensorType, 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