LCOV - code coverage report
Current view: top level - include/interfaces - PostprocessorInterface.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 8601ad Lines: 1 1 100.0 %
Date: 2025-07-18 13:27:08 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : // Standard includes
      13             : #include <string>
      14             : 
      15             : // MOOSE includes
      16             : #include "MooseTypes.h"
      17             : 
      18             : // Forward Declarations
      19             : class FEProblemBase;
      20             : class InputParameters;
      21             : class PostprocessorName;
      22             : class MooseObject;
      23             : 
      24             : #define usingPostprocessorInterfaceMembers                                                         \
      25             :   using PostprocessorInterface::getPostprocessorValue;                                             \
      26             :   using PostprocessorInterface::getPostprocessorValueOld;                                          \
      27             :   using PostprocessorInterface::getPostprocessorValueOlder;                                        \
      28             :   using PostprocessorInterface::coupledPostprocessors
      29             : 
      30             : /**
      31             :  * Interface class for classes which interact with Postprocessors.
      32             :  * Provides the getPostprocessorValueXYZ() and related interfaces.
      33             :  */
      34             : class PostprocessorInterface
      35             : {
      36             : public:
      37             :   PostprocessorInterface(const MooseObject * moose_object);
      38             : 
      39             :   PostprocessorInterface(const FEProblemBase * problem);
      40             : 
      41             :   static InputParameters validParams();
      42             : 
      43             :   ///@{
      44             :   /**
      45             :    * doco-normal-methods-begin
      46             :    * Retrieve the value of a Postprocessor or one of it's old or older values
      47             :    * @param param_name The name of the Postprocessor parameter (see below)
      48             :    * @param index The index of the Postprocessor
      49             :    * @return A reference to the desired value
      50             :    *
      51             :    * The name required by this method is the name that is hard-coded into
      52             :    * your source code. For example, if you have a Kernel that requires
      53             :    * a Postprocessor you may have an input file with "pp = my_pp", this function
      54             :    * requires the "pp" name as input (see .../moose_test/functions/PostprocessorFunction.C)
      55             :    *
      56             :    * see getPostprocessorValueByName getPostprocessorValueOldByName getPostprocessorValueOlderByName
      57             :    */
      58             :   const PostprocessorValue & getPostprocessorValue(const std::string & param_name,
      59             :                                                    const unsigned int index = 0) const;
      60             :   const PostprocessorValue & getPostprocessorValueOld(const std::string & param_name,
      61             :                                                       const unsigned int index = 0) const;
      62             :   const PostprocessorValue & getPostprocessorValueOlder(const std::string & param_name,
      63             :                                                         const unsigned int index = 0) const;
      64             :   // doco-normal-methods-end
      65             : 
      66             :   ///@}
      67             : 
      68             :   ///@{
      69             :   /**
      70             :    * Retrieve the value of the Postprocessor
      71             :    * @param name Postprocessor name (see below)
      72             :    * @return A reference to the desired value
      73             :    *
      74             :    * The name required by this method is the name defined in the input file. For example,
      75             :    * if you have a Kernel that requires a Postprocessor you may have an input file with
      76             :    * "pp = my_pp", this method requires the "my_pp" name as input
      77             :    * (see .../moose_test/functions/PostprocessorFunction.C)
      78             :    *
      79             :    * see getPostprocessorValue getPostprocessorValueOld getPostprocessorValueOlder
      80             :    */
      81             :   virtual const PostprocessorValue &
      82             :   getPostprocessorValueByName(const PostprocessorName & name) const;
      83             :   const PostprocessorValue & getPostprocessorValueOldByName(const PostprocessorName & name) const;
      84             :   const PostprocessorValue & getPostprocessorValueOlderByName(const PostprocessorName & name) const;
      85             :   ///@}
      86             : 
      87             :   /**
      88             :    * Determine whether or not the Postprocessor is a default value. A default value is when
      89             :    * the value is either the value set by addParam, or is a user-set value in input instead of
      90             :    * a name to a postprocessor.
      91             :    * @param param_name The name of the Postprocessor parameter
      92             :    * @param index The index of the postprocessor
      93             :    * @return True if the Postprocessor is a default value, false if the Postprocessor
      94             :    * is the name of a Postprocessor
      95             :    */
      96             :   bool isDefaultPostprocessorValue(const std::string & param_name,
      97             :                                    const unsigned int index = 0) const;
      98             : 
      99             :   /**
     100             :    * Determine if the Postprocessor data exists
     101             :    * @param param_name The name of the Postprocessor parameter
     102             :    * @param index The index of the Postprocessor
     103             :    * @return True if the Postprocessor exists
     104             :    *
     105             :    * @see hasPostprocessorByName getPostprocessorValue
     106             :    */
     107             :   bool hasPostprocessor(const std::string & param_name, const unsigned int index = 0) const;
     108             : 
     109             :   /**
     110             :    * Determine if the Postprocessor data exists
     111             :    * @param name The name of the Postprocessor
     112             :    * @return True if the Postprocessor exists
     113             :    *
     114             :    * @see hasPostprocessor getPostprocessorValueByName
     115             :    */
     116             :   bool hasPostprocessorByName(const PostprocessorName & name) const;
     117             : 
     118             :   /**
     119             :    * Returns number of Postprocessors coupled under parameter name
     120             :    * @param param_name The name of the Postprocessor parameter
     121             :    * @return Number of coupled post-processors, 1 if it's a single
     122             :    *
     123             :    */
     124             :   std::size_t coupledPostprocessors(const std::string & param_name) const;
     125             : 
     126             :   /**
     127             :    * Get the name of a postprocessor. This can only be used if the postprocessor
     128             :    * parameter does _not_ have a default value set (see isDefaultPostprocessorValue()),
     129             :    * in which case the "name" is actually the default value.
     130             :    * @param param_name The name of the Postprocessor parameter
     131             :    * @param index The index of the Postprocessor
     132             :    * @return The name of the given Postprocessor
     133             :    */
     134             :   const PostprocessorName & getPostprocessorName(const std::string & param_name,
     135             :                                                  const unsigned int index = 0) const;
     136             : 
     137             : protected:
     138             :   /**
     139             :    * Helper for deriving classes to override to add dependencies when a Postprocessor is requested.
     140             :    */
     141       38923 :   virtual void addPostprocessorDependencyHelper(const PostprocessorName & /* name */) const {}
     142             : 
     143             : private:
     144             :   /// The MooseObject that uses this interface
     145             :   const MooseObject & _ppi_moose_object;
     146             : 
     147             :   /// PostprocessorInterface Parameters
     148             :   const InputParameters & _ppi_params;
     149             : 
     150             :   /// Reference the the FEProblemBase class
     151             :   const FEProblemBase & _ppi_feproblem;
     152             : 
     153             :   /// Holds the default postprocessor values that are requested (key is PostprocessorName)
     154             :   mutable std::map<PostprocessorName, std::unique_ptr<PostprocessorValue>> _default_values;
     155             : 
     156             :   /**
     157             :    * Internal method for getting the PostprocessorName associated with a paremeter.
     158             :    * Needed in order to allow the return of a name that is a default value.
     159             :    */
     160             :   const PostprocessorName &
     161             :   getPostprocessorNameInternal(const std::string & param_name,
     162             :                                const unsigned int index,
     163             :                                const bool allow_default_value = true) const;
     164             : 
     165             :   /**
     166             :    * Internal methods for getting Postprocessor values.
     167             :    */
     168             :   ///@{
     169             :   const PostprocessorValue & getPostprocessorValueInternal(const std::string & param_name,
     170             :                                                            unsigned int index,
     171             :                                                            std::size_t t_index) const;
     172             :   const PostprocessorValue & getPostprocessorValueByNameInternal(const PostprocessorName & name,
     173             :                                                                  std::size_t t_index) const;
     174             :   ///@}
     175             : 
     176             :   /**
     177             :    * @returns True if the PostprocessorName \p name repesents a default value: the name
     178             :    * converts to a value (set by addParam or set via input), and a Postprocessor does not
     179             :    * exist with the same name (we do allow Postprocessors with numbered names...)
     180             :    */
     181             :   bool isDefaultPostprocessorValueByName(const PostprocessorName & name) const;
     182             : 
     183             :   /**
     184             :    * @returns The default value stored in the PostprocessorName \p name.
     185             :    */
     186             :   PostprocessorValue getDefaultPostprocessorValueByName(const PostprocessorName & name) const;
     187             : 
     188             :   /**
     189             :    * Checks the parameters relating to a Postprocessor. If \p index is not set, index
     190             :    * checking is not performed.
     191             :    */
     192             :   void checkParam(const std::string & param_name,
     193             :                   const unsigned int index = std::numeric_limits<unsigned int>::max()) const;
     194             : 
     195             :   /**
     196             :    * @returns True if all pps have been added (the task associated with adding them is complete)
     197             :    */
     198             :   bool postprocessorsAdded() const;
     199             : };

Generated by: LCOV version 1.14