Alsvinn  0.5.3
The fast FVM simulator with UQ support
HDF5Writer.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
17 #include "alsfvm/io/Writer.hpp"
18 #include <hdf5.h>
19 #include "alsfvm/io/hdf5_utils.hpp"
20 
21 namespace alsfvm {
22 namespace io {
23 
32 public:
40  HDF5Writer(const std::string& basefileName);
41 
42  virtual ~HDF5Writer() {}
43 
50  virtual void write(const volume::Volume& conservedVariables,
51  const grid::Grid& grid,
52  const simulator::TimestepInformation& timestepInformation) override;
53 
54 protected:
55 
62  void writeGrid(hid_t object, const grid::Grid& grid);
63 
64  void writeTimeGroup(hid_t object,
65  const simulator::TimestepInformation& timestepInformation);
66 
73  void writeVolume(const volume::Volume& volume, hid_t file,
74  hid_t accessList = H5P_DEFAULT);
75 
76 
77 
86  void writeMemory(const volume::Volume& volume, size_t index,
87  const std::string& name,
88  hid_t file, hid_t accessList = H5P_DEFAULT);
89 
97  virtual std::unique_ptr<HDF5Resource> createDatasetForMemory(
98  const volume::Volume& volume, size_t index, const std::string& name,
99  hid_t file);
100 
109  void writeMemoryToDataset(const volume::Volume& volume, size_t index,
110  const std::string& name,
111  hid_t dataset, hid_t accessList = H5P_DEFAULT);
112 
113 
114 
121  void writeString(hid_t object, const std::string& name,
122  const std::string& value);
123 
124 
131  void writeFloats(hid_t object, const std::string& name,
132  const std::vector<float>& values);
133 
140  void writeIntegers(hid_t object, const std::string& name,
141  const std::vector<int>& values);
142 
143 
145  const std::string basefileName;
146 };
147 
148 } // namespace io
149 } // namespace alsfvm
150 
151 
void writeGrid(hid_t object, const grid::Grid &grid)
Definition: HDF5Writer.cpp:51
The HDF5Writer class writes output to HDF5 format.
Definition: HDF5Writer.hpp:31
Definition: Grid.hpp:27
void writeFloats(hid_t object, const std::string &name, const std::vector< float > &values)
writeFloats writes the vector of floats as an attribute
Definition: HDF5Writer.cpp:218
void writeMemoryToDataset(const volume::Volume &volume, size_t index, const std::string &name, hid_t dataset, hid_t accessList=H5P_DEFAULT)
createDatasetForMemroy creates a dataset for the given memory
Definition: HDF5Writer.cpp:137
HDF5Writer(const std::string &basefileName)
HDF5Writer constructs a new HDF5Writer.
Definition: HDF5Writer.cpp:29
The Volume class represents a volume (a collection of cells with values for each cell (eg...
Definition: Volume.hpp:30
virtual std::unique_ptr< HDF5Resource > createDatasetForMemory(const volume::Volume &volume, size_t index, const std::string &name, hid_t file)
createDatasetForMemroy creates a dataset for the given memory
Definition: HDF5Writer.cpp:102
virtual void write(const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation) override
write writes the data to disk
Definition: HDF5Writer.cpp:34
size_t snapshotNumber
Definition: HDF5Writer.hpp:144
std::string name
Definition: EquationParameterFactory.cpp:39
const std::string basefileName
Definition: HDF5Writer.hpp:145
const grid::Grid & grid
Definition: NumericalFluxFactory.cpp:104
virtual ~HDF5Writer()
Definition: HDF5Writer.hpp:42
The Writer class is an abstract interface to represent output writers.
Definition: Writer.hpp:28
void writeVolume(const volume::Volume &volume, hid_t file, hid_t accessList=H5P_DEFAULT)
writeVolume takes each variable of the volume and writes it
Definition: HDF5Writer.cpp:88
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
void writeTimeGroup(hid_t object, const simulator::TimestepInformation &timestepInformation)
Definition: HDF5Writer.cpp:83
void writeIntegers(hid_t object, const std::string &name, const std::vector< int > &values)
writeIntegerss writes the vector of integers as an attribute
Definition: HDF5Writer.cpp:233
void writeString(hid_t object, const std::string &name, const std::string &value)
writeString writes the string as an attribute to the given object
Definition: HDF5Writer.cpp:201
void writeMemory(const volume::Volume &volume, size_t index, const std::string &name, hid_t file, hid_t accessList=H5P_DEFAULT)
writeMemory writes a memory area to disk
Definition: HDF5Writer.cpp:190
Definition: TimestepInformation.hpp:22