qewton.geometries.discrete package¶
Module contents¶
Submodules¶
qewton.geometries.discrete.grid_geometry module¶
- class qewton.geometries.discrete.grid_geometry.GridGeometry(variable: Variable, point_grid: TensorType, point_filter: TensorType | None = None, discretization_of: Geometry | None = None, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
DiscreteGeometry[TensorType]A grid of points. The underlying points are always in a mesh grid like pattern. To create a bit more complex shapes, a filter mask can be used.
- Parameters:
variable (Variable) – The variable connected to this geometry.
point_grid (TensorType) – The grid of points, should be of the shape [N_1, N_2, …, N_d, d], where d is the dimension of the above variable.
point_filter (TensorType | None, optional) – A grid of boolean values with the same shape as the point_grid, except the last axis should be always 1. A value of True, means the corresponding point is inside the geometry, False, that it should not be included. Default is None.
discretization_of (Geometry | None, optional) – The geometry this grid is a discretization of. Defaults to None.
backend (type[ComputingBackend[TensorType]], optional) – Defaults to DEFAULT_DL_BACKEND.
- structure¶
GRIDif every coordinate varies along exactly one grid axis (rectilinear), otherwiseMESH.- Type:
- axis_components¶
For a rectilinear grid, the coordinate component varying along each grid axis, e.g.
(1, 0)for a grid built withmeshgrid(x, y).- Type:
tuple of int
- factors¶
For a rectilinear grid of two or more axes, one 1D grid per grid axis, in the order of the axes, with the leaf of its coordinate as variable (e.g.
x_1ofVariable("x", 3)); None otherwise. The factors carry no point filter.- Type:
list of GridGeometry or None
- property topological_dim: int¶
- property cells: ndarray¶
- property axis_components: tuple[int, ...]¶
The coordinate component varying along each axis of a rectilinear grid, e.g.
(1, 0)for a grid built withmeshgrid(x, y).- Raises:
ValueError – If structure is not
Structure.GRID.
- axis_coordinates() list[ndarray][source]¶
See
axis_coordinates().
- property factors: list[GridGeometry] | None¶
- subproduct(factors: list[GridGeometry]) DiscreteGeometry[source]¶
See
subproduct(); the grid over the axes of factors.
- classmethod build_unit_grid(variable: Variable, resolution: int, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>) GridGeometry[source]¶
Builds an equidistant grid in the unit cube fitting the provided variable.
- Parameters:
variable (Variable) – The variable connected to this geometry.
resolution (int) – How many points should be used in each direction.
backend (type[ComputingBackend[TensorType]], optional) – Defaults to DEFAULT_DL_BACKEND.
- Returns:
The grid geometry.
- Return type:
- bounding_box()[source]¶
Compute the axis-aligned bounds of the geometry.
Uses the discretization points if present, otherwise the bounding box of
discretization_of.- Returns:
Tensor of the form
[axis_1_min, axis_1_max, ...].- Return type:
TensorType
- Raises:
NotImplementedError – If neither points nor a source geometry are available.
- sample_random_uniform_from_discretization(n_points: int, device: Device | str = CPU()) TensorType[source]¶
Sample random points from the discretization points.
- Parameters:
n_points – The number of points to sample. If larger than the number of discretization points, duplicates are returned.
device – The device to sample on.
- Returns:
The sampled points, shape
(n_points, dim).- Return type:
TensorType
- 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
- sample_grid_from_discretization(n_points: int, device: Device | str = CPU()) TensorType[source]¶
Sample points evenly from the discretization points.
Every discretization point is returned equally often.
- Parameters:
n_points – The number of points to sample. If larger than the number of discretization points, duplicates are returned.
device – The device to sample on.
- Returns:
The sampled points, shape
(n_points, dim).- Return type:
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
qewton.geometries.discrete.index_grid_geometry module¶
- class qewton.geometries.discrete.index_grid_geometry.IndexGridGeometry(variable: ~qewton.config.variables.Variable, shape: tuple[int, ...], point_filter: ~qewton.backends.base.TensorType | None = None, backend: type[~qewton.backends.base.ComputingBackend[~qewton.backends.base.TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
GridGeometry[TensorType]A grid geometry whose coordinates are the grid’s own indices, materialized lazily on first access and cached afterwards.
- Parameters:
variable (Variable) – The variable connected to this geometry. Its dim must equal len(shape). Build it composite (Variable(“i”, 1) * Variable(“j”, 1)) if a control should later step through a single grid axis.
shape (tuple[int, ...]) – Grid extent per axis.
point_filter (TensorType | None, optional) – A grid of boolean values of shape shape + (1,). True marks an included point, False an excluded one. Defaults to None (every point included).
backend (type[ComputingBackend[TensorType]], optional) – What backend the geometry should use for computations. Defaults to DEFAULT_DL_BACKEND.
- property discretization_points: TensorType¶
Index coordinates, built on first access and cached afterwards.
- Returns:
- Coordinate grid of shape shape + (len(shape),),
where each entry holds its own multi-index.
- Return type:
TensorType
- property is_materialized: bool¶
Whether the coordinate array currently exists in memory.
- Returns:
True if the coordinates have been built, False otherwise.
- Return type:
bool
qewton.geometries.discrete.load_meshes_helper module¶
- qewton.geometries.discrete.load_meshes_helper.load_file_with_meshio(file_path, marker_key: str | None = None, default_cell_tags: int = -1, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>, prune_z: bool = False)[source]¶
- qewton.geometries.discrete.load_meshes_helper.read_markers_from_file(msh, marker_key, default_cell_tags, cell_key, face_key, backend: type[ComputingBackend[TensorType]])[source]¶
qewton.geometries.discrete.mesh module¶
- class qewton.geometries.discrete.mesh.Mesh(vertices: list[list[float]] | TensorType, cells: list[list[int]] | TensorType, cell_markers: list[int] | None | TensorType = None, faces: list[list[int]] | None | TensorType = None, face_markers: list[int] | None | TensorType = None, marker_labels: dict[str, tuple[int, int]] | None=None, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>, device: Device | str = CPU())[source]¶
Bases:
Serializable,Generic[TensorType]A generic simplex mesh represented by vertices and cells.
- Parameters:
vertices (list[list[float]] | TensorType) – The vertices of the mesh.
cells (list[list[int]] | TensorType) – The cells of the mesh. A simplex always has d+1 corners, where d is the dimension of the vertices. For example in 2D, a vertex is some point [x, y] and a cell corresponds to a triangle given by [vertex_1, vertex_2, vertex_3].
cell_markers (list[int] | None | TensorType, optional) – Some markers of the cells. For each cell one marker must be provided. Defaults to None.
faces (list[list[int]] | None | TensorType, optional) – A list of special faces. Only needed if some faces should have special markers. Defaults to None.
face_markers (list[int] | None | TensorType, optional) – The markers of the faces. Defaults to None.
marker_labels (dict[str, tuple[int, int]] | None, optional) – The above markers are based on integers. If names should be used instead, they can be mapped with this dictionary. The dictionary has the name of the marker as a key and maps it to a tuple of (marker integer, entity dimension). Defaults to None.
backend (type[ComputingBackend[TensorType]], optional) – Defaults to DEFAULT_DL_BACKEND.
- map_cells_to_original(cell_indices: TensorType) TensorType[source]¶
Maps the given cell indices to the original mesh.
- Parameters:
cell_indices (TensorType) – The cell indices to map.
- Returns:
The mapped cell indices.
- Return type:
TensorType
- property vertex_count: int¶
Returns the number of vertices in this mesh.
- Returns:
The number of vertices.
- Return type:
int
- classmethod load_mesh(file_path, marker_key: str | None = None, default_cell_tags: int = -1, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>, prune_z: bool = False) Mesh[source]¶
Load a mesh from the disk. The mesh should already be a “volume” mesh. Currently only simplex meshes are supported.
- Parameters:
file_path – The file path to the mesh.
marker_key (str | None, optional) – Markers inside the mesh that should also be loaded/included in the mesh object.
default_cell_tags (int, optional) – A default cell tag for all cells that dont have any markers. Defaults to -1.
backend (type[ComputingBackend[TensorType]], optional) – Defaults to DEFAULT_DL_BACKEND.
prune_z (bool, optional) – If True, the z-coordinate of the vertices will be pruned if the mesh is 3D. Defaults to False.
- Raises:
ImportError – Use Meshio to convert and read the mesh, raises an error if
not installed. –
- Returns:
The mesh object containing the mesh from the file.
- Return type:
- sample_random_from_vertices(n_points: int, device: Device | str = CPU()) tuple[TensorType, TensorType][source]¶
qewton.geometries.discrete.mesh_geometry module¶
- class qewton.geometries.discrete.mesh_geometry.MeshGeometry(variable: Variable, mesh: Mesh, discretization_of: Geometry | None = None, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
DiscreteGeometry[TensorType]A geometry object representing a simplex mesh.
- Parameters:
variable (Variable) – The variable connected to this geometry.
mesh (Mesh) – The underlying mesh object.
discretization_of (Geometry | None, optional) – The geometry this mesh is a discretization of. Defaults to None.
backend (type[ComputingBackend[TensorType]], optional) – Defaults to DEFAULT_DL_BACKEND.
- classmethod load_mesh(variable: Variable, file_path: str, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>, prune_z: bool = False) MeshGeometry[source]¶
Loads a volume mesh from a path.
- Parameters:
variable (Variable) – The variable connected to this geometry.
file_path (str) – The path to the mesh file. This uses the meshio library load the mesh. Supported formats are .msh/.vtk/.vtu/.xdmf/.inp and more, see the meshio documentation.
backend (type[ComputingBackend[TensorType]], optional) – Defaults to DEFAULT_DL_BACKEND.
prune_z (bool, optional) – If True, the z-coordinate of the mesh will be removed. This is useful for 2D meshes that are stored in 3D.
- Returns:
_description_
- Return type:
- 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.
- property topological_dim: int¶
- property cells: ndarray¶
- bounding_box()[source]¶
Compute the axis-aligned bounds of the geometry.
Uses the discretization points if present, otherwise the bounding box of
discretization_of.- Returns:
Tensor of the form
[axis_1_min, axis_1_max, ...].- Return type:
TensorType
- Raises:
NotImplementedError – If neither points nor a source geometry are available.
- get_marker(marker)[source]¶
Return the subdomain stored under marker.
- Parameters:
marker (hashable) – The name of the marker.
- Returns:
The stored marker entry.
- Return type:
Any
- Raises:
KeyError – If no marker with this name exists.
- property boundary: MeshBoundaryGeometry¶
- create_boundary() MeshBoundaryGeometry[source]¶
Create the boundary of this geometry.
- Returns:
A new boundary geometry.
- Return type:
- Raises:
NotImplementedError – If the geometry has no boundary implementation.
- sample_random_uniform_from_discretization(n_points: int, device: Device | str = CPU()) TensorType[source]¶
Sample random points from the discretization points.
- Parameters:
n_points – The number of points to sample. If larger than the number of discretization points, duplicates are returned.
device – The device to sample on.
- Returns:
The sampled points, shape
(n_points, dim).- Return type:
TensorType
- sample_grid_from_discretization(n_points: int, device: Device | str = CPU()) TensorType[source]¶
Sample points evenly from the discretization points.
Every discretization point is returned equally often.
- Parameters:
n_points – The number of points to sample. If larger than the number of discretization points, duplicates are returned.
device – The device to sample on.
- Returns:
The sampled points, shape
(n_points, dim).- Return type:
TensorType
- 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
- 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
- interpolate_to(points, values)[source]¶
Interpolates a per-vertex field onto arbitrary target points, via linear (barycentric) interpolation inside whichever simplex contains each point. Generic over the points, not plane-specific - a plane slice is just one choice of points, a regular 3D resampling grid or a scattered comparison set are others equally valid.
- Parameters:
points – Target points, shape (n_points, dim).
values – Per-vertex field, shape (n_vertices,) or (n_vertices, *feature_shape).
- Returns:
Interpolated values, shape (n_points,) or (n_points, *feature_shape) matching values’s trailing shape. Points outside the mesh are NaN rather than extrapolated, so callers can render/ignore them as missing (e.g. Scale.observe() already uses nanmin/nanmax).
- locate(points)[source]¶
For each point, finds a containing simplex and its barycentric weights - the same search contains() does, but keeping the cell index and weights it computes along the way instead of collapsing them to a boolean. Used by interpolation onto arbitrary target points (e.g. a plane slice), where those weights double as the interpolation weights - no separate lookup needed.
- Parameters:
points – Points to locate, shape (n_points, dim).
- Returns:
- int array (n_points,) - index into self.mesh.cells of a
simplex containing each point. Arbitrary (0) where not found.
- weights: float array (n_points, dim + 1) - barycentric weights
against self.mesh.cells[cell_idx[i]]’s vertices, in vertex order (v0 first). Rows for points not found are all zero.
- found: bool array (n_points,) - whether a containing simplex was
found for each point.
- Return type:
cell_idx
- get_submesh(marker: int | str) MeshGeometry[source]¶
Returns a submesh of the main mesh that only contains the provided marker.
- Parameters:
marker (int | str) – The marker of the submesh
- Returns:
- A new mesh geometry that only consists of the
mesh with the marker.
- Return type:
- class qewton.geometries.discrete.mesh_geometry.MeshBoundaryGeometry(geometry: MeshGeometry)[source]¶
Bases:
BoundaryGeometry[TensorType]- bounding_box()[source]¶
Return the bounding box of the underlying geometry.
- Returns:
Tensor of the form
[axis_1_min, axis_1_max, ...].- Return type:
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
- create_mesh(max_vertex_distance: float | None = None, device: Device = CPU()) MeshBoundaryGeometry[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.
- sample_random_uniform_from_discretization(n_points: int, device: Device | str = CPU(), include_normals: bool = False)[source]¶
- sample_grid_from_discretization(n_points: int, device: Device | str = CPU(), include_normals: bool = False)[source]¶
- 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
- 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
- get_submesh(marker: int | str) MeshBoundaryGeometry[source]¶
qewton.geometries.discrete.point_cloud module¶
- class qewton.geometries.discrete.point_cloud.PointCloud(variable: Variable, discretization_points: TensorType, discretization_of: Geometry | None = None, backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
DiscreteGeometry[TensorType]A discrete collection of points.
- Parameters:
variable (Variable) – The variable connected to this geometry.
discretization_points (TensorType) – The discrete points contained in this point cloud.
discretization_of (Geometry | None, optional) – The geometry this mesh is a discretization of. Defaults to None.
backend (type[ComputingBackend[TensorType]], optional) – Defaults to DEFAULT_DL_BACKEND.
- property topological_dim: int¶
- property cells: None¶
- create_boundary()[source]¶
Create the boundary of this geometry.
- Returns:
A new boundary geometry.
- Return type:
- Raises:
NotImplementedError – If the geometry has no boundary implementation.
- sample_random_uniform_from_discretization(n_points: int, device: Device | str = CPU()) TensorType[source]¶
Sample random points from the discretization points.
- Parameters:
n_points – The number of points to sample. If larger than the number of discretization points, duplicates are returned.
device – The device to sample on.
- Returns:
The sampled points, shape
(n_points, dim).- Return type:
TensorType
- sample_grid_from_discretization(n_points: int, device: Device | str = CPU()) TensorType[source]¶
Sample points evenly from the discretization points.
Every discretization point is returned equally often.
- Parameters:
n_points – The number of points to sample. If larger than the number of discretization points, duplicates are returned.
device – The device to sample on.
- Returns:
The sampled points, shape
(n_points, dim).- Return type:
TensorType
- 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
qewton.geometries.discrete.product_mesh_geometry module¶
Discrete Cartesian products of meshes and point sets.
- qewton.geometries.discrete.product_mesh_geometry.factor_cells(factor: DiscreteGeometry) ndarray[source]¶
Return the cells of a discrete factor as an integer array.
A factor without cells (e.g. a point set, or the two end points of an interval boundary) contributes each point as a 0-simplex.
- Parameters:
factor – A discrete geometry; its points are indexed row-major over its shape.
- Returns:
The cells, shape
(n_cells, simplex_dim + 1).- Return type:
np.ndarray
- qewton.geometries.discrete.product_mesh_geometry.product_cells(factors: list) ndarray[source]¶
Return the simplex cells of the Cartesian product of discrete factors.
Vertices are indexed in product order (first factor slowest), matching
product_points().- Parameters:
factors – Discrete factor geometries.
- Returns:
The cells, shape
(n_cells, sum(simplex_dim_i) + 1).- Return type:
np.ndarray
Notes
Every product of factor cells is split by the staircase triangulation. Each factor cell’s vertices are sorted by their global index, which keeps the triangulation conforming across neighboring product cells.
- qewton.geometries.discrete.product_mesh_geometry.product_points(factors: list) ndarray[source]¶
Return the vertices of the Cartesian product of factor meshes.
- Parameters:
factors – Meshed factor geometries, each with a
meshand abackend.- Returns:
- The vertices in product order (first factor slowest), shape
(prod(n_i), sum(dim_i)).
- Return type:
np.ndarray
- class qewton.geometries.discrete.product_mesh_geometry.ProductMeshGeometry(factors: list, variable: Variable | None = None, discretization_of: Geometry | None = None, device: Device | str = CPU(), backend: type[ComputingBackend[TensorType]] = <class 'qewton.backends.base.DeepLearningBackend'>)[source]¶
Bases:
DiscreteGeometry[TensorType]Cartesian product of meshed geometries.
Used e.g. as the discretization of a space-time domain. The vertices are all combinations of the factor vertices in product order, with the first factor varying slowest, so reshaping the vertex axis to factor_shape gives one axis per factor.
- Parameters:
factors – The meshed factor geometries (at least two), each with a
meshand avariable, e.g.MeshGeometry.variable – The variable of the product. Defaults to the composition of the factor variables. Its dimension must equal the summed factor dimensions.
discretization_of – The geometry this mesh discretizes.
device – The device the vertices and cells are created on.
backend – The backend used for computations.
- Raises:
ValueError – If fewer than two factors are given.
- factors¶
The meshed factor geometries; a factor that is no discrete geometry (e.g. the boundary of a mesh) as a MeshGeometry of its mesh.
- Type:
list of DiscreteGeometry
- factor_shape¶
Number of vertices of each factor.
- Type:
tuple of int
- mesh¶
The simplex mesh of the full product, built on first access. Accessing it raises
ValueErrorif the product has more than three dimensions.- Type:
- property factors: list¶
- subproduct(factors: list) ProductMeshGeometry[source]¶
See
subproduct().
- property topological_dim: int¶
- property cells: ndarray¶
- property factor_shape: tuple[int, ...]¶
- create_mesh(max_vertex_distance=None, device: Device = CPU()) ProductMeshGeometry[source]¶
Return this geometry, which is already a mesh.
- Parameters:
max_vertex_distance (float or dict or None) – Ignored.
device – Ignored.
- Returns:
This geometry.
- Return type:
- class qewton.geometries.discrete.product_mesh_geometry.ProductDiscreteGeometry(factors: list, variable: Variable | None = None, backend: type[ComputingBackend[TensorType]] | None = None)[source]¶
Bases:
DiscreteGeometry[TensorType]Cartesian product of discrete geometries.
Used e.g. for reference data known on a grid of space points for each of a few parameter values, or for the axes of a rectilinear grid. Each factor keeps its own structural shape: factors of shapes
(3,)and(33, 33)give a product of shape(3, 33, 33), the first factor varying slowest. The point coordinates are ordered as in variable, which may name the factors in a different order than factors.The connectivity of the whole product follows from the factors: a product of rectilinear grids is a rectilinear grid (
GRID), a product of point sets a point set (POINTS), any other product the simplices of the products of factor cells (MESH; points of a factor without cells count as 0-simplices).- Parameters:
factors – Discrete geometries (at least two), each with a
variableand eitherdiscretization_pointsor amesh.variable – The variable of the product, composed of the factor variables in any order. Defaults to their composition in the order of factors.
backend – The backend used for computations. Defaults to the backend of the first factor.
- Raises:
ValueError – If fewer than two factors are given, a factor has no points, or variable does not consist of exactly the factor variables.
- factors¶
The factor geometries.
- Type:
list
- factor_shapes¶
The structural shape of each factor, in the order of factors.
- Type:
list of tuple of int
- property factors: list¶
- subproduct(factors: list) ProductDiscreteGeometry[source]¶
See
subproduct(); its variable is the part of this product’s variable made of the factors’ variables, else their composition.
- property topological_dim: int¶
- property cells: ndarray | None¶
- property axis_components: tuple[int, ...]¶
See
axis_components.
- axis_coordinates() list[ndarray][source]¶
See
axis_coordinates().
- property factor_shapes: list[tuple[int, ...]]¶
- qewton.geometries.discrete.product_mesh_geometry.product_of(variable: Variable, factors: list, backend) ProductDiscreteGeometry[source]¶
The product of some factors of a product with the Variable variable.
- Parameters:
variable – The Variable of the whole product.
factors – Some of its factors (at least two), in their order.
backend – The backend used for computations.
- Returns:
- The product of factors; its variable is
the node of variable whose leaves are those of the factors (e.g.
xoft * x), else their composition.
- Return type:
qewton.geometries.discrete.sampled_geometry module¶
Geometry holding the points a sampler currently provides.
- class qewton.geometries.discrete.sampled_geometry.SampledGeometry(geometry: Geometry, n_points: int)[source]¶
Bases:
DiscreteGeometry[TensorType]Point cloud sampled from a geometry.
Samplers use it to reference their generated points in data configurations. It holds the points (and optionally cells) of the current sampling step, set by the owning sampler through
set_current_discretization(). Meshing the source geometry for plotting is done by the sampler, which owns that geometry.- Parameters:
geometry – The geometry the points are sampled from; its variable and backend are taken over.
n_points – The number of sampled points.
- discretization_points¶
The current points.
- Type:
TensorType or None
- factors¶
The meshed factor geometries if the current points are the vertices of a product mesh (first factor varying slowest), otherwise
None.- Type:
list or None
- mesh¶
A
Meshbuilt from the current points and cells, orNonefor a plain point cloud without cell connectivity. For a product mesh the cells are built on first access.- Type:
Mesh or None
Notes
Deep copies return the same object, so copies of a data configuration keep seeing the points the sampler sets.
- property discretization_points: TensorType¶
- set_current_discretization(points: TensorType, cells: TensorType | None = None, product=None)[source]¶
Store the points (and cells) the sampler currently provides.
- Parameters:
points – The current points.
cells – Cell connectivity of the points.
product (ProductMeshGeometry or None) – Set when the points are the vertices of a product mesh. Its factors are exposed as factors, and its cells are only built when mesh is accessed.
- property topological_dim: int¶
- property cells: ndarray | None¶
- property factors: list | None¶
- subproduct(factors: list) DiscreteGeometry[source]¶
See
subproduct(); the product of the current product mesh’s factors.