DataCollector.h 7.15 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file DataCollector.h */

#ifndef AMDIS_DATACOLLECTOR_H
#define AMDIS_DATACOLLECTOR_H

#include <list>
#include <vector>

#include "ElementInfo.h"
#include "VertexInfo.h"
#include "PeriodicInfo.h"
#include "MemoryManager.h"
#include "Mesh.h"

namespace AMDiS {
  class VertexInfo;
  class ElementInfo;
  class Mesh;
  class FiniteElemSpace;
  template<typename T> class DOFVector;

  /** 
   * \ingroup Output
   *
   * \brief
45
   * Provides data collecting of element, vertex and value data for file writer.
46
47
48
49
50
51
   */
  class DataCollector 
    {
    public:
      MEMORY_MANAGED(DataCollector);

52
      /// Constructor
53
54
55
56
57
58
59
60
      DataCollector(const FiniteElemSpace *feSpace,
		    DOFVector<double> *values,
		    int level = -1,
		    Flag traverseFlag = Mesh::CALL_LEAF_EL,
		    bool (*writeElem)(ElInfo*) = NULL);

      ~DataCollector();

61
      /// Fills the DataCollector with all possible datas.
Thomas Witkowski's avatar
Thomas Witkowski committed
62
63
      void fillAllData();

64
      /// Returns list with element information.
Thomas Witkowski's avatar
Thomas Witkowski committed
65
      std::list<ElementInfo>* getElementInfos();
66

67
      /// Returns vector with vertex information.
Thomas Witkowski's avatar
Thomas Witkowski committed
68
      DOFVector< std::list<VertexInfo> >* getVertexInfos();
69

70
      /// Returns the finite element space of the problem.
71
72
      const FiniteElemSpace* getFeSpace();

73
      /// Returns vector with value information.
74
75
      DOFVector<double>* getValues();

76
      /// Returns vector with information about dof coordinates.
Thomas Witkowski's avatar
Thomas Witkowski committed
77
      DOFVector< std::list<WorldVector<double> > >* getDofCoords();
78

79
      /// Returns vector with information about interpolation point indexing.
80
81
      DOFVector<int>* getInterpPointInd();

82
      ///
Thomas Witkowski's avatar
Thomas Witkowski committed
83
      DOFVector< std::list<WorldVector<double> > >* getInterpPointCoords();
84

85
      /// Returns list of interpolation point information.
Thomas Witkowski's avatar
Thomas Witkowski committed
86
      std::vector< std::vector<int> >* getInterpPoints();
87

88
      /// Returns list of information about periodics.
Thomas Witkowski's avatar
Thomas Witkowski committed
89
      std::list<PeriodicInfo>* getPeriodicInfos();
90

91
      /// Returns the number of vertices.
92
93
      int getNumberVertices();

94
      /// Returns the number of elements.
95
96
      int getNumberElements();

97
      /// Returns the number of interpolation points.
98
99
      int getNumberInterpPoints();

100
      // Returns the number of connections.
101
102
      int getNumberConnections();
      
103
      /// Returns the mesh of the problem.
104
105
      Mesh* getMesh();

106
107
      void setMesh(Mesh *mesh) {
	mesh_ = mesh;
108
      }
109

110
    protected:  
111
      /// Start collecting element and vertex data of the problem.
112
113
      int startCollectingElementData();

114
      /// Start collecting value data of the problem.
115
116
      int startCollectingValueData();

117
      /// Start collecting periodic data of the problem.
118
119
      int startCollectingPeriodicData();

120
      /// Adds information about one element and its vertices.
121
122
      int addElementData(ElInfo* elInfo);

123
      /// Adds value information of one element.
124
125
      int addValueData(ElInfo *elInfo);

126
      /// Adds information about interpolation points of vertices.
127
128
      int addInterpData(ElInfo *elInfo);

129
      /// Adds value information of one element.
130
131
      int addPeriodicData(ElInfo *elInfo);

132
      /// Vector with vertex values
133
134
      DOFVector<double> *values_;

135
      /// Level information for traversing the mesh.
136
137
      int level_;

138
      /// Flags for traversing the mesh.
139
140
      Flag traverseFlag_;

141
      ///
142
143
      const FiniteElemSpace *feSpace_;

144
      /// Mesh that should be written
145
146
      Mesh *mesh_;
      
147
      /// DOFAdmin of values
148
149
      DOFAdmin *localAdmin_;

150
      /// vertex pre-dofs
151
152
      int nPreDofs_;

153
      /// Number of vertices.
154
155
      int nVertices_;

156
      /// Number of elements.
157
158
      int nElements_;

159
      /// Total number of interpolation points.
160
161
      int nInterpPoints_;

162
      /// Number of connections in periodic problems.
163
164
      int nConnections_;

165
      /// Dimension of \ref mesh
166
167
      int dim_;
           
168
      /// Maps internal element indices to global output indices.
Thomas Witkowski's avatar
Thomas Witkowski committed
169
      std::map<int, int> outputIndices_;
170

171
      /// Global interpolation point indexing
172
173
      DOFVector<int> *interpPointInd_;

174
      /// Stores for each simplex the interpolation points.
Thomas Witkowski's avatar
Thomas Witkowski committed
175
      std::vector< std::vector<int> > interpPoints_;
176
177

      /** \brief
178
179
       * Stores for each DOF a list of its coordinates. If there are now periodic
       * boundaries than there is also only one coordinate per DOF.
180
       */
Thomas Witkowski's avatar
Thomas Witkowski committed
181
      DOFVector< std::list<WorldVector<double> > > *interpPointCoords_;
182

183
      /// list of coords for each dof
Thomas Witkowski's avatar
Thomas Witkowski committed
184
      DOFVector< std::list<WorldVector<double> > > *dofCoords_;
185

186
      /// List that stores an ElementInfo for each element.
Thomas Witkowski's avatar
Thomas Witkowski committed
187
      std::list<ElementInfo> elements_;
188

189
      /// List stat stores information about all periodics.
Thomas Witkowski's avatar
Thomas Witkowski committed
190
      std::list<PeriodicInfo> periodicInfos_;
191

192
      /// Stores a list of vertex infos for each dof.
Thomas Witkowski's avatar
Thomas Witkowski committed
193
      DOFVector< std::list<VertexInfo> > *vertexInfos_;
194
195
196
197
198

      /** \brief
       * periodicConnections[i][j] stores whether the connection at side j of 
       * the element with output index i has already been written.
       */
Thomas Witkowski's avatar
Thomas Witkowski committed
199
      std::vector<DimVec<bool> > periodicConnections_;
200

201
      /// Stores if element data was collected before.
202
203
      bool elementDataCollected_;

204
      /// Stores if value data was collected before.   
205
206
      bool valueDataCollected_;

207
      /// Stores if periodic data was collected before.
208
209
      bool periodicDataCollected_;

210
      /// Pointer to a function which decides whether an element is considered.
211
      bool (*writeElem_)(ElInfo*);
Thomas Witkowski's avatar
Thomas Witkowski committed
212

213
      /// Temporary variable used in functions addValueData() and addInterpData().
Thomas Witkowski's avatar
Thomas Witkowski committed
214
      DegreeOfFreedom *localDOFs_;
215
216
      
      /// Temporary variable used in functions addValueData() and addInterpData().
Thomas Witkowski's avatar
Thomas Witkowski committed
217
218
      BasisFunction *basisFcts_;

219
      /// Temporary variable used in functions addValueData() and addInterpData().
Thomas Witkowski's avatar
Thomas Witkowski committed
220
      int nBasisFcts_;
Thomas Witkowski's avatar
Thomas Witkowski committed
221

222
      /// Temporary variable used in function \ref addValueData.
Thomas Witkowski's avatar
Thomas Witkowski committed
223
      WorldVector<double> *vertexCoords;
224
225
226
227
    };
}

#endif