Skip to content

Commit

Permalink
Fix more wrong comparisons and output wrong values
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Nov 2, 2016
1 parent 71ad4b4 commit 5ef7752
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions include/plugins/hdf5/LaserSource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ namespace hdf5 {
// Read where the values are defined in the cell
float2_X incellPosition;
reader["x"].getAttributeReader()("position", incellPosition);
if(swapAxis)
std::swap(incellPosition.x(), incellPosition.y());
// For now just add it to the global offset
gridGlobalOffset += incellPosition * hdf5CellSize;
float2_X hdf5GlobalSize = hdf5CellSize * float2_X(hdf5GridSize) - gridGlobalOffset;
Expand Down Expand Up @@ -327,35 +329,52 @@ namespace hdf5 {
if(PMaccMath::abs(hdf5CellSize[0] - gridSpacing[0]) >= hdf5CellSize[0] * 1e-5 ||
PMaccMath::abs(hdf5CellSize[1] - gridSpacing[1]) >= hdf5CellSize[1] * 1e-5)
{
throw std::runtime_error(std::string("Changed gridSpacing at HDF5-ID: ") +
std::to_string(reader.getId()));
throw std::runtime_error(
(boost::format("Changed gridSpacing at HDF5-ID %1%. Is: %2%x%3%\nExpected:%4%x%5%") %
std::to_string(reader.getId()) %
gridSpacing[0] % gridSpacing[1] %
hdf5CellSize[0] % hdf5CellSize[1]
).str()
);
}

splash::Dimensions hdf5FieldSize = reader["x"].getFieldReader().getGlobalSize();
if(tmpSwapAxis)
std::swap(hdf5FieldSize[0], hdf5FieldSize[1]);
if(hdf5FieldSize[0] != hdf5GridSize[0] || hdf5FieldSize[1] == hdf5GridSize[1])
if(hdf5FieldSize[0] != hdf5GridSize[0] || hdf5FieldSize[1] != hdf5GridSize[1])
{
throw std::runtime_error(std::string("Changed HDF5 field size at HDF5-ID: ") +
std::to_string(reader.getId()));
throw std::runtime_error(
(boost::format("Changed HDF5 field size at HDF5-ID %1%. Is: %2%x%3%\nExpected:%4%x%5%") %
std::to_string(reader.getId()) %
hdf5FieldSize[0] % hdf5FieldSize[1] %
hdf5GridSize[0] % hdf5GridSize[1]
).str()
);
}

float2_X hdf5GridGlobalOffset;
getAttribute("gridGlobalOffset", hdf5GridGlobalOffset);
if(swapAxis)
if(tmpSwapAxis)
std::swap(hdf5GridGlobalOffset.x(), hdf5GridGlobalOffset.y());
hdf5GridGlobalOffset *= gridUnitSI / UNIT_LENGTH;
// Read where the values are defined in the cell
float2_X incellPosition;
reader["x"].getAttributeReader()("position", incellPosition);
if(tmpSwapAxis)
std::swap(incellPosition.x(), incellPosition.y());
// For now just add it to the global offset
hdf5GridGlobalOffset += incellPosition * hdf5CellSize;

if(PMaccMath::abs(gridGlobalOffset[0] - hdf5GridGlobalOffset[0]) >= gridGlobalOffset[0] * 1e-5 ||
PMaccMath::abs(gridGlobalOffset[1] - hdf5GridGlobalOffset[1]) >= gridGlobalOffset[1] * 1e-5)
{
throw std::runtime_error(std::string("IChanged gridGlobalOffset or (incell-)position at HDF5-ID: ") +
std::to_string(reader.getId()));
throw std::runtime_error(
(boost::format("Changed gridGlobalOffset or (incell-)position at HDF5-ID %1%. Is: %2%x%3%\nExpected:%4%x%5%") %
std::to_string(reader.getId()) %
hdf5GridGlobalOffset[0] % hdf5GridGlobalOffset[1] %
gridGlobalOffset[0] % gridGlobalOffset[1]
).str()
);
}
}

Expand Down

0 comments on commit 5ef7752

Please sign in to comment.