scimba_torch.domain.meshless_domain

Meshless domains.

class Segment1D(low_high, is_main_domain=False)[source]

Bases: VolumetricDomain

Segment1D domain.

Parameters:
  • low_high (tuple[float, float] | list[tuple[float, float]] | Tensor) – Bounds of the segment

  • is_main_domain (bool) – A flag to indicate if the domain can have subdomains and holes.

full_bc_domain()[source]

Return the full boundary domain of the Segment1D.

Return type:

list[SurfacicDomain]

Returns:

A list containing the two boundary Point1D domains.

class Point1D(value, low_value, tol=1e-06)[source]

Bases: SurfacicDomain

Point1D domain.

Parameters:
  • value (float | Tensor) – The position of the point.

  • low_value (bool) – Whether the point is at the lower bound.

  • tol (float) – A small tolerance value for the point.

class ArcCircle2D(center, radius, theta1, theta2)[source]

Bases: SurfacicDomain

ArcCircle2D domain.

Parameters:
  • center (tuple[float, float] | Tensor) – Center of the circle.

  • radius (float) – Radius of the circle.

  • theta1 (float) – Start angle of the arc in radians.

  • theta2 (float) – End angle of the arc in radians.

get_sdf()[source]

Get the signed distance function of the arc.

Returns:

The signed distance function of the arc.

class Circle2D(center, radius)[source]

Bases: SurfacicDomain

Circle2D domain.

Parameters:
  • center (tuple[float, float] | Tensor) – Center of the circle.

  • radius (float) – Radius of the circle.

get_sdf()[source]

Get the signed distance function of the circle.

Return type:

Callable[[Tensor], Tensor]

Returns:

The signed distance function of the circle.

class Disk2D(center, radius, is_main_domain=False)[source]

Bases: VolumetricDomain

Disk2D domain.

Parameters:
  • center (Tensor) – Center of the disk.

  • radius (float) – Radius of the disk.

  • is_main_domain (bool) – Whether this domain is the main domain.

full_bc_domain()[source]

Return the full boundary domain of the Disk2D.

Return type:

list[SurfacicDomain]

Returns:

A list containing the boundary Circle2D domain.

class Polygon2D(vertices, threshold=0.01, is_main_domain=False)[source]

Bases: VolumetricDomain

Polygon2D domain.

The vertices must be given in counter-clockwise order.

Parameters:
  • vertices (list[tuple[float, float]]) – Vertices of the polygon.

  • threshold (float) – Threshold for the polygonal approximation.

  • is_main_domain (bool) – Whether this domain is the main domain.

full_bc_domain()[source]

Return the full boundary domain of the Polygon2D.

Return type:

list[SurfacicDomain]

Returns:

A list containing the boundary Segment2D domains.

class Segment2D(pt1, pt2)[source]

Bases: SurfacicDomain

Segment2D domain.

Parameters:
  • pt1 (tuple[float, float] | Tensor) – First point of the segment.

  • pt2 (tuple[float, float] | Tensor) – Second point of the segment.

get_sdf()[source]

Get the signed distance function of the segment.

Return type:

Callable[[Tensor], Tensor]

Returns:

The signed distance function of the segment.

class Square2D(bounds, is_main_domain=False)[source]

Bases: VolumetricDomain

Square2D domain.

Parameters:
  • bounds (list[tuple[float, float]]) – Bounds of the square in the form [(min_x, max_x), (min_y, max_y)].

  • is_main_domain (bool) – Whether this domain is the main domain.

Raises:

ValueError – If bounds is not of shape (2, 2).

full_bc_domain()[source]

Return the full boundary domain of the Square2D.

Return type:

list[Segment2D]

Returns:

A list containing the four boundary Segment2D domains.

class Cube3D(bounds, is_main_domain=False)[source]

Bases: VolumetricDomain

Cube3D domain.

Parameters:
  • bounds (list[tuple[float, float]] | Tensor) – Bounds of the cube in the form [(min_x, max_x), (min_y, max_y), (min_z, max_z)]

  • is_main_domain (bool) – Whether this domain is the main domain.

full_bc_domain()[source]

Return the full boundary domain of the Cube3D.

Returns:

(bottom, front, left, top, back, right).

Return type:

A list containing the six boundary Square3D domains

class Cylinder3D(radius, length, is_main_domain=False)[source]

Bases: VolumetricDomain

A Cylinder3D domain around \(z\) axis.

Parameters:
  • radius (float) – Radius of the cylinder

  • length (float) – Length of the cylinder

  • is_main_domain (bool) – Whether the domain is the main domain or not

full_bc_domain()[source]

Return the full boundary domain of the Cylinder3D.

Returns:

(lower disk, body, upper disk).

Return type:

A list containing the three boundary domains

class Disk3D(center, radius, is_main_domain=False)[source]

Bases: VolumetricDomain

Disk3D domain.

Parameters:
  • center (tuple[float, float, float] | Tensor) – Center of the disk.

  • radius (float) – Radius of the disk.

  • is_main_domain (bool) – Whether this domain is the main domain.

full_bc_domain()[source]

Return the full boundary domain of the Disk3D.

Return type:

list[SurfacicDomain]

Returns:

A list containing the boundary Sphere3D domain.

class Sphere3D(center, radius)[source]

Bases: SurfacicDomain

3D sphere domain.

Parameters:
  • center (tuple[float, float, float] | Tensor) – Center of the sphere.

  • radius (float) – Radius of the sphere.

get_sdf()[source]

Returns the signed distance function (SDF) for the sphere.

Return type:

Callable[[Tensor], Tensor]

Returns:

A function that computes the signed distance from the sphere surface.

class Square3D(origin, x_dir, y_dir)[source]

Bases: SurfacicDomain

Square3D domain.

Parameters:
  • origin (tuple[float, float, float] | Tensor) – Vector defining the origin of the square

  • x_dir (tuple[float, float, float] | Tensor) – Vector defining the x direction

  • y_dir (tuple[float, float, float] | Tensor) – Vector defining the y direction

class SurfaceTorus3D(radius, tube_radius, center=(0, 0, 0))[source]

Bases: SurfacicDomain

SurfaceTorus3D domain around :math: z axis.

Parameters:
  • radius (float) – Radius of the torus (distance from the center to the center of the tube).

  • tube_radius (float) – Radius of the tube.

  • center (Tensor) – Center of the torus.

class Torus3D(radius, tube_radius, center=(0, 0, 0), is_main_domain=True)[source]

Bases: VolumetricDomain

Torus3D domain around :math: z axis.

Parameters:
  • radius (float) – Radius of the torus (distance from the center to the center of the tube

  • tube_radius (float) – Radius of the tube.

  • center (Tensor | tuple[float, float, float]) – Center of the torus.

  • is_main_domain (bool) – Whether the domain is the main domain or not

full_bc_domain()[source]

Returns the boundary condition domain of the torus.

Return type:

list[SurfacicDomain]

Returns:

A list with a single SurfaceTorus3D domain.

class TorusFrom2DVolume(base_volume, radius, is_main_domain=True)[source]

Bases: VolumetricDomain

Torus from 2D volume domain.

Creates a Torus by revolving a 2D VolumetricDomain around the \(z\) axis.

Parameters:
  • base_volume (VolumetricDomain) – A 2D VolumetricDomain to be revolved around the \(z\) axis.

  • radius (float) – Radius of the torus.

  • is_main_domain (bool) – Whether this domain is the main domain.

Raises:
  • TypeError – If base_volume is not a VolumetricDomain instance.

  • ValueError – If base_volume is not a 2D domain. If base_volume does not have an invertible mapping.

is_inside(x)[source]

Test if N points x are inside the domain (before mapping if any).

Parameters:

x (Tensor) – Tensor of shape (N, dim) representing the points to test.

Return type:

Tensor

Returns:

Boolean tensor of shape (N,) indicating if the points are inside the domain.

is_outside(x)[source]

Test if N points x are outside the domain (before mapping if any).

Parameters:

x – Tensor of shape (N, dim) representing the points to test.

Returns:

Boolean tensor of shape (N,) indicating if the points are outside

the domain.

is_on_boundary(x, tol=0.0001)[source]

Test if N points x are on the boundary of the domain (before mapping if any).

Parameters:
  • x – Tensor of shape (N, dim) representing the points to test.

  • tol – Tolerance for the test (Default value = 1e-4).

Returns:

Boolean tensor of shape (N,) indicating if the points are on the boundary.

full_bc_domain()[source]

Return the full boundary domain of the Torus_from2DVolume.

Return type:

list[SurfacicDomain]

Returns:

A list with a SurfaceTorus_from2DSurface domain for each boundary of the base_volume.

class HypercubeND(bounds, is_main_domain=False)[source]

Bases: VolumetricDomain

Hypercube n-dimensional domain.

Parameters:
  • bounds (list[tuple[float, float]] | Tensor) – A list of tuples representing the bounds of the cube in each dimension.

  • is_main_domain (bool) – A flag to indicate if the domain can have subdomains and holes.

full_bc_domain()[source]

Returns the full boundary condition domain for the Hypercube_nD.

Raises:

NotImplementedError – Hypercube_nD does not have a full boundary condition domain implemented.

Modules

base

Base module for meshless domains.

domain_1d

1D domains.

domain_2d

Basic Volumetric and Surfacic domains in 2D.

domain_3d

Basic Volumetric and Surfacic domains in 3D.

domain_nd

nD domains.