Integration

CartesianGeometry.integrateFunction
integrate(Tuple{0}, f, xyz, T, bc)

Computes volume-specific (Tuple{0}) apertures of the first kind.

Returns a Tuple where

  1. The first component is a Vector{T} that stores the wet volumes of each cell,
  2. The second component is a Vector{SVector{N,T}} that stores the coordinates of the wet barycenters.

Wherever the moments can not be computed, the function bc is applied to the element type.

Arguments

  • f: the level set function.
  • xyz: the Cartesian coordinates of the lattice nodes.
  • T: the eltype of the moments.
  • bc: the boundary condition (e.g. nan or zero).
Note

To simplify the computation of second-kind moments, barycenters of -f are stored in empty cells.

source
integrate(Tuple{1}, f, xyz, T, bc)

Computes area-specific (Tuple{1}) apertures of the first kind.

Returns a NTuple where each element corresponds to direction.

Arguments

  • f: the level set function.
  • xyz: the Cartesian coordinates of the lattice nodes.
  • T: the eltype of the moments.
  • bc: the boundary condition (e.g. nan or zero).
source

integrate has four entry points:

integrate(::Type{Tuple{0}}, f, xyz, T, bc; method=:vofi)
integrate(::Type{Tuple{1}}, f, xyz, T, bc; method=:vofi)
integrate(T::Type{<:Tuple}, f, xyz, S, bc, bary; method=:vofi)
integrate(::Type{Tuple{2}}, f, xyz, S, bc, bary; method=:vofi)

Backend / f mapping

methodMeaning of f
:vofiLevel-set function (f(x...) <= 0 is wet)
:vofijulLevel-set function (f(x...) <= 0 is wet)
:voftoolsCell-centered VOF fraction field ([0,1] per cell)
:implicitintegrationLevel-set function (f(x...) <= 0 is wet)

VOFTools defaults:

  • Interface normals are estimated internally from f (Youngs-type stencil).
  • Shared-face mixture uses :softclosest05 by default.

Tuple selector meaning

SelectorGeometric familyFirst kind (integrate(..., T, bc))Second kind (integrate(..., S, bc, bary))
Tuple{0}Volume-likeV + cell barycenter/infoW
Tuple{1}Surface/face-likeAB
Tuple{2}Volume-likeN/AWbary (barycenter of W)

Arguments:

  • f: see backend mapping table above
  • xyz: NTuple{N} of node vectors
  • bc: boundary fill (nan, zero, or equivalent)
  • method: backend (:vofi, :vofijul, :voftools, or :implicitintegration)

Returns:

  • integrate(Tuple{0}, ...):
    • V: wet measure per cell slot
    • bary: wet barycenter per cell slot
    • interfacenorm: interface measure
    • celltype: 0.0 empty, 1.0 full, -1.0 cut
    • baryinterface: interface centroid (available with :vofijul)
  • integrate(Tuple{1}, ...):
    • A::NTuple{N,Vector{T}}: directional face moments
  • integrate(Tuple{0 or 1}, ..., bary):
    • second-kind moments (W/B)
  • integrate(Tuple{2}, ..., bary):
    • Wbary::NTuple{N,Vector{SVector{N,S}}} (staggered wet-volume barycenters only)

The second-kind signature stays unchanged when selecting :voftools:

integrate(T::Type{<:Tuple}, f, xyz, S, bc, bary; method=:vofi)

The regression suite includes consistency checks between the explicit-front backend and the level-set backend on shared Cartesian grids (comparing only physical entries, with tolerance-based checks for curved geometry).

Array-size convention

Moment arrays are stored on node-shaped indexing spaces for stencil/operator assembly. In 1D, if you have 5 nodes (x1..x5), you have 4 physical cells, but output vectors are length 5:

  • indices 1:4: physical cells
  • index 5: halo/boundary slot, filled with bc

This keeps data aligned with difference-matrix based gradient/divergence operators.

Example (1D with 5 nodes)

using CartesianGeometry

grid = collect.((-1.:0.5:1.,))
body = (x,_=0) -> sqrt(x^2) - 0.5

V, bary, interfacenorm, celltype, baryinterface =
    integrate(Tuple{0}, body, grid, Float64, nan)

A = integrate(Tuple{1}, body, grid, Float64, nan)
([0.0, 1.0, 1.0, 1.0, 0.0],)

Typical values:

  • V = [0.0, 0.5, 0.5, 0.0, NaN]
  • bary = [[-0.75], [-0.25], [0.25], [0.75], [NaN]]
  • A[1] = [0.0, 1.0, 1.0, 1.0, 0.0]
                  body(x) = sqrt(x^2) - 0.5
                -----------------------------
  o------x------o------x------o------x------o------x------o-----
-1.0          -0.5           0.0           0.5           1.0              Nodes
      C=-0.75       C=-0.25        C=0.25        C=0.75         C=NaN     Barycenters first moments
       V=0.0         V=0.5          V=0.5         V=0.0         V=NaN     Volumes first moments
A=0.0         A=1.0         A=1.0         A=1.0         A=0.0             Face first moments
       B=0.0         B=1.0          B=1.0         B=0.0         B=NaN     Centroid face second moments
W=NaN        W=0.25         W=0.5         W=0.25         W=NaN            Staggered volume second moments

o are nodes, x are physical cell centers. C are barycenters (first-kind moments), V are volumes (first-kind moments), A are face areas (first-kind moments). B are face centroids (second-kind moments), W are staggered volumes (second-kind moments).

The length of each vector is 5, matching the number of nodes, even though there are only 4 physical cells.