dune-grid 2.9.0
dgfidentitygrid.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_DGFPARSER_DGFIDENTITYGRID_HH
6#define DUNE_DGFPARSER_DGFIDENTITYGRID_HH
7
8#include <dune/common/typetraits.hh>
9
13
14namespace 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
The IdentityGrid class.
Include standard header files.
Definition: agrid.hh:60
Definition: dgfgridfactory.hh:38
G Grid
Definition: dgfgridfactory.hh:39
static const int dimension
Definition: dgfgridfactory.hh:40
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:164
Wrapper class for entities.
Definition: common/entity.hh:66
Grid abstract base class.
Definition: common/grid.hh:375
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
Provides a meta grid that is identical to its host.
Definition: identitygrid.hh:88
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Grid::template Codim< dimension >::Entity Vertex
Definition: dgfidentitygrid.hh:28
IdentityGrid< HostGrid > Grid
Definition: dgfidentitygrid.hh:23
std::vector< double > & parameter(const Entity &entity)
Definition: dgfidentitygrid.hh:75
int numParameters() const
Definition: dgfidentitygrid.hh:69
Grid * grid() const
Definition: dgfidentitygrid.hh:51
DGFGridFactory(const std::string &filename, MPICommunicator comm=MPIHelper::getCommunicator())
Definition: dgfidentitygrid.hh:40
DGFGridFactory(std::istream &input, MPICommunicator comm=MPIHelper::getCommunicator())
Definition: dgfidentitygrid.hh:30
int boundaryId(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:63
MPIHelper::MPICommunicator MPICommunicator
Definition: dgfidentitygrid.hh:26
Grid::template Codim< 0 >::Entity Element
Definition: dgfidentitygrid.hh:27
bool wasInserted(const Intersection &intersection) const
Definition: dgfidentitygrid.hh:57
static int refineStepsForHalf()
Definition: dgfidentitygrid.hh:93
static double refineWeight()
Definition: dgfidentitygrid.hh:98
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:56
static double refineWeight()
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5