Move write_tallies to C++

This commit is contained in:
Sterling Harper 2019-02-11 13:58:12 -05:00
parent ddaed7311b
commit 8bb0fa7791
6 changed files with 366 additions and 373 deletions

View file

@ -2,6 +2,7 @@
#define OPENMC_TALLIES_TALLY_H
#include "openmc/constants.h"
#include "openmc/tallies/filter.h"
#include "openmc/tallies/trigger.h"
#include "pugixml.hpp"
@ -21,6 +22,8 @@ class Tally {
public:
Tally() {}
void init_from_xml(pugi::xml_node node);
void set_scores(pugi::xml_node node);
void set_scores(std::vector<std::string> scores);
@ -50,6 +53,8 @@ public:
int id_; //!< user-defined identifier
std::string name_; //!< user-defined name
int type_ {TALLY_VOLUME}; //!< volume, surface current
//! Event type that contributes to this tally
@ -93,6 +98,41 @@ private:
int32_t n_filter_bins_ {0};
};
//==============================================================================
//! An iterator over all combinations of a tally's matching filter bins.
//
//! This iterator handles two distinct tasks. First, it maps the N-dimensional
//! space created by the indices of N filters onto a 1D sequence. In other
//! words, it provides a single number that uniquely identifies a combination of
//! bins for many filters. Second, it handles the task of finding each all
//! valid combinations of filter bins given that each filter can have 1 or 2 or
//! many bins that are valid for the current tally event.
//==============================================================================
class FilterBinIter
{
public:
FilterBinIter(const Tally& tally, Particle* p);
FilterBinIter(const Tally& tally, bool end);
bool operator==(const FilterBinIter& other) const
{return index_ == other.index_;}
bool operator!=(const FilterBinIter& other) const
{return !(*this == other);}
FilterBinIter& operator++();
int index_ {1};
double weight_ {1.};
private:
void compute_index_weight();
const Tally& tally_;
};
//==============================================================================
// Global variable declarations
//==============================================================================