LCOV - code coverage report
Current view: top level - src/transfers - NekTransferBase.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: 920dc5 Lines: 27 27 100.0 %
Date: 2025-08-10 20:41:39 Functions: 4 4 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 "NekRSProblem.h"
      22             : #include "NekRSMesh.h"
      23             : #include "NekTransferBase.h"
      24             : 
      25             : InputParameters
      26        2515 : NekTransferBase::validParams()
      27             : {
      28        2515 :   auto params = MooseObject::validParams();
      29        5030 :   MooseEnum direction("to_nek from_nek");
      30        5030 :   params.addRequiredParam<MooseEnum>("direction", direction, "Direction in which to send data");
      31        2515 :   params.addClassDescription("Base class for passing data between NekRS and MOOSE");
      32        2515 :   params.addPrivateParam<NekRSProblem *>("_nek_problem");
      33        2515 :   return params;
      34        2515 : }
      35             : 
      36        1264 : NekTransferBase::NekTransferBase(const InputParameters & parameters)
      37             :   : MooseObject(parameters),
      38             :     PostprocessorInterface(this),
      39        1264 :     _nek_problem(*getParam<NekRSProblem *>("_nek_problem")),
      40        3792 :     _direction(getParam<MooseEnum>("direction"))
      41             : {
      42             :   // we do not need to check for other mesh types because we already enforce
      43             :   // the usage of NekRSMesh by requiring the use of a NekRS problem
      44             :   // in the AddNekTransferAction
      45        1264 :   _nek_mesh = dynamic_cast<NekRSMesh *>(&(getMooseApp().feProblem().mesh()));
      46        1264 : }
      47             : 
      48             : void
      49         559 : NekTransferBase::checkAllocatedUsrwrkSlot(const unsigned int & u) const
      50             : {
      51         559 :   if (u >= _nek_problem.nUsrWrkSlots())
      52             :   {
      53           6 :     std::string s = "Cannot write into usrwrk slot " + Moose::stringify(u) + " because only " +
      54           2 :                     Moose::stringify(_nek_problem.nUsrWrkSlots()) +
      55             :                     " have been allocated with 'n_usrwrk_slots'.";
      56             : 
      57             :     // can only give the hint about max slot if any slots have been allocated, otherwise we overflow
      58             :     // into max(int)
      59           2 :     if (_nek_problem.nUsrWrkSlots() > 0)
      60           2 :       s += " Slots are zero-indexed, so the maximum acceptable value in 'usrwrk_slot' is " +
      61           4 :            Moose::stringify(_nek_problem.nUsrWrkSlots() - 1) + ".";
      62           2 :     paramError("usrwrk_slot", s + " You must increase 'n_usrwrk_slots' in the [Problem] block.");
      63             :   }
      64         557 : }
      65             : 
      66             : void
      67         324 : NekTransferBase::addExternalPostprocessor(const std::string name, const Real initial)
      68             : {
      69         324 :   auto pp_params = _factory.getValidParams("Receiver");
      70         324 :   pp_params.set<Real>("default") = initial;
      71             : 
      72             :   // we do not need to check for duplicate names, because MOOSE already handles
      73             :   // this error checking
      74         324 :   _nek_problem.addPostprocessor("Receiver", name, pp_params);
      75         324 : }
      76             : 
      77             : #endif

Generated by: LCOV version 1.14