DUNE-FEM (unstable)

mutable.hh
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
9#include <dune/fem/function/localfunction/localfunction.hh>
10
11namespace 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
42
45
48
50 explicit MutableLocalFunction ( DiscreteFunctionType &discreteFunction )
51 : BaseType( LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
52 discreteFunction_( &discreteFunction )
53 {}
54
56 explicit MutableLocalFunction ( const DiscreteFunctionType &discreteFunction )
57 : BaseType( LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
58 discreteFunction_( &const_cast<DiscreteFunctionType &>( discreteFunction ) )
59 {}
60
62 explicit MutableLocalFunction ( DiscreteFunctionType &discreteFunction, const EntityType &entity )
63 : BaseType( discreteFunction.space().basisFunctionSet( entity ), LocalDofVectorType( discreteFunction.localDofVectorAllocator() ) ),
64 discreteFunction_( &discreteFunction )
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
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 {
94 BaseType::init( discreteFunction().space().basisFunctionSet( entity ) );
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
105 const DiscreteFunctionType &discreteFunction () const
106 {
107 return *discreteFunction_;
108 }
109 DiscreteFunctionType &discreteFunction ()
110 {
111 return *discreteFunction_;
112 }
113
114 protected:
115 DiscreteFunctionType *discreteFunction_;
116 };
117
118 } // namespace Fem
119
120} // namespace Dune
121
122#endif // #ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_MUTABLE_HH
Wrapper class for entities.
Definition: entity.hh:66
Interface class for basis function sets.
Definition: basisfunctionset.hh:32
interface for local functions
Definition: localfunction.hh:77
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:424
void init(const EntityType &entity)
initialize the local function for an entity
Definition: localfunction.hh:446
void unbind()
clears the local function by removing the basisFunctionSet
Definition: localfunction.hh:467
const BasisFunctionSetType & basisFunctionSet() const
obtain the basis function set for this local function
Definition: localfunction.hh:299
LocalDofVector LocalDofVectorType
type of local Dof Vector
Definition: localfunction.hh:86
Definition: mutable.hh:31
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:424
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
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
BaseType::BasisFunctionSetType BasisFunctionSetType
type of BasisFunctionSet
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: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
forward declaration
Definition: discretefunction.hh:51
Dune namespace.
Definition: alignedallocator.hh:13
Traits class for a DiscreteFunction.
Definition: discretefunction.hh:61
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)