Line data Source code
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 "GeneralUserObject.h" 22 : 23 : #include "OpenMCBase.h" 24 : #include "openmc/volume_calc.h" 25 : 26 : /** 27 : * Class that computes a volume calculation over the OpenMC model 28 : * based on information from the OpenMC wrapping (OpenMCCellAverageProblem). 29 : */ 30 : class OpenMCVolumeCalculation : public GeneralUserObject, public OpenMCBase 31 : { 32 : public: 33 : static InputParameters validParams(); 34 : 35 : OpenMCVolumeCalculation(const InputParameters & parameters); 36 : 37 232 : virtual void initialize() {} 38 232 : virtual void finalize() {} 39 232 : virtual void execute() {} 40 : 41 : /// Initialize the volume calculation (not in initialize() because we want to control this from the Problem) 42 : virtual void initializeVolumeCalculation(); 43 : 44 : /// Compute the cell volumes 45 : virtual void computeVolumes(); 46 : 47 : /// Erase previously-added volume calculation 48 : virtual void resetVolumeCalculation(); 49 : 50 : /** 51 : * Convert from a Point to a Position 52 : * @param[in] point point 53 : * @return position 54 : */ 55 : openmc::Position position(const Point & pt) const; 56 : 57 : /** 58 : * Get the OpenMC cell volume 59 : * @param[in] index cell index 60 : * @param[out] vol stochastically-computed volume 61 : * @param[out] std_dev standard deviation 62 : */ 63 : void cellVolume(const unsigned int & index, Real & vol, Real & std_dev) const; 64 : 65 : protected: 66 : /// Number of stochastic samples for calculation 67 : const unsigned int & _n_samples; 68 : 69 : /// Trigger for deciding when to terminate the stochastic volume calculation 70 : const MooseEnum _trigger; 71 : 72 : /// Threshold for terminating the trigger 73 : Real _trigger_threshold; 74 : 75 : /// Length multiplier applied to [Mesh] to get into OpenMC centimeters 76 : Real _scaling; 77 : 78 : /// Lower left of the box within which to compute OpenMC volumes 79 : Point _lower_left; 80 : 81 : /// Upper right of the box within which to compute OpenMC volumes 82 : Point _upper_right; 83 : 84 : /// Volume calculation object 85 : std::unique_ptr<openmc::VolumeCalculation> _volume_calc; 86 : 87 : /// Results of the volume calculation 88 : std::vector<openmc::VolumeCalculation::Result> _results; 89 : 90 : /// Map from cell index to its volume calculation result 91 : std::map<int, int> _index_to_calc_index; 92 : 93 : /// Index of volume calculation we add in OpenMC 94 : unsigned int _calc_index; 95 : };