dune-fem  2.4.1-rc
discretefunction.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_DISCRETEFUNCTION_HH
2 #define DUNE_FEM_DISCRETEFUNCTION_HH
3 
4 // C++ includes
5 #include <string>
6 
7 // dune-common inlcudes
8 #include <dune/common/version.hh>
9 
10 // dune-fem includes
19 #include <dune/fem/misc/debug.hh>
20 #include <dune/fem/misc/functor.hh>
23 #include <dune/fem/version.hh>
26 
27 
28 namespace Dune
29 {
30 
31  namespace Fem
32  {
33 
51  {};
52 
56  {};
57 
58 
59  template< class DiscreteFunction >
61 
62  template< class Traits >
64 
65  //----------------------------------------------------------------------
66  //-
67  //- --DiscreteFunctionInterface
68  //-
69  //----------------------------------------------------------------------
80  template< class Impl >
82  : public Function< typename DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType, Impl >,
83  public IsDiscreteFunction,
84  public HasLocalFunction
85  {
88 
89  public:
92 
94  typedef typename Traits :: DiscreteFunctionType DiscreteFunctionType;
95 
97  typedef typename Traits :: DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
98 
101 
103  typedef typename DiscreteFunctionSpaceType :: DomainFieldType DomainFieldType;
105  typedef typename DiscreteFunctionSpaceType :: RangeFieldType RangeFieldType;
107  typedef typename DiscreteFunctionSpaceType :: DomainType DomainType;
109  typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
111  typedef typename DiscreteFunctionSpaceType :: JacobianRangeType JacobianRangeType;
112 
114  typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
115 
117  typedef typename DiscreteFunctionSpaceType :: GridType GridType;
118 
120  typedef typename Traits :: LocalFunctionType LocalFunctionType;
121 
123  typedef typename Traits :: DofVectorType DofVectorType;
124 
126  typedef typename Traits :: DofIteratorType DofIteratorType;
127 
129  typedef typename Traits :: ConstDofIteratorType ConstDofIteratorType;
130 
131  typedef typename Traits :: DofType DofType;
132  typedef typename Traits :: DofBlockType DofBlockType;
133  typedef typename Traits :: ConstDofBlockType ConstDofBlockType;
134  typedef typename Traits :: DofBlockPtrType DofBlockPtrType;
135  typedef typename Traits :: ConstDofBlockPtrType ConstDofBlockPtrType;
136 
139 
141  enum { blockSize = DiscreteFunctionSpaceType::localBlockSize };
142 
143  template< class Operation >
145  {
146  typedef typename DiscreteFunctionSpaceType
149  };
150 
152  typedef typename DiscreteFunctionSpaceType :: EntityType EntityType;
153 
154  protected:
155  using BaseType::asImp;
156 
159  {}
160 
161  private:
162  // prohibit copying and assignment
163  DiscreteFunctionInterface ( const ThisType &other );
164  ThisType &operator= ( const ThisType &other );
165 
166  public:
167  DofVectorType& dofVector() { return asImp().dofVector(); }
168  const DofVectorType& dofVector() const { return asImp().dofVector(); }
169 
174  const std::string &name () const
175  {
176  return asImp().name();
177  }
178 
180  const DiscreteFunctionSpaceType &space () const
181  {
182  return asImp().space();
183  }
184 
186  const GridPartType &gridPart () const
187  {
188  return asImp().gridPart();
189  }
190 
196  LocalFunctionType localFunction ( const EntityType &entity )
197  {
198  return asImp().localFunction( entity );
199  }
200 
206  const LocalFunctionType localFunction ( const EntityType &entity ) const
207  {
208  return asImp().localFunction( entity );
209  }
210 
213  inline void clear()
214  {
215  asImp().clear();
216  }
217 
226  inline int size() const
227  {
228  return asImp().size();
229  }
230 
238  inline int blocks() const
239  {
240  return asImp().blocks();
241  }
242 
247  inline ConstDofBlockPtrType block ( unsigned int index ) const
248  {
249  return asImp().block( index );
250  }
251 
256  inline DofBlockPtrType block ( unsigned int index )
257  {
258  return asImp().block( index );
259  }
260 
265  inline ConstDofIteratorType dbegin () const
266  {
267  return asImp().dbegin ();
268  }
269 
274  inline ConstDofIteratorType dend () const
275  {
276  return asImp().dend ();
277  }
278 
279 
284  inline DofIteratorType dbegin ()
285  {
286  return asImp().dbegin ();
287  }
288 
293  inline DofIteratorType dend ()
294  {
295  return asImp().dend ();
296  }
297 
310  DUNE_VERSION_DEPRECATED(3,0,remove)
311  inline RangeFieldType *allocDofPointer () const
312  {
313  return asImp().allocDofPointer();
314  }
315 
331  DUNE_VERSION_DEPRECATED(3,0,remove)
332  inline void freeDofPointer( RangeFieldType *dofPointer )
333  {
334  asImp().freeDofPointer( dofPointer );
335  }
336 
351  DUNE_VERSION_DEPRECATED(3,0,remove)
352  inline void freeDofPointerNoCopy( const RangeFieldType *dofPointer ) const
353  {
354  asImp().freeDofPointerNoCopy( dofPointer );
355  }
356 
365  {
366  asImp().axpy( s, g );
367  }
368 
382  template <class DFType>
383  inline RangeFieldType
385  {
386  return asImp().scalarProductDofs( other );
387  }
388 
400  inline typename Dune::FieldTraits< RangeFieldType >::real_type
401  normSquaredDofs ( ) const
402  {
403  return asImp().normSquaredDofs( );
404  }
405 
410  inline void print( std :: ostream &out ) const
411  {
412  asImp().print( out );
413  }
414 
418  bool dofsValid () const
419  {
420  return asImp().dofsValid();
421  }
422 
427  template < class DFType >
429  {
430  asImp().assign( g );
431  }
432 
434  template< class Operation >
435  typename CommDataHandle< Operation > :: Type
436  dataHandle( const Operation *operation )
437  {
438  return asImp().dataHandle( operation );
439  }
440 
444  inline void communicate()
445  {
446  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION( asImp().communicate() );
447  }
448 
455  template < class DFType >
457  {
458  return asImp().operator+=( g );
459  }
460 
465  template < class DFType >
467  {
468  return asImp().operator-=( g );
469  }
470 
477  inline DiscreteFunctionType &operator*= ( const RangeFieldType &scalar )
478  {
479  return asImp() *= scalar;
480  }
481 
488  inline DiscreteFunctionType &operator/= ( const RangeFieldType &scalar )
489  {
490  return asImp() /= scalar;
491  }
492 
497  template< class StreamTraits >
499  {
500  asImp().read( in );
501  }
502 
507  template< class StreamTraits >
508  inline void write ( OutStreamInterface< StreamTraits > &out ) const
509  {
510  asImp().write( out );
511  }
512 
517  inline void enableDofCompression()
518  {
519  asImp().enableDofCompression();
520  }
521 
522  // this needs to be revised, the definition should be in GridPart
523  // further discussion needed
526  {
527  return DefaultLoadBalanceContainsCheckType( *this );
528  }
529  };
530 
531 
532 
533  //*************************************************************************
534  //
535  // --DiscreteFunctionDefault
536  //
545  //*************************************************************************
546  template< class Impl >
548  : public DiscreteFunctionInterface< Impl > ,
549  public PersistentObject
550  {
553 
554  public:
555  typedef typename BaseType :: Traits Traits;
556 
558  typedef Impl DiscreteFunctionType;
559 
561 
562  private:
564 
565  enum { myId_ = 0 };
566 
568 
569  public:
572 
575 
577  typedef typename DiscreteFunctionSpaceType :: DomainType DomainType;
579  typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
581  typedef typename DiscreteFunctionSpaceType :: JacobianRangeType JacobianRangeType;
583  typedef typename DiscreteFunctionSpaceType :: HessianRangeType HessianRangeType;
584 
586  typedef typename DiscreteFunctionSpaceType :: DomainFieldType DomainFieldType;
588  typedef typename DiscreteFunctionSpaceType :: RangeFieldType RangeFieldType;
589 
591  typedef typename Traits :: DofIteratorType DofIteratorType;
593  typedef typename Traits :: ConstDofIteratorType ConstDofIteratorType;
594 
596  typedef typename Traits :: DofVectorType DofVectorType;
597 
599  typedef typename Traits :: LocalDofVectorType LocalDofVectorType;
601  typedef typename Traits :: LocalDofVectorAllocatorType LocalDofVectorAllocatorType;
602 
605 
610 
612 
613  typedef typename BaseType :: DofType DofType;
614 
616  typedef typename DofVectorType::SizeType SizeType;
617 
619  enum { blockSize = BaseType::blockSize };
620 
621  template< class Operation >
623  : public BaseType :: template CommDataHandle< Operation >
624  {};
625 
626  private:
627  struct LocalFunctionEvaluateFunctor
628  {
629  typedef typename LocalFunctionType::LocalCoordinateType LocalCoordinateType;
630  typedef typename LocalFunctionType::RangeType RangeType;
631 
632  LocalFunctionEvaluateFunctor ( RangeType &value ) : value_( value ) {}
633 
634  void operator() ( const LocalCoordinateType &x, const LocalFunctionType &localFunction )
635  {
636  localFunction.evaluate( x, value_ );
637  }
638 
639  private:
640  RangeType &value_;
641  };
642 
643  struct LocalFunctionJacobianFunctor
644  {
645  typedef typename LocalFunctionType::LocalCoordinateType LocalCoordinateType;
646  typedef typename LocalFunctionType::JacobianRangeType JacobianRangeType;
647 
648  LocalFunctionJacobianFunctor ( JacobianRangeType &jacobian ) : jacobian_( jacobian ) {}
649 
650  void operator() ( const LocalCoordinateType &x, const LocalFunctionType &localFunction )
651  {
652  localFunction.jacobian( x, jacobian_);
653  }
654 
655  private:
656  JacobianRangeType &jacobian_;
657  };
658 
659  struct LocalFunctionHessianFunctor
660  {
661  typedef typename LocalFunctionType::LocalCoordinateType LocalCoordinateType;
662  typedef typename LocalFunctionType::HessianRangeType HessianRangeType;
663 
664  LocalFunctionHessianFunctor ( HessianRangeType &hessian ) : hessian_( hessian ) {}
665 
666  void operator() ( const LocalCoordinateType &x, const LocalFunctionType &localFunction )
667  {
668  localFunction.hessian( x, hessian_ );
669  }
670 
671  private:
672  HessianRangeType &hessian_;
673  };
674 
675  protected:
676  using BaseType :: asImp;
677 
688  DiscreteFunctionDefault ( const std::string &name,
689  const DiscreteFunctionSpaceType &dfSpace );
690 
691  private:
692  // prohibit copying and assignment
693  inline DiscreteFunctionDefault ( const ThisType & );
694  ThisType &operator= ( const ThisType & );
695 
696  public:
697  // Default Implementations
698  // -----------------------
699 
701  const std::string &name () const { return name_; }
702 
704  const DiscreteFunctionSpaceType &space () const { return dfSpace_; }
705 
707  const GridPartType &gridPart () const { return space().gridPart(); }
708 
710  LocalFunctionType localFunction ( const EntityType &entity ) { return LocalFunctionType( asImp(), entity ); }
711 
713  const LocalFunctionType localFunction ( const EntityType &entity ) const { return LocalFunctionType( asImp(), entity ); }
714 
716  void clear() { dofVector().clear(); }
717 
718  DofVectorType& dofVector() { return asImp().dofVector(); }
719  const DofVectorType& dofVector() const { return asImp().dofVector(); }
720 
722  int blocks() const { return dofVector().size(); }
723 
725  DofBlockPtrType block ( unsigned int index )
726  {
727  return dofVector().blockPtr( index );
728  }
729 
731  ConstDofBlockPtrType block ( unsigned int index ) const
732  {
733  return dofVector().blockPtr( index );
734  }
735 
740  SizeType size () const { return dofVector().size() * blockSize; }
741 
746  ConstDofIteratorType dbegin () const { return dofVector().begin(); }
747 
752  DofIteratorType dbegin () { return dofVector().begin(); }
753 
758  ConstDofIteratorType dend () const { return dofVector().end(); }
759 
764  DofIteratorType dend () { return dofVector().end(); }
765 
771  inline RangeFieldType *allocDofPointer () const;
772 
778  inline void freeDofPointer( RangeFieldType *dofPointer );
779 
785  inline void freeDofPointerNoCopy( const RangeFieldType *dofPointer ) const;
786 
788  template <class DFType>
789  void axpy ( const RangeFieldType &s, const DiscreteFunctionInterface< DFType > &g );
790 
792  void axpy ( const RangeFieldType &s, const DiscreteFunctionInterfaceType& g )
793  {
794  dofVector().axpy( s, g.dofVector() );
795  }
796 
798  template <class DFType>
799  inline RangeFieldType
801  {
802  return scalarProduct_.scalarProductDofs( *this, other );
803  }
804 
806  inline typename Dune::FieldTraits< RangeFieldType >::real_type
807  normSquaredDofs ( ) const { return std::real( (*this).scalarProductDofs( *this )); }
808 
810  void print ( std :: ostream &out ) const;
811 
813  inline bool dofsValid () const;
814 
816  template <class DFType>
817  void assign ( const DiscreteFunctionInterface< DFType > &g );
818 
820  void assign ( const DiscreteFunctionType &g )
821  {
822  dofVector() = g.dofVector();
823  }
824 
826  template< class Operation >
827  typename CommDataHandle< Operation > :: Type
828  dataHandle ( const Operation *operation );
829 
831  void communicate()
832  {
834  this->space().communicate( asImp() );
835  }
836 
838  inline void evaluate ( const DomainType &x, RangeType &value ) const
839  {
840  LocalFunctionEvaluateFunctor functor( value );
841  asImp().evaluateGlobal( x, functor );
842  }
843 
845  inline void jacobian ( const DomainType &x, JacobianRangeType &jacobian ) const
846  {
847  LocalFunctionJacobianFunctor functor( jacobian );
848  asImp().evaluateGlobal( x, functor );
849  }
850 
852  inline void hessian ( const DomainType &x, HessianRangeType &hessian ) const
853  {
854  LocalFunctionHessianFunctor functor( hessian );
855  asImp().evaluateGlobal( x, functor );
856  }
857 
859  template <class DFType>
860  DiscreteFunctionType& operator+=(const DiscreteFunctionInterface< DFType > &g);
861 
863  DiscreteFunctionType& operator+=(const DiscreteFunctionType& g)
864  {
865  dofVector() += g.dofVector();
866  return asImp();
867  }
868 
870  template <class DFType>
871  DiscreteFunctionType& operator-=(const DiscreteFunctionInterface< DFType > &g);
872 
874  DiscreteFunctionType& operator-=(const DiscreteFunctionType& g)
875  {
876  dofVector() -= g.dofVector();
877  return asImp();
878  }
879 
886  inline DiscreteFunctionType &operator*= ( const RangeFieldType &scalar );
887 
894  inline DiscreteFunctionType &operator/= ( const RangeFieldType &scalar ) { return BaseType :: operator*=( RangeFieldType(1 ) / scalar ); }
895 
897  template< class StreamTraits >
898  inline void read ( InStreamInterface< StreamTraits > &in );
899 
901  template< class StreamTraits >
902  inline void write ( OutStreamInterface< StreamTraits > &out ) const;
903 
908  inline void enableDofCompression () {}
909 
910 
911  public:
912  // Non-Interface Methods
913  // ---------------------
914 
915  template <class DFType>
916  inline bool operator== ( const DiscreteFunctionInterface< DFType> &g ) const;
917 
918  template <class DFType>
919  inline bool operator!= ( const DiscreteFunctionInterface< DFType > &g ) const { return !(operator==( g )); }
920 
925  inline LocalDofVectorAllocatorType &localDofVectorAllocator () const { return ldvAllocator_; }
926 
928  template< class LocalDofs >
929  void addScaledLocalDofs ( const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs )
930  {
932  AssignFunctorType assignFunctor( localDofs, s );
933 
934  DofBlockFunctor< DiscreteFunctionType, AssignFunctorType > functor( asImp(), assignFunctor );
935  space().blockMapper().mapEach( entity, functor );
936  }
937 
939  template< class LocalDofs >
940  void addLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
941  {
942  typedef LeftAdd< const LocalDofs > AssignFunctorType;
943  AssignFunctorType assignFunctor( localDofs );
944 
945  DofBlockFunctor< DiscreteFunctionType, AssignFunctorType > functor( asImp(), assignFunctor );
946  space().blockMapper().mapEach( entity, functor );
947  }
948 
950  template< class LocalDofs >
951  void setLocalDofs ( const EntityType &entity, const LocalDofs &localDofs )
952  {
953  typedef LeftAssign< const LocalDofs > AssignFunctorType;
954  AssignFunctorType assignFunctor( localDofs );
955 
956  DofBlockFunctor< DiscreteFunctionType, AssignFunctorType > functor( asImp(), assignFunctor );
957  space().blockMapper().mapEach( entity, functor );
958  }
959 
961  void getLocalDofs ( const EntityType &entity, LocalDofVectorType &localDofs )
962  {
963  typedef AssignVectorReference< LocalDofVectorType > AssignFunctorType;
964  AssignFunctorType assignFunctor( localDofs );
965 
966  DofBlockFunctor< DiscreteFunctionType, AssignFunctorType > functor( asImp(), assignFunctor );
967  space().blockMapper().mapEach( entity, functor );
968  }
969 
971  template< class A >
972  void getLocalDofs ( const EntityType &entity, Dune::DynamicVector< DofType, A > &localDofs ) const
973  {
974  typedef AssignFunctor< Dune::DynamicVector< DofType, A > > AssignFunctorType;
975  AssignFunctorType assignFunctor( localDofs );
976 
978  space().blockMapper().mapEach( entity, functor );
979  }
980 
981  protected:
983  virtual void backup() const
984  {
985  // get backup stream from persistence manager and write to it
987  }
988 
990  virtual void restore()
991  {
992  // get restore stream from persistence manager and read from it
994  }
995 
997  virtual void insertSubData();
998 
1000  virtual void removeSubData();
1001 
1003  template< class Functor >
1004  void evaluateGlobal ( const DomainType &x, Functor functor ) const;
1005 
1006  // only PersistenceManager should call backup and restore
1007  friend class PersistenceManager;
1008 
1009  protected:
1010  const DiscreteFunctionSpaceType &dfSpace_;
1011 
1012  // the local function storage
1013  typename Traits :: LocalDofVectorStackType ldvStack_;
1014  mutable LocalDofVectorAllocatorType ldvAllocator_;
1015 
1017 
1018  protected:
1019  std::string name_;
1020  ScalarProductType scalarProduct_;
1021  }; // end class DiscreteFunctionDefault
1022 
1023 
1024  template< class DiscreteFunction >
1026 
1033  template< typename DiscreteFunctionSpace, typename DofVector >
1035  {
1036  typedef DofVector DofVectorType;
1037 
1039  typedef typename DiscreteFunctionSpaceType::DomainType DomainType;
1040  typedef typename DiscreteFunctionSpaceType::RangeType RangeType;
1041 
1042  typedef typename DofVectorType::IteratorType DofIteratorType;
1043  typedef typename DofVectorType::ConstIteratorType ConstDofIteratorType;
1044  typedef typename DofVectorType::DofBlockType DofBlockType;
1045  typedef typename DofVectorType::ConstDofBlockType ConstDofBlockType;
1046  typedef typename DofVectorType::DofBlockPtrType DofBlockPtrType;
1047  typedef typename DofVectorType::ConstDofBlockPtrType ConstDofBlockPtrType;
1048 
1049  typedef typename DiscreteFunctionSpaceType::BlockMapperType MapperType;
1050  typedef typename DofVectorType::FieldType DofType;
1051 
1055 
1056  //typedef MutableLocalFunction< DiscreteFunctionType > LocalFunctionType;
1057  };
1058 
1059 
1061 
1062  } // end namespace Fem
1063 
1064 } // end namespace Dune
1065 
1066 #include "discretefunction_inline.hh"
1067 
1068 #include "gridfunctionadapter.hh"
1069 #endif // #ifndef DUNE_FEM_DISCRETEFUNCTION_HH
DofVectorType::DofBlockPtrType DofBlockPtrType
Definition: discretefunction.hh:1046
void axpy(const RangeFieldType &s, const DiscreteFunctionInterfaceType &g)
axpy operation
Definition: discretefunction.hh:792
Definition: discretefunction.hh:622
const DofVectorType & dofVector() const
Definition: discretefunction.hh:719
DiscreteFunctionSpaceType::BlockMapperType MapperType
Definition: discretefunction.hh:1049
RangeFieldType scalarProductDofs(const DiscreteFunctionInterface< DFType > &other) const
Scalar product between the DoFs of two discrete functions.
Definition: discretefunction.hh:800
DiscreteFunctionSpace DiscreteFunctionSpaceType
Definition: discretefunction.hh:1038
RangeFieldType scalarProductDofs(const DiscreteFunctionInterface< DFType > &other) const
Scalar product between the DoFs of two discrete functions.
Definition: discretefunction.hh:384
void evaluate(const DomainType &x, RangeType &value) const
evaluate the function
Definition: discretefunction.hh:838
LocalFunctionType localFunction(const EntityType &entity)
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:196
BaseType::DofBlockPtrType DofBlockPtrType
Definition: discretefunction.hh:608
DofVectorType::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: discretefunction.hh:1047
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grdi changes a dof compression is done...
Definition: discretefunction.hh:908
const LocalFunctionType localFunction(const EntityType &entity) const
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:206
Traits::LocalDofVectorStackType ldvStack_
Definition: discretefunction.hh:1013
DiscreteFunctionSpaceType::DomainType DomainType
Definition: discretefunction.hh:1039
LocalFunctionType localFunction(const EntityType &entity)
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:710
Definition: function/common/functor.hh:39
DofVectorType::ConstDofBlockType ConstDofBlockType
Definition: discretefunction.hh:1045
A mapping from one vector space into another This class describes a general mapping from the domain v...
Definition: mapping.hh:46
DiscreteFunctionSpaceType::template CommDataHandle< DiscreteFunctionType, Operation >::Type Type
Definition: discretefunction.hh:148
Traits::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of associated discrete function space
Definition: discretefunction.hh:97
check for sets of entities for the load balance procedure
Definition: commoperations.hh:351
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:180
DiscreteFunctionType & operator+=(const DiscreteFunctionInterface< DFType > &g)
add another discrete function to this one
Definition: discretefunction.hh:456
Traits class for a DiscreteFunction.
Definition: discretefunction.hh:60
static RestoreStreamType & restoreStream()
Definition: persistencemanager.hh:338
DofVectorType::ConstIteratorType ConstDofIteratorType
Definition: discretefunction.hh:1043
ConstDofIteratorType dbegin() const
Obtain the constant iterator pointing to the first dof.
Definition: discretefunction.hh:746
class with singleton instance managing all persistent objects
Definition: persistencemanager.hh:136
virtual void backup() const
Definition: discretefunction.hh:983
Definition: discretefunction.hh:144
BaseType::Traits Traits
Definition: discretefunction.hh:555
void hessian(const DomainType &x, HessianRangeType &hessian) const
evaluate the hessian of the function (const DomainType &x,HessianRangeType &hessian) const ...
Definition: discretefunction.hh:852
BaseType::DofBlockType DofBlockType
Definition: discretefunction.hh:606
DiscreteFunctionSpaceType::DomainType DomainType
type of domain, i.e. type of coordinates
Definition: discretefunction.hh:107
Definition: discretefunction.hh:50
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
type of jacobian
Definition: discretefunction.hh:581
void axpy(const RangeFieldType &s, const DiscreteFunctionInterfaceType &g)
axpy operation
Definition: discretefunction.hh:364
Traits::DofType DofType
Definition: discretefunction.hh:131
Traits::DofIteratorType DofIteratorType
type of the dof iterator
Definition: discretefunction.hh:591
DofBlockPtrType block(unsigned int index)
obtain pointer to block of discrete function with block number index (read-only)
Definition: discretefunction.hh:725
BaseType::LocalFunctionType LocalFunctionType
type of local functions
Definition: discretefunction.hh:604
void assign(const DiscreteFunctionInterface< DFType > &g)
assign the DoFs of another discrete function to this one
Definition: discretefunction.hh:428
Construct a vector with a dynamic size.
Definition: referencevector.hh:23
std::string name_
Definition: discretefunction.hh:1019
DofIteratorType dend()
Obtain the non-constant iterator pointing to the last dof.
Definition: discretefunction.hh:764
Definition: discretefunction.hh:63
Definition: debug.hh:140
bool dofsValid() const
check for NaNs
Definition: discretefunction.hh:418
const LocalFunctionType localFunction(const EntityType &entity) const
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:713
BaseType::MappingType MappingType
type of mapping base class for this discrete function
Definition: discretefunction.hh:138
const GridPartType & gridPart() const
obtain a reference to the underlying grid part
Definition: discretefunction.hh:186
void assign(const DiscreteFunctionType &g)
Definition: discretefunction.hh:820
const DiscreteFunctionSpaceType & dfSpace_
Definition: discretefunction.hh:1010
int blocks() const
obtain total number of blocks, i.e. size / blockSize.
Definition: discretefunction.hh:722
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
type of jacobian, i.e. type of evaluated gradient
Definition: discretefunction.hh:111
DofVectorType::DofBlockType DofBlockType
Definition: discretefunction.hh:1044
Definition: function/common/functor.hh:119
Traits::DofIteratorType DofIteratorType
Type of the dof iterator used in the discrete function implementation.
Definition: discretefunction.hh:126
CommDataHandle< Operation >::Type dataHandle(const Operation *operation)
return reference to data handle object
Definition: discretefunction.hh:436
DiscreteFunctionSpaceType::EntityType EntityType
type of entity local functions are defined on
Definition: discretefunction.hh:152
virtual void restore()
Definition: discretefunction.hh:990
DiscreteFunctionSpaceType::RangeType RangeType
type of range vector
Definition: discretefunction.hh:579
void axpy(const T &a, const T &x, T &y)
Definition: space/basisfunctionset/functor.hh:37
Definition: misc/functor.hh:30
This file implements a dense vector with a dynamic size.
DiscreteFunctionType & operator+=(const DiscreteFunctionType &g)
add another discrete function to this one
Definition: discretefunction.hh:863
ConstDofIteratorType dbegin() const
obtain an iterator pointing to the first DoF (read-only)
Definition: discretefunction.hh:265
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: discretefunction.hh:508
DofVectorType::SizeType SizeType
size type of the block vector
Definition: discretefunction.hh:616
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field (usually a float type)
Definition: discretefunction.hh:588
BaseType::EntityType EntityType
Definition: discretefunction.hh:611
void jacobian(const DomainType &x, JacobianRangeType &jacobian) const
evaluate the Jacobian of the function
Definition: discretefunction.hh:845
bool operator!=(const Double &a, const Double &b)
Definition: double.hh:629
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
type of domain field (usually a float type)
Definition: discretefunction.hh:586
Impl DiscreteFunctionType
type of the discrete function (Barton-Nackman parameter)
Definition: discretefunction.hh:558
BaseType::GridPartType GridPartType
type of the underlying grid part
Definition: discretefunction.hh:574
LocalDofVectorAllocatorType ldvAllocator_
Definition: discretefunction.hh:1014
bool operator==(const Double &a, const Double &b)
Definition: double.hh:589
Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs() const
Squared small l^2 norm of all dofs.
Definition: discretefunction.hh:401
Definition: function/common/functor.hh:19
SizeType size() const
Return the number of blocks in the block vector.
Definition: discretefunction.hh:740
const DofVectorType & dofVector() const
Definition: discretefunction.hh:168
static BackupStreamType & backupStream()
Definition: persistencemanager.hh:333
const GridPartType & gridPart() const
obtain a reference to the underlying grid part
Definition: discretefunction.hh:707
void print(std::ostream &out) const
print all DoFs to a stream (for debugging purposes)
Definition: discretefunction.hh:410
Definition: coordinate.hh:4
DiscreteFunctionTraits< Impl > Traits
type of the traits
Definition: discretefunction.hh:91
Traits::DofVectorType DofVectorType
Type of the dof vector used in the discrete function implementation.
Definition: discretefunction.hh:123
Traits::DiscreteFunctionType DiscreteFunctionType
type of the implementaton (Barton-Nackman)
Definition: discretefunction.hh:94
abstract interface for an input stream
Definition: streams.hh:177
void communicate()
do default communication of space for this discrete function
Definition: discretefunction.hh:831
LocalDofVectorAllocatorType & localDofVectorAllocator() const
obtain the local function storage
Definition: discretefunction.hh:925
Traits::ConstDofIteratorType ConstDofIteratorType
type of the const dof iterator
Definition: discretefunction.hh:593
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: discretefunction.hh:498
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: discretefunction.hh:571
int size() const
obtain total number of DoFs
Definition: discretefunction.hh:226
void getLocalDofs(const EntityType &entity, LocalDofVectorType &localDofs)
get local Dofs and store a reference to it in the LocalDofVector
Definition: discretefunction.hh:961
const std::string & name() const
obtain the name of the discrete function
Definition: discretefunction.hh:701
#define DUNE_VERSION_DEPRECATED(major, minor, newmethod)
Definition: version.hh:20
Definition: discretefunction.hh:1034
void communicate()
do default communication of space for this discrete function
Definition: discretefunction.hh:444
DiscreteFunctionInterface< Impl > DiscreteFunctionInterfaceType
type of the discrete function interface (this type)
Definition: discretefunction.hh:100
Definition: function/common/functor.hh:81
void getLocalDofs(const EntityType &entity, Dune::DynamicVector< DofType, A > &localDofs) const
get local Dofs and store the values in LocalDofVector
Definition: discretefunction.hh:972
ConstDofBlockPtrType block(unsigned int index) const
obtain pointer to block of discrete function with block number index
Definition: discretefunction.hh:731
DofIteratorType dbegin()
obtain an iterator pointing to the first DoF (read-write)
Definition: discretefunction.hh:284
Definition: stackallocator.hh:61
DiscreteFunctionInterface()
default constructor
Definition: discretefunction.hh:158
BaseType::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: discretefunction.hh:609
DofIteratorType dend()
obtain an iterator pointing behind the last DoF (read-write)
Definition: discretefunction.hh:293
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
type of domain field, i.e. type of coordinate component
Definition: discretefunction.hh:103
DofVectorType & dofVector()
Definition: discretefunction.hh:167
DofIteratorType dbegin()
Obtain the non-constant iterator pointing to the first dof.
Definition: discretefunction.hh:752
DiscreteFunctionSpaceType::GridPartType GridPartType
type of the underlying grid part
Definition: discretefunction.hh:114
DofVectorType::IteratorType DofIteratorType
Definition: discretefunction.hh:1042
DiscreteFunctionType & operator-=(const DiscreteFunctionInterface< DFType > &g)
substract all degrees of freedom from given discrete function using the dof iterators ...
Definition: discretefunction.hh:466
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
type of hessian
Definition: discretefunction.hh:583
base class for persistent objects
Definition: persistencemanager.hh:96
double real(const std::complex< Double > &x)
Definition: double.hh:890
void addLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
add local Dofs to dof vector
Definition: discretefunction.hh:940
DiscreteFunctionSpaceType::RangeType RangeType
Definition: discretefunction.hh:1040
DiscreteFunctionSpaceType::DomainType DomainType
type of domain vector
Definition: discretefunction.hh:577
Traits::DofVectorType DofVectorType
type of DofVector
Definition: discretefunction.hh:596
DofBlockPtrType block(unsigned int index)
obtain pointer to block of discrete function with block number index (read-only)
Definition: discretefunction.hh:256
int blocks() const
obtain total number of blocks, i.e. size / blockSize.
Definition: discretefunction.hh:238
DiscreteFunctionSpaceType::RangeType RangeType
type of range, i.e. result of evaluation
Definition: discretefunction.hh:109
DynamicReferenceVector< DofType, LocalDofVectorAllocatorType > LocalDofVectorType
Definition: discretefunction.hh:1054
Traits::DofBlockPtrType DofBlockPtrType
Definition: discretefunction.hh:134
StackAllocator< DofType, LocalDofVectorStackType * > LocalDofVectorAllocatorType
Definition: discretefunction.hh:1053
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field, i.e. dof type
Definition: discretefunction.hh:105
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grdi changes a dof compression is done...
Definition: discretefunction.hh:517
BaseType::ConstDofBlockType ConstDofBlockType
Definition: discretefunction.hh:607
BaseType::DofType DofType
Definition: discretefunction.hh:613
discrete function space
Traits::ConstDofBlockType ConstDofBlockType
Definition: discretefunction.hh:133
ThreadSafeValue< UninitializedObjectStack > LocalDofVectorStackType
Definition: discretefunction.hh:1052
DefaultLoadBalanceContainsCheckType defaultLoadBalanceContainsCheck() const
Definition: discretefunction.hh:525
Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs() const
Squared small l^2 norm of all dofs.
Definition: discretefunction.hh:807
Definition: discretefunction.hh:1025
ScalarProductType scalarProduct_
Definition: discretefunction.hh:1020
Traits::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: discretefunction.hh:135
Abstract class representing a function.
Definition: function.hh:43
void clear()
set all degrees of freedom to zero
Definition: discretefunction.hh:716
Traits::LocalDofVectorType LocalDofVectorType
type of LocalDofVector
Definition: discretefunction.hh:599
DofVectorType::FieldType DofType
Definition: discretefunction.hh:1050
const std::string & name() const
obtain the name of the discrete function
Definition: discretefunction.hh:174
void clear()
set all degrees of freedom to zero
Definition: discretefunction.hh:213
DofVector DofVectorType
Definition: discretefunction.hh:1036
DiscreteFunctionType & operator-=(const DiscreteFunctionType &g)
substract all degrees of freedom from given discrete function using the dof iterators ...
Definition: discretefunction.hh:874
Definition: discretefunction.hh:55
Traits::LocalDofVectorAllocatorType LocalDofVectorAllocatorType
type of LocalDofVector
Definition: discretefunction.hh:601
Traits::LocalFunctionType LocalFunctionType
type of local functions
Definition: discretefunction.hh:120
static bool singleThreadMode()
returns true if program is operating on one thread currently
Definition: threadmanager.hh:217
Traits::ConstDofIteratorType ConstDofIteratorType
Type of the constantdof iterator used in the discrete function implementation.
Definition: discretefunction.hh:129
ConstDofBlockPtrType block(unsigned int index) const
obtain pointer to block of discrete function with block number index
Definition: discretefunction.hh:247
DofVectorType & dofVector()
Definition: discretefunction.hh:718
BaseType::DiscreteFunctionInterfaceType DiscreteFunctionInterfaceType
Definition: discretefunction.hh:560
Definition: function/common/functor.hh:61
ConstDofIteratorType dend() const
Obtain the constant iterator pointing to the last dof.
Definition: discretefunction.hh:758
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:704
Traits::DofBlockType DofBlockType
Definition: discretefunction.hh:132
LoadBalanceLeafData< ThisType > DefaultLoadBalanceContainsCheckType
Definition: discretefunction.hh:524
ConstDofIteratorType dend() const
obtain an iterator pointing behind the last DoF (read-only)
Definition: discretefunction.hh:274
abstract interface for an output stream
Definition: streams.hh:44
void setLocalDofs(const EntityType &entity, const LocalDofs &localDofs)
set local Dofs to dof vector
Definition: discretefunction.hh:951
DiscreteFunctionSpaceType::GridType GridType
Type of the underlying grid.
Definition: discretefunction.hh:117
Definition: discretefunction.hh:81
DebugLock dofPointerLock_
Definition: discretefunction.hh:1016
void addScaledLocalDofs(const EntityType &entity, const RangeFieldType &s, const LocalDofs &localDofs)
add scaled local Dofs to dof vector
Definition: discretefunction.hh:929