Peano
Loading...
Searching...
No Matches
FileReaderHDF5.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include "config.h"
8
9#include "tarch/logging/Log.h"
10
11#include <list>
12#include <vector>
13
14#ifdef UseHDF5
15#include "H5Cpp.h"
16#endif
17
18namespace toolbox {
19 namespace particles {
20 class FileReaderHDF5;
21 }
22}
23
24
36 private:
38
39 /* Coordinates */
40 std::list< tarch::la::Vector<Dimensions,double> > _Coordinates;
41
42 /* Other fields in the HDF5 file */
43 std::vector< tarch::la::Vector<Dimensions,double> > _Velocity;
44 std::vector<double> _Mass;
45 std::vector<double> _SmoothingLength;
46 std::vector<double> _InternalEnergy;
47 std::vector<int> _ParticleIDs;
48
49 /* If we are removing read-in particles on-the-fly while sorting
50 * them into voxels, we need to keep track of their index to access
51 * the other particle quantities correctly. This list keeps these indexes.*/
52 std::list<int> _ParticleIndex;
53
54 /* Copies that hold the data only for particles within the voxel */
55 /* If you are adding additional quantities, don't forget to update them
56 * in FileReaderHDF5.clearVoxel() and FileReaderHDF5.isVoxelEmpty()
57 * as well */
58 std::vector< tarch::la::Vector<Dimensions,double> > _VelocityWithinVoxel;
59 std::vector<double> _MassWithinVoxel;
60 std::vector<double> _SmoothingLengthWithinVoxel;
61 std::vector<double> _InternalEnergyWithinVoxel;
62 std::vector<int> _ParticleIDsWithinVoxel;
63
64 public:
72 void readHDF5File( const std::string& filename );
73
74#ifdef UseHDF5
75
87 std::vector< int > readIntScalar(
88 const H5::H5File& file,
89 const H5std_string& groupName,
90 const H5std_string& datasetName );
91
103 std::vector< double > readDoubleScalar(
104 const H5::H5File& file,
105 const H5std_string& groupName,
106 const H5std_string& datasetName );
107
119 std::list< tarch::la::Vector<Dimensions,double> > readDoubleArray(
120 const H5::H5File& file,
121 const H5std_string& groupName,
122 const H5std_string& datasetName );
123
135 std::vector< tarch::la::Vector<Dimensions,double> > readFloatArray(
136 const H5::H5File& file,
137 const H5std_string& groupName,
138 const H5std_string& datasetName );
139
140#endif
141
168 std::list< tarch::la::Vector<Dimensions,double> > getParticlesWithinVoxel(
171 bool remove
172 );
173
174
175 void clear();
176
177 bool empty() const;
178
179 bool getNumberOfCoordinates() const;
180
184 void clearVoxel();
185
190 bool isVoxelEmpty() const;
191
192 /*
193 * Get methods for data other than Coordinates.
194 */
195 std::vector< tarch::la::Vector<Dimensions,double> > getVelocityWithinVoxel() const;
196 std::vector<double> getMassWithinVoxel() const;
197 std::vector<double> getSmoothingLengthWithinVoxel() const;
198 std::vector<double> getInternalEnergyWithinVoxel() const;
199 std::vector<int> getParticleIDsWithinVoxel() const;
200
201};
202
Log Device.
Definition Log.h:516
An HDF5 file reader This class works if and only if you have compiled Peano using –with-hdf5.
std::vector< double > _MassWithinVoxel
std::vector< double > _InternalEnergyWithinVoxel
std::vector< double > _InternalEnergy
std::vector< double > getMassWithinVoxel() const
std::vector< double > _SmoothingLengthWithinVoxel
bool isVoxelEmpty() const
Check whether voxel data carried by this instance of FileReaderHDF5 is empty.
void readHDF5File(const std::string &filename)
Read HDF5 file in SWIFT format.
std::vector< double > getSmoothingLengthWithinVoxel() const
std::vector< double > _SmoothingLength
std::vector< double > getInternalEnergyWithinVoxel() const
void clearVoxel()
Clear data of a voxel carried by this instance of FileReaderHDF5.
std::list< tarch::la::Vector< Dimensions, double > > getParticlesWithinVoxel(const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h, bool remove)
Take particles from database which fall into given voxel.
std::vector< tarch::la::Vector< Dimensions, double > > getVelocityWithinVoxel() const
std::list< tarch::la::Vector< Dimensions, double > > _Coordinates
std::vector< tarch::la::Vector< Dimensions, double > > _VelocityWithinVoxel
static tarch::logging::Log _log
std::vector< int > getParticleIDsWithinVoxel() const
std::vector< tarch::la::Vector< Dimensions, double > > _Velocity
std::vector< int > _ParticleIDsWithinVoxel
Simple vector class.
Definition Vector.h:150