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 6519 : virtual ~VectorPostprocessor() = default; 42 : 43 : #ifdef MOOSE_KOKKOS_ENABLED 44 : /** 45 : * Special constructor used for Kokkos functor copy during parallel dispatch 46 : */ 47 : VectorPostprocessor(const VectorPostprocessor & object, const Moose::Kokkos::FunctorCopy & key); 48 : #endif 49 : 50 : /** 51 : * Returns the name of the VectorPostprocessor. 52 : */ 53 24511 : std::string PPName() const { return _vpp_name; } 54 : 55 : /** 56 : * Return whether or not this VectorPostprocessor contains complete history 57 : */ 58 27480 : bool containsCompleteHistory() const { return _contains_complete_history; } 59 : 60 : /** 61 : * Return true if the VPP is operating in distributed mode. 62 : */ 63 892 : bool isDistributed() const { return _is_distributed; } 64 : 65 : /** 66 : * Return the names of the vectors associated with this object. 67 : */ 68 : const std::set<std::string> & getVectorNames() const; 69 : 70 : protected: 71 : /** 72 : * Register a new vector to fill up. 73 : */ 74 : VectorPostprocessorValue & declareVector(const std::string & vector_name); 75 : 76 : /// The name of the VectorPostprocessor 77 : const std::string _vpp_name; 78 : 79 : /// The FEProblemBase 80 : FEProblemBase & _vpp_fe_problem; 81 : 82 : /// DISTRIBUTED or REPLICATED 83 : const MooseEnum & _parallel_type; 84 : 85 : friend class SamplerBase; 86 : 87 : private: 88 : const MooseObject & _vpp_moose_object; 89 : 90 : const THREAD_ID _vpp_tid; 91 : 92 : const bool _contains_complete_history; 93 : 94 : const bool _is_distributed; 95 : 96 : const bool _is_broadcast; 97 : 98 : std::map<std::string, VectorPostprocessorValue> _thread_local_vectors; 99 : 100 : std::set<std::string> _vector_names; 101 : }; 102 : 103 : ///////////////////////////////////////////////////////////////////////////////////////////////////// 104 : // The following items were created to maintain the various getScatter methods in the 105 : // VectorPostprocessorInterface. 106 : 107 : // Special consumer module add 108 : extern const ReporterMode REPORTER_MODE_VPP_SCATTER; 109 : 110 : /* 111 : * Special ReporterContext that performs a scatter operation if a getScatter method is called on the 112 : * VPP value. 113 : * 114 : * The source file contains an explicit instantiation. 115 : * @see VectorPostprocessorInterface 116 : */ 117 : template <typename T> 118 : class VectorPostprocessorContext : public ReporterGeneralContext<T> 119 : { 120 : public: 121 : VectorPostprocessorContext(const libMesh::ParallelObject & other, 122 : const MooseObject & producer, 123 : ReporterState<T> & state); 124 : virtual void finalize() override; 125 : virtual void copyValuesBack() override; 126 : 127 : const ScatterVectorPostprocessorValue & getScatterValue() const; 128 : const ScatterVectorPostprocessorValue & getScatterValueOld() const; 129 : 130 : private: 131 : ScatterVectorPostprocessorValue _scatter_value; 132 : ScatterVectorPostprocessorValue _scatter_value_old; 133 : };