Skip to content

Commit

Permalink
prepare for H5 serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
philippwindischhofer committed Nov 14, 2023
1 parent 9a375c9 commit 9282318
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: |
mkdir -p build &&
pushd build &&
cmake -DBUILD_PYTHON=ON -DBUILD_WFC=ON ../ &&
cmake -DBUILD_PYTHON=ON -DBUILD_WFC=ON -DBUILD_TESTS=ON ../ &&
make &&
popd
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ project(eisvogel)

option(BUILD_PYTHON "Build with python support." OFF)
option(BUILD_WFC "Also build weighting field creator." OFF)
option(BUILD_TESTS "Build tests." OFF)

add_subdirectory(cmake)
add_subdirectory(src)
add_subdirectory(examples)

if(BUILD_PYTHON)
add_subdirectory(cpython)
endif(BUILD_PYTHON)
add_subdirectory(examples)

if(BUILD_TESTS)
add_subdirectory(tests)
endif(BUILD_TESTS)
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ and to also build the components for the calculation of the Green's function do
cmake -DBUILD_WFC=ON ..
```

If you want to build the C++ unit tests, add

```
cmake -DBUILD_TESTS=ON ..
```

## More information

- P. Windischhofer, C. Welling, C. Deaconu, "Eisvogel: Exact and efficient calculations of radio emissions from in-ice neutrino showers", PoS(ICRC2023)
Expand Down
34 changes: 34 additions & 0 deletions include/Eisvogel/H5Serialization.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef __H5SERIALIZATION_HH
#define __H5SERIALIZATION_HH

#include "hdf5.h"
#include <string>

namespace h5stor {

template <typename T>
struct Traits;

class H5Serializer {

public:
H5Serializer(std::string filepath) {
m_file_id = H5Fcreate(filepath.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
}

template <typename T>
void serialize(const T& value, std::string name) {
Traits<T>::serialize(m_file_id, value, name);
}

template <typename T>
T deserialize(std::string name) {
return Traits<T>::deserialize(m_file_id, name);
}

private:
hid_t m_file_id;
};
}

#endif
14 changes: 13 additions & 1 deletion include/Eisvogel/NDArray.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#include "Serialization.hh"

// ======================================================
// General n-dimensional array
// ======================================================

template <class T, std::size_t dims>
class NDArray {

Expand All @@ -34,7 +38,9 @@ protected:
template <class T, std::size_t dims>
inline NDArray<T, dims>::~NDArray() { }

// ======
// ======================================================
// Dense n-dimensional array
// ======================================================

template <class T, std::size_t dims>
class DenseNDArray : public NDArray<T, dims> {
Expand Down Expand Up @@ -233,4 +239,10 @@ using IndexVector = DenseVector<std::size_t>;
template <class T>
using ScalarField3D = DenseNDArray<T, 3>;

// ======================================================
// Sparse n-dimensional array
// ======================================================



#endif
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set_target_properties(eisvogel PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/eisvogel)

if(BUILD_WFC)
find_package(MPI REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(MEEP REQUIRED meep)
find_package(HDF5 REQUIRED)
Expand All @@ -25,7 +26,7 @@ if(BUILD_WFC)
Geometry.cxx
Antenna.cxx)
target_link_directories(eisvogel_wfc PUBLIC ${MEEP_LIBRARY_DIRS} ${HDF_LIBRARY_DIRS})
target_link_libraries(eisvogel_wfc PUBLIC eisvogel ${MEEP_LIBRARIES} ${HDF_LIBRARIES})
target_link_libraries(eisvogel_wfc PUBLIC eisvogel ${MEEP_LIBRARIES} ${HDF_LIBRARIES} MPI::MPI_CXX)
target_include_directories(eisvogel_wfc PUBLIC ${PROJECT_SOURCE_DIR}/include ${MEEP_INCLUDE_DIRS} ${HDF_INCLUDE_DIRS})
target_compile_options(eisvogel_wfc PUBLIC ${MEEP_CFLAGS_OTHER} ${HDF_CFLAGS_OTHER})

Expand Down
2 changes: 1 addition & 1 deletion src/WeightingFieldCalculator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ void WeightingFieldCalculator::Calculate(double t_end) {
}
f -> step();
f -> loop_in_chunks(meep::saving_chunkloop, (void*)data.c_str(), f -> total_volume());
f -> output_hdf5(meep::Ez, gv -> surroundings());
// f -> output_hdf5(meep::Ez, gv -> surroundings());
}
}

0 comments on commit 9282318

Please sign in to comment.