dune-fem  2.4.1-rc
managedvectorfunction.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_MANAGEDVECTORFUNCTION_HH
2 #define DUNE_FEM_MANAGEDVECTORFUNCTION_HH
3 
7 
8 namespace Dune
9 {
10 
11  namespace Fem
12  {
13 
14  template< class DiscreteFunctionSpace,
15  class Vector >
18  : public VectorDiscreteFunction< DiscreteFunctionSpace, Vector >
19  {
22 
23  public:
24  typedef ThisType DiscreteFunctionType;
25 
30 
31  protected:
32  typedef typename DiscreteFunctionSpaceType :: GridPartType :: GridType
34 
35  typedef typename DiscreteFunctionSpaceType::BlockMapperType BlockMapperType;
36 
37  public:
38  inline ManagedDiscreteFunction ( const std :: string &name,
39  const DiscreteFunctionSpaceType &dfSpace )
40  : BaseType( name, dfSpace, allocDofContainer( name, dfSpace ) )
41  {}
42 
43  inline explicit ManagedDiscreteFunction ( const BaseType &other )
44  : BaseType( other.name(), other.space(),
45  allocDofContainer( other.name(), other.space() ) )
46  {
47  BaseType :: assign ( other );
48  }
49 
50  inline ManagedDiscreteFunction ( const ThisType &other )
51  : BaseType( other.name(), other.space(),
52  allocDofContainer( other.name(), other.space() ) )
53  {
54  BaseType :: assign ( other );
55  }
56 
58  {
59  if( memObject_ )
60  delete memObject_ ;
61  memObject_ = 0;
62  }
63 
64  inline void enableDofCompression ()
65  {
66  if( memObject_ )
67  memObject_->enableDofCompression();
68  }
69 
70  protected:
71  inline DofContainerType &
72  allocDofContainer ( const std :: string &name,
73  const DiscreteFunctionSpaceType &space )
74  {
75  typedef MutableBlockVector< DofContainerType,
76  DiscreteFunctionSpaceType::localBlockSize > MutableDofVectorType;
77 
78  // allocate managed dof storage
79  std::pair< DofStorageInterface *, MutableDofVectorType* > memPair
80  = allocateManagedDofStorage( space.gridPart().grid(), space.blockMapper(), name, (MutableDofVectorType *)0 );
81  memObject_ = memPair.first;
82  return memPair.second->array();
83  }
84 
85  // pointer to memory if allocated locally
87  };
88 
89  } // namespace Fem
90 
91 } // namespace Dune
92 
93 #endif // #ifndef DUNE_FEM_MANAGEDVECTORFUNCTION_HH
DofStorageInterface * memObject_
Definition: managedvectorfunction.hh:86
Definition: vectorfunction/vectorfunction.hh:25
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: vectorfunction/vectorfunction.hh:53
ManagedDiscreteFunction(const ThisType &other)
Definition: managedvectorfunction.hh:50
DofVectorType::DofContainerType DofContainerType
Definition: vectorfunction/vectorfunction.hh:55
BaseType::DofVectorType DofVectorType
Definition: vectorfunction/vectorfunction.hh:54
static std::pair< DofStorageInterface *, DofStorageType * > allocateManagedDofStorage(const GridType &grid, const MapperType &mapper, const std::string &name, const DofStorageType *=0)
default implementation for creating a managed dof storage
Definition: dofmanager.hh:610
ManagedDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &dfSpace)
Definition: managedvectorfunction.hh:38
DiscreteFunctionSpaceType::BlockMapperType BlockMapperType
Definition: managedvectorfunction.hh:35
BaseType::DofContainerType DofContainerType
Definition: managedvectorfunction.hh:29
Definition: defaultblockvectors.hh:455
BaseType::DofVectorType DofVectorType
Definition: managedvectorfunction.hh:28
Definition: coordinate.hh:4
Interface class for a dof storage object to be stored in discrete functions.
Definition: dofmanager.hh:282
DiscreteFunctionSpaceType::GridPartType::GridType GridType
Definition: managedvectorfunction.hh:33
ManagedDiscreteFunction(const BaseType &other)
Definition: managedvectorfunction.hh:43
DofContainerType & allocDofContainer(const std::string &name, const DiscreteFunctionSpaceType &space)
Definition: managedvectorfunction.hh:72
discrete function space
Definition: discretefunction.hh:1025
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: managedvectorfunction.hh:27