dune-grid 2.8.0
Loading...
Searching...
No Matches
albertareader.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALBERTA_ALBERTAREADER_HH
4#define DUNE_ALBERTA_ALBERTAREADER_HH
5
6#include <dune/geometry/type.hh>
7
10
12
13#if HAVE_ALBERTA
14
15namespace Dune
16{
17
18 template< class Grid >
20 {
22
23 public:
25
26 typedef typename Grid::ctype ctype;
27
28 static const int dimension = Grid::dimension;
30
31 private:
32 static_assert(dimensionworld == Alberta::dimWorld,
33 "AlbertaReader: world dimension must match ALBERTA's world dimension.");
34
36
37 MacroData macroData_;
38
39 AlbertaReader ( const This & );
40 This &operator= ( const This & );
41
42 public:
44 {}
45
46 void readGrid ( const std::string &fileName, GridFactory &factory )
47 {
48 // read ALBERTA macro triangulation
49 macroData_.read( fileName, false );
50
51 // insert all vertices into the factory
52 const int numVertices = macroData_.vertexCount();
53 for( int i = 0; i < numVertices; ++i )
54 {
55 FieldVector< ctype, dimensionworld > v;
56 const Alberta::GlobalVector &coords = macroData_.vertex( i );
57 for( int j = 0; j < dimensionworld; ++j )
58 v[ j ] = coords[ j ];
59 factory.insertVertex( v );
60 }
61
62 // insert all elements into the factory
63 std::vector< unsigned int > vertices( dimension+1 );
64 const int numElements = macroData_.elementCount();
65 for( int i = 0; i < numElements; ++i )
66 {
67 const typename MacroData::ElementId &id = macroData_.element( i );
68 for( int j = 0; j <= dimension; ++j )
69 vertices[ j ] = id[ j ];
70 factory.insertElement( GeometryTypes::simplex( dimension ), vertices );
71 }
72
73 // release ALBERTA macro data
74 macroData_.release();
75 }
76 };
77
78}
79
80#endif // #if HAVE_ALBERTA
81
82#endif
provides a wrapper for ALBERTA's macro_data structure
Include standard header files.
Definition: agrid.hh:58
static const int dimWorld
Definition: misc.hh:44
ALBERTA REAL_D GlobalVector
Definition: misc.hh:48
Definition: albertareader.hh:20
Grid::ctype ctype
Definition: albertareader.hh:26
static const int dimensionworld
Definition: albertareader.hh:29
static const int dimension
Definition: albertareader.hh:28
Dune::GridFactory< Grid > GridFactory
Definition: albertareader.hh:24
AlbertaReader()
Definition: albertareader.hh:43
void readGrid(const std::string &fileName, GridFactory &factory)
Definition: albertareader.hh:46
int ElementId[numVertices]
Definition: macrodata.hh:46
void release()
release the macro data structure
Definition: macrodata.hh:125
int elementCount() const
Definition: macrodata.hh:66
GlobalVector & vertex(int i) const
Definition: macrodata.hh:253
int vertexCount() const
Definition: macrodata.hh:61
ElementId & element(int i) const
Definition: macrodata.hh:244
void read(const std::string &filename, bool binary=false)
Definition: macrodata.hh:411
@ dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:392
@ dimension
The dimension of the grid.
Definition: common/grid.hh:386
ct ctype
Define type used for coordinates in grid module.
Definition: common/grid.hh:521
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
Definition: common/gridfactory.hh:344
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
Definition: common/gridfactory.hh:333
Provide a generic factory class for unstructured grids.
Different resources needed by all grid implementations.