LCOV - code coverage report
Current view: top level - src/auxkernels - CellVolumeAux.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: be601f Lines: 19 20 95.0 %
Date: 2025-07-15 20:50:38 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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             : #ifdef ENABLE_OPENMC_COUPLING
      20             : 
      21             : #include "CellVolumeAux.h"
      22             : #include "openmc/cell.h"
      23             : #include "openmc/error.h"
      24             : 
      25             : registerMooseObject("CardinalApp", CellVolumeAux);
      26             : 
      27             : InputParameters
      28         148 : CellVolumeAux::validParams()
      29             : {
      30         148 :   InputParameters params = OpenMCAuxKernel::validParams();
      31             : 
      32         296 :   MooseEnum vol_type("mapped actual");
      33         296 :   params.addRequiredParam<MooseEnum>("volume_type", vol_type,
      34             :     "Which notion of cell volume to display. For 'mapped', this shows only the volume of the "
      35             :     "MOOSE elements which map to each cell (this is mostly for testing). For 'actual', this "
      36             :     "will map to the [Mesh] the actual volumes of OpenMC cells obtained from a stochastic "
      37             :     "calculation");
      38         148 :   params.addClassDescription("OpenMC cell volumes, mapped to MOOSE");
      39         148 :   return params;
      40         148 : }
      41             : 
      42          72 : CellVolumeAux::CellVolumeAux(const InputParameters & parameters)
      43             :   : OpenMCAuxKernel(parameters),
      44         144 :     _volume_type(getParam<MooseEnum>("volume_type"))
      45             : {
      46          72 : }
      47             : 
      48             : Real
      49      782050 : CellVolumeAux::computeValue()
      50             : {
      51      782050 :   if (_volume_type == "actual" && !_openmc_problem->volumeCalculation())
      52           2 :     paramError("volume_type",
      53             :                "To display the actual OpenMC cell volumes, the [Problem] block needs to set the\n"
      54             :                "'volume_calculation' parameter.");
      55             : 
      56             :   // if the element doesn't map to an OpenMC cell, return a volume of -1; this is required
      57             :   // because otherwise OpenMC would throw an error for an invalid instance, index pair passed to the
      58             :   // C-API
      59      782048 :   if (!mappedElement())
      60             :     return OpenMCCellAverageProblem::UNMAPPED;
      61             : 
      62             :   OpenMCCellAverageProblem::cellInfo cell_info =
      63      773856 :       _openmc_problem->elemToCellInfo(_current_elem->id());
      64             : 
      65      773856 :   if (_volume_type == "mapped")
      66      164544 :     return _openmc_problem->cellMappedVolume(cell_info);
      67      609312 :   else if (_volume_type == "actual")
      68      609312 :     return _openmc_problem->cellVolume(cell_info);
      69             :   else
      70           0 :     mooseError("Unhandled vol_type enum in CellVolumeAux!");
      71             : }
      72             : 
      73             : #endif

Generated by: LCOV version 1.14