SimplexGridFactory.BinnedPointListType
mutable struct BinnedPointList{T}

Binned point list structure allowing for fast check for already existing points.

This provides better performance for indendifying already inserted points than the naive linear search.

OTOH the implementation is still quite naive - it dynamically maintains a cuboid bining region with a fixed number of bins.

Probably tree based adaptive methods (a la octree) will be more efficient, however they will be harder to implement.

In an ideal world, we would maintain a dynamic Delaunay triangulation, which at once could be the starting point of mesh generation which will follow here anyway.

SimplexGridFactory.BinnedPointListMethod
BinnedPointList(
    ,
    dim;
    tol,
    number_of_directional_bins,
    binning_region_increase_factor,
    num_allowed_unbinned_points,
    max_unbinned_ratio
)
BinnedPointList(dim; kwargs...)

Create and initialize binned point list

SimplexGridFactory.SimplexGridBuilderType
mutable struct SimplexGridBuilder

Simplex grid builder: wrapper around array based mesh generator interface. It allows to build up the input data incrementally.

SimplexGridFactory.SimplexGridBuilderMethod
SimplexGridBuilder(; Generator=nothing,
                     tol=1.0e-12,
                     checkexisting=true)

Create a SimplexGridBuilder.

  • Generator: module corresponding to mesh generator package. Valid choices are TetGen and Triangulate, corresponding to the respective Julia packages.
  • checkexisting: whether to check for already existing points
  • tol: two points below this tolerance will be merged if checkexisting is true
Base.insert!Method
insert!(bpl, p)

If another point with distance less the tol from p is in pointlist, return its index. Otherwise, insert point into pointlist.

ExtendableGrids.simplexgridMethod
function simplexgrid(Generator;
                     points=Array{Cdouble,2}(undef,0,0),
                     bfaces=Array{Cint,2}(undef,0,0),
                     bfaceregions=Array{Cint,1}(undef,0),
                     regionpoints=Array{Cdouble,2}(undef,0,0),
                     regionnumbers=Array{Cint,1}(undef,0),
                     regionvolumes=Array{Cdouble,1}(undef,0);
                     kwargs...
                  )

Create Grid from a number of input arrays. The 2D input arrays are transposed if necessary and converted to the proper data types for Triangulate or TetGen

This conversion is not performed if the data types are those indicated in the defaults and the leading dimension of 2D arrays corresponds to the space dimension.

See default_options for available kwargs.

ExtendableGrids.simplexgridMethod
simplexgrid(
    ::Type{SimplexGridFactory.TetGenType},
    TetGen,
    input;
    kwargs...
) -> ExtendableGrids.ExtendableGrid

Create Grid from TetGen data.

See default_options for available kwargs.

ExtendableGrids.simplexgridMethod
simplexgrid(
    ::Type{SimplexGridFactory.TriangulateType},
    Triangulate,
    input;
    kwargs...
) -> ExtendableGrids.ExtendableGrid

Create Grid from Triangle input data.

See default_options for available kwargs.

SimplexGridFactory.bregions!Method
bregions!(builder::SimplexGridBuilder,grid,regionlist;facetregions=nothing)

Add all boundary facets of grid with region numbers in region list to geometry description. The optional parameter facetregions allows to overwrite the numbers in regionlist.

SimplexGridFactory.bregions!Method
bregions!(builder::SimplexGridBuilder,grid, pairs...)

Add boundary facets of grid with region numbers mentioned as first element in pairs with region number mentioned as second element of pairs to the geometry description.

Example:

bregions!(builder,grid, 1=>2, 3=>5)
SimplexGridFactory.cellregion!Method
cellregion!(builder,region)

Set the current cell region (acts on subsequent regionpoint() calls)

Cell regions can be used to distinguish cells of different materials etc. In the API they are characterized by

  • region number set via cellregion!
  • maximum cell volume set via maxvolume!
  • region point set via regionpoint!. This is some point located within the respective region which must be surrounded by facets in a watertight manner.
SimplexGridFactory.default_optionsMethod
default_options()

Create dictionary of mesh generation options with default values. These at once describe the keyword arguments available to the methods of the package and are listed in the following table:

keyworddefault2D3DExplanation
PLCtrue-p-pTriangulate/tetraheralize PLSG/PLC
refinefalse-r-rRefines a previously generated mesh.
qualitytrue-q-qQuality mesh generation
minangle20Minimum angle for quality
volumecontroltrue-a-aMaximum area constraint
maxvolumeInfValue of area/volume constraint if less than Inf
attributestrue-A-ARegional attribute to each simplex.
confdelaunaytrue-DEnsure that all circumcenter lie within the domain.
nosteinerfalse-Y-YProhibits insertion of Steiner points on the mesh boundary
quiettrue-Q-QSuppress all output unless an error occurs.
verbosefalse-V-VGive detailed information.
debugfacetstrue-dDetects self-intersections of facets of the PLC.
checkfalse-C-CChecks the consistency of the final mesh.
optlevel1-OSpecifies the level of mesh optimization.
unsuitablenothingUnsuitable function
addflags""Additional flags
flagsnothingSet flags, overwrite all other options

For mesh generation, these are turned into mesh generator control flags. This process can be completely ovewritten by specifying the flags parameter.

For the flags parameter in 2D see the short resp. long documentation of the Triangle control flags.

For the 3D case, see the corresponding TetGen flags

The unsuitable parameter should be a function, see triunsuitable .

SimplexGridFactory.facet!Method
facet!(builder,i1)
facet!(builder,i1,i2)
facet!(builder,i1,i2,i3,i4)
facet!(builder,vector_or_tuple)
facet!(builder, (x1,y1), (x2,y2))
facet!(builder, (x1,y1,z1), (x2,y2,z2),(x3,y3,z3))

Add a facet via the corresponding point indices returned by point!.

Facets of two points are solely used for 2D grids. Facets with more than two poins are used for 3D grids and must be planar.

SimplexGridFactory.facetregion!Method
facetregion!(builder,region)

Set the current facet region. Subsequent facets will be marked with this number. Facet regions can be used to mark different parts of the boundary, e.g. for distinguishing boundary conditions.

SimplexGridFactory.holepoint!Method
holepoint!(builder,x)
holepoint!(builder,x,y)
holepoint!(builder,x,y,z)
holepoint!(builder,vec_or_tuple)

Add a point marking a hole region. Hole regions need to be surrounded by facets in a watertight manner.

SimplexGridFactory.lineto!Method
lineto!(builder, pt)

Generate a line from the current pen position to the target point pt, s moveto!(), (2D, 3D). pt is either an existing point index or a table of point coordinates. In the latter case, the point is added. It returns index of the target point.

Example 2D: draw a square with different facetregion numbers

 p = moveto!(b,[0,0])
 facetregion!(b,1);  lineto!(b,[1,0])
 facetregion!(b,2);  lineto!(b,[1,1])
 facetregion!(b,3);  lineto!(b,[0,1])
 facetregion!(b,4);  lineto!(b,p)

Example 3D: two planar facet with different facetregion numbers

 facetregion!(b,1);
 p1 = moveto!(b,[0,0,0])
 p2 = moveto!(b,[1,0,0])
 p3 = moveto!(b,[1,1,0])
 p4 = moveto!(b,[0,1,0])
 polyfacet!(b,[p1,p2,p3,p4])

 facetregion!(b,2);
 p1 = moveto!(b,[0,0,1])
 p2 = moveto!(b,[1,0,1])
 p3 = moveto!(b,[1,1,1])
 p4 = moveto!(b,[0,1,1])
 polyfacet!(b,[p1,p2,p3,p4])
SimplexGridFactory.maybewatertightMethod
 maybewatertight(this::SimplexGridBuilder; bregions=nothing)

Check if facets belonging to boundare regions in bregions are watertight. This is based on a nuber of heuristics, only a negative answer is definitive.

SimplexGridFactory.mesh3d!Method
  mesh3d!(builder, mesh; translate=(0,0,0), cellregion=0, hole=false)

Incorporate 3d model from mesh.

SimplexGridFactory.model3d!Method
model3d!(builder, filename; translate=(0,0,0), cellregion=0, hole=false)

Load 3D model from file. File formats are those supported by MeshIO.jl.

SimplexGridFactory.moveto!Method
moveto!(builder, pt)

Move the (virtual) pen to the target point pt (2D, 3D). pt is either an existing point index or a table of point coordinates. In the latter case, the point is added. It returns index of the target point.

SimplexGridFactory.point!Method
point!(builder,x)
point!(builder,x,y)
point!(builder,x,y,z)
point!(builder,vec_or_tuple)

Add point or merge with already existing point. Returns its index which can be used to set up facets with facet!.

SimplexGridFactory.polyfacet!Method
polyfacet!(builder,vector_or_tuple)

Add a polygonal facet via the corresponding point indices returned by point!.

Facets with more than two poins are used for 3D grids and must be planar.

SimplexGridFactory.rect2d!Method
rect2d!(builder, sw, ne; facetregions=nothing)

Add points and facets describing a rectangle via points describing its south-west and north-east corners. On default, the corresponding facet regions are deduced from the current facetregion. Alternatively, a 4-vector of facetregions can be passed.

SimplexGridFactory.rect3d!Method
rect3d!(builder, bsw, tne; facetregions=nothing)

Add points and facets describing a qudrilateral via points describing its bottom south-west and top north-east corners. On default, the corresponding facet regions are deduced from the current facetregion. Alternatively, a 6-vector of facetregions can be passed (in the sequence s-e-n-w-b-t)

SimplexGridFactory.regionpoint!Method
regionpoint!(builder,x)
regionpoint!(builder,x,y)
regionpoint!(builder,x,y,z)
regionpoint!(builder,vec_or_tuple)

Add a region point marking a region, using current cell volume an cell region See cellregion!.

SimplexGridFactory.sphere!Method
sphere!(builder, center, radius; nref=3)

Add points and facets approximating a sphere. nref is a refinement level.

SimplexGridFactory.tetgenioMethod
tetgenio(
    TetGen;
    points,
    bfaces,
    bfaceregions,
    regionpoints,
    regionnumbers,
    regionvolumes
) -> Any

Create a RawTetGenIO structure from a number of input arrays. The 2D input arrays are transposed if necessary and converted to the proper data types for TetGen.

This conversion is not performed if the data types are those indicated in the defaults and the leading dimension of 2D arrays corresponds to the space dimension.

SimplexGridFactory.tetgenioMethod
tetgenio(this::SimplexGridBuilder) -> Any

Create tetgen input from the current state of the builder.

SimplexGridFactory.triangulateioMethod
triangulateio(
    Triangulate;
    points,
    bfaces,
    bfaceregions,
    regionpoints,
    regionnumbers,
    regionvolumes
) -> Any

Create a TriangulateIO structure from a number of input arrays. The 2D input arrays are transposed if necessary and converted to the proper data types for Triangulate.

This conversion is not performed if the data types are those indicated in the defaults and the leading dimension of 2D arrays corresponds to the space dimension.