Integration
CartesianGeometry.integrate — Function
integrate(Tuple{0}, f, xyz, T, bc)Computes volume-specific (Tuple{0}) apertures of the first kind.
Returns a Tuple where
- The first component is a
Vector{T}that stores the wet volumes of each cell, - 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: theeltypeof the moments.bc: the boundary condition (e.g.nanorzero).
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: theeltypeof the moments.bc: the boundary condition (e.g.nanorzero).
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
method | Meaning of f |
|---|---|
:vofi | Level-set function (f(x...) <= 0 is wet) |
:vofijul | Level-set function (f(x...) <= 0 is wet) |
:voftools | Cell-centered VOF fraction field ([0,1] per cell) |
:implicitintegration | Level-set function (f(x...) <= 0 is wet) |
VOFTools defaults:
- Interface normals are estimated internally from
f(Youngs-type stencil). - Shared-face mixture uses
:softclosest05by default.
Tuple selector meaning
| Selector | Geometric family | First kind (integrate(..., T, bc)) | Second kind (integrate(..., S, bc, bary)) |
|---|---|---|---|
Tuple{0} | Volume-like | V + cell barycenter/info | W |
Tuple{1} | Surface/face-like | A | B |
Tuple{2} | Volume-like | N/A | Wbary (barycenter of W) |
Arguments:
f: see backend mapping table abovexyz:NTuple{N}of node vectorsbc: boundary fill (nan,zero, or equivalent)method: backend (:vofi,:vofijul,:voftools, or:implicitintegration)
Returns:
integrate(Tuple{0}, ...):V: wet measure per cell slotbary: wet barycenter per cell slotinterfacenorm: interface measurecelltype:0.0empty,1.0full,-1.0cutbaryinterface: 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)
- second-kind moments (
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 withbc
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 momentso 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.