Grid algorithmsCount boundary components AlgorithmConstructGrid Algorithm

ConstructGrid Algorithm

This documentation is still incomplete!
Declaration

This is actually a family of related functions:

[1]
template<class G1, class G2>
inline void 
ConstructGrid0(G1            & destG, 
               G2       const& srcG);

[2]
template<class G1, class G2, class VertexMap, class CellMap>
extern void 
ConstructGrid0VC(G1            & destG, 
                 G2       const& srcG,
                 VertexMap     & V21,
                 CellMap       & C21); 

[3]
template<class G1, class Geom1, class G2, class Geom2>
extern void 
ConstructGrid(G1         & destG,
              Geom1 const& destGeom,
              G2    const& srcG, 
              Geom2 const& srcGeom);

[4]
template<class G1, class Geom1, 
         class G2, class Geom2, class VertexMap>
extern void 
ConstructGridV(G1            & destG, 
               Geom1         & destGeom,
               G2       const& srcG,
               Geom2    const& srcGeom,
               VertexMap     & V21); 

[5]
template<class G1, class Geom1, 
         class G2, class Geom2, class VertexMap, class CellMap>
extern void 
ConstructGridVC(G1            & destG, 
                Geom1         & destGeom,
                G2       const& srcG,
                Geom2    const& srcGeom,
                VertexMap     & V21,
                CellMap       & C21);
Description

The ConstructGridXXX family of template functions make an associative copy of a source grid Gsrc to a destination grid Gdest. The ConstructGrid0XXX functions ([1], [2]) do only a copy of combinatoric grids, the other copy also geometry information.

The templates above are actually not really fully generic -- they must be specialized to the type of the first parameter, G1. The more general grids the G1 grid type can represent, the more useful these functions are. For very specialized grids, like Cartesian ones, they do not make much sense.

This algorithm is in some sense the analogue to the STL copy algorithm for sequences, only that it cannot be fully generic on the destination argument.

Definition

Declared in construct-grid.h.
Specialized in complex2d-construct.C for Complex2D and construct.C for Triang2D.

Template parameters
Type requirements

Geom1 is a model of Mutable Vertex Grid Geometry
G2 is a model of Cell-Vertex Input Grid Range
Geom2 is a model of Vertex Grid Geometry
VertexMap is a model of Mutable Mapping from G2::vertex_handle to G1::vertex_handle
CellMap is a model of Mutable Mapping from G2::cell_handle to G1::cell_handle

Preconditions

srcGeom is bound to srcG.

Postconditions

destG contains a copy of srcG, and ([3]-[5]) destGeom contains a copy of srcGeom, such that the mappings V21 and C21 induce a grid morphism from srcG to destG.

Complexity

Linear in the size of srcG.

Example
RegGrid2D R(10,10);  // 10x10 Cartesian grid
mapped_geometry_reg2d<Linear2D>  geomR(R, Linear2D::identity); // 
Complex2D G;         // empty grid
stored_geometry_complex2d geomG(G);
ConstructGrid(G,geomG, R,geomR); // copy R to G;
assert(G.NumOfVertices() == R.NumOfVertices());
assert(G.NumOfCells()    == R.NumOfCells());
typedef grid_types<Complex2D> gt; // 'namespace' for Complex2D-related types 
for(gt::CellIterator c(G), ! c.IsDone(); ++c)
  cout << "Cell " << c.handle() << "  "
       << "has "  << (*c).NumOfVertices() << " vertices";
Uses
Used by

The operation of copying is so fundamental that it is used virtually everywhere a grid has to be created. If a grid of any type has to be constructed in the Complex2D file format, an input adapter IstreamComplex2DFmt for this format is used. To write any grid to this format, the corresponding output adapter OstreamComplex2DFmt is used, see for instance test-construct-main.C or test-triang2d-construct.C.

Notes
See also

EnlargeGrid   IstreamComplex2DFmt   OstreamComplex2DFmt   OstreamGMV2DFmt   OstreamOFF2DFmt


Guntram Berti


Grid algorithmsCount boundary components AlgorithmConstructGrid Algorithm