API Reference
Simple Mesh
MaterialPointGenerator.meshbuilder
— Functionmeshbuilder(x::T, y::T) where T <: AbstractRange
Description:
Generate structured mesh in 2D space.
meshbuilder(x::T, y::T, z::T) where T <: AbstractRange
Description:
Generate structured mesh in 3D space.
Polygon
MaterialPointGenerator.particle_in_polygon
— Functionparticle_in_polygon(px, py, polygon)
Description:
Determine whether a point is inside a polygon. Note the vertices of the polygon should be ordered in a counterclockwise manner; otherwise, it may lead to incorrect results.
(This function is generated by ChatGPT 4o - 2024.10.10)
MaterialPointGenerator.polygon2particle
— Functionpolygon2particle(domain, lpx, lpy)
Description:
Generate structured particles from a given polygon. Note the vertices of the polygon should be ordered in a counterclockwise manner; otherwise, it may lead to incorrect results.
lpx
and lpy
are the space of particles in x
and y
directions, respectively.
domain
is the polygon, for example, domain = [0 0; 2 0; 2 1; 0 1]
means generate structured particles in a rectangle area.
Polyhedron
MaterialPointGenerator.polyhedron2particle
— Functionpolyhedron2particle(msh_path::String, lpx, lpy, lpz, ::Val{:CPU})
Description:
Generate structured particles from a given polyhedron. Please provide .msh
file that generated by Gmsh GUI/Script.
MaterialPointGenerator.particle_in_polyhedron!
— Functionparticle_in_polyhedron!(pts, node, tet, results)
Description:
Determine whether a point is inside a polyhedron. This function is able to run on any hardware backends, so the input need to preallocate the results array. Users should not call this function directly, please check polyhedron2particle
.
MaterialPointGenerator.gmsh_mesh3D
— Functiongmsh_mesh3D(msh_path::String)
Description:
Generate 3D mesh using Gmsh.
DEM
MaterialPointGenerator.dem2particle
— Functiondem2particle(dem, lpz, bottom)
Description:
Generate particles from a given DEM file. dem
is a coordinates Array with three columns (x, y, z). lpz
is the space of particles in z
direction. bottom
is a Float64
value, which means the plane z = bottom
.
dem2particle(dem, lpz, bottom_surf)
Description:
Generate particles from a given DEM file and a bottom surface file. dem
is a coordinates Array with three columns (x, y, z). bottom_surf
is a coordinates Array with three columns, but it should have the same x and y coordinates as the DEM, and the z value should be lower than the DEM. lpz
is the space of particles in z
direction.
MaterialPointGenerator.rasterizeDEM
— FunctionrasterizeDEM(lpx, lpy, dem; k=10, p=2, trimbounds=[0.0 0.0], dembounds=[0.0, 0.0])
Description:
Rasterize the DEM file to generate particles. lpx
and lpy
are the space of particles in x
and y
directions. dem
is a coordinates Array with three columns (x, y, z)
. k
is the number of nearest neighbors (10 by default), p
is the power parameter (2 by default), trimbounds
is the boundary of the particles, dembounds
is the boundary of the DEM.
MaterialPointGenerator.IDW!
— FunctionIDW!(k, p, dem, idxs, ptslist, tree)
Description:
Inverse Distance Weighting (IDW) interpolation method. k
is the number of nearest neighbors, p
is the power parameter, dem
is a coordinates Array with three columns (x, y, z)
, idxs
is the index of the nearest neighbors, ptslist
is the coordinates Array of the particles, tree
is the KDTree of the DEM.
Utils
MaterialPointGenerator.savexyz
— Functionsavexyz(file_dir::P, pts::T) where {P <: String, T <: Array{Float64, 2}}
Description:
Save the points pts
to the xyz file file_dir
.
MaterialPointGenerator.readxyz
— Functionreadxyz(file_dir::P) where P <: String
Description:
Read the xyz file from file_dir
.
MaterialPointGenerator.sortbycol
— Functionsortbycol(pts, col::T) where T <: Int
Description:
Sort the points in pts
according to the column col
.