dune-grid  2.4.1
dgfidentitygrid.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_DGFPARSER_DGFIDENTITYGRID_HH
4 #define DUNE_DGFPARSER_DGFIDENTITYGRID_HH
5 
6 #include <dune/common/typetraits.hh>
7 
11 
12 namespace Dune
13 {
14 
15  // DGFGridFactory for IdentityGrid
16  // -------------------------------
17 
18  template< class HostGrid >
19  struct DGFGridFactory< IdentityGrid< HostGrid > >
20  {
22 
23  const static int dimension = Grid::dimension;
24  typedef MPIHelper::MPICommunicator MPICommunicator;
25  typedef typename Grid::template Codim<0>::Entity Element;
26  typedef typename Grid::template Codim<dimension>::Entity Vertex;
27 
28  explicit DGFGridFactory ( std::istream &input,
29  MPICommunicator comm = MPIHelper::getCommunicator() )
30  : dgfHostFactory_( input, comm ),
31  grid_( 0 )
32  {
33  HostGrid *hostGrid = dgfHostFactory_.grid();
34  assert( hostGrid != 0 );
35  grid_ = new Grid( *hostGrid );
36  }
37 
38  explicit DGFGridFactory ( const std::string &filename,
39  MPICommunicator comm = MPIHelper::getCommunicator() )
40  : dgfHostFactory_( filename, comm ),
41  grid_( 0 )
42  {
43  HostGrid *hostGrid = dgfHostFactory_.grid();
44  assert( hostGrid != 0 );
45  std::ifstream input( filename.c_str() );
46  grid_ = new Grid( *hostGrid );
47  }
48 
49  Grid *grid () const
50  {
51  return grid_;
52  }
53 
54  template< class Intersection >
55  bool wasInserted ( const Intersection &intersection ) const
56  {
57  return dgfHostFactory_.wasInserted( HostGridAccess< Grid >::hostIntersection( intersection ) );
58  }
59 
60  template< class Intersection >
61  int boundaryId ( const Intersection &intersection ) const
62  {
63  return dgfHostFactory_.boundaryId( HostGridAccess< Grid >::hostIntersection( intersection ) );
64  }
65 
66  template< int codim >
67  int numParameters () const
68  {
69  return dgfHostFactory_.template numParameters< codim >();
70  }
71 
72  template< class Entity >
73  std::vector< double > &parameter ( const Entity &entity )
74  {
75  return dgfHostFactory_.parameter( HostGridAccess< Grid >::hostEntity( entity ) );
76  }
77 
78  private:
79  DGFGridFactory< HostGrid > dgfHostFactory_;
80  Grid *grid_;
81  };
82 
83 
84 
85  // DGFGridInfo for IdGrid
86  // ----------------------
87 
88  template< class HostGrid >
89  struct DGFGridInfo< IdentityGrid< HostGrid > >
90  {
91  static int refineStepsForHalf ()
92  {
94  }
95 
96  static double refineWeight ()
97  {
99  }
100  };
101 
102 }
103 
104 #endif // #ifndef DUNE_DGFPARSER_DGFIDENTITYGRID_HH
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
static double refineWeight()
Definition: dgfidentitygrid.hh:96
MPIHelper::MPICommunicator MPICommunicator
Definition: dgfidentitygrid.hh:24
int boundaryId(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:61
Provides a meta grid that is identical to its host.
Definition: identitygrid.hh:33
DGFGridFactory(const std::string &filename, MPICommunicator comm=MPIHelper::getCommunicator())
Definition: dgfidentitygrid.hh:38
Wrapper class for entities.
Definition: common/entity.hh:61
static const int dimension
Definition: dgfgridfactory.hh:38
std::vector< double > & parameter(const Entity &entity)
Definition: dgfidentitygrid.hh:73
bool wasInserted(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:55
static int refineStepsForHalf()
Definition: dgfidentitygrid.hh:91
IdentityGrid< HostGrid > Grid
Definition: dgfidentitygrid.hh:21
Grid::template Codim< dimension >::Entity Vertex
Definition: dgfidentitygrid.hh:26
Definition: agrid.hh:66
The IdentityGrid class.
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:388
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:54
G Grid
Definition: dgfgridfactory.hh:37
static double refineWeight()
DGFGridFactory(std::istream &input, MPICommunicator comm=MPIHelper::getCommunicator())
Definition: dgfidentitygrid.hh:28
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5
The dimension of the grid.
Definition: common/grid.hh:402
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
int numParameters() const
Definition: dgfidentitygrid.hh:67
Grid::template Codim< 0 >::Entity Element
Definition: dgfidentitygrid.hh:25
Grid * grid() const
Definition: dgfidentitygrid.hh:49