testgridviews.cc 1.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <functional>
#include <iostream>
#include <numeric>

#include <dune/common/filledarray.hh>
#include <dune/common/test/testsuite.hh>
#include <dune/common/parallel/mpihelper.hh>

#include <dune/grid/yaspgrid.hh>

#include <dune/multimesh/multimesh.hh>
19
#include <dune/multimesh/multiiterator.hh>
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

using namespace Dune;

template <std::size_t dim, class Test>
void test_dim(Test& test)
{
  FieldVector<double,dim> lower; lower = -1.5;
  FieldVector<double,dim> upper; upper =  1.5;
  auto num_elements = filledArray<dim>(2);

  using HostGrid = YaspGrid<dim, EquidistantOffsetCoordinates<double,dim>>;
  MultiMesh<HostGrid> grid(3, lower, upper, num_elements);

  grid[0].globalRefine(1);
  grid[1].globalRefine(2);
  grid[2].globalRefine(3);

  for (auto const& entities : multi_elements(grid[0].leafGridView(), grid[1].levelGridView(1))) {
    test.check(entities.size() == 2);
    test.check(entities[0].isLeaf());
    test.check(entities[1].level() == 1);
  }

}

int main(int argc, char** argv)
{
  MPIHelper::instance(argc, argv);

  Dune::TestSuite test;
  test_dim<1>(test);
  test_dim<2>(test);
  test_dim<3>(test);
  return test.exit();
}