From 254155754b2094d6d63c1955c1af4c29e373702c Mon Sep 17 00:00:00 2001
From: Adrian Burri <burriad@dune-project.org>
Date: Wed, 16 Mar 2005 08:24:36 +0000
Subject: [PATCH] const issues and alleviating the need for a registration of
 quadratures

[[Imported from SVN: r1658]]
---
 fem/common/cachingbase.cc | 12 ++++++++++--
 fem/common/cachingbase.hh | 10 +++++-----
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/fem/common/cachingbase.cc b/fem/common/cachingbase.cc
index 39d7b8773..11fab7fde 100644
--- a/fem/common/cachingbase.cc
+++ b/fem/common/cachingbase.cc
@@ -82,6 +82,10 @@ CachingBaseFunctionSet<FunctionSpaceType >::
 values(int baseFunct, const QuadratureType& quad) const {
   ConstRangeMapIterator it = vals_.find(quad.getIdentifier());
 
+  if (it == vals_.end()) {
+    registerQuadrature(quad);
+    it = vals_.find(quad.getIdentifier());
+  }
   assert(it != vals_.end()); // Forgot to initialise with quadrature, eh?
   assert(baseFunct < numOfBaseFct_);
 
@@ -95,6 +99,10 @@ CachingBaseFunctionSet<FunctionSpaceType >::
 gradients(int baseFunct, const QuadratureType& quad) const {
   ConstJacobianMapIterator it = grads_.find(quad.getIdentifier());
 
+  if (it == grads_.end()) {
+    registerQuadrature(quad);
+    it = grads_.find(quad.getIdentifier());
+  }
   assert(it != grads_.end());
   assert(baseFunct < numOfBaseFct_);
 
@@ -118,7 +126,7 @@ faces(int faceIdx, int baseFct, const QuadratureType& quad) const {
 template <class FunctionSpaceType>
 template <class QuadratureType>
 void CachingBaseFunctionSet<FunctionSpaceType>::
-registerQuadrature( const QuadratureType &quad )
+registerQuadrature( const QuadratureType &quad ) const
 {
   // check if quadrature is already registered
   int identifier = quad.getIdentifier();
@@ -156,7 +164,7 @@ registerQuadrature( const QuadratureType &quad )
 template <class FunctionSpaceType>
 template <class QuadratureType, class EntityType>
 void CachingBaseFunctionSet<FunctionSpaceType>::
-registerQuadrature(const QuadratureType &quad, const EntityType& en) {
+registerQuadrature(const QuadratureType &quad, const EntityType& en) const {
   //- Local typedefs
   typedef typename EntityType::IntersectionIterator IntersectionIterator;
 
diff --git a/fem/common/cachingbase.hh b/fem/common/cachingbase.hh
index aef483673..9e08060a3 100644
--- a/fem/common/cachingbase.hh
+++ b/fem/common/cachingbase.hh
@@ -118,12 +118,12 @@ namespace Dune {
     //! The base function set will only work for quadratures which were
     //! registered
     template <class QuadratureType>
-    void registerQuadrature(const QuadratureType & quad);
+    void registerQuadrature(const QuadratureType & quad) const;
 
     //! Register face quadrature
     template <class QuadratureType, class EntityType>
     void registerQuadrature(const QuadratureType& quad,
-                            const EntityType& en);
+                            const EntityType& en) const;
 
   private:
     //- Local typedefs
@@ -151,13 +151,13 @@ namespace Dune {
     std::vector<BaseFunctionInterfaceType *> baseFunctionList_ ;
 
     //! map with cached values for base functions
-    RangeMap vals_;
+    mutable RangeMap vals_;
 
     //! map with cached values for base function gradients
-    JacobianMap grads_;
+    mutable JacobianMap grads_;
 
     //! map with cached values for face values of base functions
-    FaceMap faces_;
+    mutable FaceMap faces_;
 
   }; // end class CachingBaseFunctionSet
 
-- 
GitLab