test0004.cc 2.2 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
1
2
3
4
5
6
7
8
9
10
11
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE 0004
#define BOOST_TEST_NO_MAIN

#include <boost/test/unit_test.hpp>
#include <AMDiS.h>

using namespace AMDiS;
using namespace std;

/*
12
  - Test DOF communicator on 2-level decomposition of a 4x4 rank domain.
Thomas Witkowski's avatar
Thomas Witkowski committed
13
14
15
16
17
18
19
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
*/

BOOST_AUTO_TEST_CASE(amdis_mpi_feti_multilevel)
{
  BOOST_REQUIRE(MPI::COMM_WORLD.Get_size() == 16);

  ProblemStat ellipt("ellipt");
  ellipt.initialize(INIT_ALL);

  MeshDistributor *meshDist = MeshDistributor::globalMeshDistributor;
  meshDist->initParallelization();

  const FiniteElemSpace *feSpace = ellipt.getFeSpace();
  vector<const FiniteElemSpace*> feSpaces;
  feSpaces.push_back(feSpace);

  Mesh* mesh = ellipt.getMesh();
  mesh->dofCompress();

  BOOST_REQUIRE(mesh->getNumberOfLeaves() == 4);
  BOOST_REQUIRE(meshDist->getMeshLevelData().getLevelNumber() == 2);
  BOOST_REQUIRE(feSpace->getAdmin()->getUsedSize() == 5);

  MeshLevelData &levelData = meshDist->getMeshLevelData();
  DofComm::LevelDataType &sendDofs = meshDist->getDofComm().getSendDofs();
  DofComm::LevelDataType &recvDofs = meshDist->getDofComm().getRecvDofs();

  ParallelDofMapping dofMap;
  dofMap.init(levelData, feSpaces, feSpaces, true, true);
  dofMap.setDofComm(meshDist->getDofComm());
  dofMap.clear();

  Spreadsheet sheet;
  sheet.read("data/data0004a");
  vector<vector<double> > &data = sheet.getData();
  for (unsigned int i = 0; i < data.size(); i++) {
    if (data[i][0] != MPI::COMM_WORLD.Get_rank()) 
      continue;

    int level = data[i][1];
    int nSendDofs = data[i][2];
    int nRecvDofs = data[i][3];

    int compareSendDofs = 
      meshDist->getDofComm().getNumberDofs(sendDofs, level, feSpace);
    int compareRecvDofs =
      meshDist->getDofComm().getNumberDofs(recvDofs, level, feSpace);

    TEST_EXIT(nSendDofs == compareSendDofs)
      ("Wrong number of SEND DOFs in level %d: %d %d\n", 
       level, nSendDofs, compareSendDofs);

    TEST_EXIT(nRecvDofs == compareRecvDofs)
      ("Wrong number of RECV DOFs in level %d: %d %d\n", 
       level, nRecvDofs, compareRecvDofs);
  }
}


int main(int argc, char **argv)
{
  AMDiS::init(argc, argv, "./init/test0004.dat.2d");

  boost::unit_test::unit_test_main(&init_unit_test, argc, argv);

  AMDiS::finalize();
}