From 8ac1a2a2a9e1dd56b912b0a29a952d7b36893c64 Mon Sep 17 00:00:00 2001 From: Adrian Burri <burriad@dune-project.org> Date: Fri, 28 Oct 2005 09:47:46 +0000 Subject: [PATCH] FastBaseFunctionSet is now responsible for deleting BaseFunction pointers [[Imported from SVN: r3327]] --- fem/common/basefunctions.hh | 22 ++++++++++++++-------- fem/common/fastbase.hh | 32 +++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/fem/common/basefunctions.hh b/fem/common/basefunctions.hh index 9ee52cfaf..88861e941 100644 --- a/fem/common/basefunctions.hh +++ b/fem/common/basefunctions.hh @@ -52,7 +52,9 @@ namespace Dune { enum { DimDomain = DiscreteFunctionSpaceType::DimDomain }; enum { DimRange = DiscreteFunctionSpaceType::DimRange }; - BaseFunctionInterface () {} ; + BaseFunctionInterface () {} + + virtual ~BaseFunctionInterface() {} //! evaluate the function at Domain x, and store the value in Range Phi //! diffVariable stores information about which gradient is to be @@ -73,8 +75,6 @@ namespace Dune { virtual void evaluate ( const FieldVector<deriType, 2> &diffVariable, const DomainType & , RangeType &) const = 0; - private: - }; /** @} end documentation group */ @@ -128,12 +128,16 @@ namespace Dune { public: //! \todo Please doc me! - BaseFunctionSetInterface () {}; + BaseFunctionSetInterface () {} - //! \todo Please doc me! - int getNumberOfBaseFunctions () const DUNE_DEPRECATED { - return asImp().getNumberOfBaseFunctions(); - }; + virtual ~BaseFunctionSetInterface() {} + + /* + //! \todo Please doc me! + int getNumberOfBaseFunctions () const DUNE_DEPRECATED { + return asImp().getNumberOfBaseFunctions(); + }; + */ //! Number of base functions int numBaseFunctions() const { @@ -210,6 +214,8 @@ namespace Dune { jacobianDiffVar_[i] = i; }; + virtual ~BaseFunctionSetDefault() {} + //! default evaluate using the evaluate interface void eval( int baseFunct, const DomainType & x, RangeType & phi ) const { diff --git a/fem/common/fastbase.hh b/fem/common/fastbase.hh index b38fac0bc..f19fc328b 100644 --- a/fem/common/fastbase.hh +++ b/fem/common/fastbase.hh @@ -66,17 +66,27 @@ namespace Dune { //! Constructor FastBaseFunctionSet (FunctionSpaceType & fuspace , int numOfBaseFct); - //! return the number of base fucntions for this BaseFunctionSet - int getNumberOfBaseFunctions () const DUNE_DEPRECATED - { - return baseFunctionList_.size(); - }; - - //! return the number of base fucntions for this BaseFunctionSet - int getNumberOfDiffBaseFuncs () const DUNE_DEPRECATED - { - return numOfDiffFct_; - }; + //! Destructor + virtual ~FastBaseFunctionSet() { + for (unsigned int i = 0; i < baseFunctionList_.size(); ++i) { + delete baseFunctionList_[i]; + baseFunctionList_[i] = 0; + } + baseFunctionList_.resize(0); + } + /* + //! return the number of base fucntions for this BaseFunctionSet + int getNumberOfBaseFunctions () const DUNE_DEPRECATED + { + return baseFunctionList_.size(); + }; + + //! return the number of base fucntions for this BaseFunctionSet + int getNumberOfDiffBaseFuncs () const DUNE_DEPRECATED + { + return numOfDiffFct_; + }; + */ //! return the number of base fucntions for this BaseFunctionSet int numBaseFunctions () const -- GitLab