LCOV - code coverage report
Current view: top level - src/transfers - NekScalarValue.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: ddd5f2 Lines: 24 25 96.0 %
Date: 2026-06-07 19:35:24 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_NEK_COUPLING
      20             : 
      21             : #include "NekScalarValue.h"
      22             : 
      23             : registerMooseObject("CardinalApp", NekScalarValue);
      24             : 
      25             : InputParameters
      26          76 : NekScalarValue::validParams()
      27             : {
      28          76 :   auto params = ScalarTransferBase::validParams();
      29         152 :   params.addParam<Real>("value", 0.0, "Scalar value to pass into NekRS");
      30         152 :   params.addParam<PostprocessorName>(
      31             :       "output_postprocessor", "Name of the postprocessor to output the value sent into NekRS");
      32         152 :   params.declareControllable("value");
      33             : 
      34          76 :   params.addClassDescription("Transfers a scalar value into NekRS");
      35          76 :   params.registerBase("ScalarTransfer");
      36          76 :   params.registerSystemAttributeName("ScalarTransfer");
      37          76 :   return params;
      38           0 : }
      39             : 
      40          37 : NekScalarValue::NekScalarValue(const InputParameters & parameters)
      41             :   : ScalarTransferBase(parameters),
      42          35 :     _value(getParam<Real>("value")),
      43          35 :     _postprocessor(isParamValid("output_postprocessor")
      44          89 :                        ? &getParam<PostprocessorName>("output_postprocessor")
      45          37 :                        : nullptr)
      46             : {
      47          35 : }
      48             : 
      49             : void
      50         242 : NekScalarValue::sendDataToNek()
      51             : {
      52         242 :   Real value_to_set = _value * _scaling;
      53         242 :   _console << "Sending scalar value (" << Moose::stringify(value_to_set) << ") to NekRS..."
      54         242 :            << std::endl;
      55             : 
      56         242 :   nrs_t * nrs = (nrs_t *)nekrs::nrsPtr();
      57         242 :   nrs->usrwrk[_usrwrk_slot * nekrs::fieldOffset() + _offset] = value_to_set;
      58             : 
      59         242 :   if (_postprocessor)
      60         162 :     _nek_problem.setPostprocessorValueByName(*_postprocessor, value_to_set);
      61         242 : }
      62             : 
      63             : #endif

Generated by: LCOV version 1.14