Dune Core Modules (2.9.0)

persistentcontainerwrapper.hh
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
8#include <dune/grid/utility/hostgridaccess.hh>
9#include <dune/grid/utility/persistentcontainer.hh>
10
11namespace Dune
12{
13
14 // PersistentContainerWrapper
15 // --------------------------
16
17 template< class G, class T >
18 class PersistentContainerWrapper
19 {
20 typedef PersistentContainerWrapper< G, T > This;
21
22 typedef Dune::HostGridAccess< G > HostGridAccess;
23
24 typedef typename HostGridAccess::HostGrid HostGrid;
25 typedef PersistentContainer< HostGrid, T > PersistentContainerHostGrid;
26
27 public:
28 typedef G Grid;
29
30 typedef typename PersistentContainer< HostGrid, T >::Value Value;
31 typedef typename PersistentContainer< HostGrid, T >::Size Size;
32
33 typedef typename PersistentContainer< HostGrid, T >::Iterator Iterator;
34 typedef typename PersistentContainer< HostGrid, T >::ConstIterator ConstIterator;
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(); }
74 Iterator begin () { 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
Dune namespace.
Definition: alignedallocator.hh:13
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)