Logo DUNE-FEM
Logo Albert-Ludwigs-Universität Freiburg Logo Abteilung für Angewandte Mathematik
fvspacebasefunctions.hh
00001 #ifndef DUNE_FVSPACEBASEFUNCTIONS_HH
00002 #define DUNE_FVSPACEBASEFUNCTIONS_HH
00003 
00004 //- Dune includes 
00005 #include <dune/common/misc.hh>
00006 #include <dune/grid/common/grid.hh>
00007 
00008 //- Dune-Fem includes 
00009 #include <dune/fem/space/basefunctions/basefunctioninterface.hh>
00010 #include <dune/fem/space/basefunctions/basefunctionfactory.hh>
00011 
00012 namespace Dune
00013 {
00014 
00015   namespace Fem 
00016   {
00017 
00019   template< class FunctionSpaceType, int polOrd >
00020   class FVBaseFunction;
00021            
00023   template< class FunctionSpaceType >
00024   class FVBaseFunction< FunctionSpaceType, 0 >
00025   : public BaseFunctionInterface< FunctionSpaceType >
00026   {
00027     typedef BaseFunctionInterface< FunctionSpaceType > BaseType;
00028 
00029     enum { dimRange = FunctionSpaceType::dimRange };
00030     int baseNum_;
00031 
00032     typedef typename FunctionSpaceType::DomainType DomainType;
00033     typedef typename FunctionSpaceType::RangeType RangeType;
00034     typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
00035     
00036   public:
00037     FVBaseFunction ( const int baseNum )
00038     : baseNum_ ( baseNum ) 
00039     { 
00040       assert( (baseNum_ >= 0) && (baseNum_ < dimRange) );
00041     }
00042     
00043     virtual void evaluate ( const FieldVector<int, 0> &diffVariable, 
00044                             const DomainType & x, RangeType & phi) const 
00045     {
00046       phi = 0;
00047       phi[baseNum_] = 1;
00048     }
00049 
00050     virtual void evaluate ( const FieldVector<int, 1> &diffVariable, 
00051                             const DomainType & x, RangeType & phi) const 
00052     {
00053       phi = 0;
00054     }
00055 
00056     virtual void evaluate ( const FieldVector<int, 2> &diffVariable, 
00057                             const DomainType & x, RangeType & phi) const 
00058     {
00059       phi = 0;
00060     }
00061   };
00062 
00063 
00064 
00066   template< class FunctionSpace, int polOrd >
00067   class FVBaseFunctionFactory
00068   : public BaseFunctionFactory< FunctionSpace >
00069   {
00070     dune_static_assert( polOrd == 0, "Only implemented for PolOrd=0." );
00071       
00072   public:
00073     typedef FunctionSpace FunctionSpaceType;
00074     typedef BaseFunctionInterface< FunctionSpaceType > BaseFunctionType;
00075 
00076     static const int dimRange = FunctionSpaceType::dimRange;
00077 
00078     FVBaseFunctionFactory ( const GeometryType &type )
00079     : BaseFunctionFactory< FunctionSpaceType >( type )
00080     {}
00081 
00082     virtual BaseFunctionType *baseFunction ( const int i ) const
00083     {
00084       return new FVBaseFunction< FunctionSpaceType, polOrd >( i );
00085     }
00086     
00087     virtual int numBaseFunctions() const 
00088     {
00089       return dimRange;
00090     }
00091   };
00092 
00093   } // end namespace Fem 
00094 
00095 } // end namespace Dune
00096 
00097 #endif // #ifndef DUNE_FVSPACEBASEFUNCTIONS_HH