1#ifndef DUNE_FEM_FUNCTION_HIERARCHICAL_FUNCTION_HH
2#define DUNE_FEM_FUNCTION_HIERARCHICAL_FUNCTION_HH
8#include <dune/istl/multitypeblockvector.hh>
11#include <dune/fem/common/hybrid.hh>
12#include <dune/fem/function/blockvectors/defaultblockvectors.hh>
13#include <dune/fem/function/common/discretefunction.hh>
14#include <dune/fem/function/hierarchical/dofvector.hh>
15#include <dune/fem/function/localfunction/mutable.hh>
16#include <dune/fem/space/common/dofmanager.hh>
27 template<
class DiscreteFunctionSpace >
28 class HierarchicalDiscreteFunction;
35 template<
class Dof,
class BlockIndices >
36 struct HierarchicalDofContainerChooser;
39 template<
class Dof,
int sz >
40 struct HierarchicalDofContainerChooser< Dof, Hybrid::IndexRange< int, sz > >
42 typedef BlockVector< FieldVector< Dof, sz > > Type;
45 template<
class Dof,
class... SR >
46 struct HierarchicalDofContainerChooser< Dof, Hybrid::CompositeIndexRange< SR... > >
48 typedef MultiTypeBlockVector< typename HierarchicalDofContainerChooser< Dof, SR >::Type... > Type;
51 template<
class Dof,
int sz >
52 struct HierarchicalDofContainerChooser< Dof, Hybrid::IndexRange< int, sz > >
54 typedef MutableBlockVector< DynamicArray< Dof >, sz > Type;
57 template<
class Dof,
class... SR >
58 struct HierarchicalDofContainerChooser< Dof, Hybrid::CompositeIndexRange< SR... > >
60 typedef MutableBlockVector< DynamicArray< Dof >, Hybrid::CompositeIndexRange< SR... >::size() > Type;
71 template<
class DiscreteFunctionSpace >
76 typedef typename DiscreteFunctionSpaceType::RangeFieldType DofType;
78 typedef typename DiscreteFunctionSpaceType::DomainType DomainType;
79 typedef typename DiscreteFunctionSpaceType::RangeType RangeType;
81 typedef HierarchicalDofVector< typename Impl::HierarchicalDofContainerChooser< DofType, typename DiscreteFunctionSpaceType::LocalBlockIndices >::Type > DofVectorType;
84 typedef DofType *DofIteratorType;
85 typedef const DofType *ConstDofIteratorType;
86 typedef DofType *DofBlockType;
87 typedef const DofType *ConstDofBlockType;
88 typedef DofType **DofBlockPtrType;
89 typedef const DofType **ConstDofBlockPtrType;
92 typedef StackAllocator< DofType, LocalDofVectorStackType * > LocalDofVectorAllocatorType;
93 typedef DynamicReferenceVector< DofType, LocalDofVectorAllocatorType > LocalDofVectorType;
103 template<
class DiscreteFunctionSpace >
104 class HierarchicalDiscreteFunction
105 :
public DiscreteFunctionDefault< HierarchicalDiscreteFunction< DiscreteFunctionSpace > >
107 typedef HierarchicalDiscreteFunction< DiscreteFunctionSpace > ThisType;
108 typedef DiscreteFunctionDefault< HierarchicalDiscreteFunction< DiscreteFunctionSpace > > BaseType;
114 using BaseType :: name;
116 HierarchicalDiscreteFunction (
const std::string &name,
const DiscreteFunctionSpaceType &space, DofVectorType &dofVector )
117 : BaseType( name, space ), dofVector_( dofVector )
120 HierarchicalDiscreteFunction (
const std::string &name,
const DiscreteFunctionSpaceType &space )
121 : BaseType( name, space ), dofVector_( allocateDofStorage( space ) )
124 HierarchicalDiscreteFunction (
const ThisType &other )
125 : BaseType(
"copy of " + other.
name(), other.
space() ), dofVector_( allocateDofStorage( other.
space() ) )
127 dofVector_ = other.dofVector_;
130 DofVectorType &dofVector () {
return dofVector_; }
131 const DofVectorType &dofVector ()
const {
return dofVector_; }
133 void enableDofCompression ()
136 memObject_->enableDofCompression();
140 DofVectorType &allocateDofStorage (
const DiscreteFunctionSpaceType &space )
142 auto memPair = allocateManagedDofStorage< DofVectorType >( space.gridPart().grid(), space.blockMapper() );
143 memObject_.reset( memPair.first );
144 return *memPair.second;
147 std::unique_ptr< DofStorageInterface > memObject_;
148 DofVectorType &dofVector_;
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Traits::DofVectorType DofVectorType
type of DofVector
Definition: discretefunction.hh:631
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
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: discretefunction.hh:606
forward declaration
Definition: discretefunction.hh:51
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:13