Reference

Contents

Index

CartesianGeometry.PLICCell2DType
PLICCell2D

Stores the PLIC reconstruction state for one 2-D Cartesian cell.

Fields

  • nx, ny : unit-normal components pointing from wet to dry
  • c : PLIC constant (the c in x·n + c = 0)
  • frac : volume fraction in [0, 1]
  • cell_type : CELLFULL, CELLEMPTY, or CELL_CUT
source
CartesianGeometry._staggered_centroidMethod
integrate(T::Type{<:Tuple}, f, xyz, S, bc, bary)

Computes second-kind moments:

  • T=Tuple{0}: staggered volumes (W)
  • T=Tuple{1}: staggered face apertures (B)
  • T=Tuple{2}: barycenter of staggered wet volumes (Wbary) only

Arguments

  • f: Level set function.
  • xyz::NTuple{N}: the Cartesian coordinates of the lattice nodes.
  • bc: Boundary condition.
  • bary: Barycenters.
Warning

The last barycenters along each dimension are undefined.

source
CartesianGeometry.build_phase_polygon_2dMethod
build_phase_polygon_2d(pc::PLICCell2D, x0, x1, y0, y1) -> Polygon2D

Build the wet polygon inside cell [x0,x1]×[y0,y1] for a cut cell described by pc. VOFTools inte2d! is used to clip the rectangle.

source
CartesianGeometry.clip_polygon_halfplaneMethod
clip_polygon_halfplane(poly::Polygon2D, dim::Int, val::Float64, keep_ge::Bool) -> Polygon2D

Clip a Polygon2D by an axis-aligned half-plane using Sutherland-Hodgman.

  • dim=1 clips by x = val, dim=2 by y = val.
  • keep_ge=true keeps the side coord ≥ val.
  • keep_ge=false keeps the side coord ≤ val.

Returns a new Polygon2D with the clipped vertices.

source
CartesianGeometry.estimate_normals_2dMethod
estimate_normals_2d(frac, nx, ny) -> (normals_x, normals_y)

Estimate interface normals from a VOF fraction field on an nx × ny Cartesian grid using the Youngs central-difference stencil.

Returns two flat arrays (normalsx, normalsy) of size nx*ny. Interior cells use the 3×3 stencil; boundary cells fall back to one-sided differences.

source
CartesianGeometry.geometric_momentsFunction
geometric_moments(f, xyz, T=Float64, bc=nan; method=:vofi)

Compute geometric moments of the region defined by f on the grid defined by xyz. The moments include:

  • V: cell volumes
  • barycenter: cell barycenters
  • interface_measure: measure of the interface in each cell
  • cell_type: -1 for cut cells, 0 for empty cells, 1 for full cells
  • barycenter_interface: interface centroids in each cell
  • A: face areas in each direction
  • B: face barycentric moments in each direction
  • W: staggered face-associated volumes

The method keyword can be used to specify the integration backend (e.g., :vofi, :implicitintegration, etc.). The bc keyword specifies the boundary condition value for cells outside the domain.

source
CartesianGeometry.integrateMethod
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
CartesianGeometry.integrateMethod
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
CartesianGeometry.integrate_spacetimeMethod
integrate_spacetime(phi, xyz, t0, t1, ::Type{T}, bc; method=:implicitintegration)

Compute true space-time moments on the product grid (x..., t) for one slab [t0, t1].

Returns a SpaceTimeMoments bundle:

  • mST: N+1 dimensional geometric moments from integrate(Tuple{0}, ...)
  • Vcap0, Vcap1: spatial cap measures extracted from the time-direction first-kind moments integrate(Tuple{1}, ...)[end] at t=t0 and t=t1.
source
CartesianGeometry.integrate_voftools_surf2nd_3d!Method
integrate_voftools_surf2nd_3d!(moms, frac, xyz, bc, bary; normals=nothing)

Second-kind staggered face apertures (Bs) in 3-D.

Bs[dim][n] = wet area of the face perpendicular to dim at the barycenter location of cell n.

source
CartesianGeometry.integrate_voftools_surf_2d!Method
integrate_voftools_surf_2d!(moms, frac, xyz, bc; normals=nothing)

Fill the face-aperture tuple moms = (Ax, Ay) for a 2-D grid.

Ax[n] = intersection length of the wet region with the left face of cell n (the face at x = x[i]). Ay[n] = intersection length of the wet region with the bottom face of cell n (the face at y = y[j]).

source
CartesianGeometry.integrate_voftools_surf_3d!Method
integrate_voftools_surf_3d!(moms, frac, xyz, bc; normals=nothing,
                            mix_law=:softclosest05, mix_kwargs=(;))

Fill the face-aperture tuple moms = (Ax, Ay, Az) for a 3-D grid.

In the single-view mode (mix_law === :none) each cell stores the aperture on its low face (left x-face, bottom y-face, back z-face). With a mixture law the left and right views are blended.

source
CartesianGeometry.integrate_voftools_vol2nd_2d!Method
integrate_voftools_vol2nd_2d!(moms, frac, xyz, bc, bary; normals=nothing)

Second-kind staggered volume moments (Ws).

Ws[dim][n] = ∫ dV over the staggered cell centred at node (i,j) for dimension dim, weighted by the wet polygon.

source
CartesianGeometry.integrate_voftools_vol2nd_3d!Method
integrate_voftools_vol2nd_3d!(moms, frac, xyz, bc, bary; normals=nothing)

Second-kind staggered volume moments (Ws) in 3-D.

Uses inte3d! (Sutherland-Hodgman on Polyhedron3D) to clip the wet polyhedron to the stagger cell extent for each dimension.

source
CartesianGeometry.interface_face_from_plic_3dMethod
interface_face_from_plic_3d(poly::Polyhedron3D, dx, dy, dz)

Identify the PLIC interface face (not on any unit-cube boundary) in a truncated unit-cube polyhedron and return

(area_phys, mx_unit, my_unit, mz_unit)

where area_phys is the face area in physical coordinates (scaled by dx, dy, dz) and (mx, my, mz) is the face centroid in unit coordinates.

source
CartesianGeometry.interface_segment_from_plicMethod
interface_segment_from_plic(poly, c, xnc, ync)

Given a full-cell polygon poly and PLIC parameters (c, xnc, ync), return (length, midpointx, midpointy) of the interface segment inside the cell.

The interface line is xncx + yncy + c = 0.

source
CartesianGeometry.levelset_curvatureMethod
levelset_curvature(phi, xyz; eps_grad=sqrt(eps(float(eltype(phi)))))

Compute nodal curvature from a nodal level-set field on a Cartesian node grid xyz.

  • 1D: returns zeros with the same shape as phi.
  • 2D/3D: computes kappa = div(∇ϕ / sqrt(|∇ϕ|² + eps_grad²)) with centered interior finite differences and one-sided boundary differences.
source
CartesianGeometry.mix01Method
mix01(xL, xR; law=:mean, eps=eps(T), p=2, beta=10,
      lambda=zero(T), fL=nothing, fR=nothing, clamp=true)

Mix two normalised candidate values xL, xR ∈ [0,1] into a single shared value using the specified law.

Supported laws

SymbolFormula
:mean(xL + xR) / 2
:geom√(max(xL,0) · max(xR,0))
:harmonic2 xL xR / (xL + xR + ε)
:minmin(xL, xR)
:maxmax(xL, xR)
:closest05whichever of xL, xR is closer to 0.5 (mean on tie)
:softclosest05weighted average with `w = 1/(
:pull05minimiser of (x−xL)² + (x−xR)² + λ(x−0.5)²
:mixednessweighted average r(f) = 4f(1−f) using fL, fR

When clamp=true (default) the result is clamped to [0, 1].

source
CartesianGeometry.mix_aperture_physMethod
mix_aperture_phys(AL, AR, ℓf; kwargs...) -> Af

Mix two physical face-aperture candidates (AL, AR) on a face of length ℓf. Normalises to [0,1], applies mix01, then scales back.

source
CartesianGeometry.plic_reconstruct_2dMethod
plic_reconstruct_2d(frac, xyz, normals_xy)

Perform PLIC reconstruction on every cell of a 2-D Cartesian grid.

Arguments

  • frac : flat array of volume fractions (row-major, size nx*ny)
  • xyz : tuple of vectors (x-nodes, y-nodes)
  • normals_xy : nothing → estimate with Youngs stencil (nx_arr, ny_arr) → user-supplied per-cell normals

Returns a Vector{PLICCell2D} of length nx*ny.

source
CartesianGeometry.polygon_line_intersection_lengthMethod
polygon_line_intersection_length(poly, dim, val)

Compute the length of the intersection of the polygon with the line x=val (dim=1) or y=val (dim=2). Returns the total intersection length (may consist of multiple segments).

source
CartesianGeometry.polyhedron_plane_intersection_areaMethod
polyhedron_plane_intersection_area(poly::Polyhedron3D, axis::Int,
                                   val::Float64) -> Float64

Compute the area of the intersection of the polyhedron with the plane coord[axis] = val by clipping and finding the resulting face. The polyhedron is not modified (a copy is used internally).

The returned area is in the same coordinate system as the polyhedron vertices.

source
CartesianGeometry.rect_polygonMethod
rect_polygon(x0, x1, y0, y1) -> Polygon2D

Build a Polygon2D representing the axis-aligned rectangle [x0, x1] × [y0, y1] (counter-clockwise winding).

source
CartesianGeometry.sample_cartesian_fieldMethod
sample_cartesian_field(field, xyz, x::SVector)
sample_cartesian_field(field, xyz, xs::AbstractVector{<:SVector})

Sample nodal Cartesian scalar fields by multilinear interpolation (linear/bilinear/trilinear in 1D/2D/3D). Points outside the box are clamped to the boundary.

source
CartesianGeometry.sample_levelset_curvatureMethod
sample_levelset_curvature(phi, xyz, x; kwargs...)
sample_levelset_curvature(phi, xyz, xs; kwargs...)

Convenience helper: compute nodal levelset_curvature(phi, xyz; kwargs...) then sample it at query points with sample_cartesian_field.

source
CartesianGeometry.unit_cube_face_wet_areaMethod
unit_cube_face_wet_area(poly::Polyhedron3D, axis::Int, side::Int) -> Float64

Find the wet area on a specific face of the unit cube [0,1]^3 after PLIC truncation.

  • axis: 1 = x, 2 = y, 3 = z
  • side: 0 = face at coord = 0, 1 = face at coord = 1

Returns the area of the polygon lying on that face (in unit-cube coordinates, so full face = 1.0).

source
CartesianGeometry.vofinit!Method

1d implementation complies with Vofi 2.0's API (see 2d and 3d).

Convention

Even if cell is empty, return full centroid coordinates.

source