LCOV - code coverage report
Current view: top level - src/auxkernels - CellDensityAux.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: faa471 Lines: 10 11 90.9 %
Date: 2026-08-05 13:00:46 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 "CellDensityAux.h"
      22             : 
      23             : registerMooseObject("CardinalApp", CellDensityAux);
      24             : 
      25             : InputParameters
      26         476 : CellDensityAux::validParams()
      27             : {
      28         476 :   InputParameters params = OpenMCAuxKernel::validParams();
      29         476 :   params.addClassDescription("OpenMC cell density (kg/m$^3$), mapped to each MOOSE element. For "
      30             :                              "cells filled by universes or lattices, returns the density of the "
      31             :                              "first-located, non-void, material cell contained within.");
      32         476 :   return params;
      33           0 : }
      34             : 
      35         237 : CellDensityAux::CellDensityAux(const InputParameters & parameters) : OpenMCAuxKernel(parameters) {}
      36             : 
      37             : Real
      38     3008704 : CellDensityAux::computeValue()
      39             : {
      40             :   // if the element doesn't map to an OpenMC cell, return a density of -1; otherwise, we would
      41             :   // get an error in the call to cellCouplingFields, since it relies on the
      42             :   // OpenMCCellAverageProblem::_cell_to_elem std::map that wouldn't have an entry that corresponds
      43             :   // to an unmapped cell
      44     3008704 :   if (!mappedElement())
      45             :     return OpenMCCellAverageProblem::UNMAPPED;
      46             : 
      47             :   OpenMCCellAverageProblem::cellInfo cell_info =
      48     2664576 :       _openmc_problem->elemToCellInfo(_current_elem->id());
      49             : 
      50     2664576 :   if (!_openmc_problem->hasDensityFeedback(cell_info))
      51             :     return OpenMCCellAverageProblem::UNMAPPED;
      52             : 
      53     1333120 :   return _openmc_problem->cellDensity(cell_info, _current_elem);
      54             : }
      55             : 
      56             : #endif

Generated by: LCOV version 1.14