www.mooseframework.org
VectorPostprocessor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 // MOOSE includes
11 #include "VectorPostprocessor.h"
12 #include "SubProblem.h"
13 #include "Conversion.h"
14 #include "UserObject.h"
16 #include "FEProblem.h"
17 
18 template <>
21 {
23  params += validParams<OutputInterface>();
24  params.addParam<bool>("contains_complete_history",
25  false,
26  "Set this flag to indicate that the values in all vectors declared by this "
27  "VPP represent a time history (e.g. with each invocation, new values are "
28  "added and old values are never removed). This changes the output so that "
29  "only a single file is output and updated with each invocation");
30 
31  // VPPs can set this to true if their resulting vectors are naturally replicated in parallel
32  // setting this to true will keep MOOSE from unnecesarily broadcasting those vectors
33  params.addPrivateParam<bool>("_is_broadcast", false);
34 
35  params.addParamNamesToGroup("outputs", "Advanced");
36  params.registerBase("VectorPostprocessor");
37  return params;
38 }
39 
41  : OutputInterface(parameters),
42  _vpp_name(MooseUtils::shortName(parameters.get<std::string>("_object_name"))),
43  _vpp_fe_problem(parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
44  _vpp_tid(parameters.isParamValid("_tid") ? parameters.get<THREAD_ID>("_tid") : 0),
45  _contains_complete_history(parameters.get<bool>("contains_complete_history")),
46  _is_broadcast(parameters.get<bool>("_is_broadcast"))
47 {
48 }
49 
51 VectorPostprocessor::getVector(const std::string & vector_name)
52 {
54 }
55 
57 VectorPostprocessor::declareVector(const std::string & vector_name)
58 {
59  if (_vpp_tid)
60  return _thread_local_vectors.emplace(vector_name, VectorPostprocessorValue()).first->second;
61  else
64 }
FEProblemBase * _vpp_fe_problem
Pointer to FEProblemBase.
std::string _vpp_name
The name of the VectorPostprocessor.
InputParameters validParams< OutputInterface >()
A class to provide an common interface to objects requiring "outputs" option.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual VectorPostprocessorValue & getVector(const std::string &vector_name)
This will get called to actually grab the final value the VectorPostprocessor has calculated...
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
Definition: MooseUtils.C:363
const bool _contains_complete_history
InputParameters validParams< UserObject >()
Definition: UserObject.C:18
InputParameters validParams< VectorPostprocessor >()
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
VectorPostprocessor(const InputParameters &parameters)
std::map< std::string, VectorPostprocessorValue > _thread_local_vectors
std::vector< Real > VectorPostprocessorValue
Definition: MooseTypes.h:155
VectorPostprocessorValue & getVectorPostprocessorValue(const VectorPostprocessorName &name, const std::string &vector_name)
DEPRECATED: Use the new version where you need to specify whether or not the vector must be broadcast...
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...
VectorPostprocessorValue & declareVectorPostprocessorVector(const VectorPostprocessorName &name, const std::string &vector_name, bool contains_complete_history, bool is_broadcast)
Declare a new VectorPostprocessor vector.
unsigned int THREAD_ID
Definition: MooseTypes.h:161