Cardinal
TallyBase.h
Go to the documentation of this file.
1 /********************************************************************/
2 /* SOFTWARE COPYRIGHT NOTIFICATION */
3 /* Cardinal */
4 /* */
5 /* (c) 2021 UChicago Argonne, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by UChicago Argonne, LLC */
9 /* Under Contract No. DE-AC02-06CH11357 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* Prepared by Battelle Energy Alliance, LLC */
13 /* Under Contract No. DE-AC07-05ID14517 */
14 /* With the U. S. Department of Energy */
15 /* */
16 /* See LICENSE for full restrictions */
17 /********************************************************************/
18 
19 #pragma once
20 
21 #include "MooseObject.h"
22 #include "CardinalEnums.h"
23 
24 #include "openmc/tallies/tally.h"
25 #include "xtensor/xview.hpp"
26 
29 class MooseMesh;
30 class AuxiliarySystem;
31 
32 class TallyBase : public MooseObject
33 {
34 public:
35  static InputParameters validParams();
36 
37  TallyBase(const InputParameters & parameters);
38 
45  virtual std::pair<unsigned int, openmc::Filter *> spatialFilter() = 0;
46 
50  virtual void initializeTally();
51 
55  virtual void resetTally();
56 
67  virtual Real storeResults(const std::vector<unsigned int> & var_numbers,
68  unsigned int local_score,
69  unsigned int global_score,
70  const std::string & output_type) = 0;
71 
76  void addScore(const std::string & score);
77 
82  void computeSumAndMean();
83 
104  void relaxAndNormalizeTally(unsigned int local_score, const Real & alpha, const Real & norm);
105 
110  const openmc::Tally * getWrappedTally() const;
111 
116  const std::vector<std::string> & getScores() const { return _tally_score; }
117 
124  const std::vector<std::string> & getAuxVarNames() const { return _tally_name; }
125 
131  const std::vector<std::string> & getOutputs() const { return _output_name; }
132 
137  openmc::TallyEstimator getTallyEstimator() const { return _estimator; }
138 
144  const Real & getMean(unsigned int local_score) const { return _local_mean_tally[local_score]; }
145 
151  const Real & getSum(unsigned int local_score) const { return _local_sum_tally[local_score]; }
152 
157  bool hasTrigger() const { return _tally_trigger != nullptr; }
158 
163  bool hasOutputs() const { return _has_outputs; }
164 
169  bool renamesTallyVars() const { return _renames_tally_vars; }
170 
171 protected:
178  void fillElementalAuxVariable(const unsigned int & var_num,
179  const std::vector<unsigned int> & elem_ids,
180  const Real & value);
181 
186  void applyTriggersToLocalTally(openmc::Tally * tally);
187 
190 
192  MooseMesh & _mesh;
193 
195  AuxiliarySystem & _aux;
196 
198  openmc::TallyEstimator _estimator;
199 
201  std::vector<std::string> _tally_score;
202 
204  std::vector<std::string> _tally_name;
205 
207  openmc::Tally * _local_tally = nullptr;
208 
210  unsigned int _local_tally_index;
211 
213  unsigned int _filter_index;
214 
216  std::vector<Real> _local_sum_tally;
217 
222  std::vector<Real> _local_mean_tally;
223 
230  const MultiMooseEnum * _tally_trigger;
231 
236  std::vector<Real> _tally_trigger_threshold;
237 
246  std::vector<xt::xtensor<double, 1>> _current_tally;
247 
249  std::vector<xt::xtensor<double, 1>> _previous_tally;
250 
252  std::vector<xt::xtensor<double, 1>> _current_raw_tally;
253 
255  std::vector<xt::xtensor<double, 1>> _current_raw_tally_std_dev;
256 
259 
261  const bool _has_outputs;
262 
264  std::vector<std::string> _output_name;
265 
267  static constexpr Real ZERO_TALLY_THRESHOLD = 1e-12;
268 };
TallyBase::_local_sum_tally
std::vector< Real > _local_sum_tally
Sum value of this tally across all bins. Indexed by score.
Definition: TallyBase.h:216
TallyBase::applyTriggersToLocalTally
void applyTriggersToLocalTally(openmc::Tally *tally)
TallyBase::getTallyEstimator
openmc::TallyEstimator getTallyEstimator() const
Definition: TallyBase.h:137
TallyBase::resetTally
virtual void resetTally()
TallyBase::relaxAndNormalizeTally
void relaxAndNormalizeTally(unsigned int local_score, const Real &alpha, const Real &norm)
TallyBase::hasTrigger
bool hasTrigger() const
Definition: TallyBase.h:157
TallyBase::_aux
AuxiliarySystem & _aux
The aux system.
Definition: TallyBase.h:195
TallyBase::_has_outputs
const bool _has_outputs
Whether this tally has additional outputs or not.
Definition: TallyBase.h:261
TallyBase::validParams
static InputParameters validParams()
TallyBase::getScores
const std::vector< std::string > & getScores() const
Definition: TallyBase.h:116
TallyBase::_tally_trigger
const MultiMooseEnum * _tally_trigger
Definition: TallyBase.h:230
TallyBase::_local_mean_tally
std::vector< Real > _local_mean_tally
Definition: TallyBase.h:222
TallyBase::TallyBase
TallyBase(const InputParameters &parameters)
TallyBase::_openmc_problem
OpenMCCellAverageProblem & _openmc_problem
The OpenMCCellAverageProblem using the tally system.
Definition: TallyBase.h:189
TallyBase::initializeTally
virtual void initializeTally()
TallyBase::getMean
const Real & getMean(unsigned int local_score) const
Definition: TallyBase.h:144
TallyBase::_tally_score
std::vector< std::string > _tally_score
OpenMC tally score(s) to use with this tally.
Definition: TallyBase.h:201
OpenMCCellAverageProblem
Tally includes.
Definition: OpenMCCellAverageProblem.h:65
TallyBase::_estimator
openmc::TallyEstimator _estimator
The OpenMC estimator to use with this tally.
Definition: TallyBase.h:198
TallyBase::fillElementalAuxVariable
void fillElementalAuxVariable(const unsigned int &var_num, const std::vector< unsigned int > &elem_ids, const Real &value)
TallyBase::getSum
const Real & getSum(unsigned int local_score) const
Definition: TallyBase.h:151
TallyBase::_current_tally
std::vector< xt::xtensor< double, 1 > > _current_tally
Definition: TallyBase.h:246
TallyBase::storeResults
virtual Real storeResults(const std::vector< unsigned int > &var_numbers, unsigned int local_score, unsigned int global_score, const std::string &output_type)=0
CardinalEnums.h
TallyBase::ZERO_TALLY_THRESHOLD
static constexpr Real ZERO_TALLY_THRESHOLD
Tolerance for setting zero tally.
Definition: TallyBase.h:267
TallyBase::_tally_trigger_threshold
std::vector< Real > _tally_trigger_threshold
Definition: TallyBase.h:236
TallyBase::_tally_name
std::vector< std::string > _tally_name
Auxiliary variable name(s) for this tally.
Definition: TallyBase.h:204
TallyBase::hasOutputs
bool hasOutputs() const
Definition: TallyBase.h:163
TallyBase::computeSumAndMean
void computeSumAndMean()
TallyBase::_output_name
std::vector< std::string > _output_name
Suffixes to apply to 'tally_name' in order to name the fields in the 'output'.
Definition: TallyBase.h:264
TallyBase::getWrappedTally
const openmc::Tally * getWrappedTally() const
TallyBase::spatialFilter
virtual std::pair< unsigned int, openmc::Filter * > spatialFilter()=0
TallyBase::_current_raw_tally
std::vector< xt::xtensor< double, 1 > > _current_raw_tally
Current "raw" tally output from Monte Carlo solution.
Definition: TallyBase.h:252
TallyBase
Definition: TallyBase.h:32
TallyBase::_renames_tally_vars
const bool _renames_tally_vars
Whether this tally stores results in variables names something other than '_tally_score'.
Definition: TallyBase.h:258
TallyBase::_local_tally_index
unsigned int _local_tally_index
The index of the OpenMC tally this object wraps.
Definition: TallyBase.h:210
TallyBase::_filter_index
unsigned int _filter_index
The index of the first filter added by this tally.
Definition: TallyBase.h:213
TallyBase::_current_raw_tally_std_dev
std::vector< xt::xtensor< double, 1 > > _current_raw_tally_std_dev
Current "raw" tally standard deviation.
Definition: TallyBase.h:255
TallyBase::getAuxVarNames
const std::vector< std::string > & getAuxVarNames() const
Definition: TallyBase.h:124
TallyBase::renamesTallyVars
bool renamesTallyVars() const
Definition: TallyBase.h:169
TallyBase::addScore
void addScore(const std::string &score)
TallyBase::getOutputs
const std::vector< std::string > & getOutputs() const
Definition: TallyBase.h:131
TallyBase::_mesh
MooseMesh & _mesh
The MooseMesh.
Definition: TallyBase.h:192
tally
Definition: CardinalEnums.h:128
TallyBase::_previous_tally
std::vector< xt::xtensor< double, 1 > > _previous_tally
Previous fixed point iteration tally result (after relaxation)
Definition: TallyBase.h:249
TallyBase::_local_tally
openmc::Tally * _local_tally
The OpenMC tally object this class wraps.
Definition: TallyBase.h:207