Peano
Loading...
Searching...
No Matches
CheckpointReader.h
Go to the documentation of this file.
1// This file is part of the ExaHyPE2 project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
6#include "tarch/la/Vector.h"
7#include "tarch/logging/Log.h"
9
10#include <array>
11#include <map>
12#include <memory>
13#include <string>
14#include <vector>
15
16
17namespace exahype2 {
18 class CheckpointReader;
19} // namespace exahype2
20
21
73public:
95 const std::string& indexFileName,
96 double timeStamp,
97 int haloWidth,
98 const tarch::la::Vector<Dimensions, double>& domainOffset,
100 );
101
105 static void release(const std::string& indexFileName);
106
108 const std::string& indexFileName,
109 double timeStamp,
110 int haloWidth,
111 const tarch::la::Vector<Dimensions, double>& domainOffset,
113 );
114
118 const std::vector<peano4::grid::GridControlEvent>& getRefinementEvents(
119 ) const;
120
136 int numberOfEntries,
137 double* patchWithHalo
138 ) const;
139
145 const std::string& getMetaData() const;
146
150 double getTimeStamp() const;
151
153
154private:
158 using Key = std::array<long long, Dimensions + 1>;
159
161
163 static std::map<std::string, std::unique_ptr<CheckpointReader>> _instances;
164
165 const int _haloWidth;
168
170 std::string _metaData;
171 std::vector<std::vector<double>> _patchData;
172 std::map<Key, int> _patchIndex;
173 std::vector<peano4::grid::GridControlEvent> _refinementEvents;
174
181 ) const;
182
186 std::vector<std::string> readIndexFile(
187 const std::string& indexFileName,
188 double timeStamp
189 );
190
191 void readPatchFile(const std::string& fileName);
192
194};
Read a checkpoint back.
static tarch::multicore::BooleanSemaphore _semaphore
std::vector< std::string > readIndexFile(const std::string &indexFileName, double timeStamp)
Files of the selected dataset in the index file.
const tarch::la::Vector< Dimensions, double > _domainSize
const std::string & getMetaData() const
Content of the meta-data block of the dataset's files, i.e.
static void release(const std::string &indexFileName)
Free the reader of an index file, if there is one.
std::vector< peano4::grid::GridControlEvent > _refinementEvents
std::map< Key, int > _patchIndex
const std::vector< peano4::grid::GridControlEvent > & getRefinementEvents() const
Refinement events which reconstruct the checkpoint's mesh.
static std::map< std::string, std::unique_ptr< CheckpointReader > > _instances
void readPatchFile(const std::string &fileName)
Key toKey(const tarch::la::Vector< Dimensions, double > &cellOffset, const tarch::la::Vector< Dimensions, double > &cellH) const
Level and integer index of a cell within the regular grid of its level.
static tarch::logging::Log _log
static CheckpointReader & getInstance(const std::string &indexFileName, double timeStamp, int haloWidth, const tarch::la::Vector< Dimensions, double > &domainOffset, const tarch::la::Vector< Dimensions, double > &domainSize)
Reader of a checkpoint dataset.
std::vector< std::vector< double > > _patchData
double getTimeStamp() const
Time stamp of the dataset as given in the index file.
CheckpointReader(const std::string &indexFileName, double timeStamp, int haloWidth, const tarch::la::Vector< Dimensions, double > &domainOffset, const tarch::la::Vector< Dimensions, double > &domainSize)
bool readPatch(const tarch::la::Vector< Dimensions, double > &cellCentre, const tarch::la::Vector< Dimensions, double > &cellH, int numberOfEntries, double *patchWithHalo) const
Copy the data of a cell's patch including its halo.
std::array< long long, Dimensions+1 > Key
Integer index of the cell per axis, followed by its level.
const tarch::la::Vector< Dimensions, double > _domainOffset
Log Device.
Definition Log.h:517
This file is part of the ExaHyPE 2 project within Peano 4.
Definition __init__.py:1
Simple vector class.
Definition Vector.h:159