Loading [MathJax]/jax/output/HTML-CSS/config.js
Cardinal
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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
29class MooseMesh;
30class AuxiliarySystem;
31class FilterBase;
32
33class TallyBase : public MooseObject
34{
35public:
36 static InputParameters validParams();
37
38 TallyBase(const InputParameters & parameters);
39
46 virtual std::pair<unsigned int, openmc::Filter *> spatialFilter() = 0;
47
51 virtual void initializeTally();
52
56 virtual void resetTally();
57
69 Real storeResults(const std::vector<unsigned int> & var_numbers,
70 unsigned int local_score,
71 unsigned int global_score,
72 const std::string & output_type);
73
78 void addScore(const std::string & score);
79
85
106 void relaxAndNormalizeTally(unsigned int local_score, const Real & alpha, const Real & norm);
107
112 const openmc::Tally * getWrappedTally() const;
113
117 int32_t getTallyID() const;
118
123 const std::vector<std::string> & getScores() const { return _tally_score; }
124
130 int scoreIndex(const std::string & score) const;
131
138 const std::vector<std::string> & getAuxVarNames() const { return _tally_name; }
139
145 const std::vector<std::string> & getOutputs() const { return _output_name; }
146
151 openmc::TallyEstimator getTallyEstimator() const { return _estimator; }
152
158 const Real & getMean(unsigned int local_score) const { return _local_mean_tally[local_score]; }
159
165 const Real & getSum(unsigned int local_score) const { return _local_sum_tally[local_score]; }
166
172 std::vector<std::string> getScoreVars(const std::string & score) const;
173
178 bool hasTrigger() const { return _tally_trigger != nullptr; }
179
184 bool hasOutputs() const { return _has_outputs; }
185
191 bool hasScore(const std::string & score) const
192 {
193 return std::find(_tally_score.begin(), _tally_score.end(), score) != _tally_score.end();
194 }
195
200 bool renamesTallyVars() const { return _renames_tally_vars; }
201
206 unsigned int numExtFilterBins() const { return _num_ext_filter_bins; }
207
208protected:
221 virtual Real storeResultsInner(const std::vector<unsigned int> & var_numbers,
222 unsigned int local_score,
223 unsigned int global_score,
224 std::vector<xt::xtensor<double, 1>> tally_vals,
225 bool norm_by_src_rate = true) = 0;
226
233 void fillElementalAuxVariable(const unsigned int & var_num,
234 const std::vector<unsigned int> & elem_ids,
235 const Real & value);
236
241 void applyTriggersToLocalTally(openmc::Tally * tally);
242
245
247 MooseMesh & _mesh;
248
250 AuxiliarySystem & _aux;
251
253 std::vector<std::shared_ptr<FilterBase>> _ext_filters;
254
256 openmc::TallyEstimator _estimator;
257
259 std::vector<std::string> _tally_score;
260
262 std::vector<std::string> _tally_name;
263
265 openmc::Tally * _local_tally = nullptr;
266
268 unsigned int _local_tally_index;
269
271 unsigned int _filter_index;
272
274 unsigned int _num_ext_filter_bins = 1;
275
277 std::vector<Real> _local_sum_tally;
278
283 std::vector<Real> _local_mean_tally;
284
291 const MultiMooseEnum * _tally_trigger;
292
297 std::vector<Real> _tally_trigger_threshold;
298
303 std::vector<bool> _trigger_ignore_zeros;
304
313 std::vector<xt::xtensor<double, 1>> _current_tally;
314
316 std::vector<xt::xtensor<double, 1>> _previous_tally;
317
319 std::vector<xt::xtensor<double, 1>> _current_raw_tally;
320
322 std::vector<xt::xtensor<double, 1>> _current_raw_tally_rel_error;
323
325 std::vector<xt::xtensor<double, 1>> _current_raw_tally_std_dev;
326
329
331 const bool _has_outputs;
332
334 std::vector<std::string> _output_name;
335
337 const bool _is_adaptive;
338
340 static constexpr Real ZERO_TALLY_THRESHOLD = 1e-12;
341};
Definition FilterBase.h:41
Definition OpenMCCellAverageProblem.h:67
Definition TallyBase.h:34
unsigned int _local_tally_index
The index of the OpenMC tally this object wraps.
Definition TallyBase.h:268
std::vector< std::shared_ptr< FilterBase > > _ext_filters
The external filters added in the [Problem/Filters] block.
Definition TallyBase.h:253
int scoreIndex(const std::string &score) const
const std::vector< std::string > & getAuxVarNames() const
Definition TallyBase.h:138
const bool _is_adaptive
Whether the problem uses adaptive mesh refinement or not.
Definition TallyBase.h:337
unsigned int numExtFilterBins() const
Definition TallyBase.h:206
openmc::TallyEstimator getTallyEstimator() const
Definition TallyBase.h:151
const bool _has_outputs
Whether this tally has additional outputs or not.
Definition TallyBase.h:331
const bool _renames_tally_vars
Whether this tally stores results in variables names something other than '_tally_score'.
Definition TallyBase.h:328
bool hasOutputs() const
Definition TallyBase.h:184
std::vector< xt::xtensor< double, 1 > > _previous_tally
Previous fixed point iteration tally result (after relaxation)
Definition TallyBase.h:316
std::vector< Real > _local_sum_tally
Sum value of this tally across all bins. Indexed by score.
Definition TallyBase.h:277
bool renamesTallyVars() const
Definition TallyBase.h:200
const openmc::Tally * getWrappedTally() const
std::vector< Real > _tally_trigger_threshold
Definition TallyBase.h:297
Real storeResults(const std::vector< unsigned int > &var_numbers, unsigned int local_score, unsigned int global_score, const std::string &output_type)
const std::vector< std::string > & getOutputs() const
Definition TallyBase.h:145
openmc::Tally * _local_tally
The OpenMC tally object this class wraps.
Definition TallyBase.h:265
const MultiMooseEnum * _tally_trigger
Definition TallyBase.h:291
std::vector< xt::xtensor< double, 1 > > _current_raw_tally_rel_error
Current "raw" tally relative error.
Definition TallyBase.h:322
unsigned int _filter_index
The index of the first filter added by this tally.
Definition TallyBase.h:271
virtual std::pair< unsigned int, openmc::Filter * > spatialFilter()=0
std::vector< Real > _local_mean_tally
Definition TallyBase.h:283
const std::vector< std::string > & getScores() const
Definition TallyBase.h:123
static InputParameters validParams()
unsigned int _num_ext_filter_bins
The number of non-spatial bins in this tally.
Definition TallyBase.h:274
const Real & getMean(unsigned int local_score) const
Definition TallyBase.h:158
void fillElementalAuxVariable(const unsigned int &var_num, const std::vector< unsigned int > &elem_ids, const Real &value)
void computeSumAndMean()
std::vector< xt::xtensor< double, 1 > > _current_tally
Definition TallyBase.h:313
bool hasTrigger() const
Definition TallyBase.h:178
const Real & getSum(unsigned int local_score) const
Definition TallyBase.h:165
int32_t getTallyID() const
OpenMCCellAverageProblem & _openmc_problem
The OpenMCCellAverageProblem using the tally system.
Definition TallyBase.h:244
AuxiliarySystem & _aux
The aux system.
Definition TallyBase.h:250
virtual void resetTally()
std::vector< bool > _trigger_ignore_zeros
Definition TallyBase.h:303
virtual Real storeResultsInner(const std::vector< unsigned int > &var_numbers, unsigned int local_score, unsigned int global_score, std::vector< xt::xtensor< double, 1 > > tally_vals, bool norm_by_src_rate=true)=0
std::vector< std::string > _tally_name
Auxiliary variable name(s) for this tally.
Definition TallyBase.h:262
std::vector< std::string > _output_name
Suffixes to apply to 'tally_name' in order to name the fields in the 'output'.
Definition TallyBase.h:334
static constexpr Real ZERO_TALLY_THRESHOLD
Tolerance for setting zero tally.
Definition TallyBase.h:340
void applyTriggersToLocalTally(openmc::Tally *tally)
std::vector< std::string > _tally_score
OpenMC tally score(s) to use with this tally.
Definition TallyBase.h:259
openmc::TallyEstimator _estimator
The OpenMC estimator to use with this tally.
Definition TallyBase.h:256
void addScore(const std::string &score)
TallyBase(const InputParameters &parameters)
std::vector< xt::xtensor< double, 1 > > _current_raw_tally
Current "raw" tally output from Monte Carlo solution.
Definition TallyBase.h:319
void relaxAndNormalizeTally(unsigned int local_score, const Real &alpha, const Real &norm)
std::vector< std::string > getScoreVars(const std::string &score) const
virtual void initializeTally()
MooseMesh & _mesh
The MooseMesh.
Definition TallyBase.h:247
std::vector< xt::xtensor< double, 1 > > _current_raw_tally_std_dev
Current "raw" tally standard deviation.
Definition TallyBase.h:325
bool hasScore(const std::string &score) const
Definition TallyBase.h:191
Definition CardinalEnums.h:138