Skip to content
Snippets Groups Projects
Commit f640f4ca authored by Felix Schindler's avatar Felix Schindler
Browse files

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
parent ae9f64cd
No related branches found
No related tags found
No related merge requests found
......@@ -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} )
#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
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment