2022-12-22 11:33:29 -06:00
|
|
|
#ifndef OPENMC_MCPL_INTERFACE_H
|
|
|
|
|
#define OPENMC_MCPL_INTERFACE_H
|
|
|
|
|
|
|
|
|
|
#include "openmc/particle_data.h"
|
2025-02-19 19:03:20 -06:00
|
|
|
#include "openmc/span.h"
|
2022-12-23 11:12:22 -06:00
|
|
|
#include "openmc/vector.h"
|
2022-12-22 11:33:29 -06:00
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace openmc {
|
|
|
|
|
|
2022-12-22 12:27:56 -06:00
|
|
|
//==============================================================================
|
|
|
|
|
// Functions
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2022-12-22 11:33:29 -06:00
|
|
|
//! 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);
|
|
|
|
|
|
2025-08-08 07:09:24 -07:00
|
|
|
//! Write an MCPL source file with stat:sum metadata
|
|
|
|
|
//!
|
|
|
|
|
//! This function writes particle data to an MCPL file. For MCPL >= 2.1.0,
|
|
|
|
|
//! it includes a stat:sum field (key: "openmc_np1") containing the total
|
|
|
|
|
//! number of source particles, which is essential for proper file merging
|
|
|
|
|
//! and weight normalization when using MCPL files with McStas/McXtrace.
|
|
|
|
|
//!
|
|
|
|
|
//! The stat:sum field follows the crash-safety pattern:
|
|
|
|
|
//! - Initially set to -1 when opening (indicates incomplete file)
|
|
|
|
|
//! - Updated with actual particle count before closing
|
|
|
|
|
//!
|
2023-03-31 13:46:42 -04:00
|
|
|
//! \param[in] filename Path to MCPL file
|
|
|
|
|
//! \param[in] source_bank Vector of SourceSites to write to file for this
|
2025-07-17 08:46:39 +06:00
|
|
|
//! MPI rank.
|
|
|
|
|
//! \param[in] bank_index Pointer to vector of site index ranges over all
|
|
|
|
|
//! MPI ranks.
|
2025-02-19 19:03:20 -06:00
|
|
|
void write_mcpl_source_point(const char* filename, span<SourceSite> source_bank,
|
|
|
|
|
const vector<int64_t>& bank_index);
|
2025-07-17 08:46:39 +06:00
|
|
|
|
2025-11-13 21:35:33 +01:00
|
|
|
//! Write an MCPL collision track file
|
|
|
|
|
//!
|
|
|
|
|
//! This function writes collision track data to an MCPL file. Additional
|
|
|
|
|
//! collision-specific metadata (such as energy deposition, material info, etc.)
|
|
|
|
|
//! is stored in the file header as blob data.
|
|
|
|
|
//!
|
|
|
|
|
//! \param[in] filename Path to MCPL file
|
|
|
|
|
//! \param[in] collision_track_bank Vector of CollisionTrackSites to write to
|
|
|
|
|
//! file for this MPI rank.
|
|
|
|
|
//! \param[in] bank_index Pointer to vector of site index ranges over all
|
|
|
|
|
//! MPI ranks.
|
|
|
|
|
void write_mcpl_collision_track(const char* filename,
|
|
|
|
|
span<CollisionTrackSite> collision_track_bank,
|
|
|
|
|
const vector<int64_t>& bank_index);
|
|
|
|
|
|
2025-07-17 08:46:39 +06:00
|
|
|
//! Check if MCPL functionality is available
|
|
|
|
|
bool is_mcpl_interface_available();
|
|
|
|
|
|
|
|
|
|
//! Initialize the MCPL interface
|
|
|
|
|
void initialize_mcpl_interface_if_needed();
|
|
|
|
|
|
2022-12-22 11:33:29 -06:00
|
|
|
} // namespace openmc
|
|
|
|
|
|
|
|
|
|
#endif // OPENMC_MCPL_INTERFACE_H
|