DUNE-FEM (unstable)

subfunction.hh
1#ifndef DUNE_FEM_SUBFUNCTION_HH
2#define DUNE_FEM_SUBFUNCTION_HH
3
4#include <memory>
5#include <vector>
6
7#include <dune/fem/space/combinedspace/combineddofstorage.hh>
8#include <dune/fem/storage/subvector.hh>
9#include <dune/fem/function/vectorfunction/vectorfunction.hh>
10
11namespace Dune
12{
13
14 namespace Fem
15 {
16
20 template <class DiscreteFunctionImp>
22 {
23 protected:
24 typedef DiscreteFunctionImp DiscreteFunctionType;
26 enum { dimRange = SpaceType :: dimRange };
27 typedef typename DiscreteFunctionType :: DofStorageType DofStorageType;
28 public:
29 typedef typename SpaceType :: template ToNewDimRange < 1 > :: Type SubSpaceType;
30
31 typedef CombinedSubMapper< typename SubSpaceType :: MapperType , dimRange, PointBased > SubMapperType;
33 typedef VectorDiscreteFunction< SubSpaceType, SubDofVectorType > SubDiscreteFunctionType;
34
36 explicit SubFunctionStorage( DiscreteFunctionType& discreteFunction ) :
37 discreteFunction_( discreteFunction ),
38 space_( discreteFunction.space() ),
39 // FIXME: this line assumes that the 'subspaces' are constructed with only a grid part
40 // which fails with higher order 'DynamicLagrangeSpace' for example.
41 subSpace_( space_.gridPart (), space_.communicationInterface(), space_.communicationDirection() ),
42 subVector_( dimRange, nullptr ),
43 subDiscreteFunction_( dimRange, nullptr )
44 {}
45
46 SubFunctionStorage( const SubFunctionStorage& ) = delete;
47
54 SubDiscreteFunctionType& subFunction(std::size_t component) const
55 {
56 assert( component < dimRange );
57 if( ! subDiscreteFunction_[ component ] )
58 {
59 subVector_[ component ] =
60 std::make_unique< SubDofVectorType >( discreteFunction_.dofStorage(), SubMapperType( subSpace_.mapper(), component ) );
61 subDiscreteFunction_[ component ] =
62 std::make_unique< SubDiscreteFunctionType >( discreteFunction_.name()+ "_sub", subSpace_, *( subVector_[ component ] ));
63 }
64 return *( subDiscreteFunction_[ component ] );
65 }
66
67 protected:
68 DiscreteFunctionType& discreteFunction_;
69 const SpaceType& space_;
70 SubSpaceType subSpace_;
71 mutable std::vector< std::unique_ptr< SubDofVectorType > > subVector_;
72 mutable std::vector< std::unique_ptr< SubDiscreteFunctionType > > subDiscreteFunction_;
73 };
74
75 } // namespace Fem
76
77} // namespace Dune
78
79#endif // #ifndef DUNE_FEM_SUBFUNCTION_HH
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
A vector valued function space.
Definition: functionspace.hh:60
Definition: subfunction.hh:22
SubDiscreteFunctionType & subFunction(std::size_t component) const
return a SubDiscreteFunction repsenting only one component of the original discrete function
Definition: subfunction.hh:54
SubFunctionStorage(DiscreteFunctionType &discreteFunction)
constructor storing the discrete function
Definition: subfunction.hh:36
An implementation of DenseVector to extract a portion, not necessarly contiguos, of a vector.
Definition: subvector.hh:161
forward declaration
Definition: discretefunction.hh:51
TupleDiscreteFunctionSpace< typename DiscreteFunctions::DiscreteFunctionSpaceType ... > DiscreteFunctionSpaceType
type for the discrete function space this function lives in
Definition: discretefunction.hh:69
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)