test0002.cc 2.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE 0002
#define BOOST_TEST_NO_MAIN

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

using namespace AMDiS;
using namespace std;

/*
12
13
  - Simple FETI-DP test on the number of local and global primal, dual and
    interior nodes.
14
15
*/

16
BOOST_AUTO_TEST_CASE(amdis_mpi_feti)
17
18
19
20
21
22
23
24
{
  BOOST_REQUIRE(MPI::COMM_WORLD.Get_size() == 16);

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

  MeshDistributor *meshDist = MeshDistributor::globalMeshDistributor;
  meshDist->initParallelization();
25
  ParallelDofMapping &dofMap = meshDist->getDofMap();
26
27
28

  Mesh* mesh = ellipt.getMesh();
  BOOST_REQUIRE(mesh->getNumberOfLeaves() == 8);
29
  BOOST_REQUIRE(meshDist->getMeshLevelData().getLevelNumber() == 1);
30
31
32
33
34
35
36
37
38
39
40

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

  PetscSolverFeti &feti = *(dynamic_cast<PetscSolverFeti*>(ellipt.getPetscSolver()));
  feti.setMeshDistributor(meshDist);
  feti.initialize(feSpaces);
  feti.createFetiData();

  BOOST_REQUIRE(feti.getNumberOfPrimals() == 21);
  BOOST_REQUIRE(feti.getNumberOfDuals() == 48);
41
42
43
44
45


  Spreadsheet sheet;
  sheet.read("data/data0002a");
  vector<double> data = sheet.getData()[MPI::COMM_WORLD.Get_rank()];
46

47
48
49
50
  const FiniteElemSpace *feSpace = ellipt.getFeSpace(0);
  vector<double> testData;
  testData.push_back(feti.getNumberOfRankPrimals());
  testData.push_back(feti.getNumberOfRankDuals());
51
52
53
  testData.push_back(dofMap[feSpace].nRankDofs[0]);
  testData.push_back(dofMap[feSpace].rStartDofs[0]);
  testData.push_back(dofMap[feSpace].nOverallDofs[0]);
54
55

  BOOST_REQUIRE(data.size() - 1 == testData.size());
56
57
58
59
60
61
  for (int i = 0; i < 5; i++) {
    if (data[i + 1] != testData[i]) {
      MSG("Wrong data in column %d: %f %f\n", i, data[i + 1], testData[i]);
      BOOST_ERROR("");
    }
  }
62
63
64
65
66
67
68
69
70
71
72

  ellipt.getRefinementManager()->globalRefine(mesh, 6);
  meshDist->checkMeshChange();
  feti.createFetiData();


  sheet.read("data/data0002b");
  data = sheet.getData()[MPI::COMM_WORLD.Get_rank()];
  testData.clear();
  testData.push_back(feti.getNumberOfRankPrimals());
  testData.push_back(feti.getNumberOfRankDuals());
73
74
75
  testData.push_back(dofMap[feSpace].nRankDofs[0]);
  testData.push_back(dofMap[feSpace].rStartDofs[0]);
  testData.push_back(dofMap[feSpace].nOverallDofs[0]);
76
77

  BOOST_REQUIRE(data.size() - 1 == testData.size());
78
79
80
81
82
83
  for (int i = 0; i < 5; i++) {
    if (data[i + 1] != testData[i]) {
      MSG("Wrong data in column %d: %f %f\n", i, data[i + 1], testData[i]);
      BOOST_ERROR("");
    }
  }
84
85
86
87
88
89
90
91
92
93
94
}


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

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

  AMDiS::finalize();
}