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