DUNE-FEM (unstable)

discretefunction.hh
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 
14 #include <dune/fem/function/common/dofiterator.hh>
15 #include <dune/fem/function/common/function.hh>
16 #include <dune/fem/function/common/functor.hh>
17 #include <dune/fem/function/common/scalarproducts.hh>
18 #include <dune/fem/function/common/rangegenerators.hh>
19 #include <dune/fem/function/localfunction/temporary.hh>
20 #include <dune/fem/gridpart/common/entitysearch.hh>
21 #include <dune/fem/io/file/persistencemanager.hh>
22 #include <dune/fem/io/streams/streams.hh>
23 #include <dune/fem/misc/functor.hh>
24 #include <dune/fem/misc/mpimanager.hh>
25 #include <dune/fem/space/common/discretefunctionspace.hh>
26 #include <dune/fem/storage/envelope.hh>
27 #include <dune/fem/storage/referencevector.hh>
28 #include <dune/fem/version.hh>
29 
30 
31 namespace 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 >
151  struct CommDataHandle
152  {
153  typedef typename DiscreteFunctionSpaceType
154  :: template CommDataHandle< DiscreteFunctionType, Operation > :: Type
155  Type;
156  };
157 
159  typedef typename DiscreteFunctionSpaceType :: EntityType EntityType;
160 
161  protected:
162  using BaseType::asImp;
163 
166 
167  DiscreteFunctionInterface ( const ThisType& ) = default;
168  DiscreteFunctionInterface ( ThisType && ) = default;
169  public:
170  ThisType& operator= ( ThisType&& ) = delete;
171  ThisType &operator= ( const ThisType& ) = delete;
172 
173  DofVectorType &dofVector()
174  {
175  return asImp().dofVector();
176  }
177  const DofVectorType &dofVector() const
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 
468  void communicate()
469  {
471  }
472 
473  template <class DFType>
474  inline bool compare ( const DiscreteFunctionInterface<DFType> &g ) const
475  {
476  return asImp().compare( g );
477  }
478 
485  template < class DFType >
487  {
488  return asImp().operator+=( g );
489  }
490 
497  template < class DFType >
499  {
500  return asImp().operator-=( g );
501  }
502 
510  {
511  return asImp() *= scalar;
512  }
513 
521  {
522  return asImp() /= scalar;
523  }
524 
532  template< class StreamTraits >
534  {
535  asImp().read( in );
536  }
537 
542  template< class StreamTraits >
544  {
545  asImp().write( out );
546  }
547 
553  {
554  asImp().enableDofCompression();
555  }
556 
557  //TODO: this needs to be revised, the definition should be in GridPart
558  typedef LoadBalanceLeafData< ThisType > DefaultLoadBalanceContainsCheckType;
559  DefaultLoadBalanceContainsCheckType defaultLoadBalanceContainsCheck() const
560  {
561  return DefaultLoadBalanceContainsCheckType( *this );
562  }
563  };
564 
565 
566 
567  //*************************************************************************
568  //
569  // --DiscreteFunctionDefault
570  //
579  //*************************************************************************
580  template< class Impl >
582  : public DiscreteFunctionInterface< Impl > ,
583  public PersistentObject
584  {
587 
588  public:
589  typedef typename BaseType :: Traits Traits;
590 
592  typedef Impl DiscreteFunctionType;
593 
595 
596  private:
598 
599  enum { myId_ = 0 };
600 
601  protected:
603 
604  public:
607 
610 
612  typedef typename DiscreteFunctionSpaceType :: DomainType DomainType;
614  typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
616  typedef typename DiscreteFunctionSpaceType :: JacobianRangeType JacobianRangeType;
618  typedef typename DiscreteFunctionSpaceType :: HessianRangeType HessianRangeType;
619 
621  typedef typename DiscreteFunctionSpaceType :: DomainFieldType DomainFieldType;
623  typedef typename DiscreteFunctionSpaceType :: RangeFieldType RangeFieldType;
624 
626  typedef typename Traits :: DofIteratorType DofIteratorType;
628  typedef typename Traits :: ConstDofIteratorType ConstDofIteratorType;
629 
631  typedef typename Traits :: DofVectorType DofVectorType;
632 
634  typedef typename Traits :: LocalDofVectorType LocalDofVectorType;
636  typedef typename Traits :: LocalDofVectorAllocatorType LocalDofVectorAllocatorType;
637 
640  typedef typename LocalFunctionType::LocalCoordinateType LocalCoordinateType;
641 
642  typedef typename BaseType :: DofBlockType DofBlockType;
643  typedef typename BaseType :: ConstDofBlockType ConstDofBlockType;
644  typedef typename BaseType :: DofBlockPtrType DofBlockPtrType;
645  typedef typename BaseType :: ConstDofBlockPtrType ConstDofBlockPtrType;
646 
647  typedef typename BaseType :: EntityType EntityType ;
648 
649  typedef typename BaseType :: DofType DofType;
650 
652  typedef typename DofVectorType::SizeType SizeType;
653 
654  using BaseType::blockSize;
655 
656  template< class Operation >
657  struct CommDataHandle
658  : public BaseType :: template CommDataHandle< Operation >
659  {};
660 
661  protected:
662  using BaseType :: asImp;
663 
664  typedef TemporaryLocalFunction< DiscreteFunctionSpaceType > TemporaryLocalFunctionType;
665 
676  DiscreteFunctionDefault ( const std::string &name, const DiscreteFunctionSpaceType &dfSpace );
677 
678  DiscreteFunctionDefault ( std::string name, std::shared_ptr< const DiscreteFunctionSpaceType > dfSpace );
679 
680  DiscreteFunctionDefault ( const ThisType& );
681  DiscreteFunctionDefault ( ThisType && other );
682 
683  public:
684  ThisType& operator= ( ThisType&& ) = delete;
685  ThisType &operator= ( const ThisType& ) = delete;
686 
687  // Default Implementations
688  // -----------------------
689 
691  const std::string &name () const { return name_; }
692 
694  std::string &name () { return name_; }
695 
697  constexpr int order() const
698  {
699  return space().order();
700  }
701 
703  bool continuous() const
704  {
705  return space().continuous();
706  }
707 
709  const DiscreteFunctionSpaceType &space () const { return *dfSpace_; }
710 
712  const GridPartType &gridPart () const { return space().gridPart(); }
713 
715  [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
716  LocalFunctionType localFunction ( const EntityType &entity ) { return LocalFunctionType( asImp(), entity ); }
717 
719  [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
720  const LocalFunctionType localFunction ( const EntityType &entity ) const { return LocalFunctionType( asImp(), entity ); }
721 
723  [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
725 
727  [[deprecated("Use {Const,Temporary,Mutable}LocalFunction and LocalContribution instead!")]]
728  const LocalFunctionType localFunction () const { return LocalFunctionType( asImp() ); }
729 
731  void clear() { dofVector().clear(); }
732 
733  DofVectorType &dofVector() { return asImp().dofVector(); }
734  const DofVectorType &dofVector() const { return asImp().dofVector(); }
735 
737  int blocks() const { return dofVector().size(); }
738 
740  DofBlockPtrType block ( unsigned int index )
741  {
742  return dofVector().blockPtr( index );
743  }
744 
746  ConstDofBlockPtrType block ( unsigned int index ) const
747  {
748  return dofVector().blockPtr( index );
749  }
750 
755  SizeType size () const { return dofVector().size() * blockSize; }
756 
761  ConstDofIteratorType dbegin () const { return dofVector().begin(); }
762 
767  DofIteratorType dbegin () { return dofVector().begin(); }
768 
773  ConstDofIteratorType dend () const { return dofVector().end(); }
774 
779  DofIteratorType dend () { return dofVector().end(); }
780 
782  template <class DFType>
783  void axpy ( const RangeFieldType &s, const DiscreteFunctionInterface< DFType > &g );
784 
787  {
788  dofVector().axpy( s, g.dofVector() );
789  }
790 
792  template <class DFType>
794  {
795  return scalarProduct_.scalarProductDofs( *this, other );
796  }
797 
799  typename Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs ( ) const
800  {
801  return std::real( (*this).scalarProductDofs( *this ));
802  }
803 
805  void print ( std :: ostream &out ) const;
806 
808  inline bool dofsValid () const;
809 
811  template <class DFType>
813 
815  void assign ( const DiscreteFunctionType &g )
816  {
817  dofVector() = g.dofVector();
818  }
819 
821  template< class Operation >
822  typename CommDataHandle< Operation >::Type dataHandle ( const Operation &operation );
823 
825  void communicate()
826  {
827  // only call in single thread mode
828  if( ! Fem :: MPIManager :: singleThreadMode() )
829  {
830  assert( Fem :: MPIManager :: singleThreadMode() );
831  DUNE_THROW(InvalidStateException,"DiscreteFunctionInterface::communicate: only call in single thread mode!");
832  }
833 
834  this->space().communicate( asImp() );
835  }
836 
838  void evaluate ( const DomainType &x, RangeType &value ) const
839  {
840  asImp().evaluateGlobal( x, [ &value ] ( const LocalCoordinateType &x, const TemporaryLocalFunctionType &localFunction )
841  { localFunction.evaluate( x, value ); } );
842  }
843 
845  void jacobian ( const DomainType &x, JacobianRangeType &jacobian ) const
846  {
847  asImp().evaluateGlobal( x, [ &jacobian ] ( const LocalCoordinateType &x, const TemporaryLocalFunctionType &localFunction )
848  { localFunction.jacobian( x, jacobian ); } );
849 
850  }
851 
853  void hessian ( const DomainType &x, HessianRangeType &hessian ) const
854  {
855  asImp().evaluateGlobal( x, [ &hessian ] ( const LocalCoordinateType &x, const TemporaryLocalFunctionType &localFunction )
856  { localFunction.hessian( x, hessian ); } );
857  }
858 
860  template <class DFType>
862 
865  {
866  dofVector() += g.dofVector();
867  return asImp();
868  }
869 
871  template <class DFType>
873 
876  {
877  dofVector() -= g.dofVector();
878  return asImp();
879  }
880 
888  {
889  dofVector() *= scalar;
890  return asImp();
891  }
892 
900  {
901  return BaseType :: operator*=( RangeFieldType(1 ) / scalar );
902  }
903 
905  template< class StreamTraits >
906  inline void read ( InStreamInterface< StreamTraits > &in );
907 
909  template< class StreamTraits >
910  inline void write ( OutStreamInterface< StreamTraits > &out ) const;
911 
917  {}
918 
919 
921  template< class LocalDofs >
922  void addScaledLocalDofs ( const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs )
923  {
924  LeftAddScaled< const LocalDofs, const RangeFieldType > assignFunctor( localDofs, s );
925  space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
926  }
927 
929  template< class LocalDofs >
930  void addLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
931  {
932  LeftAdd< const LocalDofs > assignFunctor( localDofs );
933  space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
934  }
935 
937  template< class LocalDofs >
938  void setLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
939  {
940  LeftAssign< const LocalDofs > assignFunctor( localDofs );
941  space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
942  }
943 
945  template< class Vector >
946  void getLocalDofs ( const EntityType &entity, Vector &localDofs ) const
947  {
948  AssignFunctor< Vector > assignFunctor( localDofs );
949  space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
950  }
951 
952  template <class DFType>
953  inline bool compare ( const DiscreteFunctionInterface< DFType> &g ) const;
954 
955  // Non-Interface Methods
956  // ---------------------
957 
963  {
964  return ldvAllocator_;
965  }
966 
970  template< class AssembleOperation >
972  {
973  const std::type_index id( typeid( AssembleOperation ) );
974  if( assembleOperation_ != id )
975  {
976  if( assembleOperation_ != std::type_index( typeid( void ) ) )
977  DUNE_THROW( InvalidStateException, "Another assemble operation in progress" );
978  assembleOperation_ = id;
979  assert( assembleCount_ == 0 );
980  AssembleOperation::begin( asImp() );
981  }
982  ++assembleCount_;
983  }
984 
988  template< class AssembleOperation >
989  void endAssemble ( const bool communicate = true )
990  {
991  const std::type_index id( typeid( AssembleOperation ) );
992  if( assembleOperation_ != id )
993  DUNE_THROW( InvalidStateException, "Assemble operation not in progress" );
994  assert( assembleCount_ > 0 );
995  if( --assembleCount_ == 0 )
996  {
997  AssembleOperation::end( asImp(), communicate );
998  assembleOperation_ = std::type_index( typeid( void ) );
999  }
1000  }
1001 
1003  void getLocalDofReferences ( const EntityType &entity, LocalDofVectorType &localDofs )
1004  {
1005  AssignVectorReference< LocalDofVectorType > assignFunctor( localDofs );
1006  space().blockMapper().mapEach( entity, dofBlockFunctor( dofVector(), assignFunctor ) );
1007  }
1008 
1009  protected:
1011  virtual void backup() const
1012  {
1013  // get backup stream from persistence manager and write to it
1014  write( PersistenceManager :: backupStream() );
1015  }
1016 
1018  virtual void restore()
1019  {
1020  // get restore stream from persistence manager and read from it
1021  read( PersistenceManager :: restoreStream() );
1022  }
1023 
1025  virtual void insertSubData();
1026 
1028  virtual void removeSubData();
1029 
1031  template< class Functor >
1032  void evaluateGlobal ( const DomainType &x, Functor functor ) const;
1033 
1034  // only PersistenceManager should call backup and restore
1035  friend class PersistenceManager;
1036 
1037  std::shared_ptr< const DiscreteFunctionSpaceType > dfSpace_;
1038 
1039  // the local function storage
1040  typename Traits :: LocalDofVectorStackType ldvStack_;
1041  mutable LocalDofVectorAllocatorType ldvAllocator_;
1042 
1043  mutable TemporaryLocalFunctionType localFunction_;
1044 
1045  std::string name_;
1046  ScalarProductType scalarProduct_;
1047 
1048  std::type_index assembleOperation_ = std::type_index( typeid( void ) );;
1049  std::size_t assembleCount_ = 0;
1050  }; // end class DiscreteFunctionDefault
1051 
1052  template< class ImplX, class ImplY >
1053  inline bool operator== ( const DiscreteFunctionInterface< ImplX > &x,
1054  const DiscreteFunctionInterface< ImplY > &y )
1055  {
1056  return x.compare(y);
1057  }
1058  template< class ImplX, class ImplY >
1059  inline bool operator!= ( const DiscreteFunctionInterface< ImplX > &x,
1060  const DiscreteFunctionInterface< ImplY > &y )
1061  {
1062  return !x.compare(y);
1063  }
1064 
1065  template< class DiscreteFunction >
1066  class ManagedDiscreteFunction;
1067 
1068  template< class DiscreteFunction >
1069  struct DiscreteFunctionTraits< ManagedDiscreteFunction< DiscreteFunction > >
1070  : public DiscreteFunctionTraits< DiscreteFunction > {};
1071 
1072 
1079  template< typename DiscreteFunctionSpace, typename DofVector >
1080  struct DefaultDiscreteFunctionTraits
1081  {
1082  typedef DofVector DofVectorType;
1083 
1084  typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
1085  typedef typename DiscreteFunctionSpaceType::DomainType DomainType;
1086  typedef typename DiscreteFunctionSpaceType::RangeType RangeType;
1087 
1088  typedef typename DofVectorType::IteratorType DofIteratorType;
1089  typedef typename DofVectorType::ConstIteratorType ConstDofIteratorType;
1090  typedef typename DofVectorType::DofBlockType DofBlockType;
1091  typedef typename DofVectorType::ConstDofBlockType ConstDofBlockType;
1092  typedef typename DofVectorType::DofBlockPtrType DofBlockPtrType;
1093  typedef typename DofVectorType::ConstDofBlockPtrType ConstDofBlockPtrType;
1094 
1095  typedef typename DiscreteFunctionSpaceType::BlockMapperType MapperType;
1096  typedef typename DofVectorType::FieldType DofType;
1097 
1098  typedef ThreadSafeValue< UninitializedObjectStack > LocalDofVectorStackType;
1099  typedef StackAllocator< DofType, LocalDofVectorStackType* > LocalDofVectorAllocatorType;
1100  typedef DynamicReferenceVector< DofType, LocalDofVectorAllocatorType > LocalDofVectorType;
1101  };
1102 
1103 
1105 
1106  } // end namespace Fem
1107 
1108 } // end namespace Dune
1109 
1110 #include "discretefunction_inline.hh"
1111 
1112 #include "gridfunctionadapter.hh"
1113 #endif // #ifndef DUNE_FEM_DISCRETEFUNCTION_HH
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
Definition: bartonnackmanifcheck.hh:61
discrete function space
Definition: discretefunction.hh:584
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: discretefunction.hh:703
void evaluate(const DomainType &x, RangeType &value) const
evaluate the function
Definition: discretefunction.hh:838
DofIteratorType dend()
Obtain the non-constant iterator pointing to the last dof.
Definition: discretefunction.hh:779
Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs() const
Squared small l^2 norm of all dofs.
Definition: discretefunction.hh:799
void print(std ::ostream &out) const
print all DoFs to a stream (for debugging purposes)
Definition: discretefunction_inline.hh:90
SizeType size() const
Return the number of blocks in the block vector.
Definition: discretefunction.hh:755
DiscreteFunctionType & operator+=(const DiscreteFunctionType &g)
add another discrete function to this one
Definition: discretefunction.hh:864
Traits ::LocalDofVectorAllocatorType LocalDofVectorAllocatorType
type of LocalDofVector
Definition: discretefunction.hh:636
void hessian(const DomainType &x, HessianRangeType &hessian) const
evaluate the hessian of the function (const DomainType &x,HessianRangeType &hessian) const
Definition: discretefunction.hh:853
DiscreteFunctionType & operator-=(const DiscreteFunctionType &g)
substract all degrees of freedom from given discrete function using the dof iterators
Definition: discretefunction.hh:875
Impl DiscreteFunctionType
type of the discrete function (Barton-Nackman parameter)
Definition: discretefunction.hh:592
DiscreteFunctionDefault(const std::string &name, const DiscreteFunctionSpaceType &dfSpace)
Constructor storing discrete function space and local function factory.
Definition: discretefunction_inline.hh:26
DiscreteFunctionType & operator-=(const DiscreteFunctionInterface< DFType > &g)
substract all degrees of freedom from given discrete function using the dof iterators
Definition: discretefunction_inline.hh:199
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: discretefunction_inline.hh:273
void communicate()
do default communication of space for this discrete function
Definition: discretefunction.hh:825
Traits ::ConstDofIteratorType ConstDofIteratorType
type of the const dof iterator
Definition: discretefunction.hh:628
std::string & name()
obtain the name of the discrete function
Definition: discretefunction.hh:694
BaseType::GridPartType GridPartType
type of the underlying grid part
Definition: discretefunction.hh:609
DiscreteFunctionType & operator+=(const DiscreteFunctionInterface< DFType > &g)
add another discrete function to this one
Definition: discretefunction_inline.hh:182
Traits ::DofIteratorType DofIteratorType
type of the dof iterator
Definition: discretefunction.hh:626
BaseType ::LocalFunctionType LocalFunctionType
type of local functions
Definition: discretefunction.hh:639
void clear()
set all degrees of freedom to zero
Definition: discretefunction.hh:731
void getLocalDofs(const EntityType &entity, Vector &localDofs) const
fill local Dofs to dof vector associated with the entity
Definition: discretefunction.hh:946
void beginAssemble()
Initiate the assemble of values using the LocalContribution concept.
Definition: discretefunction.hh:971
ConstDofIteratorType dbegin() const
Obtain the constant iterator pointing to the first dof.
Definition: discretefunction.hh:761
bool dofsValid() const
check for NaNs
Definition: discretefunction_inline.hh:100
int blocks() const
obtain total number of blocks, i.e. size / blockSize.
Definition: discretefunction.hh:737
void addScaledLocalDofs(const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs)
add scaled local Dofs to dof vector associated with the entity
Definition: discretefunction.hh:922
DofVectorType::SizeType SizeType
size type of the block vector
Definition: discretefunction.hh:652
const LocalFunctionType localFunction() const
obtain an uninitialized local function (read-write)
Definition: discretefunction.hh:728
ConstDofBlockPtrType block(unsigned int index) const
Definition: discretefunction.hh:746
void addLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
add local Dofs to dof vector associated with the entity
Definition: discretefunction.hh:930
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grid changes a dof compression is done...
Definition: discretefunction.hh:916
void evaluateGlobal(const DomainType &x, Functor functor) const
evaluate functor in global coordinate
Definition: discretefunction_inline.hh:161
ConstDofIteratorType dend() const
Obtain the constant iterator pointing to the last dof.
Definition: discretefunction.hh:773
const std::string & name() const
obtain the name of the discrete function
Definition: discretefunction.hh:691
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: discretefunction_inline.hh:215
DiscreteFunctionSpaceType ::JacobianRangeType JacobianRangeType
type of jacobian
Definition: discretefunction.hh:616
LocalDofVectorAllocatorType & localDofVectorAllocator() const
obtain the local function storage
Definition: discretefunction.hh:962
DofBlockPtrType block(unsigned int index)
Definition: discretefunction.hh:740
DofIteratorType dbegin()
Obtain the non-constant iterator pointing to the first dof.
Definition: discretefunction.hh:767
virtual void insertSubData()
Definition: discretefunction_inline.hh:310
DiscreteFunctionSpaceType ::DomainFieldType DomainFieldType
type of domain field (usually a float type)
Definition: discretefunction.hh:621
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: discretefunction.hh:606
virtual void backup() const
Definition: discretefunction.hh:1011
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
DiscreteFunctionSpaceType ::HessianRangeType HessianRangeType
type of hessian
Definition: discretefunction.hh:618
LocalFunctionType localFunction()
obtain an uninitialized local function (read-write)
Definition: discretefunction.hh:724
virtual void removeSubData()
Definition: discretefunction_inline.hh:326
void jacobian(const DomainType &x, JacobianRangeType &jacobian) const
evaluate the Jacobian of the function
Definition: discretefunction.hh:845
const LocalFunctionType localFunction(const EntityType &entity) const
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:720
const GridPartType & gridPart() const
obtain a reference to the underlying grid part
Definition: discretefunction.hh:712
DiscreteFunctionSpaceType ::RangeType RangeType
type of range vector
Definition: discretefunction.hh:614
void endAssemble(const bool communicate=true)
Finalize the assemble of values using the LocalContribution concept.
Definition: discretefunction.hh:989
DiscreteFunctionType & operator/=(const RangeFieldType &scalar)
devide all DoFs by a scalar factor
Definition: discretefunction.hh:899
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:709
CommDataHandle< Operation >::Type dataHandle(const Operation &operation)
return reference to data handle object
void getLocalDofReferences(const EntityType &entity, LocalDofVectorType &localDofs)
get local Dofs and store a reference to it in the LocalDofVector
Definition: discretefunction.hh:1003
Traits ::LocalDofVectorType LocalDofVectorType
type of LocalDofVector
Definition: discretefunction.hh:634
DiscreteFunctionSpaceType ::DomainType DomainType
type of domain vector
Definition: discretefunction.hh:612
virtual void restore()
Definition: discretefunction.hh:1018
void axpy(const RangeFieldType &s, const DiscreteFunctionInterface< DFType > &g)
axpy operation
Definition: discretefunction_inline.hh:116
void axpy(const RangeFieldType &s, const DiscreteFunctionInterfaceType &g)
axpy operation
Definition: discretefunction.hh:786
DiscreteFunctionSpaceType ::RangeFieldType RangeFieldType
type of range field (usually a float type)
Definition: discretefunction.hh:623
void assign(const DiscreteFunctionType &g)
Definition: discretefunction.hh:815
RangeFieldType scalarProductDofs(const DiscreteFunctionInterface< DFType > &other) const
Scalar product between the DoFs of two discrete functions.
Definition: discretefunction.hh:793
Traits ::DofVectorType DofVectorType
type of DofVector
Definition: discretefunction.hh:631
LocalFunctionType localFunction(const EntityType &entity)
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:716
void setLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
set local Dofs to dof vector associated with the entity
Definition: discretefunction.hh:938
DiscreteFunctionType & operator*=(const RangeFieldType &scalar)
multiply all DoFs with a scalar factor
Definition: discretefunction.hh:887
constexpr int order() const
obtain an upper bound on the polynomial order of the underlying space.
Definition: discretefunction.hh:697
Definition: discretefunction.hh:86
std::string & name()
obtain the name of the discrete function
Definition: discretefunction.hh:195
DiscreteFunctionType & operator+=(const DiscreteFunctionInterface< DFType > &g)
add another discrete function to this one
Definition: discretefunction.hh:486
DiscreteFunctionInterface< Impl > DiscreteFunctionInterfaceType
type of the discrete function interface (this type)
Definition: discretefunction.hh:104
DofIteratorType dbegin()
obtain an iterator pointing to the first DoF (read-write)
Definition: discretefunction.hh:372
DiscreteFunctionSpaceType ::RangeFieldType RangeFieldType
type of range field, i.e. dof type
Definition: discretefunction.hh:109
RangeFieldType scalarProductDofs(const DiscreteFunctionInterface< DFType > &other) const
Scalar product between the DoFs of two discrete functions.
Definition: discretefunction.hh:412
void addLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
add local Dofs to dof vector associated with the entity
Definition: discretefunction.hh:278
Traits ::DiscreteFunctionType DiscreteFunctionType
type of the implementaton (Barton-Nackman)
Definition: discretefunction.hh:95
Traits ::DofIteratorType DofIteratorType
type of the dof iterator used in the discrete function implementation
Definition: discretefunction.hh:131
LocalFunctionType localFunction(const EntityType &entity)
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:231
DiscreteFunctionSpaceType ::DomainFieldType DomainFieldType
type of domain field, i.e. type of coordinate component
Definition: discretefunction.hh:107
void axpy(const RangeFieldType &s, const DiscreteFunctionInterfaceType &g)
axpy operation
Definition: discretefunction.hh:393
DiscreteFunctionTraits< Impl > Traits
type of the traits
Definition: discretefunction.hh:92
int blocks() const
obtain total number of blocks, i.e. size / blockSize.
Definition: 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: discretefunction.hh:267
DiscreteFunctionSpaceType ::JacobianRangeType JacobianRangeType
type of jacobian, i.e. type of evaluated gradient
Definition: discretefunction.hh:115
DiscreteFunctionSpaceType ::RangeType RangeType
type of range, i.e. result of evaluation
Definition: discretefunction.hh:113
void clear()
set all degrees of freedom to zero
Definition: discretefunction.hh:320
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grid changes a dof compression is done...
Definition: discretefunction.hh:552
const std::string & name() const
obtain the name of the discrete function
Definition: discretefunction.hh:186
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: discretefunction.hh:543
const LocalFunctionType localFunction() const
obtain an uninitialized local function (read-write)
Definition: discretefunction.hh:314
Traits ::LocalFunctionType LocalFunctionType
type of local functions
Definition: discretefunction.hh:125
ConstDofIteratorType dbegin() const
obtain an iterator pointing to the first DoF (read-only)
Definition: discretefunction.hh:354
const GridPartType & gridPart() const
obtain a reference to the underlying grid part
Definition: discretefunction.hh:220
DiscreteFunctionInterface()=default
default constructor
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: discretefunction.hh:208
const std::string & order() const
obtain an upper bound on the polynomial order of the underlying space.
Definition: discretefunction.hh:202
DiscreteFunctionSpaceType ::FunctionSpaceType FunctionSpaceType
type of associated function space
Definition: discretefunction.hh:101
void print(std ::ostream &out) const
print all DoFs to a stream (for debugging purposes)
Definition: discretefunction.hh:437
DiscreteFunctionType & operator*=(const RangeFieldType &scalar)
multiply all DoFs by a scalar factor
Definition: discretefunction.hh:509
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: discretefunction.hh:533
void getLocalDofs(const EntityType &entity, Vector &localDofs) const
fill local Dofs to dof vector associated with the entity
Definition: discretefunction.hh:302
CommDataHandle< Operation >::Type dataHandle(const Operation &operation)
return reference to data handle object
Definition: discretefunction.hh:462
bool dofsValid() const
check for NaNs
Definition: discretefunction.hh:445
LocalFunctionType localFunction()
obtain an uninitialized local function (read-write)
Definition: discretefunction.hh:254
const LocalFunctionType localFunction(const EntityType &entity) const
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:242
ConstDofIteratorType dend() const
obtain an iterator pointing behind the last DoF (read-only)
Definition: discretefunction.hh:363
DiscreteFunctionSpaceType ::DomainType DomainType
type of domain, i.e. type of coordinates
Definition: discretefunction.hh:111
DiscreteFunctionType & operator/=(const RangeFieldType &scalar)
devide all DoFs by a scalar factor
Definition: discretefunction.hh:520
DiscreteFunctionSpaceType ::EntityType EntityType
type of entity local functions are defined on
Definition: discretefunction.hh:159
DiscreteFunctionType & operator-=(const DiscreteFunctionInterface< DFType > &g)
substract all degrees of freedom from given discrete function using the dof iterators
Definition: discretefunction.hh:498
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:214
DofIteratorType dend()
obtain an iterator pointing behind the last DoF (read-write)
Definition: discretefunction.hh:381
DiscreteFunctionSpaceType::GridPartType GridPartType
type of the underlying grid part
Definition: discretefunction.hh:118
Traits ::ConstDofIteratorType ConstDofIteratorType
type of the constantdof iterator used in the discrete function implementation
Definition: discretefunction.hh:134
static constexpr std::size_t blockSize
size of the dof blocks
Definition: discretefunction.hh:148
Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs() const
Squared small l^2 norm of all dofs.
Definition: discretefunction.hh:428
void assign(const DiscreteFunctionInterface< DFType > &g)
assign the DoFs of another discrete function to this one
Definition: discretefunction.hh:455
Traits ::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of associated discrete function space
Definition: discretefunction.hh:98
void setLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
set local Dofs to dof vector associated with the entity
Definition: discretefunction.hh:289
int size() const
obtain total number of DoFs
Definition: discretefunction.hh:333
void communicate()
do default communication of space for this discrete function
Definition: discretefunction.hh:468
Traits ::DofVectorType DofVectorType
type of the dof vector used in the discrete function implementation
Definition: discretefunction.hh:128
BaseType ::MappingType MappingType
type of mapping base class for this discrete function
Definition: discretefunction.hh:143
DiscreteFunctionSpaceType ::GridType GridType
type of the underlying grid
Definition: discretefunction.hh:122
Traits ::BlockMapperType BlockMapperType
type of block mapper of this space
Definition: discretefunctionspace.hh:203
Abstract class representing a function.
Definition: function.hh:50
Mapping< DomainFieldType, RangeFieldType, DomainType, RangeType > MappingType
type of mapping base class
Definition: function.hh:76
base class for determing whether a function has local functions or not
Definition: discretefunction.hh:57
abstract interface for an input stream
Definition: streams.hh:190
base class for determing whether a class is a discrete function or not
Definition: discretefunction.hh:53
check for sets of entities for the load balance procedure
Definition: commoperations.hh:216
abstract interface for an output stream
Definition: streams.hh:48
class with singleton instance managing all persistent objects
Definition: persistencemanager.hh:141
base class for persistent objects
Definition: persistencemanager.hh:101
forward declaration
Definition: discretefunction.hh:51
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
This file implements a dense vector with a dynamic size.
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const OtherDiscreteFunctionType &y) const
evaluate scalar product and omit auxiliary nodes
Definition: scalarproducts.hh:101
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:259
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:237
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.80.0 (May 10, 22:30, 2024)