From ab914244cb14b4f7eb4c5a6d628f4e18edbbfd8b Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Wed, 26 Oct 2011 10:17:12 +0000 Subject: [PATCH] Make the number of digits of the MultiIndex by a dynamic quantity. This is needed to test quad elements and higher-order gfe. [[Imported from SVN: r8047]] --- test/cosseratenergytest.cc | 2 +- test/harmonicenergytest.cc | 2 +- test/localgeodesicfefunctiontest.cc | 2 +- test/localgeodesicfestiffnesstest.cc | 2 +- test/localgfetestfunctiontest.cc | 2 +- test/multiindex.hh | 20 +++++++++++--------- test/svdtest.cc | 2 +- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/test/cosseratenergytest.cc b/test/cosseratenergytest.cc index 2622b6c9..751ece3d 100644 --- a/test/cosseratenergytest.cc +++ b/test/cosseratenergytest.cc @@ -156,7 +156,7 @@ int main(int argc, char** argv) // Set up elements of SO(3) std::vector<TargetSpace> corners(domainDim+1); - MultiIndex<domainDim+1> index(nTestPoints); + MultiIndex index(domainDim+1, nTestPoints); int numIndices = index.cycle(); for (int i=0; i<numIndices; i++, ++index) { diff --git a/test/harmonicenergytest.cc b/test/harmonicenergytest.cc index fcc88fde..54f8b48e 100644 --- a/test/harmonicenergytest.cc +++ b/test/harmonicenergytest.cc @@ -127,7 +127,7 @@ void testUnitVector3d() // Set up elements of S^2 std::vector<TargetSpace> coefficients(dim+1); - MultiIndex<dim+1> index(nTestPoints); + MultiIndex index(dim+1, nTestPoints); int numIndices = index.cycle(); for (int i=0; i<numIndices; i++, ++index) { diff --git a/test/localgeodesicfefunctiontest.cc b/test/localgeodesicfefunctiontest.cc index c5b27935..6d3a2b1c 100644 --- a/test/localgeodesicfefunctiontest.cc +++ b/test/localgeodesicfefunctiontest.cc @@ -275,7 +275,7 @@ void test() // Set up elements of the target space std::vector<TargetSpace> corners(domainDim+1); - MultiIndex<domainDim+1> index(nTestPoints); + MultiIndex index(domainDim+1, nTestPoints); int numIndices = index.cycle(); for (int i=0; i<numIndices; i++, ++index) { diff --git a/test/localgeodesicfestiffnesstest.cc b/test/localgeodesicfestiffnesstest.cc index 426a4eb4..7391cc05 100644 --- a/test/localgeodesicfestiffnesstest.cc +++ b/test/localgeodesicfestiffnesstest.cc @@ -116,7 +116,7 @@ void testHessian() // Set up elements of S^2 std::vector<TargetSpace> coefficients(domainDim+1); - MultiIndex<domainDim+1> index(nTestPoints); + MultiIndex index(domainDim+1, nTestPoints); int numIndices = index.cycle(); size_t nDofs = domainDim+1; diff --git a/test/localgfetestfunctiontest.cc b/test/localgfetestfunctiontest.cc index 90495d06..3a1b1d23 100644 --- a/test/localgfetestfunctiontest.cc +++ b/test/localgfetestfunctiontest.cc @@ -34,7 +34,7 @@ void test() // Set up elements of SO(3) std::vector<TargetSpace> coefficients(domainDim+1); - MultiIndex<domainDim+1> index(nTestPoints); + MultiIndex index(domainDim+1, nTestPoints); int numIndices = index.cycle(); PQkLocalFiniteElementCache<double,double,domainDim,1> feCache; diff --git a/test/multiindex.hh b/test/multiindex.hh index c088c8f3..f9b9fad3 100644 --- a/test/multiindex.hh +++ b/test/multiindex.hh @@ -1,22 +1,24 @@ #ifndef MULTI_INDEX_HH #define MULTI_INDEX_HH -#include <dune/common/array.hh> +#include <vector> -/** \brief N-dimensional multi-index +/** \brief A multi-index */ -template <int N> class MultiIndex - : public Dune::array<unsigned int,N> + : public std::vector<unsigned int> { // The range of each component unsigned int limit_; public: - /** \brief Constructor with a given range for each digit */ - MultiIndex(unsigned int limit) - : limit_(limit) + /** \brief Constructor with a given range for each digit + * \param n Number of digits + */ + MultiIndex(unsigned int n, unsigned int limit) + : std::vector<unsigned int>(n), + limit_(limit) { std::fill(this->begin(), this->end(), 0); } @@ -24,7 +26,7 @@ public: /** \brief Increment the MultiIndex */ MultiIndex& operator++() { - for (int i=0; i<N; i++) { + for (size_t i=0; i<size(); i++) { // Augment digit (*this)[i]++; @@ -42,7 +44,7 @@ public: /** \brief Compute how many times you can call operator++ before getting to (0,...,0) again */ size_t cycle() const { size_t result = 1; - for (int i=0; i<N; i++) + for (size_t i=0; i<size(); i++) result *= limit_; return result; } diff --git a/test/svdtest.cc b/test/svdtest.cc index 1d49302a..7f53915c 100644 --- a/test/svdtest.cc +++ b/test/svdtest.cc @@ -16,7 +16,7 @@ int main() int nTestValues = 5; double maxDiff = 0; - MultiIndex<N*M> index(nTestValues); + MultiIndex index(N*M, nTestValues); int numIndices = index.cycle(); for (int i=0; i<numIndices; i++, ++index) { -- GitLab