dune-fem 2.8.0
Loading...
Searching...
No Matches
managedvectorfunction.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_MANAGEDVECTORFUNCTION_HH
2#define DUNE_FEM_MANAGEDVECTORFUNCTION_HH
3
4#include <memory>
5#include <string>
6
10
11namespace Dune
12{
13
14 namespace Fem
15 {
16
17 // MemObject
18 // ---------
19
20 struct MemObject
21 {
22 template< class DofContainer, class DiscreteFunctionSpace >
23 DofContainer &allocate ( const DiscreteFunctionSpace &space )
24 {
26 auto result = allocateManagedDofStorage( space.gridPart().grid(), space.blockMapper(), static_cast< DofVector * >( nullptr ) );
27 interface_.reset( result.first );
28 return result.second->array();
29 }
30
32 {
33 if( interface_ )
34 interface_->enableDofCompression();
35 }
36
37 private:
38 std::unique_ptr< DofStorageInterface > interface_;
39 };
40
41
42
43
44 // ManagedDiscreteFunction
45 // -----------------------
46
47 template< class DiscreteFunctionSpace,
48 class Vector >
51 : private MemObject,
52 public VectorDiscreteFunction< DiscreteFunctionSpace, Vector >
53 {
56
57 public:
59
60 typedef typename BaseType :: DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
61 typedef typename BaseType :: DofVectorType DofVectorType;
62 typedef typename BaseType :: DofContainerType DofContainerType;
63
64 typedef typename DiscreteFunctionSpaceType :: GridPartType :: GridType GridType;
65
66 using BaseType :: name;
67
68 ManagedDiscreteFunction ( const std::string &name, const DiscreteFunctionSpaceType &dfSpace )
69 : BaseType( name, dfSpace, MemObject::allocate< DofContainerType >( dfSpace ) )
70 {}
71
72 explicit ManagedDiscreteFunction ( const BaseType &other )
73 : BaseType( other.name(), other.space(), MemObject::allocate< DofContainerType >( other.space() ) )
74 {
75 BaseType :: assign ( other );
76 }
77
79 : BaseType( other.name(), other.space(), MemObject::allocate< DofContainerType >( other.space() ) )
80 {
81 BaseType :: assign ( other );
82 }
83
85
87 };
88
89 } // namespace Fem
90
91} // namespace Dune
92
93#endif // #ifndef DUNE_FEM_MANAGEDVECTORFUNCTION_HH
static std::pair< DofStorageInterface *, DofStorageType * > allocateManagedDofStorage(const GridType &grid, const MapperType &mapper, const DofStorageType *=0)
default implementation for creating a managed dof storage
Definition: dofmanager.hh:560
Definition: bindguard.hh:11
Definition: defaultblockvectors.hh:346
Definition: common/discretefunction.hh:1066
Definition: managedvectorfunction.hh:21
void enableDofCompression()
Definition: managedvectorfunction.hh:31
DofContainer & allocate(const DiscreteFunctionSpace &space)
Definition: managedvectorfunction.hh:23
ManagedDiscreteFunction(const ThisType &other)
Definition: managedvectorfunction.hh:78
BaseType::DofContainerType DofContainerType
Definition: managedvectorfunction.hh:62
DiscreteFunctionSpaceType::GridPartType::GridType GridType
Definition: managedvectorfunction.hh:64
BaseType::DofVectorType DofVectorType
Definition: managedvectorfunction.hh:61
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: managedvectorfunction.hh:60
ManagedDiscreteFunction(const BaseType &other)
Definition: managedvectorfunction.hh:72
ManagedDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &dfSpace)
Definition: managedvectorfunction.hh:68
Definition: vectorfunction/vectorfunction.hh:42
discrete function space