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