Move FileSource MCPL reading to mcpl_interface.h/cpp

This commit is contained in:
Paul Romano 2022-12-22 11:33:29 -06:00
parent 987293cfff
commit a3065b479c
6 changed files with 126 additions and 83 deletions

View file

@ -0,0 +1,25 @@
#ifndef OPENMC_MCPL_INTERFACE_H
#define OPENMC_MCPL_INTERFACE_H
#include "openmc/particle_data.h"
#include <string>
#include <vector>
#ifdef OPENMC_MCPL
#include <mcpl.h>
#endif
namespace openmc {
extern "C" const bool MCPL_ENABLED;
//! Get a vector of source sites from an MCPL file
//
//! \param[in] path Path to MCPL file
//! \return Vector of source sites
vector<SourceSite> mcpl_source_sites(std::string path);
} // namespace openmc
#endif // OPENMC_MCPL_INTERFACE_H

View file

@ -14,10 +14,6 @@
#include "openmc/particle.h"
#include "openmc/vector.h"
#ifdef OPENMC_MCPL
#include <mcpl.h>
#endif
namespace openmc {
//==============================================================================
@ -32,7 +28,6 @@ constexpr double EXTSRC_REJECT_FRACTION {0.05};
//==============================================================================
// Global variables
//==============================================================================
extern "C" const bool MCPL_ENABLED;
class Source;
@ -107,9 +102,8 @@ class FileSource : public Source {
public:
// Constructors
explicit FileSource(std::string path);
#ifdef OPENMC_MCPL
explicit FileSource(mcpl_file_t mcpl_file);
#endif
explicit FileSource(const vector<SourceSite>& sites) : sites_ {sites} {}
// Methods
SourceSite sample(uint64_t* seed) const override;