test0006.cc 2.61 KB
Newer Older
1
#define BOOST_TEST_DYN_LINK
2
#define BOOST_TEST_MODULE 0006
3
4
5
6
7
8
9
10
11
12
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
80
81
82
83
84
85
86
87
88
#define BOOST_TEST_NO_MAIN

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

using namespace AMDiS;
using namespace std;

/*
  - Test for interior boundaries of the subdomains on a 2-level 
     4x4 rank decomposition.
  - Compaires the interior boundary object with a serialization file.
  - Test for DOF communicators on the subdomains.
*/


void boundaryTest(RankToBoundMap &map0, RankToBoundMap &map1)
{
  BOOST_CHECK_MESSAGE(map0.size() == map1.size(), 
		      "Boundaries have different size!\n");

  for (RankToBoundMap::iterator it = map0.begin(); it != map0.end(); ++it) {
    if (map1.count(it->first) == 0) {
      MSG("Boundary with rank %d missing!\n", it->first);
      BOOST_ERROR("");
    }

    BOOST_CHECK_MESSAGE(it->second.size() == map1[it->first].size(), 
			"Wrong boundary size!\n");

    for (unsigned int i = 0; i < it->second.size(); i++)
      BOOST_CHECK_MESSAGE(it->second[i] == map1[it->first][i],
			  "Boundary is not equal!\n");
  }
}

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();

  InteriorBoundary testBoundary;  
  string filename = "data/data0006/interior_boundary_p" + 
    lexical_cast<string>(MPI::COMM_WORLD.Get_rank()) + ".ser";
  ifstream myfile(filename.c_str());
  testBoundary.deserialize(myfile, ellipt.getMesh());
  myfile.close();

  boundaryTest(testBoundary.getOwn(), meshDist->getIntBoundarySd().getOwn());
  boundaryTest(testBoundary.getOther(), meshDist->getIntBoundarySd().getOther());
  boundaryTest(testBoundary.getPeriodic(), meshDist->getIntBoundarySd().getPeriodic());



  Spreadsheet sheet;
  sheet.read("data/data0006/dofcomm_level_1.dat");
  vector<vector<double> > &data = sheet.getData();

  DofComm &dofCommSd = meshDist->getDofCommSd();
  DofComm::LevelDataType &sendDofsSd = dofCommSd.getSendDofs();
  DofComm::LevelDataType &recvDofsSd = dofCommSd.getRecvDofs();
  int nSendDofs = dofCommSd.getNumberDofs(sendDofsSd, 0, feSpace);
  int nRecvDofs = dofCommSd.getNumberDofs(recvDofsSd, 0, feSpace);

  int rank = MPI::COMM_WORLD.Get_rank();
  BOOST_CHECK(data[rank][0] == rank);
  BOOST_CHECK(data[rank][1] == nSendDofs);
  BOOST_CHECK(data[rank][2] == nRecvDofs);
}


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

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

  AMDiS::finalize();
}