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 "CellMaterialIDAux.h" 22 : #include "CardinalEnums.h" 23 : 24 : registerMooseObject("CardinalApp", CellMaterialIDAux); 25 : 26 : InputParameters 27 300 : CellMaterialIDAux::validParams() 28 : { 29 300 : InputParameters params = OpenMCAuxKernel::validParams(); 30 300 : params.addClassDescription("OpenMC fluid material ID, mapped to each MOOSE element"); 31 300 : return params; 32 0 : } 33 : 34 149 : CellMaterialIDAux::CellMaterialIDAux(const InputParameters & parameters) 35 149 : : OpenMCAuxKernel(parameters) 36 : { 37 149 : } 38 : 39 : Real 40 3208768 : CellMaterialIDAux::computeValue() 41 : { 42 : // if the element doesn't map to an OpenMC cell, return a cell ID of -1; otherwise, we would 43 : // get an error in the call to cellCouplingFields and cellToMaterialIndex, since these 44 : // rely on a valid cell instance, index pair being passed to OpenMC's C-API 45 3208768 : if (!mappedElement()) 46 : return OpenMCCellAverageProblem::UNMAPPED; 47 : 48 : // we only extract the material information for fluid cells, because otherwise we don't 49 : // need to know the material info. So, set a value of -1 for non-fluid cells. 50 : OpenMCCellAverageProblem::cellInfo cell_info = 51 2866272 : _openmc_problem->elemToCellInfo(_current_elem->id()); 52 2866272 : if (!_openmc_problem->hasDensityFeedback(cell_info)) 53 : return -1; 54 : 55 1331520 : int32_t index = _openmc_problem->cellToMaterialIndex(cell_info); 56 1331520 : int32_t id = _openmc_problem->materialID(index); 57 : 58 1331520 : return id; 59 : } 60 : 61 : #endif