Filter weight implementation (#3345)

Co-authored-by: Grego01-biot <grego01@pc-neutronic-06.psfc.mit.edu>
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Gregoire Biot 2025-05-05 16:33:12 -04:00 committed by GitHub
parent 9942269a91
commit dc619eac17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 215 additions and 2 deletions

View file

@ -44,6 +44,7 @@ enum class FilterType {
SURFACE,
TIME,
UNIVERSE,
WEIGHT,
ZERNIKE,
ZERNIKE_RADIAL
};

View file

@ -0,0 +1,51 @@
#ifndef OPENMC_TALLIES_FILTER_WEIGHT_H
#define OPENMC_TALLIES_FILTER_WEIGHT_H
#include <string>
#include "openmc/span.h"
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
//==============================================================================
//! Bins the weights of the particles.
//==============================================================================
class WeightFilter : public Filter {
public:
//----------------------------------------------------------------------------
// Constructors, destructors
~WeightFilter() = default;
//----------------------------------------------------------------------------
// Methods
std::string type_str() const override { return "weight"; }
FilterType type() const override { return FilterType::WEIGHT; }
void from_xml(pugi::xml_node node) override;
void get_all_bins(const Particle& p, TallyEstimator estimator,
FilterMatch& match) const override;
void to_statepoint(hid_t filter_group) const override;
std::string text_label(int bin) const override;
//----------------------------------------------------------------------------
// Accessors
const vector<double>& bins() const { return bins_; }
void set_bins(span<const double> bins);
protected:
//----------------------------------------------------------------------------
// Data members
vector<double> bins_;
};
} // namespace openmc
#endif // OPENMC_TALLIES_FILTER_WEIGHT_H