DUNE-FEM (unstable)

blockvectordiscretefunction.hh
1#ifndef DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
2#define DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
3
4#include <memory>
5#include <string>
6#include <utility>
7
8#include <dune/fem/common/stackallocator.hh>
9#include <dune/fem/function/common/discretefunction.hh>
10#include <dune/fem/function/common/scalarproducts.hh>
11#include <dune/fem/function/localfunction/mutable.hh>
12#include <dune/fem/function/blockvectors/referenceblockvector.hh>
13#include <dune/fem/storage/envelope.hh>
14
15namespace Dune
16{
17 namespace Fem
18 {
19
20 template< typename DiscreteFunctionSpace, typename BlockVector >
21 class BlockVectorDiscreteFunction;
22
23
24
36
37
38
45 template< typename DiscreteFunctionSpace, typename BlockVector >
46 struct DiscreteFunctionTraits< BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > >
47 : public DefaultDiscreteFunctionTraits< DiscreteFunctionSpace, BlockVector >
48 {
49 typedef BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > DiscreteFunctionType;
50 typedef MutableLocalFunction< DiscreteFunctionType > LocalFunctionType;
51 };
52
53
54
55
62 template< typename DiscreteFunctionSpace, typename BlockVector >
63 class BlockVectorDiscreteFunction
64 : public DiscreteFunctionDefault< BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > >,
65 public IsBlockVectorDiscreteFunction
66 {
67 typedef BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > ThisType;
68 typedef DiscreteFunctionDefault< ThisType > BaseType;
69 typedef ParallelScalarProduct< ThisType > ScalarProductType;
70
71 public:
73 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
75 typedef BlockVector BlockVectorType;
77 typedef BlockVectorType DofVectorType;
78
79 using BaseType::assign;
80 using BaseType::name;
81
88 BlockVectorDiscreteFunction ( const std::string& name,
89 const DiscreteFunctionSpaceType& space,
90 DofVectorType& dofVector )
91 : BaseType( name, space ),
92 memObject_(),
93 dofVector_( dofVector )
94 {}
95
101 BlockVectorDiscreteFunction ( const std::string& name,
102 const DiscreteFunctionSpaceType& space )
103 : BaseType( name, space ),
104 memObject_(),
105 dofVector_( allocateDofStorage( space ) )
106 {}
107
109 BlockVectorDiscreteFunction ( const ThisType& other )
110 : BaseType( "copy of "+other.name(), other.space() ),
111 memObject_(),
112 dofVector_( allocateDofStorage( other.space() ) )
113 {
114 assign( other );
115 }
116
118 BlockVectorDiscreteFunction( ThisType&& other )
119 : BaseType( static_cast< BaseType && >( other ) ),
120 memObject_( std::move( other.memObject_ ) ),
121 dofVector_( other.dofVector_ )
122 {}
123
124 BlockVectorDiscreteFunction () = delete;
125 ThisType& operator= ( const ThisType& ) = delete;
126 ThisType& operator= ( ThisType&& ) = delete;
127
129 const DofVectorType &dofVector () const
130 {
131 return dofVector_;
132 }
133
135 DofVectorType &dofVector ()
136 {
137 return dofVector_;
138 }
139
141 void enableDofCompression ()
142 {
143 if( memObject_ )
144 memObject_->enableDofCompression();
145 }
146
147 protected:
148 DofVectorType& allocateDofStorage( const DiscreteFunctionSpaceType& space )
149 {
150 std::pair< DofStorageInterface*, DofVectorType* > memPair(
151 allocateManagedDofStorage< DofVectorType >( space.gridPart().grid(), space.blockMapper() ) );
152
153 memObject_.reset( memPair.first );
154 return *memPair.second;
155 }
156
157 std::unique_ptr< DofStorageInterface > memObject_;
158 DofVectorType& dofVector_;
159 };
160
161 } // namespace Fem
162} // namespace Dune
163
164#endif // #ifndef DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
discrete function space
A vector of blocks with memory management.
Definition: bvector.hh:392
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:709
const std::string & name() const
obtain the name of the discrete function
Definition: discretefunction.hh:691
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
forward declaration
Definition: discretefunction.hh:51
Scalar product for overlapping Schwarz methods.
Definition: scalarproducts.hh:99
Dune namespace.
Definition: alignedallocator.hh:13
void assign(T &dst, const T &src, bool mask)
masked Simd assignment (scalar version)
Definition: simd.hh:447
STL namespace.
Traits class for a DiscreteFunction.
Definition: discretefunction.hh:61
Tag for discrete functions using block vectors.
Definition: blockvectordiscretefunction.hh:35
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)