MacroWriter.h 3.96 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file MacroWriter.h */

#ifndef AMDIS_MACROWRITER_H
#define AMDIS_MACROWRITER_H

#include <list>
#include <vector>

#include "VertexInfo.h"
#include "ElementInfo.h"
#include "DataCollector.h"
#include "MemoryManager.h"
#include "FixVec.h"
#include "Boundary.h"
#include "Projection.h"
#include "Flag.h"
#include "Mesh.h"

namespace AMDiS {

  class VertexInfo;
  class ElementInfo;

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
85
86
87
88
89
90
91
92
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
  class Mesh;
  class ElInfo;
  class FiniteElemSpace;
  template<typename T> class DOFVector;
  template<typename T> class DimVec;

  /** 
   * \ingroup Output
   *
   * \brief
   * Writes the current leaf elements of a mesh as macro triangulation to
   * a text file. Pure static class.
   */
  class MacroWriter
  {
  public:
    /** \brief
     * Stores a list of vertex infos for each dof.
     */
    static DOFVector< ::std::list<VertexInfo> > *vertexInfos;

    /** \brief
     * List that stores an ElementInfo for each element.
     */
    static ::std::list<ElementInfo> elements;

  public:
    MEMORY_MANAGED(MacroWriter);

    /** \brief
     * Writes the leaf elements of a Mesh as a macro triangulation to a file.
     */
    static int writeMacro(DataCollector *dc,
			  const char *name, 		       
			  double time = 0.0,
			  int level = -1,
			  Flag traverseFlag = Mesh::CALL_LEAF_EL,
			  bool (*writeElem)(ElInfo*) = NULL);

    /** \brief
     * Init \ref periodicFile for the next macro to be written.
     */
    static void writePeriodicFile(DataCollector *dc,
				  const ::std::string filename);

 
  protected:
    /** \brief
     * Mesh that should be written
     */
    static Mesh *mesh;

    /** \brief
     * File to which the mesh should be written
     */
    static FILE *macroFile;

    /** \brief
     * File in which the periodic infos are stored.
     */
    static FILE *periodicFile;

    /** \brief
     * vertex pre-dofs
     */
    static int n0;

    /** \brief
     * Number of vertices.
     */
    static int nv;

    /** \brief
     * Number of elements.
     */
    static int ne;

    /** \brief
     * Number of connections.
     */
    static int nc;

    /** \brief
     * Dimension of \ref mesh
     */
    static int dim;

    /** \brief
     * Maps internal element indices to global output indices.
     */
    static ::std::map<int, int> outputIndices;

    /** \brief
     * periodicConnections[i][j] stores whether the connection at side j of 
     * the element with output index i has already been written.
     */
    static ::std::vector<DimVec<bool> > periodicConnections;

    /** \brief
     *
     */
    static bool (*writeElement)(ElInfo*);
  };
146
147
148
149

}

#endif