DofComm.cc 4.15 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
#include "parallel/DofComm.h"
#include "parallel/InteriorBoundary.h"
15
#include "parallel/MeshLevelData.h"
16
#include "FiniteElemSpace.h"
17
18
19
20
21

namespace AMDiS {

  using namespace std;

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

  void DofComm::init(int level, 
		     MeshLevelData &ld,
		     vector<const FiniteElemSpace*> &fe)
  {
    FUNCNAME("DofComm::init()");
    
    meshLevel = level;
    levelData = &ld;
    feSpaces = fe;
    
    nLevel = levelData->getLevelNumber() - meshLevel;
    TEST_EXIT_DBG(nLevel >= 1)("Should not happen!\n");

    sendDofs.clear();
    recvDofs.clear();
    periodicDofs.clear();
    
    sendDofs.resize(nLevel);
    recvDofs.resize(nLevel);
    periodicDofs.resize(nLevel);
  }


46
  void DofComm::create(InteriorBoundary &boundary)
47
  {
48
49
    FUNCNAME("DofComm::create()");

50
51
    createContainer(boundary.getOwn(), sendDofs);
    createContainer(boundary.getOther(), recvDofs);
52
53
54
  }


55
56
  void DofComm::createContainer(RankToBoundMap &boundary,
				LevelDataType &data)
57
  {
58
59
    FUNCNAME("DofComm::createContainer()");

60
61
62
63
64
65
66
67
68
69
    // === 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. ===
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

    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;
88
89
90
91
      }
    }
  }

92

Thomas Witkowski's avatar
Thomas Witkowski committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  void DofComm::serialize(ostream &out)
  {
    FUNCNAME("DofComm:serialize()");

    MSG("MUSS DAS WIRKLICH SEIN????\n");
  }

  
  void DofComm::deserialize(istream &in, 
			    map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > dofIndexMap)
  {
    FUNCNAME("DofComm::deserialize()");

    MSG("MUSS DAS WIRKLICH SEIN????\n");
  }


  void DofComm::serialize(LevelDataType &data, ostream &out)
  {
    FUNCNAME("DofComm:serialize()");
  }

   
  void DofComm::deserialize(LevelDataType &data,
			    istream &in, 
			    map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > dofIndexMap)
  {
    FUNCNAME("DofComm::deserialize()");
  }


124
125
  int DofComm::getNumberDofs(LevelDataType &data, 
			     int level, 
Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
126
127
			     const FiniteElemSpace *feSpace,
			     bool countDouble)
128
129
130
131
132
  {
    FUNCNAME("DofComm::getNumberDofs()");

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

Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
133
134
    DofContainerSet dofSet;
    DofContainer dofVec;
135
136
137
138
139
140

    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)
Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
141
142
143
144
145
146
147
148
	  if (countDouble)
	    dofVec.insert(dofVec.end(), feIt->second.begin(), feIt->second.end());
	  else
	    dofSet.insert(feIt->second.begin(), feIt->second.end());

    if (countDouble)
      return static_cast<int>(dofVec.size());    
    return static_cast<int>(dofSet.size());
149
150
151
  }
  

152
  bool DofComm::Iterator::setNextFeMap()
153
  {
154
155
    FUNCNAME("DofComm::Iterator::setNextFeMap()");

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

159
160
161
      feMapIter = dataIter->second.begin();
      
      if (traverseFeSpace != NULL) {
162
163
	if ((dataIter->second.count(traverseFeSpace) == 0))
	  return false;
164
165
166
167
168
169
170
171
172
173
	
	while (feMapIter->first != traverseFeSpace &&
	       feMapIter != dataIter->second.end())
	  ++feMapIter;
	
	TEST_EXIT_DBG(feMapIter != dataIter->second.end() &&
		      feMapIter->first == traverseFeSpace)
	  ("Should not happen!\n");
      }
      
174
      dofIter = feMapIter->second.begin();      
175
176
      dofCounter = 0;
    }
177
178

    return true;
179
180
181
  }

}