dune-grid  2.11
dgfidentitygrid.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © 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_DGFPARSER_DGFIDENTITYGRID_HH
6 #define DUNE_DGFPARSER_DGFIDENTITYGRID_HH
7 
8 #include <dune/common/typetraits.hh>
9 
13 
14 namespace Dune
15 {
16 
17  // DGFGridFactory for IdentityGrid
18  // -------------------------------
19 
20  template< class HostGrid >
21  struct DGFGridFactory< IdentityGrid< HostGrid > >
22  {
24 
25  const static int dimension = Grid::dimension;
26  typedef MPIHelper::MPICommunicator MPICommunicator;
27  typedef typename Grid::template Codim<0>::Entity Element;
28  typedef typename Grid::template Codim<dimension>::Entity Vertex;
29 
30  explicit DGFGridFactory ( std::istream &input,
31  MPICommunicator comm = MPIHelper::getCommunicator() )
32  : dgfHostFactory_( input, comm ),
33  grid_( 0 )
34  {
35  HostGrid *hostGrid = dgfHostFactory_.grid();
36  assert( hostGrid != 0 );
37  grid_ = new Grid( *hostGrid );
38  }
39 
40  explicit DGFGridFactory ( const std::string &filename,
41  MPICommunicator comm = MPIHelper::getCommunicator() )
42  : dgfHostFactory_( filename, comm ),
43  grid_( 0 )
44  {
45  HostGrid *hostGrid = dgfHostFactory_.grid();
46  assert( hostGrid != 0 );
47  std::ifstream input( filename.c_str() );
48  grid_ = new Grid( *hostGrid );
49  }
50 
51  Grid *grid () const
52  {
53  return grid_;
54  }
55 
56  template< class Intersection >
57  bool wasInserted ( const Intersection &intersection ) const
58  {
59  return dgfHostFactory_.wasInserted( HostGridAccess< Grid >::hostIntersection( intersection ) );
60  }
61 
62  template< class Intersection >
63  int boundaryId ( const Intersection &intersection ) const
64  {
65  return dgfHostFactory_.boundaryId( HostGridAccess< Grid >::hostIntersection( intersection ) );
66  }
67 
68  template< int codim >
69  int numParameters () const
70  {
71  return dgfHostFactory_.template numParameters< codim >();
72  }
73 
74  template< class Entity >
75  std::vector< double > &parameter ( const Entity &entity )
76  {
77  return dgfHostFactory_.parameter( HostGridAccess< Grid >::hostEntity( entity ) );
78  }
79 
80  private:
81  DGFGridFactory< HostGrid > dgfHostFactory_;
82  Grid *grid_;
83  };
84 
85 
86 
87  // DGFGridInfo for IdGrid
88  // ----------------------
89 
90  template< class HostGrid >
91  struct DGFGridInfo< IdentityGrid< HostGrid > >
92  {
93  static int refineStepsForHalf ()
94  {
96  }
97 
98  static double refineWeight ()
99  {
101  }
102  };
103 
104 }
105 
106 #endif // #ifndef DUNE_DGFPARSER_DGFIDENTITYGRID_HH
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
MPIHelper::MPICommunicator MPICommunicator
Definition: dgfidentitygrid.hh:26
static int refineStepsForHalf()
Definition: dgfidentitygrid.hh:93
Grid::template Codim< dimension >::Entity Vertex
Definition: dgfidentitygrid.hh:28
bool wasInserted(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:57
static double refineWeight()
Definition: dgfidentitygrid.hh:98
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:375
int numParameters() const
Definition: dgfidentitygrid.hh:69
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:55
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:40
Grid::template Codim< 0 >::Entity Element
Definition: dgfidentitygrid.hh:27
static double refineWeight()
DGFGridFactory(std::istream &input, MPICommunicator comm=MPIHelper::getCommunicator())
Definition: dgfidentitygrid.hh:30
int boundaryId(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:63
G Grid
Definition: dgfgridfactory.hh:39
Grid * grid() const
Definition: dgfidentitygrid.hh:51
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5
Include standard header files.
Definition: agrid.hh:59
IdentityGrid< HostGrid > Grid
Definition: dgfidentitygrid.hh:23
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:28
The IdentityGrid class.
Wrapper class for entities.
Definition: common/entity.hh:65
std::vector< double > & parameter(const Entity &entity)
Definition: dgfidentitygrid.hh:75
static const int dimension
Definition: dgfgridfactory.hh:40
Definition: agrid.hh:66