qewton.geometries.continuous.domains_2d package¶
Module contents¶
Submodules¶
qewton.geometries.continuous.domains_2d.circle module¶
- class qewton.geometries.continuous.domains_2d.circle.Circle(variable: ~qewton.config.variables.Variable, center: list[float] | tuple[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 circles represented by center and radius.
- Parameters:
variable (Variable) – The variable associated with the circle, must be 2D.
center (np.ndarray | list[float] | tuple[float, float]) – The center of the circle.
radius (float) – The radius of the circle.
backend (type[ComputingBackend[TensorType]], optional) – What backend the node should use for computations, etc. Defaults to the deep learning backend (DEFAULT_DL_BACKEND).
- 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:
- Raises:
NotImplementedError – If the geometry does not support meshing.
- classmethod triangulate_circle(max_vertex_distance, radius, backend, device: Device = CPU())[source]¶
- 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.
- Boolean tensor of shape
- Return type:
TensorType
- bounding_box()[source]¶
Compute the axis-aligned bounds of the geometry.
- Returns:
- Tensor of length
2 * dimof the form [axis_1_min, axis_1_max, axis_2_min, axis_2_max, ...].
- Tensor of length
- Return type:
TensorType
- sample_random_uniform(n_points: int, device: Device | str = 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 | str = 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
- class qewton.geometries.continuous.domains_2d.circle.CircleBoundary(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.
- Boolean tensor of shape
- Return type:
TensorType
- 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 isTrue.
- 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 isTrue.
- Return type:
TensorType or tuple of TensorType
qewton.geometries.continuous.domains_2d.parallelogram module¶
- class qewton.geometries.continuous.domains_2d.parallelogram.Parallelogram(variable: ~qewton.config.variables.Variable, origin: ~typing.Any | list[float] | tuple[float, float], corner_1: ~typing.Any | list[float] | tuple[float, float], corner_2: ~typing.Any | list[float] | tuple[float, float], backend: type[~qewton.backends.base.ComputingBackend[~qewton.backends.base.TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
ContinuousGeometry[TensorType]Class for parallelograms in 2D.
- Parameters:
variable (Variable) – The variable representing the underlying space.
origin (TensorType | list[float] | tuple[float, float]) – One corner of the parallelogram.
corner_1 (TensorType | list[float] | tuple[float, float]) – A second corner adjacent to origin.
corner_2 (TensorType | list[float] | tuple[float, float]) – A third corner adjacent to origin.
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.
- Boolean tensor of shape
- Return type:
TensorType
- bounding_box()[source]¶
Compute the axis-aligned bounds of the geometry.
- Returns:
- Tensor of length
2 * dimof the form [axis_1_min, axis_1_max, axis_2_min, axis_2_max, ...].
- Tensor of length
- Return type:
TensorType
- 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:
- Raises:
NotImplementedError – If the geometry does not support meshing.
- corners_on(device: Device | str)[source]¶
(origin, corner_1, corner_2)on device, without moving the parallelogram.
- sample_random_uniform(n_points: int, device: Device | str = 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 | str = 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
- class qewton.geometries.continuous.domains_2d.parallelogram.ParallelogramBoundary(geometry: Parallelogram)[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.
- Boolean tensor of shape
- Return type:
TensorType
- 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 isTrue.
- 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 isTrue.
- Return type:
TensorType or tuple of TensorType
qewton.geometries.continuous.domains_2d.rectangle module¶
- class qewton.geometries.continuous.domains_2d.rectangle.Rectangle(variable: ~qewton.config.variables.Variable, origin: list[float] | tuple[float, float], width: float, height: float, backend: type[~qewton.backends.base.ComputingBackend[~qewton.backends.base.TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
Parallelogram[TensorType]Class for rectangles represented by origin, width and height.
- Parameters:
variable (Variable) – The variable associated with the rectangle, must be 2D.
origin (list[float] | tuple[float, float]) – The origin of the rectangle (lower left corner).
width (float) – The width of the rectangle.
height (float) – The height of the rectangle.
backend (type[ComputingBackend[TensorType]], optional) – What backend the node should use for computations, etc. Defaults to the deep learning backend (DEFAULT_DL_BACKEND).
qewton.geometries.continuous.domains_2d.triangle module¶
- class qewton.geometries.continuous.domains_2d.triangle.Triangle(variable: ~qewton.config.variables.Variable, origin: ~qewton.backends.base.TensorType | list[float] | tuple[float, float], corner_1: ~qewton.backends.base.TensorType | list[float] | tuple[float, float], corner_2: ~qewton.backends.base.TensorType | list[float] | tuple[float, float], backend: type[~qewton.backends.base.ComputingBackend[~qewton.backends.base.TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
ContinuousGeometry[TensorType]Class for triangles.
- Parameters:
variable (Variable) – The variable representing the underlying 2D space, must be 2D.
origin (TensorType | list[float] | tuple[float, float]) – The origin of the triangle (first corner).
corner_1 (TensorType | list[float] | tuple[float, float]) – The second corner of the triangle.
corner_2 (TensorType | list[float] | tuple[float, float]) – The third corner of the triangle.
backend (type[ComputingBackend[TensorType]], optional) – What backend the node should use for computations, etc. Defaults to the deep learning backend (DEFAULT_DL_BACKEND).
- 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:
- Raises:
NotImplementedError – If the geometry does not support meshing.
- 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.
- Boolean tensor of shape
- Return type:
TensorType
- bounding_box()[source]¶
Compute the axis-aligned bounds of the geometry.
- Returns:
- Tensor of length
2 * dimof the form [axis_1_min, axis_1_max, axis_2_min, axis_2_max, ...].
- Tensor of length
- 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
- class qewton.geometries.continuous.domains_2d.triangle.TriangleBoundary(geometry: Triangle)[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.
- Boolean tensor of shape
- 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 isTrue.
- 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 isTrue.
- Return type:
TensorType or tuple of TensorType