Builder API
SimplexGridFactory.SimplexGridBuilder
— Typemutable struct SimplexGridBuilder
Simplex grid builder: wrapper around array based mesh generator interface. It allows to build up the input data incrementally.
SimplexGridFactory.SimplexGridBuilder
— MethodSimplexGridBuilder(; Generator=nothing,
tol=1.0e-12,
checkexisting=true)
Create a SimplexGridBuilder.
Generator
: module corresponding to mesh generator package. Valid choices areTetGen
andTriangulate
, corresponding to the respective Julia packages.checkexisting
: whether to check for already existing pointstol
: two points below this tolerance will be merged ifcheckexisting
is true
ExtendableGrids.dim_space
— Methoddim_space(builder)
Space dimension of builder.
ExtendableGrids.simplexgrid
— Methodsimplexgrid(builder; kwargs...)
Build simplex grid from the current state of the builder. kwargs
overwrite those set with the options!
method. See default_options
for available kwargs
.
SimplexGridFactory.cellregion!
— Methodcellregion!(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.checkexisting!
— Methodcheckexisting!(builder, b)
Whether to check for already existing points
SimplexGridFactory.facet!
— Methodfacet!(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!
— Methodfacetregion!(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.flags
— Methodflags(builder)
Return mesh generator specific flag string created from builder options.
SimplexGridFactory.holepoint!
— Methodholepoint!(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.maxvolume!
— Methodmaxvolume!(builder,vol)
Set the current cell volume resp. area (acts on subsequent regionpoint() calls). See cellregion!
.
SimplexGridFactory.maybewatertight
— Method 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.options!
— Methodoptions!(builder; kwargs...)
Set some mesh generation options, see default_options
SimplexGridFactory.point!
— Methodpoint!(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!
— Methodpolyfacet!(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.regionpoint!
— Methodregionpoint!(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!
.
Grid generator options
SimplexGridFactory.default_options
— Methoddefault_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:
keyword | default | 2D | 3D | Explanation |
---|---|---|---|---|
PLC | true | -p | -p | Triangulate/tetraheralize PLSG/PLC |
refine | false | -r | -r | Refines a previously generated mesh. |
quality | true | -q | -q | Quality mesh generation |
minangle | 20 | Minimum angle for quality | ||
volumecontrol | true | -a | -a | Maximum area constraint |
maxvolume | Inf | Value of area/volume constraint if less than Inf | ||
attributes | true | -A | -A | Regional attribute to each simplex. |
confdelaunay | true | -D | Ensure that all circumcenter lie within the domain. | |
nosteiner | false | -Y | -Y | Prohibits insertion of Steiner points on the mesh boundary |
quiet | true | -Q | -Q | Suppress all output unless an error occurs. |
verbose | false | -V | -V | Give detailed information. |
debugfacets | true | -d | Detects self-intersections of facets of the PLC. | |
check | false | -C | -C | Checks the consistency of the final mesh. |
optlevel | 1 | -O | Specifies the level of mesh optimization. | |
unsuitable | nothing | Unsuitable function | ||
addflags | "" | Additional flags | ||
flags | nothing | Set 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!
.
Test plots
Currently only for PyPlot. For plotting grids, see GridVisualize.jl.
SimplexGridFactory.builderplot
— Methodbuilderplot(gb::SimplexGridBuilder; Plotter, kwargs...)
Two panel visualization of gridfactory with input and resulting grid See default_options
for available kwargs
.
Some primitives
SimplexGridFactory.bregions!
— Methodbregions!(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!
— Methodbregions!(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)
SimplexGridFactory.circle!
— Methodcircle!(builder, center, radius; n=20)
Add points and facets approximating a circle.
SimplexGridFactory.lineto!
— Methodlineto!(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.mesh3d!
— Method mesh3d!(builder, mesh; translate=(0,0,0), cellregion=0, hole=false)
Incorporate 3d model from mesh.
SimplexGridFactory.model3d!
— Methodmodel3d!(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!
— Methodmoveto!(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.rect2d!
— Methodrect2d!(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!
— Methodrect3d!(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.sphere!
— Methodsphere!(builder, center, radius; nref=3)
Add points and facets approximating a sphere. nref
is a refinement level.