Types

CartesianGeometry.GeometricMomentsType
GeometricMoments{N,T,VT,BT,CT,NT,XT}

A data structure to hold geometric moments of a region defined by a level set function on a Cartesian grid. The type parameters are:

  • N: the spatial dimension
  • T: the numerical type (e.g., Float64)
  • VT: the type of the vector holding cell volumes
  • BT: the type of the vector holding cell barycenters
  • CT: the type of the vector holding cell types
  • NT: the type of the vector holding interface normals
  • XT: the type of the tuple holding node coordinates

The fields of the structure include:

  • V: a vector where V[i] is the volume of cell i
  • barycenter: a vector where barycenter[i] is the barycenter of cell i as an SVector{N,T}
  • interface_measure: a vector where interface_measure[i] is the measure of the interface in cell i
  • cell_type: a vector where cell_type[i] is -1 for cut cells, 0 for empty cells, and 1 for full cells
  • barycenter_interface: a vector where barycenter_interface[i] is the centroid of the interface in cell i
  • interface_normal: a vector where interface_normal[i] is the unit normal on the interface in cell i
  • A: a tuple of vectors where A[d][i] is the face area in direction d for cell i
  • B: a tuple of vectors where B[d][i] is the face barycentric moment in direction d for cell i
  • W: a tuple of vectors where W[d][i] is the staggered face-associated volume in direction d for cell i
  • xyz: a tuple of vectors where xyz[d][i] is the node coordinate in direction d
source
CartesianGeometry.checkFunction
check(m::GeometricMoments)

Check the consistency of the geometric moments data structure m. This function verifies that all fields have the correct lengths corresponding to the grid size. It can be used for debugging and validation purposes.

source

This section describes the main types and conventions used in CartesianGeometry.jl.

using CartesianGeometry

grid = (
    collect(range(0.0, 1.0; length=17)),
    collect(range(0.0, 1.0; length=17)),
)
f = HyperSphere{2,Float64}(0.45, (0.5, 0.5))
moms = geometric_moments(f, grid, Float64, nan; method=:vofi)
GeometricMoments{2, Float64, Vector{Float64}, Vector{StaticArraysCore.SVector{2, Float64}}, Vector{Float64}, Vector{StaticArraysCore.SVector{2, Float64}}, Tuple{Vector{Float64}, Vector{Float64}}}([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0001896273572863623, 0.0006905640876468561, 0.0006905640876468554, 0.00018962735728636084  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], StaticArraysCore.SVector{2, Float64}[[0.03125, 0.03125], [0.09375, 0.03125], [0.15625, 0.03125], [0.21875, 0.03125], [0.28125, 0.03125], [0.34375, 0.03125], [0.422643304402808, 0.05966051582788933], [0.47080389239173237, 0.05689907887331049], [0.5291961076082676, 0.0568990788733105], [0.5773566955971919, 0.059660515827889345]  …  [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN]], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04361038434118777, 0.06270270328252925, 0.06270270328252925, 0.04361038434118789  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], StaticArraysCore.SVector{2, Float64}[[NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN]  …  [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN], [NaN, NaN]], StaticArraysCore.SVector{2, Float64}[[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]  …  [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], ([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.007666666666666683, 0.011833333333333348, 0.007666666666666683  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, NaN]), ([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.005450337756035616, 0.010924093120561577, 0.010924093120561577, 0.005450337756035616  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.02503940628821083, 0.0625, 0.0625, 0.025039406288210775  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN]), ([NaN, 0.0, 0.0, 0.0, 0.0, 0.0, 8.544787979004024e-5, 0.00043901550549060045, 0.0007114561192994209, 0.0004390155054906007  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN  …  NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN]), ([0.0, 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625, 0.625, 0.6875, 0.75, 0.8125, 0.875, 0.9375, 1.0], [0.0, 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625, 0.625, 0.6875, 0.75, 0.8125, 0.875, 0.9375, 1.0]))
  • V: Vector : volumes
  • bary: Vector{SVector} : barycenters
  • interfacenorm: Vector : interface measures
  • celltype: Vector : cell types (empty 0, full 1, cut -1)
  • baryinterface: Vector{SVector} : interface centroids (available with :vofijul)
  • A,B,W: NTuple{D,Vector} : directional face moments and directional second-kind moments