LCOV - code coverage report
Current view: top level - src/postprocessors - Postprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 1f9d31 Lines: 39 67 58.2 %
Date: 2025-09-02 20:01:20 Functions: 11 22 50.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             : #include "Postprocessor.h"
      11             : #include "UserObject.h"
      12             : #include "ReporterName.h"
      13             : #include "ReporterContext.h"
      14             : #include "FEProblemBase.h"
      15             : 
      16             : InputParameters
      17     2628670 : Postprocessor::validParams()
      18             : {
      19     2628670 :   InputParameters params = UserObject::validParams();
      20     2628670 :   params += OutputInterface::validParams();
      21     2628670 :   params += NonADFunctorInterface::validParams();
      22             : 
      23    10514680 :   params.addParamNamesToGroup("outputs", "Advanced");
      24     2628670 :   params.registerBase("Postprocessor");
      25     2628670 :   return params;
      26           0 : }
      27             : 
      28       57552 : Postprocessor::Postprocessor(const MooseObject * moose_object)
      29             :   : OutputInterface(moose_object->parameters()),
      30             :     NonADFunctorInterface(moose_object),
      31             :     Moose::FunctorBase<Real>(moose_object->name()),
      32      115104 :     _pp_name(moose_object->name()),
      33       57552 :     _current_value(declareValue(*moose_object)),
      34      230208 :     _pp_moose_object(*moose_object)
      35             : {
      36      115104 : }
      37             : 
      38             : const PostprocessorValue &
      39       57552 : Postprocessor::declareValue(const MooseObject & moose_object)
      40             : {
      41             :   auto & fe_problem =
      42      230208 :       *moose_object.parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base");
      43             : 
      44       57552 :   const PostprocessorReporterName r_name(_pp_name);
      45             : 
      46       57552 :   const bool is_thread_0 = moose_object.parameters().get<THREAD_ID>("_tid") == 0;
      47             :   mooseAssert(is_thread_0 ==
      48             :                   !fe_problem.getReporterData().hasReporterValue<PostprocessorValue>(r_name),
      49             :               "Postprocessor Reporter threaded value declaration mismatch");
      50             : 
      51             :   // Declare the Reporter value on thread 0 only; this lets us add error checking to
      52             :   // make sure that it really is added only once
      53       57552 :   if (is_thread_0)
      54      110182 :     fe_problem.getReporterData(ReporterData::WriteKey())
      55       55091 :         .declareReporterValue<PostprocessorValue, ReporterGeneralContext<PostprocessorValue>>(
      56             :             r_name, REPORTER_MODE_UNSET, moose_object);
      57             : 
      58             :   // At this point, thread 0 should have declared the value and getting it should be valid
      59      115104 :   return fe_problem.getReporterData().getReporterValue<PostprocessorValue>(r_name);
      60       57552 : }
      61             : 
      62             : typename Postprocessor::ValueType
      63         799 : Postprocessor::evaluate(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
      64             : {
      65         799 :   return getCurrentValue();
      66             : }
      67             : 
      68             : typename Postprocessor::ValueType
      69        3674 : Postprocessor::evaluate(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
      70             : {
      71        3674 :   return getCurrentValue();
      72             : }
      73             : 
      74             : typename Postprocessor::ValueType
      75        4374 : Postprocessor::evaluate(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
      76             : {
      77        4374 :   return getCurrentValue();
      78             : }
      79             : 
      80             : typename Postprocessor::ValueType
      81           0 : Postprocessor::evaluate(const ElemSideQpArg & /*elem_side_qp*/,
      82             :                         const Moose::StateArg & /*state*/) const
      83             : {
      84           0 :   return getCurrentValue();
      85             : }
      86             : 
      87             : typename Postprocessor::ValueType
      88           0 : Postprocessor::evaluate(const ElemPointArg & /*elem_point_arg*/,
      89             :                         const Moose::StateArg & /*state*/) const
      90             : {
      91           0 :   return getCurrentValue();
      92             : }
      93             : 
      94             : typename Postprocessor::ValueType
      95          36 : Postprocessor::evaluate(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
      96             : {
      97          36 :   return getCurrentValue();
      98             : }
      99             : 
     100             : typename Postprocessor::GradientType
     101           0 : Postprocessor::evaluateGradient(const ElemArg & /*elem_arg*/,
     102             :                                 const Moose::StateArg & /*state*/) const
     103             : {
     104           0 :   return 0;
     105             : }
     106             : 
     107             : typename Postprocessor::GradientType
     108           0 : Postprocessor::evaluateGradient(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
     109             : {
     110           0 :   return 0;
     111             : }
     112             : 
     113             : typename Postprocessor::GradientType
     114          42 : Postprocessor::evaluateGradient(const ElemQpArg & /*elem_qp*/,
     115             :                                 const Moose::StateArg & /*state*/) const
     116             : {
     117          42 :   return 0;
     118             : }
     119             : 
     120             : typename Postprocessor::GradientType
     121           0 : Postprocessor::evaluateGradient(const ElemSideQpArg & /*elem_side_qp*/,
     122             :                                 const Moose::StateArg & /*state*/) const
     123             : {
     124           0 :   return 0;
     125             : }
     126             : 
     127             : typename Postprocessor::GradientType
     128           0 : Postprocessor::evaluateGradient(const ElemPointArg & /*elem_point_arg*/,
     129             :                                 const Moose::StateArg & /*state*/) const
     130             : {
     131           0 :   return 0;
     132             : }
     133             : 
     134             : typename Postprocessor::GradientType
     135          18 : Postprocessor::evaluateGradient(const NodeArg & /*node_arg*/,
     136             :                                 const Moose::StateArg & /*state*/) const
     137             : {
     138          18 :   return 0;
     139             : }
     140             : 
     141             : typename Postprocessor::DotType
     142           0 : Postprocessor::evaluateDot(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
     143             : {
     144           0 :   evaluateDotWarning();
     145           0 :   return 0;
     146             : }
     147             : 
     148             : typename Postprocessor::DotType
     149           0 : Postprocessor::evaluateDot(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
     150             : {
     151           0 :   evaluateDotWarning();
     152           0 :   return 0;
     153             : }
     154             : 
     155             : typename Postprocessor::DotType
     156          35 : Postprocessor::evaluateDot(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
     157             : {
     158          35 :   evaluateDotWarning();
     159          35 :   return 0;
     160             : }
     161             : 
     162             : typename Postprocessor::DotType
     163           0 : Postprocessor::evaluateDot(const ElemSideQpArg & /*elem_side_qp*/,
     164             :                            const Moose::StateArg & /*state*/) const
     165             : {
     166           0 :   evaluateDotWarning();
     167           0 :   return 0;
     168             : }
     169             : 
     170             : typename Postprocessor::DotType
     171           0 : Postprocessor::evaluateDot(const ElemPointArg & /*elem_point_arg*/,
     172             :                            const Moose::StateArg & /*state*/) const
     173             : {
     174           0 :   evaluateDotWarning();
     175           0 :   return 0;
     176             : }
     177             : 
     178             : typename Postprocessor::DotType
     179           0 : Postprocessor::evaluateDot(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
     180             : {
     181           0 :   evaluateDotWarning();
     182           0 :   return 0;
     183             : }
     184             : 
     185             : void
     186          35 : Postprocessor::evaluateDotWarning() const
     187             : {
     188          35 :   mooseDoOnce(_pp_moose_object.mooseWarning(
     189             :       "The time derivative functor operator was called on this post-processor.\n\nA zero value "
     190             :       "will always be returned, even if the post-processor value changes with time."));
     191          35 : }

Generated by: LCOV version 1.14