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 behind this decision is described below.

Extendable grid 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 neighboring nodes
Facecodimension 1 object separating a cell from outer space or neighboring 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
│  ├─ BFaceEdgeSigns
│  ├─ BFaceEdges
│  ├─ BFaceNodes
│  ├─ BFaceNodesCanonical
│  ├─ CellAssemblyGroups
│  ├─ CellEdgeSigns
│  ├─ CellEdges
│  ├─ CellFaceOrientations
│  ├─ CellFaceSigns
│  ├─ CellFaces
│  ├─ CellNodes
│  ├─ EdgeAssemblyGroups
│  ├─ EdgeCells
│  ├─ EdgeNodes
│  ├─ FaceAssemblyGroups
│  ├─ FaceCells
│  ├─ FaceEdgeSigns
│  ├─ FaceEdges
│  ├─ FaceNodes
│  ├─ NodeCells
│  ├─ NodeEdges
│  └─ NodeFaces
├─ AbstractGridFloatArray1D
│  ├─ BEdgeVolumes
│  ├─ BFaceVolumes
│  ├─ CellVolumes
│  ├─ EdgeVolumes
│  ├─ FaceVolumes
│  ├─ XCoordinates
│  ├─ YCoordinates
│  └─ ZCoordinates
├─ AbstractGridFloatArray2D
│  ├─ Coordinates
│  ├─ EdgeTangents
│  ├─ FaceNormals
│  └─ VoronoiFaceCenters
├─ AbstractGridIntegerArray1D
│  ├─ BEdgeEdges
│  ├─ BEdgeParents
│  ├─ BFaceCellPos
│  ├─ BFaceFaces
│  ├─ BFaceParents
│  ├─ CellParents
│  ├─ EdgeParents
│  ├─ FaceParents
│  ├─ NodeInParent
│  ├─ NodeParents
│  ├─ NodePatchGroups
│  ├─ NodePermutation
│  ├─ PColorPartitions
│  ├─ PartitionBFaces
│  ├─ PartitionCells
│  ├─ PartitionEdges
│  └─ PartitionNodes
├─ AbstractGridIntegerArray2D
├─ BFaceNormals
├─ BRegionDomCode
├─ CoordinateSystem
├─ AbstractGridFloatConstant
├─ AbstractGridIntegerConstant
│  ├─ NumBEdgeRegions
│  ├─ NumBFaceRegions
│  └─ NumCellRegions
├─ ParentGrid
└─ ParentGridRelation
   ├─ RefinedGrid
   └─ SubGrid

Generator clusters

Derived components are created lazily upon access. Some of them share a common element enumeration and are therefore instantiated together by a single generator; the result does not depend on the order in which the components of a cluster are accessed first.

ClusterComponents instantiated togetherRoots
A (faces)FaceNodes, FaceGeometries, FaceCells, CellFaces, CellFaceSignsCellNodes, CellGeometries
B (edges)EdgeNodes, EdgeGeometries, EdgeRegions, EdgeCells, CellEdges, CellEdgeSignsCellNodes, CellGeometries (in 2D: cluster A)
B2 (face-edge link, 3D)FaceEdges, FaceEdgeSignscluster A, cluster B
C (bface-face link)BFaceFaces, BFaceNodesCanonical (bface nodes in the node order of their faces; the basic BFaceNodes keeps the user-provided order and is never modified)cluster A, BFaceNodes
D (boundary edges)BEdgeNodes + BEdgeEdges, and BFaceEdges + BFaceEdgeSignsclusters B, C (or an externally provided BEdgeNodes, which then defines the boundary edge enumeration and is never modified)

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 endg[MyComponent]=13show(g)
ExtendableGrid{Float64, Int32}(dim=1, nnodes=4, ncells=3, nbfaces=2)

Alternatively, component creation can be performed lazily. For this purpose one needs to define an instantiate method:

abstract type NodeCells <: AbstractGridAdjacency endExtendableGrids.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.BFaceNodes — Type
abstract type BFaceNodes <: AbstractGridAdjacency

Adjacency describing nodes per grid boundary face. The node order within each bface column is the one provided by the user and is never modified by lazy component creation. Consumers which need bface local node order to coincide with face local node order (e.g. consistently oriented boundary grids) should use grid[BFaceNodesCanonical].

source
Base.getindex — Method
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.map — Method
map(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.

source
ExtendableGrids.explode — Method
explode(grid::ExtendableGrid) -> ExtendableGrid

Remove all adjacency information from a grid, creating independent cells by duplicating coordinates and assigning new node indices while keeping the original coordinates.

This function creates a new grid where each cell has its own independent set of nodes by duplicating the coordinate information and creating new node indices. The original coordinates are preserved, but adjacency information is removed.

Arguments

  • grid::ExtendableGrid: The input grid to be processed

Returns

  • ::ExtendableGrid: A new grid with duplicated coordinates and independent cells
source
ExtendableGrids.isconsistent — Method
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_equal — Method
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.trim! — Method
trim!(grid; keep)

Remove precomputed grid components for lightweight storage of the grid.

Use the keep list to exclude grid components from trimming.

source