Start reading element data on C++ side

This commit is contained in:
Paul Romano 2018-11-15 15:55:05 -06:00
parent 6940656c8a
commit 2c8bdbba6e
4 changed files with 86 additions and 0 deletions

View file

@ -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

37
include/openmc/photon.h Normal file
View file

@ -0,0 +1,37 @@
#ifndef OPENMC_PHOTON_H
#define OPENMC_PHOTON_H
#include <hdf5.h>
#include <string>
#include <vector>
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<PhotonInteraction> elements;
} // namespace data
} // namespace openmc
#endif // OPENMC_PHOTON_H

38
src/photon.cpp Normal file
View file

@ -0,0 +1,38 @@
#include "openmc/photon.h"
#include "openmc/hdf5_interface.h"
namespace openmc {
//==============================================================================
// Global variables
//==============================================================================
namespace data {
std::vector<PhotonInteraction> 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

View file

@ -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)