ArhReader.h 3 KB
Newer Older
1
2
3
4
// ============================================================================
// ==                                                                        ==
// == Amdis - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6
7
// ==                                                                        ==
// ============================================================================
8
9
10
//
// Software License for AMDiS
//
Florian Stenger's avatar
Florian Stenger committed
11
// Copyright (c) 2010 Dresden University of Technology
12
13
14
15
16
17
18
19
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


20
21
22
23
24
25
26
27
28
29

/** \file ArhReader.h */

#ifndef AMDIS_ARH_READER_H
#define AMDIS_ARH_READER_H

#include "AMDiS_fwd.h"

namespace AMDiS {

30
31
  using namespace std;

32
33
34
  class ArhReader
  {
  public:
35
    static void read(string filename, Mesh *mesh,
Florian Stenger's avatar
Florian Stenger committed
36
		     DOFVector<double>* vec0 = NULL,
37
		     DOFVector<double>* vec1 = NULL,
Florian Stenger's avatar
Florian Stenger committed
38
		     DOFVector<double>* vec2 = NULL,
39
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
40
		     bool writeParallel = true,
41
42
43
#else
		     bool writeParallel = false,
#endif
44
		     int nProcs = -1);
45

Florian Stenger's avatar
Florian Stenger committed
46
    static void read(string filename, Mesh *mesh,
47
		     vector<DOFVector<double>*> vecs,
48
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
49
		     bool writeParallel = true,
50
51
52
#else
		     bool writeParallel = false,
#endif
53
		     int nProcs = -1);
54

Florian Stenger's avatar
Florian Stenger committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    static void readFromMemoryBlock(vector<char> &data, Mesh *mesh,
           DOFVector<double>* vec0 = NULL,
           DOFVector<double>* vec1 = NULL,
           DOFVector<double>* vec2 = NULL,
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
           bool writeParallel = true,
#else
           bool writeParallel = false,
#endif
           int nProcs = -1);

    static void readFromMemoryBlock(vector<char> &data, Mesh *mesh,
           vector<DOFVector<double>*> vecs,
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
           bool writeParallel = true,
#else
           bool writeParallel = false,
#endif
           int nProcs = -1);

75
    static int getNumValueVectors(string filename)
Florian Stenger's avatar
Florian Stenger committed
76
    {
77
78
79
80
81
82
      ifstream file;
      file.open(filename.c_str(), ios::in | ios::binary);

      string typeId = "";
      uint32_t nMacroElements = 0;
      uint32_t nValueVectors = 0;
Florian Stenger's avatar
Florian Stenger committed
83
      //uint32_t nAllValues = 0;
84
85
86
87

      file.read(const_cast<char*>(typeId.data()), 4);
      file.read(reinterpret_cast<char*>(&nMacroElements), 4);
      file.read(reinterpret_cast<char*>(&nValueVectors), 4);
Florian Stenger's avatar
Florian Stenger committed
88
      //file.read(reinterpret_cast<char*>(&nAllValues), 4);
89
90

      file.close();
Florian Stenger's avatar
Florian Stenger committed
91

92
93
      return nValueVectors;
    }
Florian Stenger's avatar
Florian Stenger committed
94

95
  private:
96

Florian Stenger's avatar
Florian Stenger committed
97
    static void readFile(string filename,
98
99
100
			 Mesh *mesh,
			 vector<DOFVector<double>*> vecs);

Florian Stenger's avatar
Florian Stenger committed
101
    static void setDofValues(int macroElIndex, Mesh *mesh,
102
			     vector<double>& values, DOFVector<double>* vec);
Florian Stenger's avatar
Florian Stenger committed
103
104
105
106
107

    static void readBlock(vector<char> &data,
         Mesh *mesh,
         vector<DOFVector<double>*> vecs);

108
109
110
111
  };
}

#endif