Cardinal
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
TallyBase Class Referenceabstract

#include <TallyBase.h>

Inheritance diagram for TallyBase:
[legend]

Public Member Functions

 TallyBase (const InputParameters &parameters)
 
virtual std::pair< unsigned int, openmc::Filter * > spatialFilter ()=0
 
virtual void initializeTally ()
 
virtual void resetTally ()
 
Real storeResults (const std::vector< unsigned int > &var_numbers, unsigned int local_score, const std::string &output_type)
 
void addScore (const std::string &score)
 
void setRelaxation (relaxation::RelaxationEnum relaxation_type, const Real &relaxation_factor)
 
void computeSumAndMean ()
 
virtual void gatherLinkedSum ()
 
virtual void renormalizeLinkedTallies ()
 
void relaxAndNormalizeTally ()
 
void addLinkedTally (const TallyBase *other)
 
const openmc::Tally * getWrappedTally () const
 
const openmc::Tally * getWrappedGlobalTally () const
 
int32_t getTallyID () const
 
int32_t getGlobalTallyID () const
 
const std::vector< std::string > & getScores () const
 
int scoreIndex (const std::string &score) const
 
const std::vector< std::string > & getAuxVarNames () const
 
const std::vector< std::string > & getOutputs () const
 
openmc::TallyEstimator getTallyEstimator () const
 
const Real & getMean (unsigned int local_score) const
 
const Real & getSum (unsigned int local_score) const
 
std::vector< std::string > getScoreVars (const std::string &score) const
 
bool extBinSkipped (unsigned int ext_bin) const
 
bool hasTrigger () const
 
bool hasOutputs () const
 
bool hasScore (const std::string &score) const
 
bool renamesTallyVars () const
 
unsigned int numExtFilterBins () const
 
const std::set< SubdomainID > & getBlocks () const
 
virtual bool addingGlobalTally () const
 
const std::vector< const TallyBase * > & linkedTallies () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

virtual Real storeResultsInner (const std::vector< unsigned int > &var_numbers, unsigned int local_score, const std::vector< OMCTensor > &tally_vals, bool norm_by_src_rate=true)=0
 
void fillElementalAuxVariable (const unsigned int &var_num, const std::vector< unsigned int > &elem_ids, const Real &value)
 
void applyTriggersToLocalTally (openmc::Tally *tally)
 
Real tallyNormalization (unsigned int score) const
 
void checkTallySum (const unsigned int &score) const
 
void checkNormalization (const Real &sum, unsigned int score) const
 

Protected Attributes

OpenMCCellAverageProblem_openmc_problem
 The OpenMCCellAverageProblem using the tally system. More...
 
MooseMesh & _mesh
 The MooseMesh. More...
 
AuxiliarySystem & _aux
 The aux system. More...
 
std::vector< std::shared_ptr< FilterBase > > _ext_filters
 The external filters added in the [Problem/Filters] block. More...
 
openmc::TallyEstimator _estimator
 The OpenMC estimator to use with this tally. More...
 
std::vector< std::string > _tally_score
 OpenMC tally score(s) to use with this tally. More...
 
std::vector< std::string > _tally_name
 Auxiliary variable name(s) for this tally. More...
 
openmc::Tally * _local_tally = nullptr
 The OpenMC tally object this class wraps. More...
 
unsigned int _local_tally_index
 The index of the OpenMC tally this object wraps. More...
 
openmc::Tally * _global_tally = nullptr
 
unsigned int _global_tally_index
 The index of the global OpenMC tally this object wraps. More...
 
unsigned int _filter_index
 The index of the first filter added by this tally. More...
 
unsigned int _num_ext_filter_bins = 1
 The number of non-spatial bins in this tally. More...
 
std::vector< Real > _local_sum_tally
 Sum value of this tally across all bins. Indexed by score. More...
 
std::vector< Real > _global_sum_tally
 
std::vector< Real > _local_mean_tally
 
std::vector< Real > _linked_local_sum_tally
 Linked sum value across all bins. Indexed by score. More...
 
const MultiMooseEnum * _tally_trigger
 
std::vector< Real > _tally_trigger_threshold
 
std::vector< bool > _trigger_ignore_zeros
 
std::vector< OMCTensor_current_tally
 
std::vector< OMCTensor_previous_tally
 Previous fixed point iteration tally result (after relaxation) More...
 
std::vector< OMCTensor_current_raw_tally
 Current "raw" tally output from Monte Carlo solution. More...
 
std::vector< OMCTensor_current_raw_tally_rel_error
 Current "raw" tally relative error. More...
 
std::vector< OMCTensor_current_raw_tally_std_dev
 Current "raw" tally standard deviation. More...
 
const bool _normalize_by_global
 
const bool _check_tally_sum
 
const bool _needs_global_tally
 
const bool _renames_tally_vars
 Whether this tally stores results in variables names something other than '_tally_score'. More...
 
const bool _has_outputs
 Whether this tally has additional outputs or not. More...
 
std::vector< std::string > _output_name
 Suffixes to apply to 'tally_name' in order to name the fields in the 'output'. More...
 
const bool _is_adaptive
 Whether the problem uses adaptive mesh refinement or not. More...
 
std::vector< bool > _ext_bins_to_skip
 External filter bins to skip while computing the tally sum and mean for normalization. More...
 
std::set< SubdomainID > _tally_blocks
 Blocks for which to add tallies. More...
 
std::vector< const TallyBase * > _linked_tallies
 Other tallies linked for normalization. More...
 
relaxation::RelaxationEnum _relaxation_type
 The type of relaxation this tally should employ. More...
 
Real _relaxation_factor
 The relaxation factor this tally should use (for constant relaxation). More...
 

Static Protected Attributes

static constexpr Real ZERO_TALLY_THRESHOLD = 1e-12
 Tolerance for setting zero tally. More...
 

Constructor & Destructor Documentation

◆ TallyBase()

TallyBase::TallyBase ( const InputParameters &  parameters)

Member Function Documentation

◆ addingGlobalTally()

virtual bool TallyBase::addingGlobalTally ( ) const
inlinevirtual

Whether this tally requires a global tally or not.

Returns
if the tally adds a global tally in addition to a mapped local tally

Reimplemented in MeshTally.

◆ addLinkedTally()

void TallyBase::addLinkedTally ( const TallyBase other)

Add a linked tally for normalization.

Parameters
[in]tallythe other tally to link for normalization

◆ addScore()

void TallyBase::addScore ( const std::string &  score)

Add a score to this tally.

Parameters
[in]scorescore to add

◆ applyTriggersToLocalTally()

void TallyBase::applyTriggersToLocalTally ( openmc::Tally *  tally)
protected

Applies triggers to a tally. This is often the local tally wrapped by this object.

Parameters
[in]tallythe tally to apply triggers to

◆ checkNormalization()

void TallyBase::checkNormalization ( const Real &  sum,
unsigned int  score 
) const
protected

Check that the tally normalization gives a total tally sum of 1.0 (when normalized against the total tally value).

Parameters
[in]sumsum of the tally
[in]scoretally score

◆ checkTallySum()

void TallyBase::checkTallySum ( const unsigned int &  score) const
protected

Check the sum of the tallies against the global tally

Parameters
[in]scoretally score

◆ computeSumAndMean()

void TallyBase::computeSumAndMean ( )

A function which computes and stores the sum and mean of the tally across all bins for a particular score.

◆ extBinSkipped()

bool TallyBase::extBinSkipped ( unsigned int  ext_bin) const
inline

Check to see if the given external filter bin is skipped during normalization.

Parameters
[in]ext_binthe external filter bin
Returns
whether the bin is skipped during normalization or not

◆ fillElementalAuxVariable()

void TallyBase::fillElementalAuxVariable ( const unsigned int &  var_num,
const std::vector< unsigned int > &  elem_ids,
const Real &  value 
)
protected

Set an auxiliary elemental variable to a specified value

Parameters
[in]var_numvariable number
[in]elem_idselement IDs to set
[in]valuevalue to set

◆ gatherLinkedSum()

virtual void TallyBase::gatherLinkedSum ( )
virtual

A function which gathers the sums and means from all tallies linked to this tally.

Reimplemented in MeshTally.

◆ getAuxVarNames()

const std::vector<std::string>& TallyBase::getAuxVarNames ( ) const
inline

Gets the auxvariable names for use in creating and storing tally results. This allows for the splitting of tally results into energy bins, angular bins, etc.

Returns
vector of variable names to be associated with this tally

◆ getBlocks()

const std::set<SubdomainID>& TallyBase::getBlocks ( ) const
inline

A function to get the blocks associated with this CellTally.

Returns
a set of blocks associated with this tally.

◆ getGlobalTallyID()

int32_t TallyBase::getGlobalTallyID ( ) const

Get the global ID of the tally this object wraps.

◆ getMean()

const Real& TallyBase::getMean ( unsigned int  local_score) const
inline

Get the mean for a score summed over all bins.

Parameters
[in]local_scorethe index representing a tally score
Returns
mean for a score summed over all bins.

◆ getOutputs()

const std::vector<std::string>& TallyBase::getOutputs ( ) const
inline

Gets the output names to append to the end of the '_tally_name' when adding tally auxvariables for additional outputs.

Returns
additional tally outputs

◆ getScores()

const std::vector<std::string>& TallyBase::getScores ( ) const
inline

Get the list of scores this tally uses.

Returns
list of scores this tally uses

◆ getScoreVars()

std::vector<std::string> TallyBase::getScoreVars ( const std::string &  score) const

Get a vector of variable names corresponding to the provided score.

Parameters
[in]scorethe score that the user wishes to fetch variable names from
Returns
a vector of variables corresponding to the score

◆ getSum()

const Real& TallyBase::getSum ( unsigned int  local_score) const
inline

Get the sum for a score summed over all bins.

Parameters
[in]local_scorethe index representing a tally score
Returns
sum for a score summed over all bins.

◆ getTallyEstimator()

openmc::TallyEstimator TallyBase::getTallyEstimator ( ) const
inline

Get the estimator used in this tally.

Returns
the tally estimator

◆ getTallyID()

int32_t TallyBase::getTallyID ( ) const

Get the ID of the tally this object wraps.

◆ getWrappedGlobalTally()

const openmc::Tally* TallyBase::getWrappedGlobalTally ( ) const

Get the global OpenMC tally that this object wraps.

Returns
the OpenMC tally object

◆ getWrappedTally()

const openmc::Tally* TallyBase::getWrappedTally ( ) const

Get the local OpenMC tally that this object wraps.

Returns
the OpenMC tally object

◆ hasOutputs()

bool TallyBase::hasOutputs ( ) const
inline

Check to see if this tally adds additional output variables or not.

Returns
whether this tally adds additional output variables or not

◆ hasScore()

bool TallyBase::hasScore ( const std::string &  score) const
inline

Check to see if this tally contains a specific score.

Parameters
[in]scorethe score to check
Returns
whether this tally has

◆ hasTrigger()

bool TallyBase::hasTrigger ( ) const
inline

Check to see if this tally uses a trigger or not.

Returns
whether this tally uses a trigger or not

◆ initializeTally()

virtual void TallyBase::initializeTally ( )
virtual

A function to initialize the tally object. Override with care.

◆ linkedTallies()

const std::vector<const TallyBase *>& TallyBase::linkedTallies ( ) const
inline

Get the vector of tallies linked to this tally object for normalization

Returns
the vector of linked tallies

◆ numExtFilterBins()

unsigned int TallyBase::numExtFilterBins ( ) const
inline

Get the total number of external filter bins applied to this tally.

Returns
the total number of external filter bins.

◆ relaxAndNormalizeTally()

void TallyBase::relaxAndNormalizeTally ( )

Relax the tally and normalize it according to some normalization factor 'norm'. This tends to either be the sum of the over all bins OR a global tally over the entire problem.

NOTE: This function relaxes the tally distribution, and not the actual magnitude of the sum. That is, we relax the shape distribution and then multiply it by the power (for k-eigenvalue) or source strength (for fixed source) of the current step before applying it to MOOSE. If the magnitude of the power or source strength is constant in time, there is zero error in this. But if the magnitude of the tally varies in time, we are basically relaxing the distribution of the tally, but then multiplying it by the current mean tally magnitude.

There will be very small errors in these approximations unless the power/source strength change dramatically with iteration. But because relaxation is itself a numerical approximation, this is still inconsequential at the end of the day as long as your problem has converged the relaxed tally to the raw (unrelaxed) tally.

◆ renamesTallyVars()

bool TallyBase::renamesTallyVars ( ) const
inline

Check to see if the user has requested special names for the tallies.

Returns
whether this tally names stored values something other than '_tally_score'

◆ renormalizeLinkedTallies()

virtual void TallyBase::renormalizeLinkedTallies ( )
virtual

A function which renormalizes this tally based on the gathered sum from linked tallies.

◆ resetTally()

virtual void TallyBase::resetTally ( )
virtual

A function to reset the tally object. Override with care.

Reimplemented in MeshTally.

◆ scoreIndex()

int TallyBase::scoreIndex ( const std::string &  score) const

Get the index corresponding to a specific score.

Parameters
[in]scorethe score
Returns
the index of the score, -1 indicates the score does not exist

◆ setRelaxation()

void TallyBase::setRelaxation ( relaxation::RelaxationEnum  relaxation_type,
const Real &  relaxation_factor 
)

A function which sets the relaxation type and factor for a tally.

Parameters
[in]relaxation_typethe type of relaxation to use
[in]factorthe relaxation factor to use (for constant relxation or no relaxation)

◆ spatialFilter()

virtual std::pair<unsigned int, openmc::Filter *> TallyBase::spatialFilter ( )
pure virtual

A function which the derivied tally must override to create the OpenMC spatial filter the object maps to.

Returns
a pair where the first entry is the filter index in the global filter array and the second entry is the OpenMC filter

Implemented in MeshTally, and CellTally.

◆ storeResults()

Real TallyBase::storeResults ( const std::vector< unsigned int > &  var_numbers,
unsigned int  local_score,
const std::string &  output_type 
)

A function which stores the results of this tally into the created auxvariables. This calls storeResultsInner.

Parameters
[in]var_numbersvariables which the tally will store results in
[in]local_scoreindex into the tally's local array of scores which represents the current score being stored
[in]output_typethe output type
Returns
the sum of the tally over all bins. Only applicable for 'output_type = relaxed'

◆ storeResultsInner()

virtual Real TallyBase::storeResultsInner ( const std::vector< unsigned int > &  var_numbers,
unsigned int  local_score,
const std::vector< OMCTensor > &  tally_vals,
bool  norm_by_src_rate = true 
)
protectedpure virtual

A function which stores the results of this tally into the created auxvariables. This must be implemented by the derived class.

Parameters
[in]var_numbersvariables which the tally will store results in
[in]local_scoreindex into the tally's local array of scores which represents the current score being stored
[in]tally_valsthe tally values to store
[in]norm_by_src_ratewhether or not tally_vals should be normalized by the source rate
Returns
the sum of the tally over all bins.

Implemented in MeshTally, and CellTally.

◆ tallyNormalization()

Real TallyBase::tallyNormalization ( unsigned int  score) const
protected

Factor by which to normalize a tally

Parameters
[in]scoreindex for the tally score
Returns
value to divide tally sum by for normalization

◆ validParams()

static InputParameters TallyBase::validParams ( )
static

Member Data Documentation

◆ _aux

AuxiliarySystem& TallyBase::_aux
protected

The aux system.

◆ _check_tally_sum

const bool TallyBase::_check_tally_sum
protected

Whether to check the tallies against the global tally; if set to true, and the tallies added for the 'tally_blocks' do not sum to the global tally, an error is thrown. If you are only performing multiphysics feedback for, say, a single assembly in a full-core OpenMC model, you must set this check to false, because there are known fission sources outside the domain of interest.

If not specified, then this is set to 'true' if normalizing by a global tally, and to 'false' if normalizing by the local tally (because when we choose to normalize by the local tally, we're probably using mesh tallies). But you can of course still set a value for this parameter to override the default.

◆ _current_raw_tally

std::vector<OMCTensor> TallyBase::_current_raw_tally
protected

Current "raw" tally output from Monte Carlo solution.

◆ _current_raw_tally_rel_error

std::vector<OMCTensor> TallyBase::_current_raw_tally_rel_error
protected

Current "raw" tally relative error.

◆ _current_raw_tally_std_dev

std::vector<OMCTensor> TallyBase::_current_raw_tally_std_dev
protected

Current "raw" tally standard deviation.

◆ _current_tally

std::vector<OMCTensor> TallyBase::_current_tally
protected

Current fixed point iteration tally result; for instance, when using constant relaxation, the tally is updated as: q(n+1) = (1-a) * q(n) + a * PHI(q(n), s) where q(n+1) is _current_tally, a is the relaxation factor, q(n) is _previous_tally, and PHI is the most-recently-computed tally result (the _current_raw_tally).

◆ _estimator

openmc::TallyEstimator TallyBase::_estimator
protected

The OpenMC estimator to use with this tally.

◆ _ext_bins_to_skip

std::vector<bool> TallyBase::_ext_bins_to_skip
protected

External filter bins to skip while computing the tally sum and mean for normalization.

◆ _ext_filters

std::vector<std::shared_ptr<FilterBase> > TallyBase::_ext_filters
protected

The external filters added in the [Problem/Filters] block.

◆ _filter_index

unsigned int TallyBase::_filter_index
protected

The index of the first filter added by this tally.

◆ _global_sum_tally

std::vector<Real> TallyBase::_global_sum_tally
protected

Sum value of the global tally associated with this tally object. Each entry in _global_sum_tally corresponds to a score in _tally_score. As an example, _global_sum_tally[0] corresponds to the score located at _tally_score[0].

◆ _global_tally

openmc::Tally* TallyBase::_global_tally = nullptr
protected

The global OpenMC tally object this class wraps. Used for global normalization and error-checking of the sum of local tally results over all bins.

◆ _global_tally_index

unsigned int TallyBase::_global_tally_index
protected

The index of the global OpenMC tally this object wraps.

◆ _has_outputs

const bool TallyBase::_has_outputs
protected

Whether this tally has additional outputs or not.

◆ _is_adaptive

const bool TallyBase::_is_adaptive
protected

Whether the problem uses adaptive mesh refinement or not.

◆ _linked_local_sum_tally

std::vector<Real> TallyBase::_linked_local_sum_tally
protected

Linked sum value across all bins. Indexed by score.

◆ _linked_tallies

std::vector<const TallyBase *> TallyBase::_linked_tallies
protected

Other tallies linked for normalization.

◆ _local_mean_tally

std::vector<Real> TallyBase::_local_mean_tally
protected

Mean value of this tally across all bins; only used for fixed source mode. Each entry in _local_mean_tally corresponds to a score in _tally_score. As an example, _local_mean_tally[0] corresponds to the score located at _tally_score[0].

◆ _local_sum_tally

std::vector<Real> TallyBase::_local_sum_tally
protected

Sum value of this tally across all bins. Indexed by score.

◆ _local_tally

openmc::Tally* TallyBase::_local_tally = nullptr
protected

The OpenMC tally object this class wraps.

◆ _local_tally_index

unsigned int TallyBase::_local_tally_index
protected

The index of the OpenMC tally this object wraps.

◆ _mesh

MooseMesh& TallyBase::_mesh
protected

The MooseMesh.

◆ _needs_global_tally

const bool TallyBase::_needs_global_tally
protected

Whether a global tally is required for the sake of normalization and/or checking the tally sum

◆ _normalize_by_global

const bool TallyBase::_normalize_by_global
protected

How to normalize the OpenMC tally into units of W/volume. If 'true', normalization is performed by dividing each local tally against a problem-global tally. The advantage of this approach is that some non-zero tally regions of the OpenMC domain can be excluded from multiphysics feedback (without us having to guess what the power of the included part of the domain is). This can let us do "zooming" type calculations, where perhaps we only want to send T/H feedback to one bundle in a full core.

If 'false', normalization is performed by dividing each local tally by the sum of the local tally itself. The advantage of this approach becomes evident when using mesh tallies. If a mesh tally does not perfectly align with an OpenMC cell - for instance, a first-order sphere mesh will not perfectly match the volume of a TRISO pebble - then not all of the power actually produced in the pebble is tallies on the mesh approximation to that pebble. Therefore, if you set a core power of 1 MW and you normalized based on a global tally, you'd always miss some of that power when sending to MOOSE. So, in this case, it is better to normalize against the local tally itself so that the correct power is preserved.

◆ _num_ext_filter_bins

unsigned int TallyBase::_num_ext_filter_bins = 1
protected

The number of non-spatial bins in this tally.

◆ _openmc_problem

OpenMCCellAverageProblem& TallyBase::_openmc_problem
protected

The OpenMCCellAverageProblem using the tally system.

◆ _output_name

std::vector<std::string> TallyBase::_output_name
protected

Suffixes to apply to 'tally_name' in order to name the fields in the 'output'.

◆ _previous_tally

std::vector<OMCTensor> TallyBase::_previous_tally
protected

Previous fixed point iteration tally result (after relaxation)

◆ _relaxation_factor

Real TallyBase::_relaxation_factor
protected

The relaxation factor this tally should use (for constant relaxation).

◆ _relaxation_type

relaxation::RelaxationEnum TallyBase::_relaxation_type
protected

The type of relaxation this tally should employ.

◆ _renames_tally_vars

const bool TallyBase::_renames_tally_vars
protected

Whether this tally stores results in variables names something other than '_tally_score'.

◆ _tally_blocks

std::set<SubdomainID> TallyBase::_tally_blocks
protected

Blocks for which to add tallies.

◆ _tally_name

std::vector<std::string> TallyBase::_tally_name
protected

Auxiliary variable name(s) for this tally.

◆ _tally_score

std::vector<std::string> TallyBase::_tally_score
protected

OpenMC tally score(s) to use with this tally.

◆ _tally_trigger

const MultiMooseEnum* TallyBase::_tally_trigger
protected

Type of trigger to apply to OpenMC tallies to indicate when the simulation is complete. These can be used to on-the-fly adjust the number of active batches in order to reach some desired criteria (which is specified by this parameter).

◆ _tally_trigger_threshold

std::vector<Real> TallyBase::_tally_trigger_threshold
protected

Thresholds to use for accepting this tally when using triggers. Indexed by score.

◆ _trigger_ignore_zeros

std::vector<bool> TallyBase::_trigger_ignore_zeros
protected

Whether tally bins for certain scores should ignore bins with zeros when computing trigger metrics. Indexed by the tally score.

◆ ZERO_TALLY_THRESHOLD

constexpr Real TallyBase::ZERO_TALLY_THRESHOLD = 1e-12
staticprotected

Tolerance for setting zero tally.


The documentation for this class was generated from the following file: