dune-grid  2.9.0
persistentcontainerwrapper.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_PERSISTENTCONTAINERWRAPPER_HH
6 #define DUNE_PERSISTENTCONTAINERWRAPPER_HH
7 
10 
11 namespace Dune
12 {
13 
14  // PersistentContainerWrapper
15  // --------------------------
16 
17  template< class G, class T >
19  {
21 
23 
24  typedef typename HostGridAccess::HostGrid HostGrid;
26 
27  public:
28  typedef G Grid;
29 
32 
35 
36  PersistentContainerWrapper ( const Grid &grid, int codim, const Value &value = Value() )
37  : hostContainer_( HostGridAccess::hostGrid( grid ), codim, value )
38  {}
39 
40  template< class Entity >
41  const Value &operator[] ( const Entity &entity ) const
42  {
43  return hostContainer_[ HostGridAccess::hostEntity( entity ) ];
44  }
45 
46  template< class Entity >
47  Value &operator[] ( const Entity &entity )
48  {
49  return hostContainer_[ HostGridAccess::hostEntity( entity ) ];
50  }
51 
52  template< class Entity >
53  const Value &operator() ( const Entity &entity, int subEntity ) const
54  {
55  return hostContainer_( HostGridAccess::hostEntity( entity ), subEntity );
56  }
57 
58  template< class Entity >
59  Value &operator() ( const Entity &entity, int subEntity )
60  {
61  return hostContainer_( HostGridAccess::hostEntity( entity ), subEntity );
62  }
63 
64  Size size () const { return hostContainer_.size(); }
65 
66  void resize ( const Value &value = Value() ) { hostContainer_.resize( value ); }
67  void shrinkToFit () { return hostContainer_.shrinkToFit(); }
68 
69  void fill ( const Value &value = Value() ) { hostContainer_.fill( value ); }
70 
71  void swap ( This &other ) { hostContainer_.swap( other.hostContainer_ ); }
72 
73  ConstIterator begin () const { return hostContainer_.begin(); }
75 
76  ConstIterator end () const { return hostContainer_.end(); }
77  Iterator end () { return hostContainer_.end(); }
78 
79  int codimension () const { return hostContainer_.codimension(); }
80 
81  protected:
83  };
84 
85 } // namespace Dune
86 
87 #endif // #ifndef DUNE_PERSISTENTCONTAINERWRAPPER_HH
Include standard header files.
Definition: agrid.hh:60
Wrapper class for entities.
Definition: common/entity.hh:66
provides access to host grid objects from GeometryGrid
Definition: hostgridaccess.hh:29
void swap(This &other)
Definition: persistentcontainermap.hh:97
void fill(const Value &value)
Definition: persistentcontainermap.hh:95
int codimension() const
Definition: persistentcontainermap.hh:111
void resize(const Value &value=Value())
Definition: persistentcontainermap.hh:87
ConstIterator begin() const
Definition: persistentcontainermap.hh:175
ConstIterator end() const
Definition: persistentcontainermap.hh:190
Size size() const
Definition: persistentcontainermap.hh:85
void shrinkToFit()
Definition: persistentcontainermap.hh:93
Definition: persistentcontainerwrapper.hh:19
void fill(const Value &value=Value())
Definition: persistentcontainerwrapper.hh:69
Size size() const
Definition: persistentcontainerwrapper.hh:64
ConstIterator begin() const
Definition: persistentcontainerwrapper.hh:73
PersistentContainer< HostGrid, T >::Value Value
Definition: persistentcontainerwrapper.hh:30
PersistentContainer< HostGrid, T >::ConstIterator ConstIterator
Definition: persistentcontainerwrapper.hh:34
G Grid
Definition: persistentcontainerwrapper.hh:28
const Value & operator()(const Entity &entity, int subEntity) const
Definition: persistentcontainerwrapper.hh:53
void resize(const Value &value=Value())
Definition: persistentcontainerwrapper.hh:66
const Value & operator[](const Entity &entity) const
Definition: persistentcontainerwrapper.hh:41
int codimension() const
Definition: persistentcontainerwrapper.hh:79
void swap(This &other)
Definition: persistentcontainerwrapper.hh:71
ConstIterator end() const
Definition: persistentcontainerwrapper.hh:76
PersistentContainerWrapper(const Grid &grid, int codim, const Value &value=Value())
Definition: persistentcontainerwrapper.hh:36
void shrinkToFit()
Definition: persistentcontainerwrapper.hh:67
Iterator begin()
Definition: persistentcontainerwrapper.hh:74
PersistentContainer< HostGrid, T >::Iterator Iterator
Definition: persistentcontainerwrapper.hh:33
PersistentContainer< HostGrid, T > hostContainer_
Definition: persistentcontainerwrapper.hh:82
PersistentContainer< HostGrid, T >::Size Size
Definition: persistentcontainerwrapper.hh:31
Iterator end()
Definition: persistentcontainerwrapper.hh:77