LCOV - code coverage report
Current view: top level - src/controls - OpenMCNuclideDensitiesControl.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: be601f Lines: 26 28 92.9 %
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 "OpenMCNuclideDensitiesControl.h"
      22             : 
      23             : #include "CardinalAppTypes.h"
      24             : #include "OpenMCNuclideDensities.h"
      25             : 
      26             : registerMooseObject("CardinalApp", OpenMCNuclideDensitiesControl);
      27             : 
      28             : InputParameters
      29          18 : OpenMCNuclideDensitiesControl::validParams()
      30             : {
      31          18 :   InputParameters params = Control::validParams();
      32          18 :   params.addClassDescription("Controls the densities in a OpenMCNuclideDensities object.");
      33          36 :   params.addRequiredParam<UserObjectName>("user_object",
      34             :                                           "The name of the associated OpenMCNuclideDensities");
      35             : 
      36             :   // each index in the vectors represents one time step
      37          36 :   params.addRequiredParam<std::vector<std::vector<std::string>>>(
      38             :       "names", "Names of the nuclides to modifiy densities for each timestep");
      39          36 :   params.addRequiredParam<std::vector<std::vector<Real>>>(
      40             :       "densities", "Nuclide densities (atom/b/cm) to set for each timestep");
      41             : 
      42          18 :   auto & exec_enum = params.set<ExecFlagEnum>("execute_on", true);
      43          18 :   exec_enum.addAvailableFlags(EXEC_SEND_OPENMC_DENSITIES);
      44          54 :   exec_enum = {EXEC_SEND_OPENMC_DENSITIES};
      45          18 :   params.suppressParameter<ExecFlagEnum>("execute_on");
      46             : 
      47          18 :   return params;
      48          18 : }
      49             : 
      50          10 : OpenMCNuclideDensitiesControl::OpenMCNuclideDensitiesControl(const InputParameters & parameters)
      51             :   : Control(parameters),
      52          10 :     _controllable_prefix("UserObjects/" + getParam<UserObjectName>("user_object") + "/"),
      53          20 :     _names(getParam<std::vector<std::vector<std::string>>>("names")),
      54          20 :     _densities(getParam<std::vector<std::vector<Real>>>("densities")),
      55          10 :     _current_execution(0)
      56             : {
      57             :   // This will make sure that the associated name is actually a OpenMCNuclideDensities
      58          20 :   if (!hasUserObject<OpenMCNuclideDensities>("user_object"))
      59           2 :     paramError("user_object",
      60             :                "The given UserObject does not exist or it is not a OpenMCNuclideDensities object");
      61             : 
      62             :   // do not need any error checking here, because we perform it in OpenMCNuclideDensities
      63           8 : }
      64             : 
      65             : void
      66           8 : OpenMCNuclideDensitiesControl::execute()
      67             : {
      68           8 :   if (_current_execution >= _names.size())
      69             :   {
      70           0 :     mooseWarning("Skipping nuclide control as data was not provided for this execution");
      71           0 :     return;
      72             :   }
      73             : 
      74           8 :   setControllableValueByName<std::vector<std::string>>(_controllable_prefix + "names",
      75             :                                                        _names[_current_execution]);
      76           8 :   setControllableValueByName<std::vector<Real>>(_controllable_prefix + "densities",
      77           8 :                                                 _densities[_current_execution]);
      78             : 
      79           8 :   ++_current_execution;
      80             : }
      81             : 
      82             : #endif

Generated by: LCOV version 1.14