Arh3Writer.h 4.32 KB
Newer Older
Siqi Ling's avatar
Siqi Ling committed
1
2
3
4
5
6
7
8
#ifndef AMDIS_ARH_WRITER3_DETAIL_H
#define AMDIS_ARH_WRITER3_DETAIL_H

#include "Global.h"
#include "Mesh.h"
#include "MeshStructure.h"
#include "DOFVector.h"
#include "SystemVector.h"
Siqi Ling's avatar
Siqi Ling committed
9
#include "AdaptInfo.h"
Siqi Ling's avatar
Siqi Ling committed
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
45
46
#include "boost/assign.hpp"

namespace AMDiS { namespace io {

  namespace Arh3Writer
  {
    typedef enum{
        NONE = 0,
	ZLIB = 1,
	BZIP2 = 2
    } Cpsformat;
    
    typedef enum{SI08, SI16, SI32, SI64, UI08, UI16, UI32, UI64, SF32, SF64} Valformat;
    
    using namespace boost::assign;
    
    static const std::map<std::string, Valformat> dataformatMap = map_list_of("SI08", SI08)
									  ("SI16", SI16)
									  ("SI32", SI32)
									  ("SI64", SI64)
									  ("UI08", UI08)
									  ("UI16", UI16)
									  ("UI32", UI32)
									  ("UI64", UI64)
									  ("SF32", SF32)
									  ("SF64", SF64);
      
    namespace detail
    {
      //Maybe remove this later
      void write(std::string filename,                                                
                      DOFVector<double>* vec0 = NULL,                                                  
                      DOFVector<double>* vec1 = NULL,
                      DOFVector<double>* vec2 = NULL,
		      bool writeParallel = true,
		      Cpsformat cps = NONE,
		      std::string dataformat = "SF64",
47
		      bool writeMacro = false);
Siqi Ling's avatar
Siqi Ling committed
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
    
      /**
       * \ingroup Output
       *
       * \brief
       * checks the arguments, eventually splits the list of DOFVectors, to write
       * these to different files.
       * 
       * The behavior is as follows:
       * 
       * If mesh is given, then all the DOFVectors in vecs must belong to the
       * same mesh as the given one.
       * 
       * Else vecs can contain DOFVector belong to different meshes and they
       * will be seperated to diff files. If multiple output files generated, 
       * they are named like "filename.meshname.arh". 
       * 
       * Note: NULL pointer in vecs is not allowed for writeFile.
       *       If mesh is NULL and vecs is empty, a warning is showed and returned.
       *       Identical name in DOFVectors is not allowed.
      */
       void write(std::string filename, 
		  Mesh* mesh, 
		  std::vector<DOFVector<double>*> vecs,
		  bool writeParallel = true,
		  Cpsformat cps = NONE,
		  std::string dataformat = "SF64",
75
		  bool writeMacro = false);
Siqi Ling's avatar
Siqi Ling committed
76
77
78
79

       void writeAux(std::string filename, Mesh *mesh,
		       std::vector<DOFVector<double>*> vecs,
		       bool writeParallel, Cpsformat cps,
80
81
		       std::string dataformat,
		       bool writeMacro = false);
Siqi Ling's avatar
Siqi Ling committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

       ///\return the size of the macro block in file
       std::pair<int, int> writeMacroElement(std::ofstream &file,
                                  MeshStructure &code,
                                  std::vector<std::vector<double> >& values,
                                  std::map<const FiniteElemSpace*, 
				  std::vector<int> >& feSpaces, 
				  Cpsformat cps, std::string dataformat);
       
       int writeValues(std::stringstream& file,
		       std::string dataformat, 
		       std::vector<double>& values);
       
       template<typename T>
       int writeValues(std::stringstream& file, std::vector<double>& values);

       int writeHeader(std::ofstream& file,
                            Mesh* mesh,
                            std::vector<DOFVector<double>*> vecs,
                            std::map<const FiniteElemSpace*, 
			    std::vector<int> >& feSpaces, 
103
104
			    Cpsformat cps, 
			    std::string dataformat);    
Siqi Ling's avatar
Siqi Ling committed
105
106
107
       
       ///internal method, don't call
       void setMacrosPos(std::ofstream& file, int headerLen,
108
109
110
111
112
113
	                    std::vector<std::pair<int, int> >& macroSize);  
       
       ///internal method, don't call
       void setMacroFile(std::ofstream& file, int headerLen, Mesh* mesh);
       
       void readFileToString(std::string filename, std::string& data);
Siqi Ling's avatar
Siqi Ling committed
114
       
Siqi Ling's avatar
Siqi Ling committed
115
116
117
118
119
120
121
       void updateAnimationFile(AdaptInfo *adaptInfo, 
				std::vector<double>* arhAnimationFrames,
				bool createSubDir,
				int indexLength,
				int indexDecimals,
				std::string animationFilename);
       
Siqi Ling's avatar
Siqi Ling committed
122
123
124
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS         
       void writeParallelFile(std::string filename,
			      Mesh* mesh,
125
126
			      bool createSubDir,
			      bool writeMacro = true);
Siqi Ling's avatar
Siqi Ling committed
127
128
129
130
131
132
#endif
    }//end namespace detail
  } // end namespace Arh3Writer
} } // end namespace io, AMDiS

#endif