dune-grid  2.5.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
MPIHelper::MPICommunicator MPICommunicator
Definition: dgfidentitygrid.hh:24
Grid * grid() const
Definition: dgfidentitygrid.hh:49
static double refineWeight()
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:26
bool wasInserted(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:55
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:36
static int refineStepsForHalf()
Definition: dgfidentitygrid.hh:91
G Grid
Definition: dgfgridfactory.hh:37
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5
Grid::template Codim< dimension >::Entity Vertex
Definition: dgfidentitygrid.hh:26
DGFGridFactory(std::istream &input, MPICommunicator comm=MPIHelper::getCommunicator())
Definition: dgfidentitygrid.hh:28
IdentityGrid< HostGrid > Grid
Definition: dgfidentitygrid.hh:21
int boundaryId(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:61
Include standard header files.
Definition: agrid.hh:59
Definition: agrid.hh:66
int numParameters() const
Definition: dgfidentitygrid.hh:67
static double refineWeight()
Definition: dgfidentitygrid.hh:96
Wrapper class for entities.
Definition: common/entity.hh:64
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:54
DGFGridFactory(const std::string &filename, MPICommunicator comm=MPIHelper::getCommunicator())
Definition: dgfidentitygrid.hh:38
Grid::template Codim< 0 >::Entity Element
Definition: dgfidentitygrid.hh:25
Provides a meta grid that is identical to its host.
Definition: identitygrid.hh:32
static const int dimension
Definition: dgfgridfactory.hh:38
The dimension of the grid.
Definition: common/grid.hh:387
The IdentityGrid class.
std::vector< double > & parameter(const Entity &entity)
Definition: dgfidentitygrid.hh:73