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 88 : NekScalarValue::validParams() 27 : { 28 88 : auto params = ScalarTransferBase::validParams(); 29 176 : params.addParam<Real>("value", 0.0, "Scalar value to pass into NekRS"); 30 176 : params.addParam<PostprocessorName>( 31 : "output_postprocessor", "Name of the postprocessor to output the value sent into NekRS"); 32 176 : params.declareControllable("value"); 33 : 34 88 : params.addClassDescription("Transfers a scalar value into NekRS"); 35 88 : params.registerBase("ScalarTransfer"); 36 88 : params.registerSystemAttributeName("ScalarTransfer"); 37 88 : return params; 38 0 : } 39 : 40 43 : NekScalarValue::NekScalarValue(const InputParameters & parameters) 41 : : ScalarTransferBase(parameters), 42 41 : _value(getParam<Real>("value")), 43 41 : _postprocessor(isParamValid("output_postprocessor") 44 107 : ? &getParam<PostprocessorName>("output_postprocessor") 45 43 : : nullptr) 46 : { 47 41 : } 48 : 49 : void 50 642 : NekScalarValue::sendDataToNek() 51 : { 52 642 : Real value_to_set = _value * _scaling; 53 642 : _console << "Sending scalar value (" << Moose::stringify(value_to_set) << ") to NekRS..." 54 642 : << std::endl; 55 : 56 642 : nrs_t * nrs = (nrs_t *)nekrs::nrsPtr(); 57 642 : nrs->usrwrk[_usrwrk_slot * nekrs::fieldOffset() + _offset] = value_to_set; 58 : 59 642 : if (_postprocessor) 60 562 : _nek_problem.setPostprocessorValueByName(*_postprocessor, value_to_set); 61 642 : } 62 : 63 : #endif