DofComm.cc 2.68 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.


13
14
15
#include "parallel/DofComm.h"
#include "parallel/InteriorBoundary.h"
#include "FiniteElemSpace.h"
16
17
18
19
20

namespace AMDiS {

  using namespace std;

21
  void DofComm::create(InteriorBoundary &boundary)
22
  {
23
24
    createContainer(boundary.getOwn(), sendDofs);
    createContainer(boundary.getOther(), recvDofs);
25
26
27
  }


28
29
  void DofComm::createContainer(RankToBoundMap &boundary,
				LevelDataType &data)
30
31
32
33
34
35
36
37
38
39
40
  {
    // === Fill data. ===

    for (unsigned int i = 0; i < feSpaces.size(); i++)
      for (int level = 0; level < nLevel; level++)
	for (InteriorBoundary::iterator it(boundary, level); !it.end(); ++it)
	  it->rankObj.el->getAllDofs(feSpaces[i], it->rankObj, 
				     data[level][it.getRank()][feSpaces[i]]);


    // === Remove empty data containers. ===
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

    for (unsigned int i = 0; i < data.size(); i++) {
      DataIter dit = data[i].begin();
      while (dit != data[i].end()) {
	FeMapIter it = dit->second.begin();
	while (it != dit->second.end()) {
	  if (it->second.size() == 0) {
	    const FiniteElemSpace *fe = it->first;
	    ++it;
	    dit->second.erase(fe);
	  } else
	    ++it;
	}
	
	if (dit->second.size() == 0)
	  data[i].erase(dit++);
	else
	  ++dit;
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
  int DofComm::getNumberDofs(LevelDataType &data, 
			     int level, 
			     const FiniteElemSpace *feSpace)
  {
    FUNCNAME("DofComm::getNumberDofs()");

    TEST_EXIT_DBG(level < data.size())("Should not happen!\n");

    DofContainerSet dofs;

    for (DataIter rankIt = data[level].begin(); 
	 rankIt != data[level].end(); ++rankIt)
      for (FeMapIter feIt = rankIt->second.begin();
	   feIt != rankIt->second.end(); ++feIt)
	if (feIt->first == feSpace)
	  dofs.insert(feIt->second.begin(), feIt->second.end());

    return static_cast<int>(dofs.size());
  }
  

85
  bool DofComm::Iterator::setNextFeMap()
86
  {
87
88
    FUNCNAME("DofComm::Iterator::setNextFeMap()");

89
    if (dataIter != data[traverseLevel].end()) {
90
91
      TEST_EXIT_DBG(dataIter->second.size())("Should not happen!\n");

92
93
94
      feMapIter = dataIter->second.begin();
      
      if (traverseFeSpace != NULL) {
95
96
	if ((dataIter->second.count(traverseFeSpace) == 0))
	  return false;
97
98
99
100
101
102
103
104
105
106
	
	while (feMapIter->first != traverseFeSpace &&
	       feMapIter != dataIter->second.end())
	  ++feMapIter;
	
	TEST_EXIT_DBG(feMapIter != dataIter->second.end() &&
		      feMapIter->first == traverseFeSpace)
	  ("Should not happen!\n");
      }
      
107
      dofIter = feMapIter->second.begin();      
108
109
      dofCounter = 0;
    }
110
111

    return true;
112
113
114
  }

}