LCOV - code coverage report
Current view: top level - src/base - UserErrorChecking.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: be601f Lines: 25 27 92.6 %
Date: 2025-07-15 20:50:38 Functions: 5 5 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             : #include "UserErrorChecking.h"
      20             : #include "CardinalApp.h"
      21             : 
      22             : void
      23         519 : checkUnusedParam(const InputParameters & p,
      24             :                  const std::vector<std::string> & names,
      25             :                  const std::string & explanation,
      26             :                  const bool error)
      27             : {
      28        4131 :   for (const auto & n : names)
      29        3612 :     checkUnusedParam(p, n, explanation, error);
      30         519 : }
      31             : 
      32             : void
      33       30224 : checkUnusedParam(const InputParameters & p,
      34             :                  const std::string & name,
      35             :                  const std::string & explanation,
      36             :                  const bool error)
      37             : {
      38       30224 :   if (p.isParamSetByUser(name))
      39             :   {
      40         158 :     if (error)
      41           3 :       mooseError("When " + explanation + ", the '" + name + "' parameter is unused!");
      42             :     else
      43         469 :       mooseWarning("When " + explanation + ", the '" + name + "' parameter is unused!");
      44             :   }
      45       30221 : }
      46             : 
      47             : void
      48          75 : checkRequiredParam(const InputParameters & p,
      49             :                    const std::vector<std::string> & names,
      50             :                    const std::string & explanation)
      51             : {
      52         375 :   for (const auto & n : names)
      53         300 :     checkRequiredParam(p, n, explanation);
      54          75 : }
      55             : 
      56             : void
      57        4410 : checkRequiredParam(const InputParameters & p,
      58             :                    const std::string & name,
      59             :                    const std::string & explanation)
      60             : {
      61        4410 :   if (!p.isParamValid(name))
      62           6 :     mooseError("When " + explanation + ", the '" + name + "' parameter is required!");
      63        4408 : }
      64             : 
      65             : void
      66         880 : checkJointParams(const InputParameters & p,
      67             :                  const std::vector<std::string> & name,
      68             :                  const std::string & explanation)
      69             : {
      70             :   bool at_least_one_present = false;
      71             :   bool at_least_one_not_present = false;
      72         880 :   std::string name_list = "";
      73             : 
      74        2640 :   for (const auto & s : name)
      75             :   {
      76        1760 :     name_list += " '" + s + "',";
      77             : 
      78        1760 :     if (p.isParamValid(s))
      79             :       at_least_one_present = true;
      80             :     else
      81             :       at_least_one_not_present = true;
      82             :   }
      83             : 
      84         880 :   if (at_least_one_present && at_least_one_not_present)
      85             :   {
      86           0 :     name_list.pop_back();
      87           0 :     mooseError("When " + explanation + ", the" + name_list +
      88             :                " parameters\nmust either ALL "
      89             :                "be specified or ALL omitted; you have only provided a subset of parameters!");
      90             :   }
      91         880 : }

Generated by: LCOV version 1.14