diff --git a/CMakeLists.txt b/CMakeLists.txt index ed7f3b9f0..613637223 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,6 +409,7 @@ add_library(libopenmc SHARED src/nuclide.cpp src/output.cpp src/particle.cpp + src/photon.cpp src/physics_common.cpp src/physics_mg.cpp src/plot.cpp diff --git a/include/openmc/photon.h b/include/openmc/photon.h new file mode 100644 index 000000000..3f36decdb --- /dev/null +++ b/include/openmc/photon.h @@ -0,0 +1,37 @@ +#ifndef OPENMC_PHOTON_H +#define OPENMC_PHOTON_H + +#include + +#include +#include + +namespace openmc { + +//============================================================================== +//! Photon interaction data for a single element +//============================================================================== + +class PhotonInteraction { +public: + // Constructors + PhotonInteraction(hid_t group); + + // Data members + std::string name_; //! Name of element, e.g. "Zr" + int Z_; //! Atomic number +}; + +//============================================================================== +// Global variables +//============================================================================== + +namespace data { + +extern std::vector elements; + +} // namespace data + +} // namespace openmc + +#endif // OPENMC_PHOTON_H diff --git a/src/photon.cpp b/src/photon.cpp new file mode 100644 index 000000000..b36f29a5c --- /dev/null +++ b/src/photon.cpp @@ -0,0 +1,38 @@ +#include "openmc/photon.h" + +#include "openmc/hdf5_interface.h" + +namespace openmc { + +//============================================================================== +// Global variables +//============================================================================== + +namespace data { + +std::vector elements; + +} // namespace data + +//============================================================================== +// PhotonInteraction implementation +//============================================================================== + +PhotonInteraction::PhotonInteraction(hid_t group) +{ + // Get name of nuclide from group, removing leading '/' + name_ = object_name(group).substr(1); + + read_attribute(group, "Z", Z_); +} + +//============================================================================== +// Fortran compatibility +//============================================================================== + +extern "C" void photon_from_hdf5_c(hid_t group) +{ + data::elements.emplace_back(group); +} + +} // namespace openmc diff --git a/src/photon_header.F90 b/src/photon_header.F90 index a284c7cc0..9da958a6f 100644 --- a/src/photon_header.F90 +++ b/src/photon_header.F90 @@ -130,6 +130,16 @@ contains real(8), allocatable :: matrix(:,:) real(8), allocatable :: dcs(:,:) + interface + subroutine photon_from_hdf5_c(group) bind(C) + import HID_T + integer(HID_T), value :: group + end subroutine + end interface + + ! Read element data on C++ side + call photon_from_hdf5_c(group_id) + ! Get name of nuclide from group this % name = get_name(group_id)