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 : // MOOSE includes 13 : #include "MooseTypes.h" 14 : 15 : // Forward Declarations 16 : class FEProblemBase; 17 : class InputParameters; 18 : class MooseObject; 19 : template <typename T> 20 : class VectorPostprocessorContext; 21 : 22 : class VectorPostprocessorInterface 23 : { 24 : public: 25 : static InputParameters validParams(); 26 : 27 : /** 28 : * Constructor 29 : * 30 : * @param broadcast_by_default Set to true if the system inheriting from this interface always 31 : * needs the VPPs to be broadcast 32 : */ 33 : VectorPostprocessorInterface(const MooseObject * moose_object, bool broadcast_by_default = false); 34 : 35 : /** 36 : * This class has virtual methods, so it needs a virtual dtor. 37 : */ 38 604022 : virtual ~VectorPostprocessorInterface() = default; 39 : 40 : /** 41 : * DEPRECATED: Use the new version where you need to specify whether or 42 : * not the vector must be broadcast 43 : * 44 : * Retrieve the value of a VectorPostprocessor 45 : * @param param_name The name of the VectorPostprocessor parameter (see below) 46 : * @param vector_name The name of the particular vector you want. 47 : * @return A reference to the desired value 48 : * 49 : * The name required by this method is the name that is hard-coded into 50 : * your source code. For example, if you have a Kernel that requires 51 : * a VectorPostprocessor you may have an input file with "pp = my_pp", this function 52 : * requires the "pp" name as input (see .../moose_test/functions/VectorPostprocessorFunction.C) 53 : * 54 : * see getVectorPostprocessorValueOld getVectorPostprocessorValueByName 55 : * getVectorPostprocessorValueOldByName 56 : */ 57 : const VectorPostprocessorValue & 58 : getVectorPostprocessorValue(const std::string & param_name, 59 : const std::string & vector_name) const; 60 : 61 : /** 62 : * DEPRECATED: Use the new version where you need to specify whether or 63 : * not the vector must be broadcast 64 : * 65 : * Retrieve the value of the VectorPostprocessor 66 : * @param name VectorPostprocessor name (see below) 67 : * @param vector_name The name of the particular vector you want. 68 : * @return A reference to the desired value 69 : * 70 : * The name required by this method is the name defined in the input file. For example, 71 : * if you have a Kernel that requires a VectorPostprocessor you may have an input file with 72 : * "pp = my_pp", this method requires the "my_pp" name as input 73 : * (see .../moose_test/functions/VectorPostprocessorFunction.C) 74 : * 75 : * see getVectorPostprocessorValue getVectorPostprocessorValueOldByName 76 : * getVectorPostprocessorValueByName 77 : */ 78 : const VectorPostprocessorValue & 79 : getVectorPostprocessorValueByName(const VectorPostprocessorName & name, 80 : const std::string & vector_name) const; 81 : 82 : /** 83 : * DEPRECATED: Use the new version where you need to specify whether or 84 : * not the vector must be broadcast 85 : * 86 : * Retrieve the old value of a VectorPostprocessor 87 : * @param param_name The name of the VectorPostprocessor parameter 88 : * @param vector_name The name of the particular vector you want. 89 : * @return The value of the VectorPostprocessor 90 : * 91 : * see getVectorPostprocessorValue 92 : */ 93 : const VectorPostprocessorValue & 94 : getVectorPostprocessorValueOld(const std::string & param_name, 95 : const std::string & vector_name) const; 96 : 97 : /** 98 : * DEPRECATED: Use the new version where you need to specify whether or 99 : * not the vector must be broadcast 100 : * 101 : * Retrieve the old value of a VectorPostprocessor 102 : * @param name The name of the VectorPostprocessor 103 : * @param vector_name The name of the particular vector you want. 104 : * @return The value of the VectorPostprocessor 105 : * 106 : * If within the validParams for the object the addVectorPostprocessorParam was called this method 107 : * will retun a reference to the default value specified in the call to the 108 : * addVectorPostprocessorParam 109 : * function if the postVectorPostprocessor does not exist. 110 : * 111 : * see getVectorPostprocessorValueByName 112 : */ 113 : const VectorPostprocessorValue & 114 : getVectorPostprocessorValueOldByName(const VectorPostprocessorName & name, 115 : const std::string & vector_name) const; 116 : 117 : // doco-normal-methods-begin 118 : /** 119 : * Retrieve the value of a VectorPostprocessor 120 : * @param param_name The name of the VectorPostprocessor parameter (see below) 121 : * @param vector_name The name of the particular vector you want. 122 : * @param need_broadcast Whether or not this object requires the vector to 123 : * be replicated in parallel 124 : * @return A reference to the desired value 125 : * 126 : * The name required by this method is the name that is hard-coded into 127 : * your source code. For example, if you have a Kernel that requires 128 : * a VectorPostprocessor you may have an input file with "pp = my_pp", this function 129 : * requires the "pp" name as input (see .../moose_test/functions/VectorPostprocessorFunction.C) 130 : * 131 : * see getVectorPostprocessorValueOld getVectorPostprocessorValueByName 132 : * getVectorPostprocessorValueOldByName 133 : */ 134 : const VectorPostprocessorValue & getVectorPostprocessorValue(const std::string & param_name, 135 : const std::string & vector_name, 136 : bool needs_broadcast) const; 137 : // doco-normal-methods-end 138 : 139 : /** 140 : * Retrieve the value of the VectorPostprocessor 141 : * @param name VectorPostprocessor name (see below) 142 : * @param vector_name The name of the particular vector you want. 143 : * @param need_broadcast Whether or not this object requires the vector to 144 : * be replicated in parallel 145 : * @return A reference to the desired value 146 : * 147 : * The name required by this method is the name defined in the input file. For example, 148 : * if you have a Kernel that requires a VectorPostprocessor you may have an input file with 149 : * "pp = my_pp", this method requires the "my_pp" name as input 150 : * (see .../moose_test/functions/VectorPostprocessorFunction.C) 151 : * 152 : * see getVectorPostprocessorValue getVectorPostprocessorValueOldByName 153 : * getVectorPostprocessorValueByName 154 : */ 155 : const VectorPostprocessorValue & 156 : getVectorPostprocessorValueByName(const VectorPostprocessorName & name, 157 : const std::string & vector_name, 158 : bool needs_broadcast) const; 159 : 160 : /** 161 : * Retrieve the old value of a VectorPostprocessor 162 : * @param param_name The name of the VectorPostprocessor parameter 163 : * @param vector_name The name of the particular vector you want. 164 : * @param need_broadcast Whether or not this object requires the vector to 165 : * be replicated in parallel 166 : * @return The value of the VectorPostprocessor 167 : * 168 : * see getVectorPostprocessorValue 169 : */ 170 : const VectorPostprocessorValue & getVectorPostprocessorValueOld(const std::string & param_name, 171 : const std::string & vector_name, 172 : bool needs_broadcast) const; 173 : 174 : /** 175 : * Retrieve the old value of a VectorPostprocessor 176 : * @param name The name of the VectorPostprocessor 177 : * @param vector_name The name of the particular vector you want. 178 : * @param need_broadcast Whether or not this object requires the vector to 179 : * be replicated in parallel 180 : * @return The value of the VectorPostprocessor 181 : * 182 : * If within the validParams for the object the addVectorPostprocessorParam was called this method 183 : * will retun a reference to the default value specified in the call to the 184 : * addVectorPostprocessorParam 185 : * function if the postVectorPostprocessor does not exist. 186 : * 187 : * see getVectorPostprocessorValueByName 188 : */ 189 : const VectorPostprocessorValue & 190 : getVectorPostprocessorValueOldByName(const VectorPostprocessorName & name, 191 : const std::string & vector_name, 192 : bool needs_broadcast) const; 193 : 194 : /** 195 : * Return the scatter value for the post processor 196 : * 197 : * This is only valid when you expec the vector to be of lenghth "num_procs" 198 : * In that case - this will return a reference to a value that will be _this_ processor's value 199 : * from that vector 200 : * 201 : * @param param_name The name of the parameter holding the vpp name 202 : * @param vector_name The name of the vector 203 : * @return The reference to the current scatter value 204 : */ 205 : const ScatterVectorPostprocessorValue & 206 : getScatterVectorPostprocessorValue(const std::string & param_name, 207 : const std::string & vector_name) const; 208 : 209 : /** 210 : * Return the scatter value for the post processor 211 : * 212 : * This is only valid when you expec the vector to be of lenghth "num_procs" 213 : * In that case - this will return a reference to a value that will be _this_ processor's value 214 : * from that vector 215 : * 216 : * @param name The name of the VectorPostprocessor 217 : * @param vector_name The name of the vector 218 : * @return The reference to the current scatter value 219 : */ 220 : const ScatterVectorPostprocessorValue & 221 : getScatterVectorPostprocessorValueByName(const VectorPostprocessorName & name, 222 : const std::string & vector_name) const; 223 : 224 : /** 225 : * Return the old scatter value for the post processor 226 : * 227 : * This is only valid when you expec the vector to be of lenghth "num_procs" 228 : * In that case - this will return a reference to a value that will be _this_ processor's 229 : * value from that vector 230 : * 231 : * @param param_name The name of the parameter holding the vpp name 232 : * @param vector_name The name of the vector 233 : * @return The reference to the old scatter value 234 : */ 235 : const ScatterVectorPostprocessorValue & 236 : getScatterVectorPostprocessorValueOld(const std::string & param_name, 237 : const std::string & vector_name) const; 238 : 239 : /** 240 : * Return the old scatter value for the post processor 241 : * 242 : * This is only valid when you expect the vector to be of length "num_procs" 243 : * In that case - this will return a reference to a value that will be _this_ processor's 244 : * value from that vector 245 : * 246 : * @param name The name of the VectorPostprocessor 247 : * @param vector_name The name of the vector 248 : * @return The reference to the old scatter value 249 : */ 250 : const ScatterVectorPostprocessorValue & 251 : getScatterVectorPostprocessorValueOldByName(const VectorPostprocessorName & name, 252 : const std::string & vector_name) const; 253 : 254 : /** 255 : * Determine if the VectorPostprocessor data exists by parameter 256 : * @param param_name The name of the VectorPostprocessor parameter 257 : * @param vector_name The vector name within the VectorPostprocessor 258 : * @return True if the VectorPostprocessor data exists 259 : * 260 : * @see hasVectorPostprocessorByName getVectorPostprocessorValue 261 : */ 262 : bool hasVectorPostprocessor(const std::string & param_name, 263 : const std::string & vector_name) const; 264 : 265 : /** 266 : * Determine if the VectorPostprocessor data exists by name 267 : * @param name The name of the VectorPostprocessor 268 : * @param vector_name The vector name within the VectorPostprocessor 269 : * @return True if the VectorPostprocessor data exists 270 : * 271 : * @see hasVectorPostprocessor getVectorPostprocessorValueByName 272 : */ 273 : bool hasVectorPostprocessorByName(const VectorPostprocessorName & name, 274 : const std::string & vector_name) const; 275 : 276 : /** 277 : * Determine if the VectorPostprocessor exists by parameter 278 : * @param name The name of the VectorPostprocessor parameter 279 : * @return True if the VectorPostprocessor exists 280 : */ 281 : bool hasVectorPostprocessor(const std::string & param_name) const; 282 : 283 : /** 284 : * Determine if the VectorPostprocessor exists by name 285 : * @param name The name of the VectorPostprocessor 286 : * @return True if the VectorPostprocessor exists 287 : */ 288 : bool hasVectorPostprocessorByName(const VectorPostprocessorName & name) const; 289 : 290 : ///@{ 291 : /** 292 : * Return true if the VectorPostprocessor is marked with parallel_type as DISTRIBUTED 293 : */ 294 : bool isVectorPostprocessorDistributed(const std::string & param_name) const; 295 : bool isVectorPostprocessorDistributedByName(const VectorPostprocessorName & name) const; 296 : ///@} 297 : 298 : /** 299 : * Get the name of a VectorPostprocessor associated with a parameter. 300 : * @param param_name The name of the VectorPostprocessor parameter 301 : * @return The name of the given VectorPostprocessor 302 : */ 303 : const VectorPostprocessorName & getVectorPostprocessorName(const std::string & param_name) const; 304 : 305 : protected: 306 : /** 307 : * Helper for deriving classes to override to add dependencies when a VectorPostprocessor is 308 : * requested. 309 : */ 310 : virtual void 311 142 : addVectorPostprocessorDependencyHelper(const VectorPostprocessorName & /* name */) const 312 : { 313 142 : } 314 : 315 : private: 316 : /** 317 : * Helper function for extracting VPP data from ReporterData object 318 : */ 319 : const VectorPostprocessorValue & 320 : getVectorPostprocessorByNameHelper(const VectorPostprocessorName & name, 321 : const std::string & vector_name, 322 : bool broadcast, 323 : std::size_t t_index) const; 324 : 325 : /** 326 : * Helper for getting the VPP context that handles scatter values 327 : */ 328 : const VectorPostprocessorContext<VectorPostprocessorValue> & 329 : getVectorPostprocessorContextByNameHelper(const VectorPostprocessorName & name, 330 : const std::string & vector_name) const; 331 : 332 : ///@{ 333 : /** 334 : * Helpers for "possibly" checking if a vpp exists. This is only able to check for 335 : * existance after all vpps have been added (after the task creating them has 336 : * been called). If called before said task, this will do nothing, hence the 337 : * "possibly". This allows us to have errors reported directly by the object 338 : * requesting the vpp instead of through a system with less context. 339 : */ 340 : void possiblyCheckHasVectorPostprocessor(const std::string & param_name, 341 : const std::string & vector_name) const; 342 : void possiblyCheckHasVectorPostprocessorByName(const VectorPostprocessorName & name, 343 : const std::string & vector_name) const; 344 : ///@} 345 : 346 : /** 347 : * @returns True if all vpps have been added (the task associated with adding them is complete) 348 : */ 349 : bool vectorPostprocessorsAdded() const; 350 : 351 : /// Whether or not to force broadcasting by default 352 : const bool _broadcast_by_default; 353 : 354 : /// The MooseObject that uses this interface 355 : const MooseObject & _vpi_moose_object; 356 : 357 : /// Reference the FEProblemBase class 358 : const FEProblemBase & _vpi_feproblem; 359 : 360 : /// Thread ID 361 : const THREAD_ID _vpi_tid; 362 : };