Builder API

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
source
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.
source
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 points are used for 3D grids and must be planar.

source
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.

source
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.

source
SimplexGridFactory.maybewatertightMethod
 maybewatertight(this::SimplexGridBuilder; bregions=nothing)

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

source
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!.

source
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 points are used for 3D grids and must be planar.

source
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!.

source

Grid generator options

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 overwritten 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! .

source

Test plots

Currently only for PyPlot. For plotting grids, see GridVisualize.jl.

Some primitives

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.

source
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. If no pairs are given, add all boundary facets of grid with their original region numbers to builder.

Example:

bregions!(builder,grid, 1=>2, 3=>5)
source
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])
source
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.

source
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.

source
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)

source