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 : #include "OutputInterface.h" 15 : #include "MooseEnum.h" 16 : #include "ReporterContext.h" 17 : #include "NonADFunctorInterface.h" 18 : 19 : // libMesh 20 : #include "libmesh/parallel.h" 21 : 22 : // Forward declarations 23 : class FEProblemBase; 24 : class InputParameters; 25 : class SamplerBase; 26 : class VectorPostprocessorData; 27 : 28 : template <typename T> 29 : InputParameters validParams(); 30 : 31 : /** 32 : * Base class for Postprocessors that produce a vector of values. 33 : */ 34 : class VectorPostprocessor : public OutputInterface, public NonADFunctorInterface 35 : { 36 : public: 37 : static InputParameters validParams(); 38 : 39 : VectorPostprocessor(const MooseObject * moose_object); 40 : 41 5589 : virtual ~VectorPostprocessor() = default; 42 : 43 : /** 44 : * Returns the name of the VectorPostprocessor. 45 : */ 46 22316 : std::string PPName() const { return _vpp_name; } 47 : 48 : /** 49 : * Return whether or not this VectorPostprocessor contains complete history 50 : */ 51 28071 : bool containsCompleteHistory() const { return _contains_complete_history; } 52 : 53 : /** 54 : * Return true if the VPP is operating in distributed mode. 55 : */ 56 971 : bool isDistributed() const { return _is_distributed; } 57 : 58 : /** 59 : * Return the names of the vectors associated with this object. 60 : */ 61 : const std::set<std::string> & getVectorNames() const; 62 : 63 : protected: 64 : /** 65 : * Register a new vector to fill up. 66 : */ 67 : VectorPostprocessorValue & declareVector(const std::string & vector_name); 68 : 69 : /// The name of the VectorPostprocessor 70 : const std::string _vpp_name; 71 : 72 : /// The FEProblemBase 73 : FEProblemBase & _vpp_fe_problem; 74 : 75 : /// DISTRIBUTED or REPLICATED 76 : const MooseEnum & _parallel_type; 77 : 78 : friend class SamplerBase; 79 : 80 : private: 81 : const MooseObject & _vpp_moose_object; 82 : 83 : const THREAD_ID _vpp_tid; 84 : 85 : const bool _contains_complete_history; 86 : 87 : const bool _is_distributed; 88 : 89 : const bool _is_broadcast; 90 : 91 : std::map<std::string, VectorPostprocessorValue> _thread_local_vectors; 92 : 93 : std::set<std::string> _vector_names; 94 : }; 95 : 96 : ///////////////////////////////////////////////////////////////////////////////////////////////////// 97 : // The following items were created to maintain the various getScatter methods in the 98 : // VectorPostprocessorInterface. 99 : 100 : // Special consumer module add 101 : extern const ReporterMode REPORTER_MODE_VPP_SCATTER; 102 : 103 : /* 104 : * Special ReporterContext that performs a scatter operation if a getScatter method is called on the 105 : * VPP value. 106 : * 107 : * The source file contains an explicit instantiation. 108 : * @see VectorPostprocessorInterface 109 : */ 110 : template <typename T> 111 : class VectorPostprocessorContext : public ReporterGeneralContext<T> 112 : { 113 : public: 114 : VectorPostprocessorContext(const libMesh::ParallelObject & other, 115 : const MooseObject & producer, 116 : ReporterState<T> & state); 117 : virtual void finalize() override; 118 : virtual void copyValuesBack() override; 119 : 120 : const ScatterVectorPostprocessorValue & getScatterValue() const; 121 : const ScatterVectorPostprocessorValue & getScatterValueOld() const; 122 : 123 : private: 124 : ScatterVectorPostprocessorValue _scatter_value; 125 : ScatterVectorPostprocessorValue _scatter_value_old; 126 : };