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