PeriodicMap.cc 3.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//
// 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.


#include <fstream>
#include "parallel/PeriodicMap.h"

namespace AMDiS {

18
  void PeriodicMap::add(const FiniteElemSpace *feSpace,
19
			PeriodicDofMap &newMap)
20
21
22
23
  {
    FUNCNAME("PeriodicMap::add()");
    
    for (PeriodicDofMap::iterator it = newMap.begin(); it != newMap.end(); ++it)
Thomas Witkowski's avatar
Thomas Witkowski committed
24
      for (DofMap::iterator dofIt =it->second.begin();
25
	   dofIt != it->second.end(); ++dofIt)
26
	add(feSpace, it->first, dofIt->second, dofIt->first);
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
  void PeriodicMap::serialize(ostream &out, 
			      vector<const FiniteElemSpace*> feSpaces)
  {
    FUNCNAME("PeriodicMap::serialize()");
    
    int nFeSpace = static_cast<int>(feSpaces.size());
    
    for (int i = 0; i < nFeSpace; i++)
      serialize(out, periodicDofMap[feSpaces[i]]);
    
    for (int i = 0; i < nFeSpace; i++)
      serialize(out, periodicDofAssociations[feSpaces[i]]);
  }


  void PeriodicMap::deserialize(istream &in, 
				vector<const FiniteElemSpace*> feSpaces)
  {      
    FUNCNAME("PeriodicMap::deserialize()");
    
    int nFeSpace = static_cast<int>(feSpaces.size());
    
    for (int i = 0; i < nFeSpace; i++)
      deserialize(in, periodicDofMap[feSpaces[i]]);
    
    for (int i = 0; i < nFeSpace; i++)
      deserialize(in, periodicDofAssociations[feSpaces[i]]);
  }
  
  
  void PeriodicMap::serialize(ostream &out, PeriodicDofMap &data)
  {
    int mapSize = data.size();
    SerUtil::serialize(out, mapSize);
    
    for (PeriodicDofMap::iterator it = data.begin(); it != data.end(); ++it) {
      int type = it->first;
Thomas Witkowski's avatar
Thomas Witkowski committed
67
      DofMap dofMap = it->second;
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
93
94
95
96
97
98
99
      
      SerUtil::serialize(out, type);
      SerUtil::serialize(out, dofMap);
    }
  }
  

  void PeriodicMap::serialize(ostream &out, std::map<int, std::set<int> >& data)
  {
    int mapSize = data.size();
    SerUtil::serialize(out, mapSize);
    
    for (std::map<int, std::set<int> >::iterator it = data.begin(); 
	 it != data.end(); ++it) {
      int dof = it->first;
      std::set<int> typeSet = it->second;
      
      SerUtil::serialize(out, dof);
      SerUtil::serialize(out, typeSet);
    }
  }
  
  
  void PeriodicMap::deserialize(istream &in, PeriodicDofMap &data)
  {
    data.clear();
    
    int mapSize = 0;
    SerUtil::deserialize(in, mapSize);
    
    for (int i = 0; i < mapSize; i++) {
      int type;
Thomas Witkowski's avatar
Thomas Witkowski committed
100
      DofMap dofMap;
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
      
      SerUtil::deserialize(in, type);
      SerUtil::deserialize(in, dofMap);
      
      data[type] = dofMap;
    }
  }
  
  
  void PeriodicMap::deserialize(istream &in, std::map<int, std::set<int> >& data)
  {
    data.clear();
    
    int mapSize = 0;
    SerUtil::deserialize(in, mapSize);
    
    for (int i = 0; i < mapSize; i++) {
      int dof;
      std::set<int> typeSet;
      
      SerUtil::deserialize(in, dof);
      SerUtil::deserialize(in, typeSet);
      
      data[dof] = typeSet;
    }
  }
  
}