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 classMeaning
Node0-dimensional node
Edge1-dimensional line connecting two neigboring nodes
Facecodimension 1 object separating a cell from outer space or neigboring cell
Cellcodimension 0 object
BFaceFace situated at inner or domain boundary
Regionnumber 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 keyMeaning
CoordinatesCoordinates of the vertices of the grid cells
CellNodesAdjacency describing the nodes of grid cell
CellGeometriesAbstract array of subtypes of AbstractElementGeometry describing the geometry of each cell
CellRegionsAbstract array of integers describing region numbers
BFaceNodesAdjacency structure describing the nodes corresponding to each grid boundary face
BFaceGeometriesAbstract array of subtypes of AbstractElementGeometry describing the geometry of each boundary face
BFaceRegionsAbstract array of integers describig region numbers
CoordinateSystemAbstract 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
├─ AbstractGridIntegerArray2D
├─ BFaceNormals
├─ CoordinateSystem
├─ AbstractGridFloatConstant
├─ AbstractGridIntegerConstant
│  ├─ NumBEdgeRegions
│  ├─ NumBFaceRegions
│  └─ NumCellRegions
├─ ParentGrid
└─ ParentGridRelation
   ├─ BoundarySubGrid
   ├─ 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 nodes: 4 cells: 3 bfaces: 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

Base.delete!Method
delete!(
    grid::ExtendableGrid,
    T::Type{<:AbstractGridComponent}
) -> Dict{Type{<:AbstractGridComponent}, Any}

Remove grid component

source
Base.get!Method
get!(
    grid::ExtendableGrid,
    T::Type{<:AbstractGridComponent}
) -> Any

To be called by getindex. This triggers lazy creation of non-existing gridcomponents

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

source
Base.haskeyMethod
haskey(g::ExtendableGrid, k) -> Bool

Check if key is in grid

source
Base.keysMethod
keys(
    g::ExtendableGrid
) -> Base.KeySet{Type{<:AbstractGridComponent}, Dict{Type{<:AbstractGridComponent}, Any}}

Keys in grid

source
Base.mapMethod
map(f::Function, grid::ExtendableGrid) -> Any

Map a function onto node coordinates of grid

source
Base.setindex!Method
setindex!(
    grid::ExtendableGrid,
    v,
    T::Type{<:AbstractGridComponent}
) -> Any

Set new grid component

source
ExtendableGrids.isconsistentMethod
isconsistent(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.

source
ExtendableGrids.seemingly_equalMethod
seemingly_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 points
  • confidence: 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)
source
ExtendableGrids.update!Method
update!(
    grid::ExtendableGrid,
    T::Type{<:AbstractGridComponent}
) -> Any

Reinstantiate grid component (only if it exists)

source
ExtendableGrids.veryformMethod
veryform(
    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.

source
ExtendableGrids.veryformMethod
veryform(grid::ExtendableGrid{Tc,Ti},v,T::Type{<:AbstractGridAdjacency}) where{Tc,Ti}

Check proper type of adjacencies upon insertion

source