dune-fem 2.8-git
common/discretefunction.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_DISCRETEFUNCTION_HH
2#define DUNE_FEM_DISCRETEFUNCTION_HH
3
4#include <cassert>
5
6#include <complex>
7#include <memory>
8#include <ostream>
9#include <string>
10#include <typeindex>
11
12#include <dune/common/dynvector.hh>
13
28#include <dune/fem/version.hh>
29
30
31namespace Dune
32{
33
34 namespace Fem
35 {
36
53 {};
54
57 {};
58
59
60 template< class DiscreteFunction >
62
63 template< class Traits >
65
66 //----------------------------------------------------------------------
67 //-
68 //- --DiscreteFunctionInterface
69 //-
70 //----------------------------------------------------------------------
81 template< class Impl >
83 : public Fem::Function< typename DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType, Impl >,
84 public IsDiscreteFunction,
85 public HasLocalFunction
86 {
89
90 public:
93
95 typedef typename Traits :: DiscreteFunctionType DiscreteFunctionType;
96
98 typedef typename Traits :: DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
99
101 typedef typename DiscreteFunctionSpaceType :: FunctionSpaceType FunctionSpaceType;
102
105
107 typedef typename DiscreteFunctionSpaceType :: DomainFieldType DomainFieldType;
109 typedef typename DiscreteFunctionSpaceType :: RangeFieldType RangeFieldType;
111 typedef typename DiscreteFunctionSpaceType :: DomainType DomainType;
113 typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
115 typedef typename DiscreteFunctionSpaceType :: JacobianRangeType JacobianRangeType;
116
118 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
119 typedef typename GridPartType::GridViewType GridView;
120
122 typedef typename DiscreteFunctionSpaceType :: GridType GridType;
123
125 typedef typename Traits :: LocalFunctionType LocalFunctionType;
126
128 typedef typename Traits :: DofVectorType DofVectorType;
129
131 typedef typename Traits :: DofIteratorType DofIteratorType;
132
134 typedef typename Traits :: ConstDofIteratorType ConstDofIteratorType;
135
136 typedef typename Traits :: DofType DofType;
137 typedef typename Traits :: DofBlockType DofBlockType;
138 typedef typename Traits :: ConstDofBlockType ConstDofBlockType;
139 typedef typename Traits :: DofBlockPtrType DofBlockPtrType;
140 typedef typename Traits :: ConstDofBlockPtrType ConstDofBlockPtrType;
141
144
145 typedef typename DiscreteFunctionSpaceType::LocalBlockIndices BlockIndices;
146
148 static constexpr std::size_t blockSize = Hybrid::size( BlockIndices() );
149
150 template< class Operation >
152 {
153 typedef typename DiscreteFunctionSpaceType
156 };
157
159 typedef typename DiscreteFunctionSpaceType :: EntityType EntityType;
160
161 protected:
162 using BaseType::asImp;
163
166
169 public:
171 ThisType &operator= ( const ThisType& ) = delete;
172
174 {
175 return asImp().dofVector();
176 }
178 {
179 return asImp().dofVector();
180 }
181
186 const std::string &name () const
187 {
188 return asImp().name();
189 }
190
195 std::string &name ()
196 {
197 return asImp().name();
198 }
199
202 const std::string &order () const
203 {
204 return asImp().order();
205 }
206
208 bool continuous() const
209 {
210 return asImp().continuous();
211 }
212
215 {
216 return asImp().space();
217 }
218
220 const GridPartType &gridPart () const
221 {
222 return asImp().gridPart();
223 }
224
230 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
232 {
233 return asImp().localFunction( entity );
234 }
235
241 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
242 const LocalFunctionType localFunction ( const EntityType &entity ) const
243 {
244 return asImp().localFunction( entity );
245 }
246
253 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
255 {
256 return asImp().localFunction();
257 }
258
259
266 template< class LocalDofs >
267 void addScaledLocalDofs ( const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs )
268 {
269 asImp().addScaledLocalDofs( entity, s, localDofs );
270 }
271
277 template< class LocalDofs >
278 void addLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
279 {
280 asImp().addLocalDofs( entity, localDofs );
281 }
282
288 template< class LocalDofs >
289 void setLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
290 {
291 asImp().setLocalDofs( entity, localDofs );
292 }
293
301 template< class Vector >
302 void getLocalDofs ( const EntityType &entity, Vector &localDofs ) const
303 {
304 asImp().getLocalDofs( entity, localDofs );
305 }
306
313 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
315 {
316 return asImp().localFunction();
317 }
318
320 void clear()
321 {
322 asImp().clear();
323 }
324
333 int size() const
334 {
335 return asImp().size();
336 }
337
345 int blocks() const
346 {
347 return asImp().blocks();
348 }
349
355 {
356 return asImp().dbegin ();
357 }
358
364 {
365 return asImp().dend ();
366 }
367
373 {
374 return asImp().dbegin ();
375 }
376
382 {
383 return asImp().dend ();
384 }
385
394 {
395 asImp().axpy( s, g );
396 }
397
411 template <class DFType>
413 {
414 return asImp().scalarProductDofs( other.asImp() );
415 }
416
428 typename Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs ( ) const
429 {
430 return asImp().normSquaredDofs( );
431 }
432
437 void print( std :: ostream &out ) const
438 {
439 asImp().print( out );
440 }
441
445 bool dofsValid () const
446 {
447 return asImp().dofsValid();
448 }
449
454 template < class DFType >
456 {
457 asImp().assign( g );
458 }
459
461 template< class Operation >
462 typename CommDataHandle< Operation >::Type dataHandle( const Operation &operation )
463 {
464 return asImp().dataHandle( operation );
465 }
466
469 {
470 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION( asImp().communicate() );
471 }
472
479 template < class DFType >
481 {
482 return asImp().operator+=( g );
483 }
484
491 template < class DFType >
493 {
494 return asImp().operator-=( g );
495 }
496
504 {
505 return asImp() *= scalar;
506 }
507
515 {
516 return asImp() /= scalar;
517 }
518
526 template< class StreamTraits >
528 {
529 asImp().read( in );
530 }
531
536 template< class StreamTraits >
538 {
539 asImp().write( out );
540 }
541
547 {
548 asImp().enableDofCompression();
549 }
550
551 //TODO: this needs to be revised, the definition should be in GridPart
554 {
556 }
557 };
558
559
560
561 //*************************************************************************
562 //
563 // --DiscreteFunctionDefault
564 //
573 //*************************************************************************
574 template< class Impl >
576 : public DiscreteFunctionInterface< Impl > ,
577 public PersistentObject
578 {
581
582 public:
583 typedef typename BaseType :: Traits Traits;
584
587
589
590 private:
592
593 enum { myId_ = 0 };
594
595 protected:
597
598 public:
601
604
606 typedef typename DiscreteFunctionSpaceType :: DomainType DomainType;
608 typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
610 typedef typename DiscreteFunctionSpaceType :: JacobianRangeType JacobianRangeType;
612 typedef typename DiscreteFunctionSpaceType :: HessianRangeType HessianRangeType;
613
615 typedef typename DiscreteFunctionSpaceType :: DomainFieldType DomainFieldType;
617 typedef typename DiscreteFunctionSpaceType :: RangeFieldType RangeFieldType;
618
620 typedef typename Traits :: DofIteratorType DofIteratorType;
622 typedef typename Traits :: ConstDofIteratorType ConstDofIteratorType;
623
625 typedef typename Traits :: DofVectorType DofVectorType;
626
628 typedef typename Traits :: LocalDofVectorType LocalDofVectorType;
630 typedef typename Traits :: LocalDofVectorAllocatorType LocalDofVectorAllocatorType;
631
634 typedef typename LocalFunctionType::LocalCoordinateType LocalCoordinateType;
635
640
642
643 typedef typename BaseType :: DofType DofType;
644
646 typedef typename DofVectorType::SizeType SizeType;
647
649
650 template< class Operation >
652 : public BaseType :: template CommDataHandle< Operation >
653 {};
654
655 protected:
656 using BaseType :: asImp;
657
659
670 DiscreteFunctionDefault ( const std::string &name, const DiscreteFunctionSpaceType &dfSpace );
671
672 DiscreteFunctionDefault ( std::string name, std::shared_ptr< const DiscreteFunctionSpaceType > dfSpace );
673
676
677 public:
679 ThisType &operator= ( const ThisType& ) = delete;
680
681 // Default Implementations
682 // -----------------------
683
685 const std::string &name () const { return name_; }
686
688 std::string &name () { return name_; }
689
691 constexpr int order() const
692 {
693 return space().order();
694 }
695
697 bool continuous() const
698 {
699 return space().continuous();
700 }
701
703 const DiscreteFunctionSpaceType &space () const { return *dfSpace_; }
704
706 const GridPartType &gridPart () const { return space().gridPart(); }
707
709 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
710 LocalFunctionType localFunction ( const EntityType &entity ) { return LocalFunctionType( asImp(), entity ); }
711
713 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
714 const LocalFunctionType localFunction ( const EntityType &entity ) const { return LocalFunctionType( asImp(), entity ); }
715
717 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
719
721 [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
723
725 void clear() { dofVector().clear(); }
726
727 DofVectorType &dofVector() { return asImp().dofVector(); }
728 const DofVectorType &dofVector() const { return asImp().dofVector(); }
729
731 int blocks() const { return dofVector().size(); }
732
734 DofBlockPtrType block ( unsigned int index )
735 {
736 return dofVector().blockPtr( index );
737 }
738
740 ConstDofBlockPtrType block ( unsigned int index ) const
741 {
742 return dofVector().blockPtr( index );
743 }
744
749 SizeType size () const { return dofVector().size() * blockSize; }
750
755 ConstDofIteratorType dbegin () const { return dofVector().begin(); }
756
761 DofIteratorType dbegin () { return dofVector().begin(); }
762
767 ConstDofIteratorType dend () const { return dofVector().end(); }
768
773 DofIteratorType dend () { return dofVector().end(); }
774
776 template <class DFType>
777 void axpy ( const RangeFieldType &s, const DiscreteFunctionInterface< DFType > &g );
778
781 {
782 dofVector().axpy( s, g.dofVector() );
783 }
784
786 template <class DFType>
788 {
789 return scalarProduct_.scalarProductDofs( *this, other );
790 }
791
793 typename Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs ( ) const
794 {
795 return std::real( (*this).scalarProductDofs( *this ));
796 }
797
799 void print ( std :: ostream &out ) const;
800
802 inline bool dofsValid () const;
803
805 template <class DFType>
807
809 void assign ( const DiscreteFunctionType &g )
810 {
811 dofVector() = g.dofVector();
812 }
813
815 template< class Operation >
816 typename CommDataHandle< Operation >::Type dataHandle ( const Operation &operation );
817
820 {
821 assert( Fem :: ThreadManager :: singleThreadMode() );
822 this->space().communicate( asImp() );
823 }
824
826 void evaluate ( const DomainType &x, RangeType &value ) const
827 {
828 asImp().evaluateGlobal( x, [ &value ] ( const LocalCoordinateType &x, const TemporaryLocalFunctionType &localFunction )
829 { localFunction.evaluate( x, value ); } );
830 }
831
834 {
835 asImp().evaluateGlobal( x, [ &jacobian ] ( const LocalCoordinateType &x, const TemporaryLocalFunctionType &localFunction )
836 { localFunction.jacobian( x, jacobian ); } );
837
838 }
839
841 void hessian ( const DomainType &x, HessianRangeType &hessian ) const
842 {
843 asImp().evaluateGlobal( x, [ &hessian ] ( const LocalCoordinateType &x, const TemporaryLocalFunctionType &localFunction )
844 { localFunction.hessian( x, hessian ); } );
845 }
846
848 template <class DFType>
850
853 {
854 dofVector() += g.dofVector();
855 return asImp();
856 }
857
859 template <class DFType>
861
864 {
865 dofVector() -= g.dofVector();
866 return asImp();
867 }
868
876 {
877 dofVector() *= scalar;
878 return asImp();
879 }
880
888 {
889 return BaseType :: operator*=( RangeFieldType(1 ) / scalar );
890 }
891
893 template< class StreamTraits >
894 inline void read ( InStreamInterface< StreamTraits > &in );
895
897 template< class StreamTraits >
898 inline void write ( OutStreamInterface< StreamTraits > &out ) const;
899
905 {}
906
907
909 template< class LocalDofs >
910 void addScaledLocalDofs ( const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs )
911 {
912 LeftAddScaled< const LocalDofs, const RangeFieldType > assignFunctor( localDofs, s );
913 space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
914 }
915
917 template< class LocalDofs >
918 void addLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
919 {
920 LeftAdd< const LocalDofs > assignFunctor( localDofs );
921 space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
922 }
923
925 template< class LocalDofs >
926 void setLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
927 {
928 LeftAssign< const LocalDofs > assignFunctor( localDofs );
929 space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
930 }
931
933 template< class Vector >
934 void getLocalDofs ( const EntityType &entity, Vector &localDofs ) const
935 {
936 AssignFunctor< Vector > assignFunctor( localDofs );
937 space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
938 }
939
940 // Non-Interface Methods
941 // ---------------------
942
943 template <class DFType>
944 inline bool operator== ( const DiscreteFunctionInterface< DFType> &g ) const;
945
946 template <class DFType>
948 {
949 return !(operator==( g ));
950 }
951
957 {
958 return ldvAllocator_;
959 }
960
964 template< class AssembleOperation >
966 {
967 const std::type_index id( typeid( AssembleOperation ) );
968 if( assembleOperation_ != id )
969 {
970 if( assembleOperation_ != std::type_index( typeid( void ) ) )
971 DUNE_THROW( InvalidStateException, "Another assemble operation in progress" );
973 assert( assembleCount_ == 0 );
974 AssembleOperation::begin( asImp() );
975 }
977 }
978
982 template< class AssembleOperation >
984 {
985 const std::type_index id( typeid( AssembleOperation ) );
986 if( assembleOperation_ != id )
987 DUNE_THROW( InvalidStateException, "Assemble operation not in progress" );
988 assert( assembleCount_ > 0 );
989 if( --assembleCount_ == 0 )
990 {
991 AssembleOperation::end( asImp() );
992 assembleOperation_ = std::type_index( typeid( void ) );
993 }
994 }
995
997 void getLocalDofReferences ( const EntityType &entity, LocalDofVectorType &localDofs )
998 {
999 AssignVectorReference< LocalDofVectorType > assignFunctor( localDofs );
1000 space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
1001 }
1002
1003 protected:
1005 virtual void backup() const
1006 {
1007 // get backup stream from persistence manager and write to it
1009 }
1010
1012 virtual void restore()
1013 {
1014 // get restore stream from persistence manager and read from it
1016 }
1017
1019 virtual void insertSubData();
1020
1022 virtual void removeSubData();
1023
1025 template< class Functor >
1026 void evaluateGlobal ( const DomainType &x, Functor functor ) const;
1027
1028 // only PersistenceManager should call backup and restore
1030
1031 std::shared_ptr< const DiscreteFunctionSpaceType > dfSpace_;
1032
1033 // the local function storage
1034 typename Traits :: LocalDofVectorStackType ldvStack_;
1036
1038
1039 std::string name_;
1041
1042 std::type_index assembleOperation_ = std::type_index( typeid( void ) );;
1043 std::size_t assembleCount_ = 0;
1044 }; // end class DiscreteFunctionDefault
1045
1046
1047 template< class DiscreteFunction >
1049
1050
1051 template< class DiscreteFunction >
1053 : public DiscreteFunctionTraits< DiscreteFunction > {};
1054
1055
1062 template< typename DiscreteFunctionSpace, typename DofVector >
1064 {
1065 typedef DofVector DofVectorType;
1066
1068 typedef typename DiscreteFunctionSpaceType::DomainType DomainType;
1069 typedef typename DiscreteFunctionSpaceType::RangeType RangeType;
1070
1071 typedef typename DofVectorType::IteratorType DofIteratorType;
1072 typedef typename DofVectorType::ConstIteratorType ConstDofIteratorType;
1073 typedef typename DofVectorType::DofBlockType DofBlockType;
1074 typedef typename DofVectorType::ConstDofBlockType ConstDofBlockType;
1075 typedef typename DofVectorType::DofBlockPtrType DofBlockPtrType;
1076 typedef typename DofVectorType::ConstDofBlockPtrType ConstDofBlockPtrType;
1077
1078 typedef typename DiscreteFunctionSpaceType::BlockMapperType MapperType;
1079 typedef typename DofVectorType::FieldType DofType;
1080
1084 };
1085
1086
1088
1089 } // end namespace Fem
1090
1091} // end namespace Dune
1092
1094
1095#include "gridfunctionadapter.hh"
1096#endif // #ifndef DUNE_FEM_DISCRETEFUNCTION_HH
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const OtherDiscreteFunctionType &y) const
evaluate scalar product and omit auxiliary nodes
Definition: common/scalarproducts.hh:109
double real(const complex< Dune::Fem::Double > &x)
Definition: double.hh:983
Definition: bindguard.hh:11
static DofBlockFunctor< DofVector, Functor > dofBlockFunctor(DofVector &dofVector, Functor functor)
Definition: function/common/functor.hh:132
Definition: stackallocator.hh:61
base class for determing whether a class is a discrete function or not
Definition: common/discretefunction.hh:53
base class for determing whether a function has local functions or not
Definition: common/discretefunction.hh:57
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:61
Definition: common/discretefunction.hh:578
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: common/discretefunction.hh:697
DiscreteFunctionType & operator*=(const RangeFieldType &scalar)
multiply all DoFs with a scalar factor
Definition: common/discretefunction.hh:875
void evaluate(const DomainType &x, RangeType &value) const
evaluate the function
Definition: common/discretefunction.hh:826
DiscreteFunctionType & operator+=(const DiscreteFunctionType &g)
add another discrete function to this one
Definition: common/discretefunction.hh:852
std::string name_
Definition: common/discretefunction.hh:1039
LocalDofVectorAllocatorType ldvAllocator_
Definition: common/discretefunction.hh:1035
void endAssemble()
Finalize the assemble of values using the LocalContribution concept.
Definition: common/discretefunction.hh:983
Traits::DofVectorType DofVectorType
type of DofVector
Definition: common/discretefunction.hh:625
DofIteratorType dend()
Obtain the non-constant iterator pointing to the last dof.
Definition: common/discretefunction.hh:773
Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs() const
Squared small l^2 norm of all dofs.
Definition: common/discretefunction.hh:793
void print(std ::ostream &out) const
print all DoFs to a stream (for debugging purposes)
Definition: discretefunction_inline.hh:91
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
type of hessian
Definition: common/discretefunction.hh:612
SizeType size() const
Return the number of blocks in the block vector.
Definition: common/discretefunction.hh:749
BaseType::ConstDofBlockType ConstDofBlockType
Definition: common/discretefunction.hh:637
void hessian(const DomainType &x, HessianRangeType &hessian) const
evaluate the hessian of the function (const DomainType &x,HessianRangeType &hessian) const
Definition: common/discretefunction.hh:841
Impl DiscreteFunctionType
type of the discrete function (Barton-Nackman parameter)
Definition: common/discretefunction.hh:586
BaseType::Traits Traits
Definition: common/discretefunction.hh:583
BaseType::LocalFunctionType LocalFunctionType
type of local functions
Definition: common/discretefunction.hh:633
ScalarProductType scalarProduct_
Definition: common/discretefunction.hh:1040
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: common/discretefunction.hh:703
DiscreteFunctionDefault(const ThisType &)
DiscreteFunctionDefault(const std::string &name, const DiscreteFunctionSpaceType &dfSpace)
Constructor storing discrete function space and local function factory.
Definition: discretefunction_inline.hh:27
DiscreteFunctionType & operator-=(const DiscreteFunctionInterface< DFType > &g)
substract all degrees of freedom from given discrete function using the dof iterators
Definition: discretefunction_inline.hh:200
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: discretefunction_inline.hh:274
void communicate()
do default communication of space for this discrete function
Definition: common/discretefunction.hh:819
BaseType::GridPartType GridPartType
type of the underlying grid part
Definition: common/discretefunction.hh:603
DiscreteFunctionType & operator+=(const DiscreteFunctionInterface< DFType > &g)
add another discrete function to this one
Definition: discretefunction_inline.hh:183
void clear()
set all degrees of freedom to zero
Definition: common/discretefunction.hh:725
Traits::LocalDofVectorAllocatorType LocalDofVectorAllocatorType
type of LocalDofVector
Definition: common/discretefunction.hh:630
BaseType::EntityType EntityType
Definition: common/discretefunction.hh:641
Traits::ConstDofIteratorType ConstDofIteratorType
type of the const dof iterator
Definition: common/discretefunction.hh:622
DofVectorType & dofVector()
Definition: common/discretefunction.hh:727
void getLocalDofs(const EntityType &entity, Vector &localDofs) const
fill local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:934
BaseType::DiscreteFunctionInterfaceType DiscreteFunctionInterfaceType
Definition: common/discretefunction.hh:588
DiscreteFunctionDefault(ThisType &&other)
void beginAssemble()
Initiate the assemble of values using the LocalContribution concept.
Definition: common/discretefunction.hh:965
ConstDofIteratorType dbegin() const
Obtain the constant iterator pointing to the first dof.
Definition: common/discretefunction.hh:755
bool dofsValid() const
check for NaNs
Definition: discretefunction_inline.hh:101
int blocks() const
obtain total number of blocks, i.e. size / blockSize.
Definition: common/discretefunction.hh:731
const DofVectorType & dofVector() const
Definition: common/discretefunction.hh:728
BaseType::DofType DofType
Definition: common/discretefunction.hh:643
void addScaledLocalDofs(const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs)
add scaled local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:910
DofVectorType::SizeType SizeType
size type of the block vector
Definition: common/discretefunction.hh:646
ThisType & operator=(ThisType &&)=delete
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:685
Traits::LocalDofVectorType LocalDofVectorType
type of LocalDofVector
Definition: common/discretefunction.hh:628
const LocalFunctionType localFunction() const
obtain an uninitialized local function (read-write)
Definition: common/discretefunction.hh:722
std::type_index assembleOperation_
Definition: common/discretefunction.hh:1042
ConstDofBlockPtrType block(unsigned int index) const
Definition: common/discretefunction.hh:740
void addLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
add local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:918
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grid changes a dof compression is done...
Definition: common/discretefunction.hh:904
void evaluateGlobal(const DomainType &x, Functor functor) const
evaluate functor in global coordinate
Definition: discretefunction_inline.hh:162
ConstDofIteratorType dend() const
Obtain the constant iterator pointing to the last dof.
Definition: common/discretefunction.hh:767
DiscreteFunctionSpaceType::RangeType RangeType
type of range vector
Definition: common/discretefunction.hh:608
LocalFunctionType::LocalCoordinateType LocalCoordinateType
Definition: common/discretefunction.hh:634
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: discretefunction_inline.hh:216
TemporaryLocalFunctionType localFunction_
Definition: common/discretefunction.hh:1037
Traits::LocalDofVectorStackType ldvStack_
Definition: common/discretefunction.hh:1034
DofBlockPtrType block(unsigned int index)
Definition: common/discretefunction.hh:734
DofIteratorType dbegin()
Obtain the non-constant iterator pointing to the first dof.
Definition: common/discretefunction.hh:761
virtual void insertSubData()
Definition: discretefunction_inline.hh:311
TemporaryLocalFunction< DiscreteFunctionSpaceType > TemporaryLocalFunctionType
Definition: common/discretefunction.hh:658
DiscreteFunctionType & operator/=(const RangeFieldType &scalar)
devide all DoFs by a scalar factor
Definition: common/discretefunction.hh:887
Traits::DofIteratorType DofIteratorType
type of the dof iterator
Definition: common/discretefunction.hh:620
const GridPartType & gridPart() const
obtain a reference to the underlying grid part
Definition: common/discretefunction.hh:706
bool operator!=(const DiscreteFunctionInterface< DFType > &g) const
Definition: common/discretefunction.hh:947
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: common/discretefunction.hh:600
virtual void backup() const
Definition: common/discretefunction.hh:1005
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:133
LocalFunctionType localFunction()
obtain an uninitialized local function (read-write)
Definition: common/discretefunction.hh:718
BaseType::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: common/discretefunction.hh:639
virtual void removeSubData()
Definition: discretefunction_inline.hh:327
LocalDofVectorAllocatorType & localDofVectorAllocator() const
obtain the local function storage
Definition: common/discretefunction.hh:956
void jacobian(const DomainType &x, JacobianRangeType &jacobian) const
evaluate the Jacobian of the function
Definition: common/discretefunction.hh:833
const LocalFunctionType localFunction(const EntityType &entity) const
obtain a local function for an entity (read-write)
Definition: common/discretefunction.hh:714
DiscreteFunctionSpaceType::DomainType DomainType
type of domain vector
Definition: common/discretefunction.hh:606
CommDataHandle< Operation >::Type dataHandle(const Operation &operation)
return reference to data handle object
ParallelScalarProduct< DiscreteFunctionInterfaceType > ScalarProductType
Definition: common/discretefunction.hh:596
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field (usually a float type)
Definition: common/discretefunction.hh:617
void getLocalDofReferences(const EntityType &entity, LocalDofVectorType &localDofs)
get local Dofs and store a reference to it in the LocalDofVector
Definition: common/discretefunction.hh:997
BaseType::DofBlockPtrType DofBlockPtrType
Definition: common/discretefunction.hh:638
DiscreteFunctionType & operator-=(const DiscreteFunctionType &g)
substract all degrees of freedom from given discrete function using the dof iterators
Definition: common/discretefunction.hh:863
virtual void restore()
Definition: common/discretefunction.hh:1012
void axpy(const RangeFieldType &s, const DiscreteFunctionInterface< DFType > &g)
axpy operation
Definition: discretefunction_inline.hh:117
std::string & name()
obtain the name of the discrete function
Definition: common/discretefunction.hh:688
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
type of domain field (usually a float type)
Definition: common/discretefunction.hh:615
std::size_t assembleCount_
Definition: common/discretefunction.hh:1043
BaseType::DofBlockType DofBlockType
Definition: common/discretefunction.hh:636
std::shared_ptr< const DiscreteFunctionSpaceType > dfSpace_
Definition: common/discretefunction.hh:1031
void axpy(const RangeFieldType &s, const DiscreteFunctionInterfaceType &g)
axpy operation
Definition: common/discretefunction.hh:780
void assign(const DiscreteFunctionType &g)
Definition: common/discretefunction.hh:809
RangeFieldType scalarProductDofs(const DiscreteFunctionInterface< DFType > &other) const
Scalar product between the DoFs of two discrete functions.
Definition: common/discretefunction.hh:787
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
type of jacobian
Definition: common/discretefunction.hh:610
LocalFunctionType localFunction(const EntityType &entity)
obtain a local function for an entity (read-write)
Definition: common/discretefunction.hh:710
void setLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
set local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:926
bool operator==(const DiscreteFunctionInterface< DFType > &g) const
Definition: discretefunction_inline.hh:345
constexpr int order() const
obtain an upper bound on the polynomial order of the underlying space.
Definition: common/discretefunction.hh:691
Definition: common/discretefunction.hh:86
DofVectorType & dofVector()
Definition: common/discretefunction.hh:173
Traits::ConstDofIteratorType ConstDofIteratorType
type of the constantdof iterator used in the discrete function implementation
Definition: common/discretefunction.hh:134
DiscreteFunctionInterface< Impl > DiscreteFunctionInterfaceType
type of the discrete function interface (this type)
Definition: common/discretefunction.hh:104
DofIteratorType dbegin()
obtain an iterator pointing to the first DoF (read-write)
Definition: common/discretefunction.hh:372
BaseType::MappingType MappingType
type of mapping base class for this discrete function
Definition: common/discretefunction.hh:143
RangeFieldType scalarProductDofs(const DiscreteFunctionInterface< DFType > &other) const
Scalar product between the DoFs of two discrete functions.
Definition: common/discretefunction.hh:412
void addLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
add local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:278
Traits::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of associated discrete function space
Definition: common/discretefunction.hh:98
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
type of jacobian, i.e. type of evaluated gradient
Definition: common/discretefunction.hh:115
DiscreteFunctionType & operator/=(const RangeFieldType &scalar)
devide all DoFs by a scalar factor
Definition: common/discretefunction.hh:514
DiscreteFunctionSpaceType::LocalBlockIndices BlockIndices
Definition: common/discretefunction.hh:145
LocalFunctionType localFunction(const EntityType &entity)
obtain a local function for an entity (read-write)
Definition: common/discretefunction.hh:231
void axpy(const RangeFieldType &s, const DiscreteFunctionInterfaceType &g)
axpy operation
Definition: common/discretefunction.hh:393
DiscreteFunctionTraits< Impl > Traits
type of the traits
Definition: common/discretefunction.hh:92
int blocks() const
obtain total number of blocks, i.e. size / blockSize.
Definition: common/discretefunction.hh:345
void addScaledLocalDofs(const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs)
add scaled local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:267
void clear()
set all degrees of freedom to zero
Definition: common/discretefunction.hh:320
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grid changes a dof compression is done...
Definition: common/discretefunction.hh:546
DiscreteFunctionType & operator+=(const DiscreteFunctionInterface< DFType > &g)
add another discrete function to this one
Definition: common/discretefunction.hh:480
DiscreteFunctionType & operator-=(const DiscreteFunctionInterface< DFType > &g)
substract all degrees of freedom from given discrete function using the dof iterators
Definition: common/discretefunction.hh:492
DefaultLoadBalanceContainsCheckType defaultLoadBalanceContainsCheck() const
Definition: common/discretefunction.hh:553
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: common/discretefunction.hh:537
const LocalFunctionType localFunction() const
obtain an uninitialized local function (read-write)
Definition: common/discretefunction.hh:314
ConstDofIteratorType dbegin() const
obtain an iterator pointing to the first DoF (read-only)
Definition: common/discretefunction.hh:354
DiscreteFunctionInterface()=default
default constructor
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: common/discretefunction.hh:208
ThisType & operator=(ThisType &&)=delete
GridPartType::GridViewType GridView
Definition: common/discretefunction.hh:119
void print(std ::ostream &out) const
print all DoFs to a stream (for debugging purposes)
Definition: common/discretefunction.hh:437
LoadBalanceLeafData< ThisType > DefaultLoadBalanceContainsCheckType
Definition: common/discretefunction.hh:552
Traits::DofVectorType DofVectorType
type of the dof vector used in the discrete function implementation
Definition: common/discretefunction.hh:128
Traits::DofBlockType DofBlockType
Definition: common/discretefunction.hh:137
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:186
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: common/discretefunction.hh:527
void getLocalDofs(const EntityType &entity, Vector &localDofs) const
fill local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:302
CommDataHandle< Operation >::Type dataHandle(const Operation &operation)
return reference to data handle object
Definition: common/discretefunction.hh:462
bool dofsValid() const
check for NaNs
Definition: common/discretefunction.hh:445
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
type of domain field, i.e. type of coordinate component
Definition: common/discretefunction.hh:107
LocalFunctionType localFunction()
obtain an uninitialized local function (read-write)
Definition: common/discretefunction.hh:254
DiscreteFunctionInterface(ThisType &&)=default
const LocalFunctionType localFunction(const EntityType &entity) const
obtain a local function for an entity (read-write)
Definition: common/discretefunction.hh:242
Traits::LocalFunctionType LocalFunctionType
type of local functions
Definition: common/discretefunction.hh:125
DiscreteFunctionInterface(const ThisType &)=default
const DofVectorType & dofVector() const
Definition: common/discretefunction.hh:177
ConstDofIteratorType dend() const
obtain an iterator pointing behind the last DoF (read-only)
Definition: common/discretefunction.hh:363
const GridPartType & gridPart() const
obtain a reference to the underlying grid part
Definition: common/discretefunction.hh:220
DiscreteFunctionSpaceType::GridType GridType
type of the underlying grid
Definition: common/discretefunction.hh:122
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field, i.e. dof type
Definition: common/discretefunction.hh:109
Traits::DofBlockPtrType DofBlockPtrType
Definition: common/discretefunction.hh:139
Traits::DofIteratorType DofIteratorType
type of the dof iterator used in the discrete function implementation
Definition: common/discretefunction.hh:131
Traits::ConstDofBlockType ConstDofBlockType
Definition: common/discretefunction.hh:138
DiscreteFunctionType & operator*=(const RangeFieldType &scalar)
multiply all DoFs by a scalar factor
Definition: common/discretefunction.hh:503
Traits::DiscreteFunctionType DiscreteFunctionType
type of the implementaton (Barton-Nackman)
Definition: common/discretefunction.hh:95
DiscreteFunctionSpaceType::EntityType EntityType
type of entity local functions are defined on
Definition: common/discretefunction.hh:159
DiscreteFunctionSpaceType::FunctionSpaceType FunctionSpaceType
type of associated function space
Definition: common/discretefunction.hh:101
std::string & name()
obtain the name of the discrete function
Definition: common/discretefunction.hh:195
DiscreteFunctionSpaceType::DomainType DomainType
type of domain, i.e. type of coordinates
Definition: common/discretefunction.hh:111
DiscreteFunctionSpaceType::RangeType RangeType
type of range, i.e. result of evaluation
Definition: common/discretefunction.hh:113
Traits::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: common/discretefunction.hh:140
Traits::DofType DofType
Definition: common/discretefunction.hh:136
DofIteratorType dend()
obtain an iterator pointing behind the last DoF (read-write)
Definition: common/discretefunction.hh:381
DiscreteFunctionSpaceType::GridPartType GridPartType
type of the underlying grid part
Definition: common/discretefunction.hh:118
static constexpr std::size_t blockSize
size of the dof blocks
Definition: common/discretefunction.hh:148
const std::string & order() const
obtain an upper bound on the polynomial order of the underlying space.
Definition: common/discretefunction.hh:202
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: common/discretefunction.hh:214
Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs() const
Squared small l^2 norm of all dofs.
Definition: common/discretefunction.hh:428
void assign(const DiscreteFunctionInterface< DFType > &g)
assign the DoFs of another discrete function to this one
Definition: common/discretefunction.hh:455
void setLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
set local Dofs to dof vector associated with the entity
Definition: common/discretefunction.hh:289
int size() const
obtain total number of DoFs
Definition: common/discretefunction.hh:333
void communicate()
do default communication of space for this discrete function
Definition: common/discretefunction.hh:468
Definition: common/discretefunction.hh:152
DiscreteFunctionSpaceType::template CommDataHandle< DiscreteFunctionType, Operation >::Type Type
Definition: common/discretefunction.hh:155
Definition: common/discretefunction.hh:653
Definition: common/discretefunction.hh:1048
Definition: common/discretefunction.hh:1064
DofVectorType::ConstIteratorType ConstDofIteratorType
Definition: common/discretefunction.hh:1072
StackAllocator< DofType, LocalDofVectorStackType * > LocalDofVectorAllocatorType
Definition: common/discretefunction.hh:1082
ThreadSafeValue< UninitializedObjectStack > LocalDofVectorStackType
Definition: common/discretefunction.hh:1081
DofVector DofVectorType
Definition: common/discretefunction.hh:1065
DynamicReferenceVector< DofType, LocalDofVectorAllocatorType > LocalDofVectorType
Definition: common/discretefunction.hh:1083
DofVectorType::ConstDofBlockType ConstDofBlockType
Definition: common/discretefunction.hh:1074
DiscreteFunctionSpaceType::BlockMapperType MapperType
Definition: common/discretefunction.hh:1078
DofVectorType::IteratorType DofIteratorType
Definition: common/discretefunction.hh:1071
DiscreteFunctionSpaceType::DomainType DomainType
Definition: common/discretefunction.hh:1068
DofVectorType::FieldType DofType
Definition: common/discretefunction.hh:1079
DiscreteFunctionSpace DiscreteFunctionSpaceType
Definition: common/discretefunction.hh:1067
DiscreteFunctionSpaceType::RangeType RangeType
Definition: common/discretefunction.hh:1069
DofVectorType::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: common/discretefunction.hh:1076
DofVectorType::DofBlockPtrType DofBlockPtrType
Definition: common/discretefunction.hh:1075
DofVectorType::DofBlockType DofBlockType
Definition: common/discretefunction.hh:1073
Abstract class representing a function.
Definition: common/function.hh:50
Mapping< DomainFieldType, RangeFieldType, DomainType, RangeType > MappingType
type of mapping base class
Definition: common/function.hh:76
const Implementation & asImp() const
Definition: bartonnackmaninterface.hh:37
Definition: function/common/functor.hh:23
Definition: function/common/functor.hh:43
Definition: function/common/functor.hh:65
Definition: function/common/functor.hh:85
base class for persistent objects
Definition: persistencemanager.hh:101
class with singleton instance managing all persistent objects
Definition: persistencemanager.hh:141
static BackupStreamType & backupStream()
Definition: persistencemanager.hh:349
static RestoreStreamType & restoreStream()
Definition: persistencemanager.hh:354
abstract interface for an output stream
Definition: streams.hh:46
abstract interface for an input stream
Definition: streams.hh:179
Definition: misc/functor.hh:31
check for sets of entities for the load balance procedure
Definition: commoperations.hh:216
An implementation of DenseVector which uses a std::vector of references as storage.
Definition: storage/referencevector.hh:53
discrete function space