Builder API
SimplexGridFactory.SimplexGridBuilder — Type
mutable struct SimplexGridBuilderSimplex grid builder: wrapper around array based mesh generator interface. It allows to build up the input data incrementally.
SimplexGridFactory.SimplexGridBuilder — Method
SimplexGridBuilder(; Generator=nothing,
tol=1.0e-12,
checkexisting=true)Create a SimplexGridBuilder.
Generator: module corresponding to mesh generator package. Valid choices areTetGenandTriangulate, corresponding to the respective Julia packages.checkexisting: whether to check for already existing pointstol: two points below this tolerance will be merged ifcheckexistingis true
ExtendableGrids.dim_space — Method
dim_space(builder)
Space dimension of builder.
ExtendableGrids.simplexgrid — Method
simplexgrid(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! — 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.checkexisting! — Method
checkexisting!(builder, b)
Whether to check for already existing points
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.
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.flags — Method
flags(builder)Return mesh generator specific flag string created from builder options.
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.maxvolume! — Method
maxvolume!(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 number of heuristics, only a negative answer is definitive.
SimplexGridFactory.options! — Method
options!(builder; kwargs...)
Set some mesh generation options, see default_options
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 points are used for 3D grids and must be planar.
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!.
Grid generator options
SimplexGridFactory.default_options — Method
default_options(mesher)
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 | 2D: 20 | Minimum angle for quality | ||
| 3D: 0 | ||||
| radiusedgeratio | 2.0 | (3D only) Minimum radius/edge ratio 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 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! .
Test plots
Currently only for PyPlot. For plotting grids, see GridVisualize.jl.
SimplexGridFactory.builderplot — Method
builderplot(
builder::SimplexGridBuilder;
Plotter::Module = nothing,
size = (650, 300),
input_slot = (1, 1),
output_slot = (1, 2),
layout = (1, 2),
vis = GridVisualizer(; Plotter, layout, size),
circumcircles = false,
reveal = true,
kwargs...
)Two panel visualization of gridfactory with input and resulting grid
builder: Simplex grid builderPlotter: Plottersize: size of plotinput_slot: slot in visualizer for input plotoutput_slot: slot in visualizer for output plotlayout: layout of grid visualizervis: grid visualizercircumcircles: plot circumcircles in outputreveal: reveal plot upon return. Ifrevel==true,reveal(vis)is returned, and the plot is shown automatically. Ifrevel==false, the visualizervisis returned, giving the user the possibility to add plots in other visualizer slots.kwargs...: passed to output constructor; seedefault_optionsfor availablekwargs.
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.
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)SimplexGridFactory.circle! — Method
circle!(builder, center, radius; n=20)Add points and facets approximating a circle.
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.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.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.sphere! — Method
sphere!(builder, center, radius; nref=3)Add points and facets approximating a sphere. nref is a refinement level.