MeshLevelData.cc 2.21 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


Thomas Witkowski's avatar
Thomas Witkowski committed
13
#include <boost/lexical_cast.hpp>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "parallel/MeshLevelData.h"
#include "Global.h"

namespace AMDiS {

  using namespace std;


  void MeshLevelData::init(std::set<int> &neighbourRanks)
  {
    levelRanks.resize(1);
    levelRanks[0].insert(-1);
    nLevel = 1;
    
Thomas Witkowski's avatar
Thomas Witkowski committed
28
29
    levelNeighbours.resize(1);
    levelNeighbours[0] = neighbourRanks;
30
31
32
33
34
35
36
37
38
39
40
41
42
  }


  void MeshLevelData::addLevel(std::set<int> &ranksInDomain)
  {
    FUNCNAME("MeshLevelData()::addLevel()");

    TEST_EXIT(nLevel >= 1)("Mesh level structure is not initialized()");
    TEST_EXIT(nLevel == 1)("Only 2 level are supported yet!\n");

    levelRanks.insert(levelRanks.begin(), ranksInDomain);
    nLevel++;

Thomas Witkowski's avatar
Thomas Witkowski committed
43
44
45
46
47
    levelNeighbours.resize(2);    
    levelNeighbours[1] = levelNeighbours[0];
    levelNeighbours[0].clear();
    for (std::set<int>::iterator it = levelNeighbours[1].begin(); 
	 it != levelNeighbours[1].end(); ++it)
48
      if (levelRanks[0].count(*it) == 0)
Thomas Witkowski's avatar
Thomas Witkowski committed
49
	levelNeighbours[0].insert(*it);
50
51
52
53
54
55
56
57
58
59
60
61
  }


  void MeshLevelData::serialize(ostream &out)
  {
  }

  
  void MeshLevelData::deserialize(istream &in)
  {
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
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
89
90
91
92

  void MeshLevelData::print()
  {
    FUNCNAME("MeshLevelData::print()");

    using boost::lexical_cast;

    MSG("Print mesh level structure with %d levels: \n", nLevel);

    for (int i = 0; i < nLevel; i++) {
      string ranks = "ranks in level " + lexical_cast<string>(i) + ":";
      for (std::set<int>::iterator it = levelRanks[i].begin(); 
	   it != levelRanks[i].end(); ++it)
	ranks += " " + lexical_cast<string>(*it);

      string neighbours = "neighbours in level " + lexical_cast<string>(i) + ": ";
      for (std::set<int>::iterator it = levelNeighbours[i].begin(); 
	   it != levelNeighbours[i].end(); ++it)
	neighbours += " " + lexical_cast<string>(*it);

      if (ranks.length() < 250)
	MSG("  %s\n", ranks.c_str());
      else
	MSG("  ranks string to long!\n");

      if (neighbours.length() < 250)
	MSG("%s\n", neighbours.c_str());
      else
	MSG("  neighbours string to long!\n");
    }
  }
93
}