Meshgrid

Replacement for Matlab's meshgrid function with helper for obtaining a triangulation and plotting the grid.

BaseUtilities.MeshGridType
grid = MeshGrid(X, Y)
grid = MeshGrid(x, y = x)
grid = MeshGrid(meshgrid(x, y))

Generate data structure that captures contents generated by meshgrid.

The constructor calls meshgrid for non-matrix arguments x, y. A MeshGrid object can be deconstructed by

X, Y = grid[]

You can "enumerate" all vertex positions as SVector{2, T} with

collect(grid[:])
map(grid[:]) do x
    @SVector[x..., 0]
end

You can pass grid::MeshGrid to Plots.plot

plot(grid, scatter=false, ...)

See also meshgrid, perturb!, triangles

source
BaseUtilities.perturb!Function
perturb!(grid, p=0.05; boundary::Bool = true)

Perturb vertex positions of grid with uniform random noise. p is the maximum amplitude relative to the cell size. If boundary = false, boundary vertices will not be perturbed.

Warning

This method does not check whether cells "flip orientation"!

See also MeshGrid

source
BaseUtilities.trianglesMethod
triangles(grid) :: Vector

Collect triangles in MeshGrid with each cell split into two triangles. Each triangle is represented as a triple of linear vertex indices.

See also MeshGrid

source