LCOV - code coverage report
Current view: top level - src/transfers - ConservativeFieldTransfer.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: be601f Lines: 24 26 92.3 %
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_NEK_COUPLING
      20             : 
      21             : #include "ConservativeFieldTransfer.h"
      22             : #include "NekInterface.h"
      23             : 
      24             : InputParameters
      25         690 : ConservativeFieldTransfer::validParams()
      26             : {
      27         690 :   auto params = FieldTransferBase::validParams();
      28             : 
      29        2070 :   params.addRangeCheckedParam<Real>(
      30             :       "normalization_abs_tol",
      31        1380 :       1e-8,
      32             :       "normalization_abs_tol > 0",
      33             :       "Absolute tolerance for checking if conservation is maintained during transfer");
      34        2070 :   params.addRangeCheckedParam<Real>(
      35             :       "normalization_rel_tol",
      36        1380 :       1e-5,
      37             :       "normalization_rel_tol > 0",
      38             :       "Relative tolerance for checking if conservation is maintained during transfer");
      39        1380 :   params.addParam<std::string>(
      40             :       "postprocessor_to_conserve",
      41             :       "Name of the postprocessor/vectorpostprocessor containing the integral(s) used to ensure "
      42             :       "conservation; defaults to the name of the object plus '_integral'");
      43             : 
      44         690 :   params.addClassDescription("Base class for defining input parameters shared by conservative "
      45             :                              "transfers between NekRS and MOOSE");
      46         690 :   return params;
      47           0 : }
      48             : 
      49         350 : ConservativeFieldTransfer::ConservativeFieldTransfer(const InputParameters & parameters)
      50             :   : FieldTransferBase(parameters),
      51         348 :     _abs_tol(getParam<Real>("normalization_abs_tol")),
      52        1046 :     _rel_tol(getParam<Real>("normalization_rel_tol"))
      53             : {
      54         696 :   nekrs::setAbsoluteTol(getParam<Real>("normalization_abs_tol"));
      55         696 :   nekrs::setRelativeTol(getParam<Real>("normalization_rel_tol"));
      56             : 
      57         696 :   if (isParamValid("postprocessor_to_conserve"))
      58         588 :     _postprocessor_name = getParam<std::string>("postprocessor_to_conserve");
      59             :   else
      60         108 :     _postprocessor_name = name() + "_integral";
      61         348 : }
      62             : 
      63             : std::string
      64           1 : ConservativeFieldTransfer::normalizationHint() const
      65             : {
      66             :   std::string s;
      67             :   s += "There are a few reason this might happen:\n\n"
      68           2 :        "- You forgot to add a transfer from another app to write into the " +
      69           1 :        _variable + "\n\n- You forgot to add a transfer from another app to write into the " +
      70           1 :        _postprocessor_name +
      71           1 :        "postprocessor, in which case the value of the postprocessor will always be zero.\n\n" +
      72             :        "- You have a mismatch between the NekRS mesh and the MOOSE mesh. Try visualizing the "
      73           0 :        "meshes in Paraview by running your input files with the --mesh-only flag.\n\n" +
      74             :        "- Your tolerances for comparing the re-normalized value with the incoming data are too "
      75             :        "tight. If the NekRS integrated value is close enough to the MOOSE integrated value, you "
      76             :        "can try relaxing the 'normalization_abs_tol' and/or 'normalization_rel_tol' parameters";
      77           1 :   return s;
      78             : }
      79             : 
      80             : #endif

Generated by: LCOV version 1.14