From f640f4ca34cd29da8bc2fc87dbdd3205f11178a0 Mon Sep 17 00:00:00 2001
From: "felix.albrecht" <felix.albrecht@4028485c-44d9-4cde-a312-5a4635ee2db9>
Date: Thu, 17 Feb 2011 10:41:33 +0000
Subject: [PATCH] moved LocalDoFVector into seperate header

git-svn-id: https://dune.mathematik.uni-freiburg.de/svn/dune-fem-functionals/trunk@34 4028485c-44d9-4cde-a312-5a4635ee2db9
---
 CMakeLists.txt                      |  9 +--
 dune/fem/dofvector/dofvector.hh     | 95 +++++++++++++++++++++++++++++
 dune/fem/functional/l2functional.hh | 88 ++------------------------
 3 files changed, 105 insertions(+), 87 deletions(-)
 create mode 100644 dune/fem/dofvector/dofvector.hh

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92055e66d..70fcc37c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,17 +109,18 @@ ADD_CXX_FLAGS( ${CUSTOM_FLAGS} )
 #----------------------------------------------------------------------------------------------------
 # Source listing
 #----------------------------------------------------------------------------------------------------
-FILE( GLOB_RECURSE header "dune/fem/*.hh" )
+FILE( GLOB_RECURSE header "tools/*.hh" )
 FILE( GLOB_RECURSE common "../dune-common/dune/common/*.hh" )
 FILE( GLOB_RECURSE grid "../dune-grid/dune/grid/*.hh" )
 FILE( GLOB_RECURSE istl "../dune-istl/dune/istl/*.hh" )
-FILE( GLOB_RECURSE fem "../dune-fem/dune/fem/*.hh" )
 FILE( GLOB_RECURSE fem-howto "../dune-fem-howto/dune/fem-howto/*.hh" )
+FILE( GLOB_RECURSE fem "../dune-fem/dune/fem/*.hh" )
+FILE( GLOB_RECURSE fem-functionals "../dune-fem-functionals/dune/fem/*.hh" )
 
-set_source_files_properties( ${header} ${common} ${grid} ${istl} ${fem} ${fem-howto} PROPERTIES HEADER_FILE_ONLY 1 )
+set_source_files_properties( ${header} ${common} ${grid} ${istl} ${fem} ${fem-howto} ${fem-functionals} PROPERTIES HEADER_FILE_ONLY 1 )
 set( COMMON_LIBS "fem" "grid" "common" ${BLAS_LIB} "alugrid" "GL" )
 
-ADD_EXECUTABLE( l2functional_test "tests/functional/l2functional_test.cc" ${header} ${common} ${grid} ${istl} ${fem} ${femhowto} )
+ADD_EXECUTABLE( l2functional_test "tests/functional/l2functional_test.cc" ${header} ${common} ${grid} ${istl} ${fem} ${femhowto} ${fem-functionals} )
 TARGET_LINK_LIBRARIES( l2functional_test ${COMMON_LIBS}  )
 
 #HEADERCHECK( ${header} )
diff --git a/dune/fem/dofvector/dofvector.hh b/dune/fem/dofvector/dofvector.hh
new file mode 100644
index 000000000..58bff1933
--- /dev/null
+++ b/dune/fem/dofvector/dofvector.hh
@@ -0,0 +1,95 @@
+#ifndef DUNE_FEM_FUNCTIONALS_DOFVECTOR_HH
+#define DUNE_FEM_FUNCTIONALS_DOFVECTOR_HH
+
+namespace Dune {
+
+namespace Functionals {
+
+/**
+  * \brief      This class represents a local DoF vector.
+  *
+  *             It is based upon std::vector and should be replaced by something clever in the future!
+  *
+  * \todo       Doc me, please!
+  **/
+template <class ElementType>
+class LocalDoFVector
+{
+public:
+  /**
+    * \brief    Initializes an empty vector, according to the given size.
+    **/
+  LocalDoFVector(const unsigned size)
+    : size_(size)
+  {
+    // resize
+    storage_.resize(size, 0.0);
+  }
+
+  /**
+    * \brief    Initializes a DoF vector and sets its entries to the
+    *           corresponding entries of the given localFunction.
+    **/
+  template <class LocalFunctionType>
+  LocalDoFVector(const LocalFunctionType& localFunction)
+    : size_(localFunction.numDofs())
+  {
+    // resize
+    storage_.resize(localFunction.numDofs());
+
+    // copy entries
+    for (unsigned ii = 0; ii < localFunction.numDofs(); ++ii) {
+      storage_[ii] = localFunction[ii];
+    }
+  }
+
+  /**
+    * \brief    Returns the size.
+    */
+  unsigned size() const
+  {
+    return size_;
+  }
+
+  /**
+    * \brief    Random read and write access.
+    **/
+  ElementType& operator[](const unsigned ii)
+  {
+    return storage_[ii];
+  }
+
+  /**
+    * \brief    Random read access.
+    **/
+  const ElementType operator[](const unsigned ii) const
+  {
+    return storage_[ii];
+  }
+
+  /**
+    * \brief    Scalar product of two local DoF vectors of same type.
+    **/
+  ElementType operator*(const LocalDoFVector<ElementType>& other) const
+  {
+    assert(size_ == other.size());
+    ElementType result = 0.0;
+
+    for (unsigned ii = 0; ii < size_; ++ii) {
+      result += storage_[ii] * other[ii];
+    }
+
+    return result;
+  }
+
+private:
+  std::vector<ElementType> storage_;
+  const unsigned size_;
+
+}; // end class LocalDoFVector
+
+} // end namespace Functionals
+
+} // end namespace Dune
+
+#endif // end DUNE_FEM_FUNCTIONALS_DOFVECTOR_HH
diff --git a/dune/fem/functional/l2functional.hh b/dune/fem/functional/l2functional.hh
index 52459a2aa..ba1d32345 100644
--- a/dune/fem/functional/l2functional.hh
+++ b/dune/fem/functional/l2functional.hh
@@ -8,6 +8,9 @@
 // dune fem includes
 #include <dune/fem/quadrature/cachingquadrature.hh>
 
+// dune fem-functionals includes
+#include <dune/fem/dofvector/dofvector.hh>
+
 // dune fem-tools includes
 #include "../../../tools/function/functiontools.hh" // should be removed in the end!
 
@@ -15,88 +18,6 @@ namespace Dune {
 
 namespace Functionals {
 
-/**
-  * \brief      This class represents a local DoF vector.
-  *
-  *             It is based upon std::vector and should be replaced by something clever in the future!
-  *
-  * \todo       Doc me, please!
-  **/
-template <class ElementType>
-class LocalDoFVector
-{
-public:
-  /**
-    * \brief    Initializes an empty vector, according to the given size.
-    **/
-  LocalDoFVector(const unsigned size)
-    : size_(size)
-  {
-    // resize
-    storage_.resize(size);
-  }
-
-  /**
-    * \brief    Initializes a DoF vector and sets its entries to the
-    *           corresponding entries of the given localFunction.
-    **/
-  template <class LocalFunctionType>
-  LocalDoFVector(const LocalFunctionType& localFunction)
-    : size_(localFunction.numDofs())
-  {
-    // resize
-    storage_.resize(localFunction.numDofs());
-
-    // copy entries
-    for (unsigned ii = 0; ii < localFunction.numDofs(); ++ii) {
-      storage_[ii] = localFunction[ii];
-    }
-  }
-
-  /**
-    * \brief    Returns the size.
-    */
-  unsigned size() const
-  {
-    return size_;
-  }
-
-  /**
-    * \brief    Random read and write access.
-    **/
-  ElementType& operator[](const unsigned ii)
-  {
-    return storage_[ii];
-  }
-
-  /**
-    * \brief    Random read access.
-    **/
-  const ElementType operator[](const unsigned ii) const
-  {
-    return storage_[ii];
-  }
-
-  /**
-    * \brief    Scalar product of two local DoF vectors of same type.
-    **/
-  ElementType operator*(const LocalDoFVector<ElementType>& other) const
-  {
-    assert(size_ == other.size());
-    ElementType result = 0.0;
-
-    for (unsigned ii = 0; ii < size_; ++ii) {
-      result += storage_[ii] * other[ii];
-    }
-
-    return result;
-  }
-
-private:
-  std::vector<ElementType> storage_;
-  const unsigned size_;
-};
-
 /**
   * \brief      This class represents an L2 functional.
   *
@@ -112,7 +33,7 @@ public:
 
   typedef typename InducingFunctionType::RangeFieldType RangeFieldType;
 
-  typedef LocalDoFVector<RangeFieldType> LocalDoFVectorType;
+  typedef Dune::Functionals::LocalDoFVector<RangeFieldType> LocalDoFVectorType;
 
   L2Functional(const InducingFunctionType& inducingFunction)
     : inducingFunction_(inducingFunction)
@@ -201,6 +122,7 @@ public:
     for (unsigned int localDoF = 0; localDoF < numberOfLocalDoFs; ++localDoF) {
       // value of the L2 functional, applied to the local basefunction, associated with the local DoF
       RangeFieldType localFunctionalValue = 0.0;
+
       // do walk over quadrature points
       for (unsigned int quadraturePoint = 0; quadraturePoint < numberOfQuadraturePoints; ++quadraturePoint) {
         // coordinates
-- 
GitLab