dune-fem  2.8-git
mutable.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_MUTABLE_HH
2 #define DUNE_FEM_FUNCTION_LOCALFUNCTION_MUTABLE_HH
3 
4 //-s system includes
5 #include <cassert>
6 #include <utility>
7 
8 //- Dune includes
10 
11 namespace Dune
12 {
13 
14  namespace Fem
15  {
16 
17  template< class >
18  struct DiscreteFunctionTraits;
19 
20  //**************************************************************************
21  //
22  // --MutableLocalFunction
23  //
24  //**************************************************************************
27  template < class DiscreteFunction >
29  : public LocalFunction< typename DiscreteFunctionTraits< DiscreteFunction > :: DiscreteFunctionSpaceType :: BasisFunctionSetType,
30  typename DiscreteFunctionTraits< DiscreteFunction > :: LocalDofVectorType >
31  {
33  typedef LocalFunction< typename DiscreteFunctionTraits< DiscreteFunction > :: DiscreteFunctionSpaceType :: BasisFunctionSetType,
35 
36  public:
38  typedef DiscreteFunction DiscreteFunctionType;
39 
41  typedef typename BaseType::EntityType EntityType;
42 
45 
48 
51  : BaseType( LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
53  {}
54 
57  : BaseType( LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
59  {}
60 
63  : BaseType( discreteFunction.space().basisFunctionSet( entity ), LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
65  {
66  discreteFunction.getLocalDofReferences( entity, localDofVector() );
67  }
68 
70  explicit MutableLocalFunction ( const DiscreteFunctionType &dFunction, const EntityType &entity )
71  : BaseType( dFunction.space().basisFunctionSet( entity ), LocalDofVectorType( dFunction.localDofVectorAllocator() ) ),
72  discreteFunction_( &const_cast<DiscreteFunctionType &>( dFunction ) )
73  {
74  discreteFunction().getLocalDofReferences( entity, localDofVector() );
75  }
76 
78  MutableLocalFunction ( const ThisType &other )
79  : BaseType( static_cast< const BaseType& > ( other ) ), discreteFunction_( other.discreteFunction_ )
80  {}
81 
84  : BaseType( static_cast< BaseType&& > ( other ) ), discreteFunction_( other.discreteFunction_ )
85  {}
86 
87  ThisType& operator= ( const ThisType& ) = delete;
88  ThisType& operator= ( ThisType&& ) = delete;
89 
91 
92  void init ( const EntityType &entity )
93  {
95  discreteFunction().getLocalDofReferences( entity, localDofVector() );
96  }
97 
98  void bind ( const EntityType &entity )
99  {
100  init(entity);
101  }
102 
103  void unbind() { BaseType::unbind(); }
104 
106  {
107  return *discreteFunction_;
108  }
110  {
111  return *discreteFunction_;
112  }
113 
114  protected:
116  };
117 
118  } // namespace Fem
119 
120 } // namespace Dune
121 
122 #endif // #ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_MUTABLE_HH
Definition: bindguard.hh:11
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:61
interface for local functions
Definition: localfunction.hh:77
void init(const EntityType &entity)
initialize the local function for an entity
Definition: localfunction.hh:437
const BasisFunctionSetType & basisFunctionSet() const
obtain the basis function set for this local function
Definition: localfunction.hh:296
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:415
void unbind()
clears the local function by removing the basisFunctionSet
Definition: localfunction.hh:458
BasisFunctionSetType::EntityType EntityType
type of the entity, the local function lives on is given by the space
Definition: localfunction.hh:95
LocalDofVector LocalDofVectorType
type of local Dof Vector
Definition: localfunction.hh:86
Definition: mutable.hh:31
const DiscreteFunctionType & discreteFunction() const
Definition: mutable.hh:105
DiscreteFunction DiscreteFunctionType
type of DiscreteFunction
Definition: mutable.hh:38
MutableLocalFunction(const DiscreteFunctionType &discreteFunction)
Constructor creating empty local function from given discrete function.
Definition: mutable.hh:56
MutableLocalFunction(ThisType &&other)
move constructor
Definition: mutable.hh:83
void unbind()
Definition: mutable.hh:103
void bind(const EntityType &entity)
Definition: mutable.hh:98
ThisType & operator=(const ThisType &)=delete
MutableLocalFunction(DiscreteFunctionType &discreteFunction)
Constructor creating empty local function from given discrete function.
Definition: mutable.hh:50
BaseType::LocalDofVectorType LocalDofVectorType
type of local Dof vector object
Definition: mutable.hh:44
DiscreteFunctionType & discreteFunction()
Definition: mutable.hh:109
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:415
void init(const EntityType &entity)
Definition: mutable.hh:92
BaseType::BasisFunctionSetType BasisFunctionSetType
type of BasisFunctionSet
Definition: mutable.hh:47
DiscreteFunctionType * discreteFunction_
Definition: mutable.hh:115
MutableLocalFunction(const DiscreteFunctionType &dFunction, const EntityType &entity)
Constructor creating local function from given discrete function and entity, not empty.
Definition: mutable.hh:70
MutableLocalFunction(DiscreteFunctionType &discreteFunction, const EntityType &entity)
Constructor creating local function from given discrete function and entity, not empty.
Definition: mutable.hh:62
MutableLocalFunction(const ThisType &other)
copy constructor
Definition: mutable.hh:78
BaseType::EntityType EntityType
type of the entity, the local function lives on is given by the space
Definition: mutable.hh:41
Interface class for basis function sets.
Definition: basisfunctionset/basisfunctionset.hh:31