ArchetypedGrid Concept

### ArchetypedGrid Concept

##### Description

An ArchetypedGrid is a grid which associates an archetype with each cell. An archetype is a combinatorial model of a cell, or, more precisely, of the boundary of a cell. Thus, the archetype A of a cell C of dimension d is a grid of dimension d-1. The cells of A correspond to the facets of C.

The rationale for having archetypes stems from the fact that in general, it is not enough to know the vertices of a cell to determine its topology. We must also know how the vertices form the facets of the cell. In general, the archetype will again be a model of ArchetypedGrid, so that we can apply the concept recursively.

For an example of how to use archetypes, consider the problem of copying grids from one representation (source) into a different one (target). Consider the case of quadrilateral cells, where the vertices of a cell are ordered in a binary way in the source representation (for example, row-major numbering in a Cartesian grid), and cyclically in the target representation. If we don't care about this different numbering, twisted cells will result. In order to avoid this, we must somehow know about the different orderings. We can of course implement ad hoc copy procedures for each pair of grid representations, but this is against the "generic spirit".

A better way is to make this ordering explicit and amenable to algorithmic treatment. This is what archetypes are for. Before starting the actual copying of the grid, we try to match the archetypes of the source grid to that of the target grid by calculating isomorphisms between source and target archetypes. These isomorphisms will define a permutation of the vertex ordering of the source cells, such that an isomorphic copy of the source grid results.

##### Notation

G is a type which is a model of ArchetypedGrid
g is an object of type G
A is an object of type G::archetype_type
a is an object of type G::archetype_handle
ai is an object of type G::archetype_iterator
C is an object of type G::Cell c is an object of type G::cell_handle

##### Associated types
 Name Expression Description archetype type `G::archetype_type` The type of cell archetypes, model of Grid and of Cell-Vertex Input Grid Range of dimension `G::dimension()-1` archetype handle `G::archetype_handle` unique handle for an archetype within the grid `G` archetype iterator `G::archetype_iterator` iterator over all archetypes of a grid

##### Valid Expressions
 Name Expression Type requirements return type Archetype association `g.Archetypeof(C)` archetype_type const& Archetype association `g.archetype_of(c)` archetype_handle Archetype iteration start `g.BeginArchetype()` archetype_iterator Archetype iteration past-the-end `g.EndArchetype()` archetype_iterator Archetype count `g.NumOfArchetypes()` unsigned Handle to archetype `g.Archetype(a)` archetype_type const& iterator to handle `g.handle(ai)` archetype_handle

##### Expression semantics
 Name Expression Precondition Semantics Postcondition

##### Invariants
 `&(g.Archetype(archetype_of(C))) == &(g.ArchetypeOf(C))` `std::distance(g.BeginArchetype(), g.EndArchetype()) == g.NumOfArchetypes()` ` &(*ai) == &(g.Archetype(g.handle(ai)))`