www.mooseframework.org
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
VectorPostprocessor Class Reference

Base class for Postprocessors that produce a vector of values. More...

#include <VectorPostprocessor.h>

Inheritance diagram for VectorPostprocessor:
[legend]

Public Member Functions

 VectorPostprocessor (const MooseObject *moose_object)
 
virtual ~VectorPostprocessor ()=default
 
std::string PPName () const
 Returns the name of the VectorPostprocessor. More...
 
bool containsCompleteHistory () const
 Return whether or not this VectorPostprocessor contains complete history. More...
 
bool isDistributed () const
 Return true if the VPP is operating in distributed mode. More...
 
const std::set< std::string > & getVectorNames () const
 Return the names of the vectors associated with this object. More...
 
void buildOutputHideVariableList (std::set< std::string > variable_names)
 Builds hide lists for output objects NOT listed in the 'outputs' parameter. More...
 
const std::set< OutputName > & getOutputs ()
 Get the list of output objects that this class is restricted. More...
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

VectorPostprocessorValuedeclareVector (const std::string &vector_name)
 Register a new vector to fill up. More...
 

Protected Attributes

const std::string _vpp_name
 The name of the VectorPostprocessor. More...
 
FEProblemBase_vpp_fe_problem
 The FEProblemBase. More...
 
const MooseEnum_parallel_type
 DISTRIBUTED or REPLICATED. More...
 

Private Attributes

const MooseObject_vpp_moose_object
 
const THREAD_ID _vpp_tid
 
const bool _contains_complete_history
 
const bool _is_distributed
 
const bool _is_broadcast
 
std::map< std::string, VectorPostprocessorValue_thread_local_vectors
 
std::set< std::string > _vector_names
 

Friends

class SamplerBase
 

Detailed Description

Base class for Postprocessors that produce a vector of values.

Definition at line 33 of file VectorPostprocessor.h.

Constructor & Destructor Documentation

◆ VectorPostprocessor()

VectorPostprocessor::VectorPostprocessor ( const MooseObject moose_object)

Definition at line 51 of file VectorPostprocessor.C.

52  : OutputInterface(moose_object->parameters()),
53  _vpp_name(MooseUtils::shortName(moose_object->parameters().get<std::string>("_object_name"))),
55  *moose_object->parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
56  _parallel_type(moose_object->parameters().get<MooseEnum>("parallel_type")),
57  _vpp_moose_object(*moose_object),
58  _vpp_tid(moose_object->parameters().isParamValid("_tid")
59  ? moose_object->parameters().get<THREAD_ID>("_tid")
60  : 0),
61  _contains_complete_history(moose_object->parameters().get<bool>("contains_complete_history")),
62  _is_distributed(_parallel_type == "DISTRIBUTED"),
63  _is_broadcast(_is_distributed || !moose_object->parameters().get<bool>("_auto_broadcast"))
64 {
65 }
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const THREAD_ID _vpp_tid
const MooseEnum & _parallel_type
DISTRIBUTED or REPLICATED.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
OutputInterface(const InputParameters &parameters, bool build_list=true)
Handles &#39;outputs&#39; parameter for objects that desire control of variable outputs.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
Definition: MooseUtils.C:598
const bool _contains_complete_history
const MooseObject & _vpp_moose_object
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
FEProblemBase & _vpp_fe_problem
The FEProblemBase.
const InputParameters & parameters() const
Get the parameters of the object.
unsigned int THREAD_ID
Definition: MooseTypes.h:198
const std::string _vpp_name
The name of the VectorPostprocessor.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

◆ ~VectorPostprocessor()

virtual VectorPostprocessor::~VectorPostprocessor ( )
virtualdefault

Member Function Documentation

◆ buildOutputHideVariableList()

void OutputInterface::buildOutputHideVariableList ( std::set< std::string >  variable_names)
inherited

Builds hide lists for output objects NOT listed in the 'outputs' parameter.

Parameters
variable_namesA set of variables for which the 'outputs' parameter controls

By default this is called by the constructor and passes the block name as the list of variables. This needs to be called explicitly if the build_list flag is set to False in the constructor. The latter cases is needed by the Material object to work correctly with the automatic material output capability.

Definition at line 61 of file OutputInterface.C.

Referenced by ReporterTransferInterface::hideVariableHelper(), and OutputInterface::OutputInterface().

62 {
63  // Set of available names
64  const std::set<OutputName> & avail = _oi_output_warehouse.getOutputNames();
65 
66  // Check for 'none'; hide variables on all outputs
67  if (_oi_outputs.find("none") != _oi_outputs.end())
68  for (const auto & name : avail)
69  _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
70 
71  // Check for empty and 'all' in 'outputs' parameter; do not perform any variable restrictions in
72  // these cases
73  else if (_oi_outputs.empty() || _oi_outputs.find("all") != _oi_outputs.end())
74  return;
75 
76  // Limit the variable output to Output objects listed
77  else
78  {
79  // Create a list of outputs where the variable should be hidden
80  std::set<OutputName> hide;
81  std::set_difference(avail.begin(),
82  avail.end(),
83  _oi_outputs.begin(),
84  _oi_outputs.end(),
85  std::inserter(hide, hide.begin()));
86 
87  // If 'outputs' is specified add the object name to the list of items to hide
88  for (const auto & name : hide)
89  _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
90  }
91 }
OutputWarehouse & _oi_output_warehouse
Reference to the OutputWarehouse for populating the Output object hide lists.
std::set< OutputName > _oi_outputs
The set of Output object names listed in the &#39;outputs&#39; parameter.
const std::set< OutputName > & getOutputNames()
Get a complete set of all output object names.
void addInterfaceHideVariables(const std::string &output_name, const std::set< std::string > &variable_names)
Insert variable names for hiding via the OutoutInterface.

◆ containsCompleteHistory()

bool VectorPostprocessor::containsCompleteHistory ( ) const
inline

Return whether or not this VectorPostprocessor contains complete history.

Definition at line 50 of file VectorPostprocessor.h.

Referenced by MaterialVectorPostprocessor::initialize(), SamplerBase::initialize(), and CSV::output().

const bool _contains_complete_history

◆ declareVector()

VectorPostprocessorValue & VectorPostprocessor::declareVector ( const std::string &  vector_name)
protected

Register a new vector to fill up.

Definition at line 68 of file VectorPostprocessor.C.

Referenced by ConstantVectorPostprocessor::ConstantVectorPostprocessor(), CSVReaderVectorPostprocessor::CSVReaderVectorPostprocessor(), ExtraIDIntegralVectorPostprocessor::ExtraIDIntegralVectorPostprocessor(), HistogramVectorPostprocessor::initialSetup(), LeastSquaresFit::LeastSquaresFit(), LeastSquaresFitHistory::LeastSquaresFitHistory(), MaterialVectorPostprocessor::MaterialVectorPostprocessor(), MeshDivisionFunctorReductionVectorPostprocessor::MeshDivisionFunctorReductionVectorPostprocessor(), SamplerBase::setupVariables(), SidesetInfoVectorPostprocessor::SidesetInfoVectorPostprocessor(), SpatialAverageBase::SpatialAverageBase(), and WorkBalance::WorkBalance().

69 {
70  _vector_names.insert(vector_name);
71 
72  if (_vpp_tid)
73  return _thread_local_vectors.emplace(vector_name, VectorPostprocessorValue()).first->second;
74 
75  // _is_broadcast = true (_auto_broadcast = false) then data is produced in a replicated manner
77  if (_is_broadcast)
79  if (_is_distributed)
81 
86 }
T & declareReporterValue(const ReporterName &reporter_name, const ReporterMode &mode, const MooseObject &producer, Args &&... args)
Method for returning a writable reference to the current Reporter value.
Definition: ReporterData.h:391
const THREAD_ID _vpp_tid
const ReporterMode REPORTER_MODE_ROOT
A ReporterName that represents a VectorPostprocessor.
Definition: ReporterName.h:143
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
const MooseObject & _vpp_moose_object
const ReporterMode REPORTER_MODE_DISTRIBUTED
std::map< std::string, VectorPostprocessorValue > _thread_local_vectors
FEProblemBase & _vpp_fe_problem
The FEProblemBase.
std::vector< Real > VectorPostprocessorValue
Definition: MooseTypes.h:192
std::set< std::string > _vector_names
const ReporterMode REPORTER_MODE_REPLICATED
MooseEnumItem that automatically creates the ID and doesn&#39;t allow the ID to be assigned.
Definition: ReporterMode.h:44
const std::string _vpp_name
The name of the VectorPostprocessor.

◆ getOutputs()

const std::set< OutputName > & OutputInterface::getOutputs ( )
inherited

Get the list of output objects that this class is restricted.

Returns
A set of OutputNames

Definition at line 94 of file OutputInterface.C.

95 {
96  return _oi_outputs;
97 }
std::set< OutputName > _oi_outputs
The set of Output object names listed in the &#39;outputs&#39; parameter.

◆ getVectorNames()

const std::set< std::string > & VectorPostprocessor::getVectorNames ( ) const

Return the names of the vectors associated with this object.

Definition at line 89 of file VectorPostprocessor.C.

Referenced by HistogramVectorPostprocessor::execute(), and HistogramVectorPostprocessor::initialSetup().

90 {
91  return _vector_names;
92 }
std::set< std::string > _vector_names

◆ isDistributed()

bool VectorPostprocessor::isDistributed ( ) const
inline

Return true if the VPP is operating in distributed mode.

Definition at line 55 of file VectorPostprocessor.h.

Referenced by VectorPostprocessorInterface::isVectorPostprocessorDistributedByName(), and XMLOutput::outputVectorPostprocessors().

55 { return _is_distributed; }

◆ PPName()

std::string VectorPostprocessor::PPName ( ) const
inline

Returns the name of the VectorPostprocessor.

Definition at line 45 of file VectorPostprocessor.h.

45 { return _vpp_name; }
const std::string _vpp_name
The name of the VectorPostprocessor.

◆ validParams()

InputParameters VectorPostprocessor::validParams ( )
static

Definition at line 18 of file VectorPostprocessor.C.

Referenced by ElementVectorPostprocessor::validParams(), SideVectorPostprocessor::validParams(), InternalSideVectorPostprocessor::validParams(), InterfaceVectorPostprocessor::validParams(), NodalVectorPostprocessor::validParams(), and GeneralVectorPostprocessor::validParams().

19 {
21  params += OutputInterface::validParams();
22  params.addParam<bool>("contains_complete_history",
23  false,
24  "Set this flag to indicate that the values in all vectors declared by this "
25  "VPP represent a time history (e.g. with each invocation, new values are "
26  "added and old values are never removed). This changes the output so that "
27  "only a single file is output and updated with each invocation");
28 
29  // VPPs can set this to true if their resulting vectors are naturally replicated in parallel
30  // setting this to false will keep MOOSE from unnecessarily broadcasting those vectors
31  params.addPrivateParam<bool>("_auto_broadcast", true);
32 
33  // VPPs can operate in "distributed" mode, which disables the automatic broadcasting
34  // and results in an individual file per processor if CSV output is enabled
35  MooseEnum parallel_type("DISTRIBUTED REPLICATED", "REPLICATED");
36  params.addParam<MooseEnum>(
37  "parallel_type",
38  parallel_type,
39  "Set how the data is represented within the VectorPostprocessor (VPP); 'distributed' "
40  "indicates that data within the VPP is distributed and no auto communication is performed, "
41  "this setting will result in parallel output within the CSV output; 'replicated' indicates "
42  "that the data within the VPP is correct on processor 0, the data will automatically be "
43  "broadcast to all processors unless the '_auto_broadcast' param is set to false within the "
44  "validParams function.");
45 
46  params.addParamNamesToGroup("outputs", "Advanced");
47  params.registerBase("VectorPostprocessor");
48  return params;
49 }
static InputParameters validParams()
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
static InputParameters validParams()
Definition: UserObject.C:18

Friends And Related Function Documentation

◆ SamplerBase

friend class SamplerBase
friend

Definition at line 77 of file VectorPostprocessor.h.

Member Data Documentation

◆ _contains_complete_history

const bool VectorPostprocessor::_contains_complete_history
private

Definition at line 84 of file VectorPostprocessor.h.

Referenced by containsCompleteHistory().

◆ _is_broadcast

const bool VectorPostprocessor::_is_broadcast
private

Definition at line 88 of file VectorPostprocessor.h.

Referenced by declareVector().

◆ _is_distributed

const bool VectorPostprocessor::_is_distributed
private

Definition at line 86 of file VectorPostprocessor.h.

Referenced by declareVector(), and isDistributed().

◆ _parallel_type

const MooseEnum& VectorPostprocessor::_parallel_type
protected

DISTRIBUTED or REPLICATED.

Definition at line 75 of file VectorPostprocessor.h.

◆ _thread_local_vectors

std::map<std::string, VectorPostprocessorValue> VectorPostprocessor::_thread_local_vectors
private

Definition at line 90 of file VectorPostprocessor.h.

Referenced by declareVector().

◆ _vector_names

std::set<std::string> VectorPostprocessor::_vector_names
private

Definition at line 92 of file VectorPostprocessor.h.

Referenced by declareVector(), and getVectorNames().

◆ _vpp_fe_problem

FEProblemBase& VectorPostprocessor::_vpp_fe_problem
protected

The FEProblemBase.

Definition at line 72 of file VectorPostprocessor.h.

Referenced by declareVector().

◆ _vpp_moose_object

const MooseObject& VectorPostprocessor::_vpp_moose_object
private

Definition at line 80 of file VectorPostprocessor.h.

Referenced by declareVector().

◆ _vpp_name

const std::string VectorPostprocessor::_vpp_name
protected

The name of the VectorPostprocessor.

Definition at line 69 of file VectorPostprocessor.h.

Referenced by declareVector(), and PPName().

◆ _vpp_tid

const THREAD_ID VectorPostprocessor::_vpp_tid
private

Definition at line 82 of file VectorPostprocessor.h.

Referenced by declareVector().


The documentation for this class was generated from the following files: