DTFE in 3D¶
Introduction¶
FIESTA provides Delaunay Tessellation Field Estimation (DTFE) tools for interpolating irregularly sampled data onto continuous fields using Delaunay triangulations.
The DTFE implementation supports:
density estimation
scalar field interpolation
boundary detection
simplex querying
distributed tessellation merging
Main classes:
Delaunay3DDelaunayMerger3D
Basic Workflow¶
The typical DTFE workflow is:
create the tessellation
compute densities or assign fields
estimate values at arbitrary coordinates
Example workflow:
dtfe = fiesta.dtfe.Delaunay3D()
dtfe.setup(x, y, z, boundary)
dtfe.run()
dtfe.get_dens()
dtfe.set_field2dens()
f_est = dtfe.estimate(xq, yq, zq)
Creating a Delaunay Tessellation¶
Generate random points:
import numpy as np
import fiesta
np.random.seed(0)
npoints = 1000
x = np.random.uniform(0.0, 1.0, npoints)
y = np.random.uniform(0.0, 1.0, npoints)
z = np.random.uniform(0.0, 1.0, npoints)
Define the domain boundary:
boundary = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
Construct the tessellation:
dtfe = fiesta.dtfe.Delaunay3D()
dtfe.setup(x, y, z, boundary)
dtfe.run()
The tessellation is now available through:
dtfe.simplices
Density Estimation¶
DTFE naturally estimates densities from the inverse area surrounding each particle.
Compute point densities:
dtfe.get_dens()
The densities are stored in:
dtfe.point_dens
Convert the density into the interpolated field:
dtfe.set_field2dens()
Field Interpolation¶
Instead of density estimation, arbitrary scalar fields can be assigned to the particles.
Example:
f = np.sin(2*np.pi*x) * np.cos(2*np.pi*y) + 0.5 * z / 100.0
Assign the field:
dtfe.set_field(f)
The field can now be interpolated continuously.
Estimating the Field¶
Evaluate the field at arbitrary coordinates.
Generate query points:
xq = np.random.uniform(0.0, 1.0, 1000)
yq = np.random.uniform(0.0, 1.0, 1000)
zq = np.random.uniform(0.0, 1.0, 1000)
Estimate the field:
f_est = dtfe.estimate(xq, yq, zq)
The returned values contain interpolated estimates inside valid simplices.
Points outside the tessellation return:
np.nan
Finding Simplices¶
Determine which simplex contains a coordinate:
simplex_ids = dtfe.find_simplex(xq, yq, zq)
Returned values:
-1indicates the point lies outside the tessellationnon-negative integers identify simplex indices
Boundary Handling¶
DTFE interpolation near boundaries can become unreliable because simplices may extend beyond the sampled domain.
FIESTA automatically classifies:
interior simplices
boundary simplices
exterior simplices
The simplex classifications are stored in:
dtfe.simptypes
Point classifications are stored in:
dtfe.point_type
Classification meanings:
Value |
Meaning |
|---|---|
1 |
interior |
0 |
boundary |
-1 |
invalid / exterior |
Allowing Border Interpolation¶
By default, interpolation excludes boundary simplices.
To allow interpolation near borders:
f_est = dtfe.estimate(
xq,
yq,
zq,
allow_border=True
)
This option is only valid for non-density field interpolation.
Circumcircles¶
The circumcircle of each simplex can be computed:
dtfe.get_circumcircles()
Results are stored in:
dtfe.circumcircles
Each row contains:
[x_center, y_center, z_center, radius]
Triangle Areas¶
Compute simplex areas:
dtfe.get_volume()
Results:
dtfe.delaunay_volume
Border Extraction¶
Extract boundary information from a tessellation:
border = dtfe.get_border()
The returned dictionary contains:
border particles
simplex information
field values
point classifications
This is useful for distributed or tiled DTFE calculations.
Distributed DTFE Merging¶
DelaunayMerger3D merges border regions from multiple DTFE calculations.
This is intended for:
MPI workflows
tiled datasets
domain decomposition methods
Creating a Merger¶
merger = fiesta.dtfe.DelaunayMerger3D()
Adding Borders¶
Suppose multiple tessellations were computed independently:
border1 = dtfe1.get_border()
border2 = dtfe2.get_border()
Add them to the merger:
merger.add_border(border1)
merger.add_border(border2)
Construct the merged tessellation:
merger.run(boundary)
Estimating from the Merged DTFE¶
Interpolate using the merged tessellation:
f_est = merger.estimate(xq, yq, zq)
Filtering Boundary Regions¶
The merger can optionally remove simplices outside the desired domain:
merger.run(
boundary,
apply_filter=True
)
Cleaning Objects¶
Reset a DTFE object:
dtfe.clean()
Reset a merger object:
merger.clean()
Performance Notes¶
DTFE computations involve:
Delaunay triangulation construction
simplex neighbour analysis
geometric interpolation
For large datasets:
triangulation can become memory intensive
interpolation scales approximately linearly after triangulation
boundary merging adds overhead
The implementation is best suited for:
irregular spatial data
particle simulations
adaptive density estimation
mesh-free interpolation
API Reference¶
- class fiesta.dtfe.Delaunay3D
- clean() None
Reinitialise the class.
- construct() None
Construct Delaunay triangulation.
- determine_delaunay_boundary() None
Determine Delaunay boundary simplices and points.
- estimate(x: float | ndarray, y: float | ndarray, z: float | ndarray, allow_border: bool = False) float | ndarray
Estimates a field from the Delaunay tesselation.
- Parameters:
x (array) – X-coordinate for the field estimation.
y (array) – Y-coordinate for the field estimation.
z (array) – Z-coordinate for the field estimation.
allow_border (bool, optional) – Allow border interpolation for non-density related interpolation.
- Returns:
f_est – Estimates of the field
- Return type:
array
- find_simplex(x: float | ndarray, y: float | ndarray, z: float | ndarray) ndarray
Find the simplex the coordinates lie within.
- Parameters:
x (array) – X-coordinate for the field estimation.
y (array) – Y-coordinate for the field estimation.
z (array) – Z-coordinate for the field estimation.
- Returns:
simplices – Simplex ID that the point lies in, -1 if point lies outside of all simplices.
- Return type:
array
- get_border() dict
Returns border points and simplices.
- Returns:
border – Dictionary object contained border points and simplices from previously computed Delaunay tesselation.
- Return type:
- get_boundary_simplex() None
Determines whether a simplex circumcircle crosses boundaries.
- get_circumcircles() None
Computes the circumcirles centers and radius for all simplices.
- get_dens() None
Calculates the density of each point in the delaunay tessellation.
- get_solid_angle(px0: float | ndarray, py0: float | ndarray, pz0: float | ndarray, x1: float | ndarray, y1: float | ndarray, z1: float | ndarray, x2: float | ndarray, y2: float | ndarray, z2: float | ndarray, x3: float | ndarray, y3: float | ndarray, z3: float | ndarray) ndarray
Computes the solid angle subtended from a point p and three points 1, 2 and 3.
- Parameters:
px0 (float or array) – X value for point we want to compute the angle from.
py0 (float or array) – Y value for point we want to compute the angle from.
pz0 (float or array) – Z value for point we want to compute the angle from.
x1 (float or array) – Point 1’s x value.
y1 (float or array) – Point 1’s y value.
z1 (float or array) – Point 1’s z value.
x2 (float or array) – Point 2’s x value.
y2 (float or array) – Point 2’s y value.
z2 (float or array) – Point 2’s z value.
x3 (float or array) – Point 3’s x value.
y3 (float or array) – Point 3’s y value.
z3 (float or array) – Point 3’s z value.
- Returns:
solid_angle – Solid angle subtended from a point p and two points 1, 2 and 3.
- Return type:
array
- get_solid_angle_total() None
Determines the total solid angle subtended by simplices attached to each points.
- get_volume() None
Calculates the volume of the delaunay simplex.
- run() None
Run Delaunay tesselation and compute boundary information.
- set_field(f: ndarray) None
Sets the field values of the input points.
- Parameters:
f (array) – Field values.
- set_field2dens() None
Sets the field values to the density.
- setup(x: ndarray, y: ndarray, z: ndarray, boundary: List[float], mass: ndarray | None = None) None
Assign particles and field values.
- Parameters:
x (array) – X-axis positions for points.
y (array) – Y-axis positions for points.
z (array) – Z-axis positions for points.
boundary (list) – List of boundary values given as [xmin, xmax, ymin, ymax, zmin, zmax].
mass (array, optional) – Mass weights.
- class fiesta.dtfe.DelaunayMerger3D
- add_border(border: dict) None
Add border points and simplices from an already computed Delaunay tesselation.
- Parameters:
border (dict) – Dictionary object contained border points and simplices from previously computed Delaunay tesselation.
- clean() None
Reinitialises the class.
- estimate(x: float | ndarray, y: float | ndarray, z: float | ndarray) float | ndarray
Estimates the field from input coordinates, if coordinate is not in simplex or the simplex is of type != 1 then a Nan is returned.
- get_border() dict
Returns border points and simplices from a merged delaunay tesselation.