dune-fem  2.4.1-rc
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  template< class >
21  class ConstLocalFunction;
22 
23  //**************************************************************************
24  //
25  // --MutableLocalFunction
26  //
27  //**************************************************************************
30  template < class DiscreteFunction >
31  class MutableLocalFunction
32  : public LocalFunction< typename DiscreteFunctionTraits< DiscreteFunction > :: DiscreteFunctionSpaceType :: BasisFunctionSetType,
33  typename DiscreteFunctionTraits< DiscreteFunction > :: LocalDofVectorType >
34  {
35  typedef MutableLocalFunction< DiscreteFunction > ThisType;
36  typedef LocalFunction< typename DiscreteFunctionTraits< DiscreteFunction > :: DiscreteFunctionSpaceType :: BasisFunctionSetType,
37  typename DiscreteFunctionTraits< DiscreteFunction > :: LocalDofVectorType > BaseType;
38 
39  public:
41  typedef DiscreteFunction DiscreteFunctionType;
42 
44  typedef typename BaseType::EntityType EntityType;
45 
48 
51 
53  MutableLocalFunction( const ConstLocalFunction< DiscreteFunctionType > &constLocalFunction ) DUNE_DEPRECATED
54  : BaseType( constLocalFunction.basisFunctionSet(), LocalDofVectorType( constLocalFunction.discreteFunction_.localDofVectorAllocator() ) ),
55  discreteFunction_( &const_cast< DiscreteFunctionType& >( constLocalFunction.discreteFunction() ) )
56  {
57  discreteFunction().getLocalDofs( constLocalFunction.entity(), localDofVector() );
58  }
59 
61  explicit MutableLocalFunction ( DiscreteFunctionType &discreteFunction )
62  : BaseType( LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
63  discreteFunction_( &discreteFunction )
64  {}
65 
67  explicit MutableLocalFunction ( const DiscreteFunctionType &discreteFunction )
68  : BaseType( LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
69  discreteFunction_( &const_cast<DiscreteFunctionType &>( discreteFunction ) )
70  {}
71 
73  explicit MutableLocalFunction ( DiscreteFunctionType &discreteFunction, const EntityType &entity )
74  : BaseType( discreteFunction.space().basisFunctionSet( entity ), LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
75  discreteFunction_( &discreteFunction )
76  {
77  discreteFunction.getLocalDofs( entity, localDofVector() );
78  }
79 
81  explicit MutableLocalFunction ( const DiscreteFunctionType &dFunction, const EntityType &entity )
82  : BaseType( dFunction.space().basisFunctionSet( entity ), LocalDofVectorType( dFunction.localDofVectorAllocator() ) ),
83  discreteFunction_( &const_cast<DiscreteFunctionType &>( dFunction ) )
84  {
85  discreteFunction().getLocalDofs( entity, localDofVector() );
86  }
87 
89  MutableLocalFunction ( const ThisType &other )
90  : BaseType( static_cast< const BaseType& > ( other ) ),
91  discreteFunction_( other.discreteFunction_ )
92  {}
93 
95  MutableLocalFunction ( ThisType &&other )
96  : BaseType( static_cast< BaseType&& > ( other ) ),
97  discreteFunction_( other.discreteFunction_ )
98  {}
99 
100  // prohibit assignment
101  ThisType &operator= ( const ThisType & ) = delete;
102  ThisType &operator= ( ThisType && ) = delete;
103 
105 
106  void init ( const EntityType &entity )
107  {
108  BaseType::init( discreteFunction().space().basisFunctionSet( entity ) );
109  discreteFunction().getLocalDofs( entity, localDofVector() );
110  }
111 
112  const DiscreteFunctionType &discreteFunction () const { return *discreteFunction_; }
113  DiscreteFunctionType &discreteFunction () { return *discreteFunction_; }
114 
115  private:
116  DiscreteFunctionType *discreteFunction_;
117  };
118 
119  } // namespace Fem
120 
121 } // namespace Dune
122 
123 #endif // #ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_MUTABLE_HH
BaseType::LocalDofVectorType LocalDofVectorType
type of local Dof vector object
Definition: mutable.hh:47
MutableLocalFunction(const DiscreteFunctionType &dFunction, const EntityType &entity)
Constructor creating local function from given discrete function and entity, not empty.
Definition: mutable.hh:81
MutableLocalFunction(ThisType &&other)
move constructor
Definition: mutable.hh:95
MutableLocalFunction(DiscreteFunctionType &discreteFunction, const EntityType &entity)
Constructor creating local function from given discrete function and entity, not empty.
Definition: mutable.hh:73
BaseType::BasisFunctionSetType BasisFunctionSetType
type of BasisFunctionSet
Definition: mutable.hh:50
const BasisFunctionSetType & basisFunctionSet() const
obtain the basis function set for this local function
Definition: localfunction.hh:279
void init(const EntityType &entity)
Definition: mutable.hh:106
DiscreteFunction DiscreteFunctionType
type of DiscreteFunction
Definition: mutable.hh:41
BasisFunctionSetType::EntityType EntityType
type of the entity, the local function lives on is given by the space
Definition: localfunction.hh:59
BaseType::EntityType EntityType
type of the entity, the local function lives on is given by the space
Definition: mutable.hh:44
Definition: coordinate.hh:4
const DiscreteFunctionType & discreteFunction() const
Definition: mutable.hh:112
MutableLocalFunction(const DiscreteFunctionType &discreteFunction)
Constructor creating empty local function from given discrete function.
Definition: mutable.hh:67
MutableLocalFunction(const ThisType &other)
copy constructor
Definition: mutable.hh:89
LocalDofVector LocalDofVectorType
type of local Dof Vector
Definition: localfunction.hh:50
A constant local function carrying values for one entity.
Definition: const.hh:31
void init(const BasisFunctionSetType &basisFunctionSet)
Definition: localfunction.hh:288
MutableLocalFunction(DiscreteFunctionType &discreteFunction)
Constructor creating empty local function from given discrete function.
Definition: mutable.hh:61
MutableLocalFunction(const ConstLocalFunction< DiscreteFunctionType > &constLocalFunction)
cast from ConstLocalFunction
Definition: mutable.hh:53
ThisType & operator=(const ThisType &)=delete
Definition: basisfunctionset/basisfunctionset.hh:31
DiscreteFunctionType & discreteFunction()
Definition: mutable.hh:113