Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

DOFVectorTest.cpp 2.2 KB
Newer Older
1 2
#include "config.h"

Praetorius, Simon's avatar
Praetorius, Simon committed
3 4
#include <dune/common/filledarray.hh>
#include <dune/grid/yaspgrid.hh>
5
#include <dune/functions/backends/concepts.hh>
Praetorius, Simon's avatar
Praetorius, Simon committed
6 7 8 9
#include <dune/functions/functionspacebases/compositebasis.hh>
#include <dune/functions/functionspacebases/powerbasis.hh>
#include <dune/functions/functionspacebases/lagrangebasis.hh>

10
#include <amdis/GridTransferManager.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <amdis/LinearAlgebra.hpp>

#include "Tests.hpp"

using namespace AMDiS;
using namespace Dune::Functions::BasisFactory;

template <class B, class T>
void test_dofvector(B const& basis, DOFVector<B,T>& vec)
{
  AMDIS_TEST( vec.size() == basis.dimension() );
  vec.compress();

  vec = T(0);
  vec[0] = T(1);
26
#if HAVE_MTL || HAVE_ISTL
Praetorius, Simon's avatar
Praetorius, Simon committed
27 28 29 30
  auto m0 = std::min_element(std::begin(vec.vector()), std::end(vec.vector()));
  auto m1 = std::max_element(std::begin(vec.vector()), std::end(vec.vector()));
  AMDIS_TEST( *m0 == T(0) );
  AMDIS_TEST( *m1 == T(1) );
31
#endif
32 33 34

  // DOFVector models the concept of a VectorBackend in Dune::Functions
  static_assert(Dune::models<Dune::Functions::Concept::VectorBackend<B>, decltype(vec)>(), "");
Praetorius, Simon's avatar
Praetorius, Simon committed
35 36
}

37
int main(int argc, char** argv)
Praetorius, Simon's avatar
Praetorius, Simon committed
38
{
39 40
  Dune::MPIHelper::instance(argc, argv);

Praetorius, Simon's avatar
Praetorius, Simon committed
41 42 43 44
  // create grid
  Dune::FieldVector<double, 2> L; L = 1.0;
  auto s = Dune::filledArray<2>(1);
  Dune::YaspGrid<2> grid(L, s);
45
  auto const& gridView = grid.leafGridView();
Praetorius, Simon's avatar
Praetorius, Simon committed
46 47

  // create basis
48
  auto basis = makeBasis(gridView,
Praetorius, Simon's avatar
Praetorius, Simon committed
49 50 51
    composite(power<2>(lagrange<2>(), flatInterleaved()), lagrange<1>(), flatLexicographic()));
  using Basis = decltype(basis);

52 53 54 55 56 57
  {
    DOFVector<Basis> vec1(basis);
    test_dofvector(basis, vec1);

    DOFVector<Basis, float> vec2(basis);
    test_dofvector(basis, vec2);
Praetorius, Simon's avatar
Praetorius, Simon committed
58

59 60
    auto vec3 = makeDOFVector(basis);
    test_dofvector(basis, vec3);
Praetorius, Simon's avatar
Praetorius, Simon committed
61

62 63
    auto vec4 = makeDOFVector<float>(basis);
    test_dofvector(basis, vec4);
Praetorius, Simon's avatar
Praetorius, Simon committed
64 65

#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
66 67
    DOFVector vec5(basis);
    test_dofvector(basis, vec5);
Praetorius, Simon's avatar
Praetorius, Simon committed
68
#endif
69 70 71 72 73 74 75 76 77 78 79 80 81 82
  }

  // test GridTransferManager registration
  {
    DOFVector<Basis> vec1(basis);
    test_dofvector(basis, vec1);
    for (auto const& e : elements(gridView))
      grid.mark(1, e);
    GridTransferManager::adapt(grid);
    AMDIS_TEST_EQ(vec1.size(), basis.dimension());
  }

  report_errors();
}