LCOV - code coverage report
Current view: top level - src/postprocessors - NekVolumeNorm.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: 9f356e Lines: 23 26 88.5 %
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 "NekVolumeNorm.h"
      22             : #include "NekInterface.h"
      23             : 
      24             : #include <algorithm>
      25             : #include <cctype>
      26             : #include <cmath>
      27             : #include <limits>
      28             : #include <string>
      29             : 
      30             : registerMooseObject("CardinalApp", NekVolumeNorm);
      31             : 
      32             : InputParameters
      33          72 : NekVolumeNorm::validParams()
      34             : {
      35          72 :   InputParameters params = NekFieldPostprocessor::validParams();
      36         144 :   params.addParam<std::string>("N",
      37             :                                "2",
      38             :                                "Order of the volume norm. Specify a finite real value N >= 1, "
      39             :                                "or use 'infinity' for the L-infinity norm.");
      40             : 
      41          72 :   params.addClassDescription("Computes a finite L^N norm or an L-infinity norm of the difference "
      42             :                              "between a NekRS solution field and an optional analytical function.");
      43             : 
      44          72 :   return params;
      45           0 : }
      46             : 
      47          19 : NekVolumeNorm::NekVolumeNorm(const InputParameters & parameters) : NekFieldPostprocessor(parameters)
      48             : {
      49          19 :   if (_nek_problem->nondimensional())
      50           0 :     mooseError("The NekVolumeNorm object does not yet support non-dimensional runs! "
      51             :                "Please contact the development team to accelerate this feature "
      52             :                "addition to support your use case.");
      53             : 
      54          57 :   auto value = getParam<std::string>("N");
      55             : 
      56          19 :   std::transform(
      57          81 :       value.begin(), value.end(), value.begin(), [](unsigned char c) { return std::tolower(c); });
      58             : 
      59          19 :   if (value == "infinity")
      60           8 :     _N = std::numeric_limits<Real>::infinity();
      61             : 
      62          19 :   std::size_t parsed_characters = 0;
      63             : 
      64             :   try
      65             :   {
      66          18 :     _N = std::stod(value, &parsed_characters);
      67             :   }
      68           1 :   catch (const std::exception &)
      69             :   {
      70           1 :     paramError("N", "Specify a finite real value N >= 1, or use 'infinity'.");
      71           0 :   }
      72             : 
      73          18 :   if (parsed_characters != value.size())
      74           1 :     paramError("N", "Specify a finite real value N >= 1, or use 'infinity'.");
      75             : 
      76          17 :   if (_N < 1.0)
      77           1 :     paramError("N", "Norm orders must satisfy N >= 1.");
      78          16 : }
      79             : 
      80             : Real
      81          16 : NekVolumeNorm::getValue() const
      82             : {
      83          16 :   return nekrs::volumeNorm(_field, _pp_mesh, _function, _t, _N);
      84             : }
      85             : 
      86             : #endif

Generated by: LCOV version 1.14