diff --git a/fem/common/basefunctions.hh b/fem/common/basefunctions.hh index 0c272e09ca18315058aec3e6147638aa86fa7bb8..9ee52cfaf6a187710e0f8546002174c18aac0219 100644 --- a/fem/common/basefunctions.hh +++ b/fem/common/basefunctions.hh @@ -20,9 +20,6 @@ namespace Dune { @{ */ - - - // just to make it easy to change typedef int deriType; @@ -128,36 +125,32 @@ namespace Dune { //typedef Quadrature < FunctionSpaceType > QuadratureType ; typedef BaseFunctionInterface<DiscreteFunctionSpaceType> BaseFunctionType; - // to be declared in derived extension class: - // void gradient ( int baseFunct, Domain & x, GradientRange & phi ) ; - // void gradient ( int baseFunct, QuadratureType & quad, int quadPoint, GradientRange & phi ) ; - - // void hessian ( int baseFunct, Domain & x, HessianRange & phi ) ; - // void hessian ( int baseFunct, QuadratureType & quad, int quadPoint, HessianRange & phi ) ; - // Range baseIntegral( int baseFunct1, int diffOrder1, int diffVariable1, - // int baseFunct2, int diffOrder2, int diffVariable2 ); - - /*** Begin Interface ***/ + public: //! \todo Please doc me! BaseFunctionSetInterface () {}; //! \todo Please doc me! - int getNumberOfBaseFunctions () const { + int getNumberOfBaseFunctions () const DUNE_DEPRECATED { return asImp().getNumberOfBaseFunctions(); }; + //! Number of base functions + int numBaseFunctions() const { + // stay on the safe side and call the deprecated version for now + return asImp().numBaseFunctions(); + } + //! \todo Please doc me! template <int diffOrd> void evaluate (int baseFunct, const FieldVector<deriType, diffOrd> &diffVariable, const DomainType & x, RangeType & phi ) const { - std::cout << "BaseFunctionSetInterface::evaluate \n"; asImp().evaluate( baseFunct, diffVariable, x, phi ); } //! \todo Please doc me! - template <int diffOrd, class QuadratureType > + template <int diffOrd, class QuadratureType> void evaluate (int baseFunct, const FieldVector<deriType, diffOrd> &diffVariable, QuadratureType & quad, @@ -196,8 +189,8 @@ namespace Dune { //! //************************************************************************* template<class BaseFunctionSetTraits> - class BaseFunctionSetDefault - : public BaseFunctionSetInterface <BaseFunctionSetTraits> + class BaseFunctionSetDefault : + public BaseFunctionSetInterface <BaseFunctionSetTraits> { public: typedef typename BaseFunctionSetTraits::BaseFunctionSetType BaseFunctionSetType; @@ -218,7 +211,7 @@ namespace Dune { }; //! default evaluate using the evaluate interface - void eval ( int baseFunct, const DomainType & x, RangeType & phi ) const + void eval( int baseFunct, const DomainType & x, RangeType & phi ) const { asImp().evaluate(baseFunct, diffVariable_ , x , phi); return; @@ -226,7 +219,7 @@ namespace Dune { //! default implementation for evaluation template <class QuadratureType> - void eval ( int baseFunct, QuadratureType & quad, int quadPoint, RangeType & phi ) const + void eval( int baseFunct, QuadratureType & quad, int quadPoint, RangeType & phi ) const { asImp().evaluate( baseFunct, diffVariable_ , quad, quadPoint, phi ); return; diff --git a/fem/common/discretefunction.cc b/fem/common/discretefunction.cc index 3f1cd74abf0c96ebb87a7d709ef677cf44913b17..cab85bf451f9c19c0d8939892833505e413e8568 100644 --- a/fem/common/discretefunction.cc +++ b/fem/common/discretefunction.cc @@ -23,6 +23,7 @@ namespace Dune template <class DiscreteFunctionTraits> void DiscreteFunctionDefault<DiscreteFunctionTraits>:: addScaled(const DiscreteFunctionType& g, const RangeFieldType& c) { + assert(this->size() == g.size()); DofIteratorType endit = this->dend(); ConstDofIteratorType oit = g.dbegin(); for (DofIteratorType it = this->dbegin(); it != endit; ++it, ++oit) { @@ -37,6 +38,8 @@ namespace Dune scalarProductDofs(const DiscreteFunctionType& g) const { typedef typename DiscreteFunctionSpaceType::RangeFieldType RangeFieldType; + assert(this->size() == g.size()); + RangeFieldType skp = 0.; ConstDofIteratorType endit = this->dend (); @@ -64,6 +67,8 @@ namespace Dune const DiscreteFunctionDefaultType &gc = static_cast<const DiscreteFunctionDefaultType &> ( g ); + assert(this->size() == gc.size()); + DofIteratorType endit = this->dend (); ConstDofIteratorType git = gc.dbegin (); for (DofIteratorType it = this->dbegin(); it != endit; ++it, ++git) { @@ -89,6 +94,8 @@ namespace Dune const DiscreteFunctionDefaultType &gc = static_cast<const DiscreteFunctionDefaultType &> ( g ); + assert(this->size() == gc.size()); + DofIteratorType endit = this->dend (); ConstDofIteratorType git = gc.dbegin (); for(DofIteratorType it = this->dbegin(); it != endit; ++it, ++git) @@ -113,6 +120,8 @@ namespace Dune const DiscreteFunctionDefaultType &gc = static_cast<const DiscreteFunctionDefaultType &> ( g ); + assert(this->size() == gc.size()); + DofIteratorType endit = this->dend (); ConstDofIteratorType git = gc.dbegin (); for(DofIteratorType it = this->dbegin(); it != endit; ++it, ++git) @@ -158,7 +167,8 @@ namespace Dune const DiscreteFunctionDefaultType &gc = static_cast<const DiscreteFunctionDefaultType &> ( g ); - // we would need const_iterators..... + + assert(this->size() == gc.size()); DofIteratorType endit = this->dend (); ConstDofIteratorType git = gc.dbegin (); diff --git a/fem/common/dofmapperinterface.hh b/fem/common/dofmapperinterface.hh index 0ded8dcd7f06fa9953ec0d057b222f24fb20afb1..b5f03400c8dd07a80a00258f08c891ef04582241 100644 --- a/fem/common/dofmapperinterface.hh +++ b/fem/common/dofmapperinterface.hh @@ -35,7 +35,10 @@ namespace Dune { virtual void calcInsertPoints () = 0; //! return max number of local dofs per entity - virtual int numberOfDofs () const =0; + virtual int numberOfDofs () const DUNE_DEPRECATED = 0; + + //! return max number of local dofs per entity + virtual int numDofs () const = 0; //! returns true if index is new ( for dof compress ) virtual bool indexNew (int num) const = 0; @@ -88,7 +91,15 @@ namespace Dune { } //! default implementation if not overlaoded - virtual int numberOfDofs () const + virtual int numberOfDofs () const DUNE_DEPRECATED + { + // overload this method in derived class + assert(false); + return -1; + } + + //! default implementation if not overlaoded + virtual int numDofs () const { // overload this method in derived class assert(false); diff --git a/fem/common/fastbase.cc b/fem/common/fastbase.cc index dafe2f10c535c283c967552815e7a7acbaca4557..300b2393bb13091942339671d0a9bc79a618030a 100644 --- a/fem/common/fastbase.cc +++ b/fem/common/fastbase.cc @@ -79,7 +79,7 @@ evaluateInit( const QuadratureType &quad ) for(int j=0; j<diffOrd; j++) diffVariable[j] = i % DimDomain; - for ( int baseFunc = 0; baseFunc < this->getNumberOfBaseFunctions(); baseFunc++ ) + for ( int baseFunc = 0; baseFunc < this->numBaseFunctions(); baseFunc++ ) { for ( int quadPt = 0; quadPt < quad.nop(); quadPt++ ) { diff --git a/fem/common/fastbase.hh b/fem/common/fastbase.hh index 5b3eefc276c9d2d0384c68741615be878edcdee4..6283e8e28292ca7d5a52645d91bf3a4c2df180ad 100644 --- a/fem/common/fastbase.hh +++ b/fem/common/fastbase.hh @@ -67,17 +67,29 @@ namespace Dune { FastBaseFunctionSet (FunctionSpaceType & fuspace , int numOfBaseFct); //! return the number of base fucntions for this BaseFunctionSet - int getNumberOfBaseFunctions () const + int getNumberOfBaseFunctions () const DUNE_DEPRECATED { return baseFunctionList_.size(); }; //! return the number of base fucntions for this BaseFunctionSet - int getNumberOfDiffBaseFuncs () const + int getNumberOfDiffBaseFuncs () const DUNE_DEPRECATED { return numOfDiffFct_; }; + //! return the number of base fucntions for this BaseFunctionSet + int numBaseFunctions () const + { + return baseFunctionList_.size(); + } + + //! return the number of base fucntions for this BaseFunctionSet + int numDifferentBaseFunctions () const + { + return numOfDiffFct_; + } + //! evaluate base function baseFunct with the given diffVariable and a //! point x and range phi template <int diffOrd> diff --git a/fem/common/localfunction.hh b/fem/common/localfunction.hh index 02834c27942c611665213d6a7045db11e36f00a0..ff91aad544d9567e56ec18d43808f45c77e2928f 100644 --- a/fem/common/localfunction.hh +++ b/fem/common/localfunction.hh @@ -1,7 +1,7 @@ // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: -#ifndef __DUNE_LOCALFUNCTION_HH__ -#define __DUNE_LOCALFUNCTION_HH__ +#ifndef DUNE_LOCALFUNCTION_HH +#define DUNE_LOCALFUNCTION_HH namespace Dune { @@ -49,12 +49,28 @@ namespace Dune { } //! return the number of local dof of this local function - int numberOfDofs () const + //! use numDofs instead + int numberOfDofs () const DUNE_DEPRECATED { return asImp().numberOfDofs (); - }; + } + + //! return the number of local dof of this local function + int numDofs() const + { + return asImp().numDofs(); + } - //! evaluate the local function on x and return ret + //! evaluate local function. is replaced by evaluateLocal (evaluateLocal + //! stands for local (reference element) coordinate x, whereas evaluateGlobal + //! gets an x in physical (real world) coordinates + template <class EntityType> + void evaluate (EntityType &en, const DomainType & x, RangeType & ret) DUNE_DEPRECATED + { + asImp().evaluate(en,x,ret); + } + + //! evaluate the local function on reference element coordinate x template <class EntityType> void evaluateLocal(EntityType& en, const DomainType& x, @@ -63,6 +79,7 @@ namespace Dune { asImp().evaluateLocal(en,x,ret); } + //! evaluate jacobian on reference element coordinate x template <class EntityType> void jacobianLocal(EntityType& en, const DomainType& x, @@ -108,25 +125,46 @@ namespace Dune { //! Constructor LocalFunctionDefault() : xLoc_(0.0) {} - //! evaluate the local function on x and return ret + //! evaluate the local function on real world coordinate x and return ret template <class EntityType> - void evaluate(EntityType& en, - const DomainType& x, - RangeType & ret) + void evaluateGlobal(EntityType& en, + const DomainType& x, + RangeType& ret) { ret = 0.0; xLoc_ = en.geometry().local(x); evaluateLocal(en,xLoc_,ret); } + //! Evaluation using a quadrature + template <class EntityType, class QuadratureType> + void evaluate(EntityType& en, + QuadratureType& quad, + int quadPoint, + RangeType& ret) + { + evaluateLocal(en, quad.point(quadPoint), ret); + } + + //! jacobian of the local function using real world coordinate x template <class EntityType> - void jacobian(EntityType& en, - const DomainType& x, - JacobianRangeType& ret) + void jacobianGlobal(EntityType& en, + const DomainType& x, + JacobianRangeType& ret) { ret = 0.0; xLoc_ = en.geometry().local(x); - jacobian(en,xLoc_,ret); + jacobianLocal(en,xLoc_,ret); + } + + //! Evaluation of jacobian using a quadrature + template <class EntityType, class QuadratureType> + void jacobian(EntityType& en, + QuadratureType& quad, + int quadPoint, + JacobianRangeType& ret) + { + jacobianLocal(en, quad.point(quadPoint), ret); } private: