Extendable grid
An ExtendableGrid in form of a dictionary with types as keys and type stable value access. This means that grid components are accessed as dict entries, e.g. grid[Coordinates]
. The rationale of this approach is explained here.
Notations
A grid is assumed to be a subset of components of a polyhedral complex in d-dimensional space. We distinguish the following element classes characterized by their dimension:
Element class | Meaning |
---|---|
Node | 0-dimensional node |
Edge | 1-dimensional line connecting two neigboring nodes |
Face | codimension 1 object separating a cell from outer space or neigboring cell |
Cell | codimension 0 object |
BFace | Face situated at inner or domain boundary |
Region | number to be used to characterize subdomains, contacts etc. |
Grid components
Grid components are accessed like Dict entries, the keys must be subtypes of AbstractGridComponent
.
Basic set of grid components
Upon construction, an ExtendableGrid needs to be provided with the basic set of grid components denoted by the following component type keys:
Component type key | Meaning |
---|---|
Coordinates | Coordinates of the vertices of the grid cells |
CellNodes | Adjacency describing the nodes of grid cell |
CellGeometries | Abstract array of subtypes of AbstractElementGeometry describing the geometry of each cell |
CellRegions | Abstract array of integers describing region numbers |
BFaceNodes | Adjacency structure describing the nodes corresponding to each grid boundary face |
BFaceGeometries | Abstract array of subtypes of AbstractElementGeometry describing the geometry of each boundary face |
BFaceRegions | Abstract array of integers describig region numbers |
CoordinateSystem | Abstract type describing the coordinate system to be used |
Hierarchy of component type keys
The list of components can be printed using the gridcomponents
method.
AbstractGridComponent
├─ AbstractElementGeometries
│ ├─ BEdgeGeometries
│ ├─ BFaceGeometries
│ ├─ CellGeometries
│ ├─ EdgeGeometries
│ ├─ FaceGeometries
│ ├─ UniqueBEdgeGeometries
│ ├─ UniqueBFaceGeometries
│ ├─ UniqueCellGeometries
│ ├─ UniqueEdgeGeometries
│ └─ UniqueFaceGeometries
├─ AbstractElementRegions
│ ├─ BEdgeRegions
│ ├─ BFaceRegions
│ ├─ CellRegions
│ ├─ EdgeRegions
│ └─ FaceRegions
├─ AbstractGridAdjacency
│ ├─ BEdgeAssemblyGroups
│ ├─ BEdgeNodes
│ ├─ BFaceAssemblyGroups
│ ├─ BFaceCells
│ ├─ BFaceEdges
│ ├─ BFaceNodes
│ ├─ CellAssemblyGroups
│ ├─ CellEdgeSigns
│ ├─ CellEdges
│ ├─ CellFaceOrientations
│ ├─ CellFaceSigns
│ ├─ CellFaces
│ ├─ CellNodes
│ ├─ EdgeAssemblyGroups
│ ├─ EdgeCells
│ ├─ EdgeNodes
│ ├─ FaceAssemblyGroups
│ ├─ FaceCells
│ ├─ FaceEdgeSigns
│ ├─ FaceEdges
│ └─ FaceNodes
├─ AbstractGridFloatArray1D
│ ├─ BEdgeVolumes
│ ├─ BFaceVolumes
│ ├─ CellVolumes
│ ├─ EdgeVolumes
│ ├─ FaceVolumes
│ ├─ XCoordinates
│ ├─ YCoordinates
│ └─ ZCoordinates
├─ AbstractGridFloatArray2D
│ ├─ Coordinates
│ ├─ EdgeTangents
│ ├─ FaceNormals
│ └─ VoronoiFaceCenters
├─ AbstractGridIntegerArray1D
│ ├─ BEdgeEdges
│ ├─ BFaceCellPos
│ ├─ BFaceFaces
│ ├─ BFaceParents
│ ├─ CellParents
│ ├─ FaceParents
│ ├─ NodeInParent
│ ├─ NodeParents
│ ├─ NodePatchGroups
│ ├─ NodePermutation
│ ├─ PColorPartitions
│ ├─ PartitionBFaces
│ ├─ PartitionCells
│ ├─ PartitionEdges
│ └─ PartitionNodes
├─ AbstractGridIntegerArray2D
├─ BFaceNormals
├─ CoordinateSystem
├─ AbstractGridFloatConstant
├─ AbstractGridIntegerConstant
│ ├─ NumBEdgeRegions
│ ├─ NumBFaceRegions
│ └─ NumCellRegions
├─ ParentGrid
└─ ParentGridRelation
├─ RefinedGrid
└─ SubGrid
Additional components
Additional components can be added by defining a subtype of AbstractGridComponent
or a fitting subtype thereof, and assigning the value to the corresponding Dict entry:
g=simplexgrid([1,2,3,4.0])
abstract type MyComponent <: AbstractGridComponent end
g[MyComponent]=13
show(g)
ExtendableGrid{Float64, Int32}(dim=1, nnodes=4, ncells=3, nbfaces=2)
Alternatively, component creation can be perfomed lazily. For this purpose one needs to define an instantiate
method:
abstract type NodeCells <: AbstractGridAdjacency end
ExtendableGrids.instantiate(grid, ::Type{NodeCells})=atranspose(grid[CellNodes])
g=simplexgrid([1,2,3,4.0])
show(g[NodeCells])
1
1 2
2 3
3
Grid API
ExtendableGrids.ElementInfo
— Typeconst ElementInfo{T}=Union{Vector{T},VectorOfConstants{T}}
Union type for element information arrays. If all elements have the same information, it can be stored in an economical form as a VectorOfConstants
.
ExtendableGrids.AbstractElementGeometries
— Typeabstract type AbstractElementGeometries <: AbstractGridComponent
Array of element geometry information.
ExtendableGrids.AbstractElementRegions
— Typeabstract type AbstractElementRegions <: AbstractGridComponent
Array of element region number information.
ExtendableGrids.AbstractGridAdjacency
— Typeabstract type AbstractGridAdjacency <: AbstractGridComponent
Any kind of adjacency between grid components
ExtendableGrids.AbstractGridComponent
— Typeabstract type AbstractGridComponent <: AbstractExtendableGridApexType
Apex type for grid components.
ExtendableGrids.AbstractGridFloatArray1D
— Typeabstract type AbstractGridFloatArray1D <: AbstractGridComponent
1D Array of floating point data
ExtendableGrids.AbstractGridFloatArray2D
— Typeabstract type AbstractGridFloatArray2D <: AbstractGridComponent
2D Array of floating point data
ExtendableGrids.AbstractGridFloatConstant
— Typeabstract type AbstractGridFloatConstant <: AbstractGridComponent
Floating point number
ExtendableGrids.AbstractGridIntegerArray1D
— Typeabstract type AbstractGridIntegerArray1D <: AbstractGridComponent
1D Array of interger data
ExtendableGrids.AbstractGridIntegerArray2D
— Typeabstract type AbstractGridIntegerArray2D <: AbstractGridComponent
2D Array of integer data
ExtendableGrids.AbstractGridIntegerConstant
— Typeabstract type AbstractGridIntegerConstant <: AbstractGridComponent
Integer number
ExtendableGrids.BEdgeRegions
— Typeabstract type BEdgeRegions <: AbstractElementRegions
Boundary edge region number per boundary edge
ExtendableGrids.BFaceGeometries
— TypeDescription of boundary face geometries
abstract type BFaceGeometries <: AbstractElementGeometries
ExtendableGrids.BFaceNodes
— Typeabstract type BFaceNodes <: AbstractGridAdjacency
Adjacency describing nodes per grid boundary face
ExtendableGrids.BFaceRegions
— Typeabstract type BFaceRegions <: AbstractElementRegions
Boundary region number per boundary face
ExtendableGrids.CellGeometries
— Typeabstract type CellGeometries <: AbstractElementGeometries
Description of cell geometries
ExtendableGrids.CellNodes
— Typeabstract type CellNodes <: AbstractGridAdjacency
Adjacency describing nodes per grid cell
ExtendableGrids.CellRegions
— Typeabstract type CellRegions <: AbstractElementRegions
Cell region number per cell
ExtendableGrids.CoordinateSystem
— Typeabstract type CoordinateSystem <: AbstractGridComponent
Coordinate system
ExtendableGrids.Coordinates
— Typeabstract type Coordinates <: AbstractGridFloatArray2D
Node coordinates
ExtendableGrids.ExtendableGrid
— Typemutable struct ExtendableGrid{Tc, Ti}
Grid type wrapping Dict
ExtendableGrids.NumBEdgeRegions
— Typeabstract type NumBEdgeRegions <: ExtendableGrids.AbstractGridIntegerConstant
Number of boundary edge regions
ExtendableGrids.NumBFaceRegions
— Typeabstract type NumBFaceRegions <: ExtendableGrids.AbstractGridIntegerConstant
Number of boundary face regions
ExtendableGrids.NumCellRegions
— Typeabstract type NumCellRegions <: ExtendableGrids.AbstractGridIntegerConstant
Number of cell regions
Base.delete!
— Methoddelete!(
grid::ExtendableGrid,
T::Type{<:AbstractGridComponent}
) -> Dict{Type{<:AbstractGridComponent}, Any}
Remove grid component
Base.get!
— Methodget!(
grid::ExtendableGrid,
T::Type{<:AbstractGridComponent}
) -> Any
To be called by getindex. This triggers lazy creation of non-existing gridcomponents
Base.getindex
— MethodBase.getindex(grid::ExtendableGrid,T::Type{<:AbstractGridComponent})
Generic method for obtaining grid component.
This method is mutating in the sense that non-existing grid components are created on demand.
Due to the fact that components are stored as Any the return value triggers type instability. To prevent this, specialized methods must be (and are) defined.
Base.haskey
— Methodhaskey(g::ExtendableGrid, k) -> Bool
Check if key is in grid
Base.keys
— Methodkeys(
g::ExtendableGrid
) -> Base.KeySet{Type{<:AbstractGridComponent}, Dict{Type{<:AbstractGridComponent}, Any}}
Keys in grid
Base.map
— Methodmap(f,grid)
Map function f
returning a number onto node coordinates of grid. Returns a vector of length corresponding to the number of nodes of the grid. The function can take either a vector or a numbers as arguments. E.g. for a two-dimensional grid g
, both
map(X->X[1]+X[2], g)
and
map((x,y)->x+y, g)
are possible.
Base.setindex!
— Methodsetindex!(
grid::ExtendableGrid,
v,
T::Type{<:AbstractGridComponent}
) -> Any
Set new grid component
ExtendableGrids.coord_type
— Methodcoord_type(grid)
Type of coordinates in grid
ExtendableGrids.dim_grid
— Methoddim_grid(grid)
Grid dimension dimension of grid (larges element dimension)
ExtendableGrids.dim_space
— Methoddim_space(grid)
Space dimension of grid
ExtendableGrids.gridcomponents
— Methodgridcomponents()
Print the hierarchy of grid component key types (subtypes of AbstractGridComponent
. This includes additionally user defined subptypes.
ExtendableGrids.index_type
— Methodindex_type(grid)
Type of indices
ExtendableGrids.instantiate
— Function"Hook" for methods instantiating lazy components.
ExtendableGrids.instantiate
— Methodinstantiate(grid, _::Type{NumBEdgeRegions}) -> Any
Instantiate number of boundary edge regions
ExtendableGrids.instantiate
— Methodinstantiate(grid, _::Type{NumBFaceRegions}) -> Any
Instantiate number of bface regions
ExtendableGrids.instantiate
— Methodinstantiate(grid, _::Type{NumCellRegions}) -> Any
Instantiate number of cell regions
ExtendableGrids.isconsistent
— Methodisconsistent(grid; warnonly=false)
Check consistency of grid: a grid is consistent if
- Grid has no dangling nodes
- ... more to be added
If grid is consistent, return true, otherwise throw an error, or, if warnoly==true
, return false.
ExtendableGrids.num_bedgeregions
— Methodnum_bedgeregions(grid::ExtendableGrid) -> Any
Maximum boundary edge region numbers
ExtendableGrids.num_bedges
— Methodnum_bedges(grid::ExtendableGrid) -> Int64
Number of boundary edges in grid.
ExtendableGrids.num_bfaceregions
— Methodnum_bfaceregions(grid::ExtendableGrid) -> Any
Maximum boundary face region numbers
ExtendableGrids.num_bfaces
— Methodnum_bfaces(grid::ExtendableGrid) -> Int64
Number of boundary faces in grid.
ExtendableGrids.num_cellregions
— Methodnum_cellregions(grid::ExtendableGrid) -> Any
Maximum cell region number
ExtendableGrids.num_cells
— Methodnum_cells(grid::ExtendableGrid) -> Int64
Number of cells in grid
ExtendableGrids.num_nodes
— Methodnum_nodes(grid)
Number of nodes in grid
ExtendableGrids.seemingly_equal
— Methodseemingly_equal(array1, array2)
Check for seeming equality of two arrays by random sample.
ExtendableGrids.seemingly_equal
— Methodseemingly_equal(grid1, grid2; sort=false, confidence=:full
Recursively check seeming equality of two grids. Seemingly means that long arrays are only compared via random samples.
Keyword args:
sort
: if true, sort grid pointsconfidence
: Confidence level:- :low : Point numbers etc are the same
- :full : all arrays are equal (besides the coordinate array, the arrays only have to be equal up to permutations)
ExtendableGrids.update!
— Methodupdate!(
grid::ExtendableGrid,
T::Type{<:AbstractGridComponent}
) -> Any
Reinstantiate grid component (only if it exists)
ExtendableGrids.veryform
— Methodveryform(
grid::ExtendableGrid,
v,
_::Type{<:AbstractGridComponent}
) -> Any
Default veryform method.
"veryform" means "verify and/or transform" and is called to check and possibly transform components to be added to the grid via setindex!
.
The default method just passes data through.
ExtendableGrids.veryform
— Methodveryform(grid::ExtendableGrid{Tc,Ti},v,T::Type{<:AbstractGridAdjacency}) where{Tc,Ti}
Check proper type of adjacencies upon insertion