Mesh
A background mesh and a background grid are often used interchangeably in MPM literature, but Tesserae keeps them separate. A mesh stores the geometry of the background domain, while a grid is a state container generated from that mesh. Grid fields such as mass, momentum, velocity, and force live on the grid; coordinates and spacing come from the mesh.
A simulation typically shares one mesh between the grid, particles, and basis weights. This keeps coordinates and particle-grid connectivity consistent across the calculation.
MPM workflows currently use CartesianMesh. FEMesh is used for finite-element calculations; IGAMesh is used for isogeometric calculations. See Finite element calculations and Isogeometric analysis calculations.
Cartesian mesh
Tesserae.CartesianMesh — Type
CartesianMesh([T,] h, (xmin, xmax), (ymin, ymax)...; warn=true, block_size_log2=Val(2))Construct a uniform Cartesian mesh with scalar spacing h (same in all directions). If an axis length is not divisible by h, the upper bound is expanded to cover the requested domain. Set warn=false to suppress the expansion warning. block_size_log2 sets the block decomposition used by ThreadPartition and SpArray grids generated from this mesh.
Examples
julia> CartesianMesh(1.0, (0,3), (1,4))
4×4 CartesianMesh{2, Float64, Vector{Float64}, 2}:
[0.0, 1.0] [0.0, 2.0] [0.0, 3.0] [0.0, 4.0]
[1.0, 1.0] [1.0, 2.0] [1.0, 3.0] [1.0, 4.0]
[2.0, 1.0] [2.0, 2.0] [2.0, 3.0] [2.0, 4.0]
[3.0, 1.0] [3.0, 2.0] [3.0, 3.0] [3.0, 4.0]Tesserae.spacing — Function
spacing(::CartesianMesh)Return the spacing of the mesh.
Tesserae.volume — Function
volume(::CartesianMesh)Return the volume of the mesh.
Tesserae.extract — Method
extract(mesh::CartesianMesh, (xmin, xmax), (ymin, ymax)...)Extract a portion of the mesh. The extracted mesh retains the original origin and spacing.
Tesserae.isinside — Function
isinside(x::Vec, mesh::CartesianMesh)Check if x is inside the mesh.
Tesserae.findcell — Function
findcell(x::Vec, mesh::CartesianMesh)Return the cell index where x is located.
Examples
julia> mesh = CartesianMesh(1, (0,5), (0,5))
6×6 CartesianMesh{2, Float64, Vector{Float64}, 2}:
[0.0, 0.0] [0.0, 1.0] [0.0, 2.0] [0.0, 3.0] [0.0, 4.0] [0.0, 5.0]
[1.0, 0.0] [1.0, 1.0] [1.0, 2.0] [1.0, 3.0] [1.0, 4.0] [1.0, 5.0]
[2.0, 0.0] [2.0, 1.0] [2.0, 2.0] [2.0, 3.0] [2.0, 4.0] [2.0, 5.0]
[3.0, 0.0] [3.0, 1.0] [3.0, 2.0] [3.0, 3.0] [3.0, 4.0] [3.0, 5.0]
[4.0, 0.0] [4.0, 1.0] [4.0, 2.0] [4.0, 3.0] [4.0, 4.0] [4.0, 5.0]
[5.0, 0.0] [5.0, 1.0] [5.0, 2.0] [5.0, 3.0] [5.0, 4.0] [5.0, 5.0]
julia> findcell(Vec(1.5, 1.5), mesh)
CartesianIndex(2, 2)