DTFE in 2D

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:

  • Delaunay2D

  • DelaunayMerger2D

Basic Workflow

The typical DTFE workflow is:

  1. create the tessellation

  2. compute densities or assign fields

  3. estimate values at arbitrary coordinates

Example workflow:

dtfe = fiesta.dtfe.Delaunay2D()

dtfe.setup(x, y, boundary)

dtfe.run()

dtfe.get_dens()

dtfe.set_field2dens()

f_est = dtfe.estimate(xq, yq)

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)

Define the domain boundary:

boundary = [0.0, 1.0, 0.0, 1.0]

Construct the tessellation:

dtfe = fiesta.dtfe.Delaunay2D()

dtfe.setup(x, y, 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)

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)

Estimate the field:

f_est = dtfe.estimate(xq, yq)

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)

Returned values:

  • -1 indicates the point lies outside the tessellation

  • non-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,
    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, radius]

Triangle Areas

Compute simplex areas:

dtfe.get_area()

Results:

dtfe.delaunay_area

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

DelaunayMerger2D merges border regions from multiple DTFE calculations.

This is intended for:

  • MPI workflows

  • tiled datasets

  • domain decomposition methods

Creating a Merger

merger = fiesta.dtfe.DelaunayMerger2D()

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)

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.Delaunay2D
clean() None

Reinitialises the class.

construct() None

Construct Delaunay triangulation.

determine_delaunay_boundary() None

Determine Delaunay boundary simplices and points.

estimate(x: float | ndarray, y: 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.

  • 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) ndarray

Find the simplex the coordinates lie within.

get_angle(px0: float | ndarray, py0: float | ndarray, x1: float | ndarray, y1: float | ndarray, x2: float | ndarray, y2: float | ndarray) ndarray

Computes the angle subtended from a point p and two points 1 and 2.

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.

  • x1 (float or array) – Point 1’s x value.

  • y1 (float or array) – Point 1’s y value.

  • x2 (float or array) – Point 2’s x value.

  • y2 (float or array) – Point 2’s y value.

Returns:

angle – Angle subtended from a point p and two points 1 and 2

Return type:

array

get_angle_total() None

Determines the total angle subtended by simplices attached to each points.

get_area() None

Calculates the area of the delaunay simplex.

get_border() dict

Returns border points and simplices.

Returns:

border – Dictionary object contained border points and simplices from previously computed Delaunay tesselation.

Return type:

dict

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.

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

  • boundary (list) – List of boundary values given as [xmin, xmax, ymin, ymax].

  • mass (array, optional) – Mass weights.

class fiesta.dtfe.DelaunayMerger2D
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) 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.

Parameters:
  • x (float or array) – X-axis coordinate.

  • y (float or array) – Y-axis coordinate

get_border() dict

Returns border points and simplices from a merged delaunay tesselation.

run(boundary: List[float], apply_filter: bool = False) None

Constructes the Delaunay tesselation from the border input points.

Parameters:
  • Boundary (list) – A list containing the minimum and maximum x values, given in this order: [xmin, xmax, ymin, ymax].

  • apply_filter (bool, optional) – Apply filter on boundary particles, this will cut out all points and simplices that are beyond or cross the boundary. Default set to False.