LCOV - code coverage report
Current view: top level - src/transfers - NekVolumetricData.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: 9f356e Lines: 20 25 80.0 %
Date: 2026-08-19 15:42:22 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 "NekVolumetricData.h"
      22             : 
      23             : registerMooseObject("CardinalApp", NekVolumetricData);
      24             : 
      25             : InputParameters
      26         166 : NekVolumetricData::validParams()
      27             : {
      28         166 :   auto params = FieldTransferBase::validParams();
      29         166 :   params.addClassDescription("Reads/writes volumetric source data between NekRS and MOOSE.");
      30         166 :   return params;
      31           0 : }
      32             : 
      33          83 : NekVolumetricData::NekVolumetricData(const InputParameters & parameters)
      34          83 :   : FieldTransferBase(parameters)
      35             : {
      36          83 :   if (_usrwrk_slot.size() > 1)
      37           0 :     paramError("usrwrk_slot",
      38             :                "'usrwrk_slot' must be of length 1 for general volume transfers; you have entered "
      39           0 :                "a vector of length " +
      40           0 :                    Moose::stringify(_usrwrk_slot.size()));
      41             : 
      42          83 :   addExternalVariable(_usrwrk_slot[0], _variable, 0.0, 1.0);
      43             : 
      44          83 :   if (!_nek_mesh->volume())
      45           0 :     mooseError("The NekVolumetricData object can only be used when there is volumetric coupling "
      46             :                "of NekRS with MOOSE, i.e. when 'volume = true' in NekRSMesh.");
      47          83 : }
      48             : 
      49             : void
      50          96 : NekVolumetricData::sendDataToNek()
      51             : {
      52          96 :   _console << "Sending volumetric data to NekRS..." << std::endl;
      53             : 
      54          96 :   auto d = 1.0;
      55          96 :   auto a = 0.0;
      56       42720 :   for (unsigned int e = 0; e < _nek_mesh->numVolumeElems(); e++)
      57             :   {
      58             :     // We can only write into the nekRS scratch space if that element is "owned" by the current
      59             :     // process
      60       42624 :     if (nekrs::commRank() != _nek_mesh->volumeCoupling().processor_id(e))
      61       21312 :       continue;
      62             : 
      63       21312 :     _nek_problem.mapVolumeDataToNekVolume(e, _variable_number[_variable], d, a, &_v_elem);
      64       21312 :     _nek_problem.writeVolumeSolution(_usrwrk_slot[0] * nekrs::fieldOffset(), e, _v_elem);
      65             :   }
      66          96 : }
      67             : 
      68             : #endif

Generated by: LCOV version 1.14