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