From 23b984ba3af71fd0445b0dd82014961a7f37b17c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 23 Apr 2020 09:44:14 -0500 Subject: [PATCH] Change get_all_bins to accept a const ref instead of pointer --- include/openmc/tallies/filter.h | 4 +++- include/openmc/tallies/filter_azimuthal.h | 2 +- include/openmc/tallies/filter_cell.h | 2 +- include/openmc/tallies/filter_cell_instance.h | 2 +- include/openmc/tallies/filter_cellborn.h | 2 +- include/openmc/tallies/filter_cellfrom.h | 2 +- include/openmc/tallies/filter_delayedgroup.h | 2 +- include/openmc/tallies/filter_distribcell.h | 2 +- include/openmc/tallies/filter_energy.h | 4 ++-- include/openmc/tallies/filter_energyfunc.h | 2 +- include/openmc/tallies/filter_legendre.h | 2 +- include/openmc/tallies/filter_material.h | 2 +- include/openmc/tallies/filter_mesh.h | 2 +- include/openmc/tallies/filter_meshsurface.h | 2 +- include/openmc/tallies/filter_mu.h | 2 +- include/openmc/tallies/filter_particle.h | 2 +- include/openmc/tallies/filter_polar.h | 2 +- include/openmc/tallies/filter_sph_harm.h | 2 +- include/openmc/tallies/filter_sptl_legendre.h | 2 +- include/openmc/tallies/filter_surface.h | 2 +- include/openmc/tallies/filter_universe.h | 2 +- include/openmc/tallies/filter_zernike.h | 4 ++-- src/tallies/filter_azimuthal.cpp | 6 +++--- src/tallies/filter_cell.cpp | 6 +++--- src/tallies/filter_cell_instance.cpp | 6 +++--- src/tallies/filter_cellborn.cpp | 4 ++-- src/tallies/filter_cellfrom.cpp | 6 +++--- src/tallies/filter_delayedgroup.cpp | 2 +- src/tallies/filter_distribcell.cpp | 16 +++++++-------- src/tallies/filter_energy.cpp | 20 +++++++++---------- src/tallies/filter_energyfunc.cpp | 8 ++++---- src/tallies/filter_legendre.cpp | 4 ++-- src/tallies/filter_material.cpp | 4 ++-- src/tallies/filter_mesh.cpp | 6 +++--- src/tallies/filter_meshsurface.cpp | 4 ++-- src/tallies/filter_mu.cpp | 6 +++--- src/tallies/filter_particle.cpp | 4 ++-- src/tallies/filter_polar.cpp | 11 ++++------ src/tallies/filter_sph_harm.cpp | 10 ++++++---- src/tallies/filter_sptl_legendre.cpp | 8 ++++---- src/tallies/filter_surface.cpp | 6 +++--- src/tallies/filter_universe.cpp | 6 +++--- src/tallies/filter_zernike.cpp | 12 +++++------ src/tallies/tally_scoring.cpp | 2 +- 44 files changed, 104 insertions(+), 103 deletions(-) diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index 53e3437b21..fbafd7e072 100644 --- a/include/openmc/tallies/filter.h +++ b/include/openmc/tallies/filter.h @@ -55,10 +55,12 @@ public: //! Matches a tally event to a set of filter bins and weights. //! + //! \param[in] p Particle being tracked + //! \param[in] estimator Tally estimator being used //! \param[out] match will contain the matching bins and corresponding //! weights; note that there may be zero matching bins virtual void - get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) const = 0; + get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const = 0; //! Writes data describing this filter to an HDF5 statepoint group. virtual void diff --git a/include/openmc/tallies/filter_azimuthal.h b/include/openmc/tallies/filter_azimuthal.h index 71fa5baa63..7259f0f00c 100644 --- a/include/openmc/tallies/filter_azimuthal.h +++ b/include/openmc/tallies/filter_azimuthal.h @@ -29,7 +29,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_cell.h b/include/openmc/tallies/filter_cell.h index a5cc716853..83114ea122 100644 --- a/include/openmc/tallies/filter_cell.h +++ b/include/openmc/tallies/filter_cell.h @@ -30,7 +30,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_cell_instance.h b/include/openmc/tallies/filter_cell_instance.h index 8898815575..a406e73d77 100644 --- a/include/openmc/tallies/filter_cell_instance.h +++ b/include/openmc/tallies/filter_cell_instance.h @@ -33,7 +33,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_cellborn.h b/include/openmc/tallies/filter_cellborn.h index 6300b9e1af..e1e1225dda 100644 --- a/include/openmc/tallies/filter_cellborn.h +++ b/include/openmc/tallies/filter_cellborn.h @@ -19,7 +19,7 @@ public: std::string type() const override {return "cellborn";} - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; std::string text_label(int bin) const override; diff --git a/include/openmc/tallies/filter_cellfrom.h b/include/openmc/tallies/filter_cellfrom.h index d64b80466d..cf11937bd9 100644 --- a/include/openmc/tallies/filter_cellfrom.h +++ b/include/openmc/tallies/filter_cellfrom.h @@ -19,7 +19,7 @@ public: std::string type() const override {return "cellfrom";} - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; std::string text_label(int bin) const override; diff --git a/include/openmc/tallies/filter_delayedgroup.h b/include/openmc/tallies/filter_delayedgroup.h index 9f82cfbed0..64bdd33985 100644 --- a/include/openmc/tallies/filter_delayedgroup.h +++ b/include/openmc/tallies/filter_delayedgroup.h @@ -31,7 +31,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_distribcell.h b/include/openmc/tallies/filter_distribcell.h index 145292eb2a..68cb694e79 100644 --- a/include/openmc/tallies/filter_distribcell.h +++ b/include/openmc/tallies/filter_distribcell.h @@ -26,7 +26,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_energy.h b/include/openmc/tallies/filter_energy.h index 7b2c6ec754..3eac0a9c12 100644 --- a/include/openmc/tallies/filter_energy.h +++ b/include/openmc/tallies/filter_energy.h @@ -28,7 +28,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; @@ -68,7 +68,7 @@ public: std::string type() const override {return "energyout";} - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; std::string text_label(int bin) const override; diff --git a/include/openmc/tallies/filter_energyfunc.h b/include/openmc/tallies/filter_energyfunc.h index 7810a651f6..562d7f36d5 100644 --- a/include/openmc/tallies/filter_energyfunc.h +++ b/include/openmc/tallies/filter_energyfunc.h @@ -33,7 +33,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_legendre.h b/include/openmc/tallies/filter_legendre.h index 24952e60b9..5a489b9465 100644 --- a/include/openmc/tallies/filter_legendre.h +++ b/include/openmc/tallies/filter_legendre.h @@ -26,7 +26,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_material.h b/include/openmc/tallies/filter_material.h index 064da2293f..71396cf2b9 100644 --- a/include/openmc/tallies/filter_material.h +++ b/include/openmc/tallies/filter_material.h @@ -30,7 +30,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_mesh.h b/include/openmc/tallies/filter_mesh.h index 3d4ff2fa21..fa64877e36 100644 --- a/include/openmc/tallies/filter_mesh.h +++ b/include/openmc/tallies/filter_mesh.h @@ -28,7 +28,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_meshsurface.h b/include/openmc/tallies/filter_meshsurface.h index 6994052254..baaf1e53ca 100644 --- a/include/openmc/tallies/filter_meshsurface.h +++ b/include/openmc/tallies/filter_meshsurface.h @@ -13,7 +13,7 @@ public: std::string type() const override {return "meshsurface";} - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; std::string text_label(int bin) const override; diff --git a/include/openmc/tallies/filter_mu.h b/include/openmc/tallies/filter_mu.h index 810f333689..7f6f29e5f7 100644 --- a/include/openmc/tallies/filter_mu.h +++ b/include/openmc/tallies/filter_mu.h @@ -29,7 +29,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_particle.h b/include/openmc/tallies/filter_particle.h index c2a27aaaa8..c7eb3ce41f 100644 --- a/include/openmc/tallies/filter_particle.h +++ b/include/openmc/tallies/filter_particle.h @@ -27,7 +27,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_polar.h b/include/openmc/tallies/filter_polar.h index ef6ceaec18..fd800e2edc 100644 --- a/include/openmc/tallies/filter_polar.h +++ b/include/openmc/tallies/filter_polar.h @@ -29,7 +29,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_sph_harm.h b/include/openmc/tallies/filter_sph_harm.h index aec21e117b..91c81bdae7 100644 --- a/include/openmc/tallies/filter_sph_harm.h +++ b/include/openmc/tallies/filter_sph_harm.h @@ -32,7 +32,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_sptl_legendre.h b/include/openmc/tallies/filter_sptl_legendre.h index c39bd01009..581142f788 100644 --- a/include/openmc/tallies/filter_sptl_legendre.h +++ b/include/openmc/tallies/filter_sptl_legendre.h @@ -30,7 +30,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_surface.h b/include/openmc/tallies/filter_surface.h index 417e770d03..cf27024c50 100644 --- a/include/openmc/tallies/filter_surface.h +++ b/include/openmc/tallies/filter_surface.h @@ -30,7 +30,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_universe.h b/include/openmc/tallies/filter_universe.h index ce93b79e51..1dabf96712 100644 --- a/include/openmc/tallies/filter_universe.h +++ b/include/openmc/tallies/filter_universe.h @@ -30,7 +30,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; diff --git a/include/openmc/tallies/filter_zernike.h b/include/openmc/tallies/filter_zernike.h index 3108bd4871..a1248eac1a 100644 --- a/include/openmc/tallies/filter_zernike.h +++ b/include/openmc/tallies/filter_zernike.h @@ -26,7 +26,7 @@ public: void from_xml(pugi::xml_node node) override; - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; void to_statepoint(hid_t filter_group) const override; @@ -76,7 +76,7 @@ public: std::string type() const override {return "zernikeradial";} - void get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) + void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const override; std::string text_label(int bin) const override; diff --git a/src/tallies/filter_azimuthal.cpp b/src/tallies/filter_azimuthal.cpp index a7c29b2dbb..5ff83f19d7 100644 --- a/src/tallies/filter_azimuthal.cpp +++ b/src/tallies/filter_azimuthal.cpp @@ -51,14 +51,14 @@ void AzimuthalFilter::set_bins(gsl::span bins) } void -AzimuthalFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +AzimuthalFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { double phi; if (estimator == TallyEstimator::TRACKLENGTH) { - phi = std::atan2(p->u().y, p->u().x); + phi = std::atan2(p.u().y, p.u().x); } else { - phi = std::atan2(p->u_last_.y, p->u_last_.x); + phi = std::atan2(p.u_last_.y, p.u_last_.x); } if (phi >= bins_.front() && phi <= bins_.back()) { diff --git a/src/tallies/filter_cell.cpp b/src/tallies/filter_cell.cpp index 76a80f0d56..f6b804ab96 100644 --- a/src/tallies/filter_cell.cpp +++ b/src/tallies/filter_cell.cpp @@ -46,11 +46,11 @@ CellFilter::set_cells(gsl::span cells) } void -CellFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +CellFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - for (int i = 0; i < p->n_coord_; i++) { - auto search = map_.find(p->coord_[i].cell); + for (int i = 0; i < p.n_coord_; i++) { + auto search = map_.find(p.coord_[i].cell); if (search != map_.end()) { match.bins_.push_back(search->second); match.weights_.push_back(1.0); diff --git a/src/tallies/filter_cell_instance.cpp b/src/tallies/filter_cell_instance.cpp index e3d7e02b22..d44cdfcf68 100644 --- a/src/tallies/filter_cell_instance.cpp +++ b/src/tallies/filter_cell_instance.cpp @@ -66,11 +66,11 @@ CellInstanceFilter::set_cell_instances(gsl::span instances) } void -CellInstanceFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +CellInstanceFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - gsl::index index_cell = p->coord_[p->n_coord_ - 1].cell; - gsl::index instance = p->cell_instance_; + gsl::index index_cell = p.coord_[p.n_coord_ - 1].cell; + gsl::index instance = p.cell_instance_; auto search = map_.find({index_cell, instance}); if (search != map_.end()) { int index_bin = search->second; diff --git a/src/tallies/filter_cellborn.cpp b/src/tallies/filter_cellborn.cpp index 6743b7b905..572b1503c9 100644 --- a/src/tallies/filter_cellborn.cpp +++ b/src/tallies/filter_cellborn.cpp @@ -5,10 +5,10 @@ namespace openmc { void -CellbornFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +CellbornFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - auto search = map_.find(p->cell_born_); + auto search = map_.find(p.cell_born_); if (search != map_.end()) { match.bins_.push_back(search->second); match.weights_.push_back(1.0); diff --git a/src/tallies/filter_cellfrom.cpp b/src/tallies/filter_cellfrom.cpp index 49c0f4f797..39fde39766 100644 --- a/src/tallies/filter_cellfrom.cpp +++ b/src/tallies/filter_cellfrom.cpp @@ -5,11 +5,11 @@ namespace openmc { void -CellFromFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +CellFromFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - for (int i = 0; i < p->n_coord_last_; i++) { - auto search = map_.find(p->cell_last_[i]); + for (int i = 0; i < p.n_coord_last_; i++) { + auto search = map_.find(p.cell_last_[i]); if (search != map_.end()) { match.bins_.push_back(search->second); match.weights_.push_back(1.0); diff --git a/src/tallies/filter_delayedgroup.cpp b/src/tallies/filter_delayedgroup.cpp index 65076e2acc..824b2e8150 100644 --- a/src/tallies/filter_delayedgroup.cpp +++ b/src/tallies/filter_delayedgroup.cpp @@ -37,7 +37,7 @@ DelayedGroupFilter::set_groups(gsl::span groups) } void -DelayedGroupFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +DelayedGroupFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { match.bins_.push_back(0); diff --git a/src/tallies/filter_distribcell.cpp b/src/tallies/filter_distribcell.cpp index 43e68a8f93..d3a2ffe5f1 100644 --- a/src/tallies/filter_distribcell.cpp +++ b/src/tallies/filter_distribcell.cpp @@ -38,25 +38,25 @@ DistribcellFilter::set_cell(int32_t cell) } void -DistribcellFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +DistribcellFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { int offset = 0; auto distribcell_index = model::cells[cell_]->distribcell_index_; - for (int i = 0; i < p->n_coord_; i++) { - auto& c {*model::cells[p->coord_[i].cell]}; + for (int i = 0; i < p.n_coord_; i++) { + auto& c {*model::cells[p.coord_[i].cell]}; if (c.type_ == Fill::UNIVERSE) { offset += c.offset_[distribcell_index]; } else if (c.type_ == Fill::LATTICE) { - auto& lat {*model::lattices[p->coord_[i+1].lattice]}; - int i_xyz[3] {p->coord_[i+1].lattice_x, - p->coord_[i+1].lattice_y, - p->coord_[i+1].lattice_z}; + auto& lat {*model::lattices[p.coord_[i+1].lattice]}; + int i_xyz[3] {p.coord_[i+1].lattice_x, + p.coord_[i+1].lattice_y, + p.coord_[i+1].lattice_z}; if (lat.are_valid_indices(i_xyz)) { offset += lat.offset(distribcell_index, i_xyz); } } - if (cell_ == p->coord_[i].cell) { + if (cell_ == p.coord_[i].cell) { match.bins_.push_back(offset); match.weights_.push_back(1.0); return; diff --git a/src/tallies/filter_energy.cpp b/src/tallies/filter_energy.cpp index 1138dabe2c..e4bf018d29 100644 --- a/src/tallies/filter_energy.cpp +++ b/src/tallies/filter_energy.cpp @@ -58,20 +58,20 @@ EnergyFilter::set_bins(gsl::span bins) } void -EnergyFilter::get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) +EnergyFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - if (p->g_ != F90_NONE && matches_transport_groups_) { + if (p.g_ != F90_NONE && matches_transport_groups_) { if (estimator == TallyEstimator::TRACKLENGTH) { - match.bins_.push_back(data::mg.num_energy_groups_ - p->g_ - 1); + match.bins_.push_back(data::mg.num_energy_groups_ - p.g_ - 1); } else { - match.bins_.push_back(data::mg.num_energy_groups_ - p->g_last_ - 1); + match.bins_.push_back(data::mg.num_energy_groups_ - p.g_last_ - 1); } match.weights_.push_back(1.0); } else { // Get the pre-collision energy of the particle. - auto E = p->E_last_; + auto E = p.E_last_; // Bin the energy. if (E >= bins_.front() && E <= bins_.back()) { @@ -100,16 +100,16 @@ EnergyFilter::text_label(int bin) const //============================================================================== void -EnergyoutFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +EnergyoutFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - if (p->g_ != F90_NONE && matches_transport_groups_) { - match.bins_.push_back(data::mg.num_energy_groups_ - p->g_ - 1); + if (p.g_ != F90_NONE && matches_transport_groups_) { + match.bins_.push_back(data::mg.num_energy_groups_ - p.g_ - 1); match.weights_.push_back(1.0); } else { - if (p->E_ >= bins_.front() && p->E_ <= bins_.back()) { - auto bin = lower_bound_index(bins_.begin(), bins_.end(), p->E_); + if (p.E_ >= bins_.front() && p.E_ <= bins_.back()) { + auto bin = lower_bound_index(bins_.begin(), bins_.end(), p.E_); match.bins_.push_back(bin); match.weights_.push_back(1.0); } diff --git a/src/tallies/filter_energyfunc.cpp b/src/tallies/filter_energyfunc.cpp index 8c4e5609d7..498fd52e8f 100644 --- a/src/tallies/filter_energyfunc.cpp +++ b/src/tallies/filter_energyfunc.cpp @@ -53,15 +53,15 @@ EnergyFunctionFilter::set_data(gsl::span energy, } void -EnergyFunctionFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +EnergyFunctionFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - if (p->E_last_ >= energy_.front() && p->E_last_ <= energy_.back()) { + if (p.E_last_ >= energy_.front() && p.E_last_ <= energy_.back()) { // Search for the incoming energy bin. - auto i = lower_bound_index(energy_.begin(), energy_.end(), p->E_last_); + auto i = lower_bound_index(energy_.begin(), energy_.end(), p.E_last_); // Compute the interpolation factor between the nearest bins. - double f = (p->E_last_ - energy_[i]) / (energy_[i+1] - energy_[i]); + double f = (p.E_last_ - energy_[i]) / (energy_[i+1] - energy_[i]); // Interpolate on the lin-lin grid. match.bins_.push_back(0); diff --git a/src/tallies/filter_legendre.cpp b/src/tallies/filter_legendre.cpp index 240054dde8..57912983cd 100644 --- a/src/tallies/filter_legendre.cpp +++ b/src/tallies/filter_legendre.cpp @@ -24,11 +24,11 @@ LegendreFilter::set_order(int order) } void -LegendreFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +LegendreFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { std::vector wgt(n_bins_); - calc_pn_c(order_, p->mu_, wgt.data()); + calc_pn_c(order_, p.mu_, wgt.data()); for (int i = 0; i < n_bins_; i++) { match.bins_.push_back(i); match.weights_.push_back(wgt[i]); diff --git a/src/tallies/filter_material.cpp b/src/tallies/filter_material.cpp index 8311fc73b1..df50ff6971 100644 --- a/src/tallies/filter_material.cpp +++ b/src/tallies/filter_material.cpp @@ -45,10 +45,10 @@ MaterialFilter::set_materials(gsl::span materials) } void -MaterialFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +MaterialFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - auto search = map_.find(p->material_); + auto search = map_.find(p.material_); if (search != map_.end()) { match.bins_.push_back(search->second); match.weights_.push_back(1.0); diff --git a/src/tallies/filter_mesh.cpp b/src/tallies/filter_mesh.cpp index 60ab318cc1..8b6789cb9b 100644 --- a/src/tallies/filter_mesh.cpp +++ b/src/tallies/filter_mesh.cpp @@ -31,17 +31,17 @@ MeshFilter::from_xml(pugi::xml_node node) } void -MeshFilter::get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) +MeshFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { if (estimator != TallyEstimator::TRACKLENGTH) { - auto bin = model::meshes[mesh_]->get_bin(p->r()); + auto bin = model::meshes[mesh_]->get_bin(p.r()); if (bin >= 0) { match.bins_.push_back(bin); match.weights_.push_back(1.0); } } else { - model::meshes[mesh_]->bins_crossed(p, match.bins_, match.weights_); + model::meshes[mesh_]->bins_crossed(&p, match.bins_, match.weights_); } } diff --git a/src/tallies/filter_meshsurface.cpp b/src/tallies/filter_meshsurface.cpp index 80e3988806..05aa440813 100644 --- a/src/tallies/filter_meshsurface.cpp +++ b/src/tallies/filter_meshsurface.cpp @@ -8,10 +8,10 @@ namespace openmc { void -MeshSurfaceFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +MeshSurfaceFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - model::meshes[mesh_]->surface_bins_crossed(p, match.bins_); + model::meshes[mesh_]->surface_bins_crossed(&p, match.bins_); for (auto b : match.bins_) match.weights_.push_back(1.0); } diff --git a/src/tallies/filter_mu.cpp b/src/tallies/filter_mu.cpp index f874488b1e..d1f5569cdd 100644 --- a/src/tallies/filter_mu.cpp +++ b/src/tallies/filter_mu.cpp @@ -49,11 +49,11 @@ MuFilter::set_bins(gsl::span bins) } void -MuFilter::get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) +MuFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - if (p->mu_ >= bins_.front() && p->mu_ <= bins_.back()) { - auto bin = lower_bound_index(bins_.begin(), bins_.end(), p->mu_); + if (p.mu_ >= bins_.front() && p.mu_ <= bins_.back()) { + auto bin = lower_bound_index(bins_.begin(), bins_.end(), p.mu_); match.bins_.push_back(bin); match.weights_.push_back(1.0); } diff --git a/src/tallies/filter_particle.cpp b/src/tallies/filter_particle.cpp index caccbc961e..8354f0a2d6 100644 --- a/src/tallies/filter_particle.cpp +++ b/src/tallies/filter_particle.cpp @@ -40,11 +40,11 @@ ParticleFilter::set_particles(gsl::span particles) } void -ParticleFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +ParticleFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { for (auto i = 0; i < particles_.size(); i++) { - if (particles_[i] == p->type_) { + if (particles_[i] == p.type_) { match.bins_.push_back(i); match.weights_.push_back(1.0); } diff --git a/src/tallies/filter_polar.cpp b/src/tallies/filter_polar.cpp index c814107508..d4d929b539 100644 --- a/src/tallies/filter_polar.cpp +++ b/src/tallies/filter_polar.cpp @@ -50,15 +50,12 @@ PolarFilter::set_bins(gsl::span bins) } void -PolarFilter::get_all_bins(const Particle* p, TallyEstimator estimator, FilterMatch& match) +PolarFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - double theta; - if (estimator == TallyEstimator::TRACKLENGTH) { - theta = std::acos(p->u().z); - } else { - theta = std::acos(p->u_last_.z); - } + double theta = std::acos( + estimator == TallyEstimator::TRACKLENGTH ? p.u().z : p.u_last_.z + ); if (theta >= bins_.front() && theta <= bins_.back()) { auto bin = lower_bound_index(bins_.begin(), bins_.end(), theta); diff --git a/src/tallies/filter_sph_harm.cpp b/src/tallies/filter_sph_harm.cpp index fe014d0f46..44ec5f160d 100644 --- a/src/tallies/filter_sph_harm.cpp +++ b/src/tallies/filter_sph_harm.cpp @@ -45,20 +45,22 @@ SphericalHarmonicsFilter::set_cosine(gsl::cstring_span cosine) } void -SphericalHarmonicsFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +SphericalHarmonicsFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { // Determine cosine term for scatter expansion if necessary std::vector wgt(order_ + 1); if (cosine_ == SphericalHarmonicsCosine::scatter) { - calc_pn_c(order_, p->mu_, wgt.data()); + calc_pn_c(order_, p.mu_, wgt.data()); } else { - for (int i = 0; i < order_ + 1; i++) wgt[i] = 1; + for (int i = 0; i < order_ + 1; i++) { + wgt[i] = 1; + } } // Find the Rn,m values std::vector rn(n_bins_); - calc_rn(order_, p->u_last_, rn.data()); + calc_rn(order_, p.u_last_, rn.data()); int j = 0; for (int n = 0; n < order_ + 1; n++) { diff --git a/src/tallies/filter_sptl_legendre.cpp b/src/tallies/filter_sptl_legendre.cpp index 6f060ed446..9478ae9ff1 100644 --- a/src/tallies/filter_sptl_legendre.cpp +++ b/src/tallies/filter_sptl_legendre.cpp @@ -63,17 +63,17 @@ SpatialLegendreFilter::set_minmax(double min, double max) } void -SpatialLegendreFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +SpatialLegendreFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { // Get the coordinate along the axis of interest. double x; if (axis_ == LegendreAxis::x) { - x = p->r().x; + x = p.r().x; } else if (axis_ == LegendreAxis::y) { - x = p->r().y; + x = p.r().y; } else { - x = p->r().z; + x = p.r().z; } if (x >= min_ && x <= max_) { diff --git a/src/tallies/filter_surface.cpp b/src/tallies/filter_surface.cpp index 72061becbe..141e1e847c 100644 --- a/src/tallies/filter_surface.cpp +++ b/src/tallies/filter_surface.cpp @@ -47,13 +47,13 @@ SurfaceFilter::set_surfaces(gsl::span surfaces) } void -SurfaceFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +SurfaceFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - auto search = map_.find(std::abs(p->surface_)-1); + auto search = map_.find(std::abs(p.surface_)-1); if (search != map_.end()) { match.bins_.push_back(search->second); - if (p->surface_ < 0) { + if (p.surface_ < 0) { match.weights_.push_back(-1.0); } else { match.weights_.push_back(1.0); diff --git a/src/tallies/filter_universe.cpp b/src/tallies/filter_universe.cpp index ac39030419..d1b0d057e1 100644 --- a/src/tallies/filter_universe.cpp +++ b/src/tallies/filter_universe.cpp @@ -45,11 +45,11 @@ UniverseFilter::set_universes(gsl::span universes) } void -UniverseFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +UniverseFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - for (int i = 0; i < p->n_coord_; i++) { - auto search = map_.find(p->coord_[i].universe); + for (int i = 0; i < p.n_coord_; i++) { + auto search = map_.find(p.coord_[i].universe); if (search != map_.end()) { match.bins_.push_back(search->second); match.weights_.push_back(1.0); diff --git a/src/tallies/filter_zernike.cpp b/src/tallies/filter_zernike.cpp index eab76cbc8d..f57a0be7c0 100644 --- a/src/tallies/filter_zernike.cpp +++ b/src/tallies/filter_zernike.cpp @@ -28,12 +28,12 @@ ZernikeFilter::from_xml(pugi::xml_node node) } void -ZernikeFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +ZernikeFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { // Determine the normalized (r,theta) coordinates. - double x = p->r().x - x_; - double y = p->r().y - y_; + double x = p.r().x - x_; + double y = p.r().y - y_; double r = std::sqrt(x*x + y*y) / r_; double theta = std::atan2(y, x); @@ -88,12 +88,12 @@ ZernikeFilter::set_order(int order) //============================================================================== void -ZernikeRadialFilter::get_all_bins(const Particle* p, TallyEstimator estimator, +ZernikeRadialFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { // Determine the normalized radius coordinate. - double x = p->r().x - x_; - double y = p->r().y - y_; + double x = p.r().x - x_; + double y = p.r().y - y_; double r = std::sqrt(x*x + y*y) / r_; if (r <= 1.0) { diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index e0cd5d095c..3ec6dd3d04 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -36,7 +36,7 @@ FilterBinIter::FilterBinIter(const Tally& tally, Particle* p) if (!match.bins_present_) { match.bins_.clear(); match.weights_.clear(); - model::tally_filters[i_filt]->get_all_bins(p, tally_.estimator_, match); + model::tally_filters[i_filt]->get_all_bins(*p, tally_.estimator_, match); match.bins_present_ = true; }