https://mooseframework.inl.gov
StochasticResultsAction.C
Go to the documentation of this file.
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 
11 #include "ActionWarehouse.h"
12 #include "ActionFactory.h"
13 #include "Transfer.h"
14 #include "SetupMeshAction.h"
16 #include "StochasticResults.h"
17 
18 registerMooseAction("StochasticToolsApp",
20  "declare_stochastic_results_vectors");
21 
24 {
26  params.addClassDescription("Action for performing initialization of StochasticResults vectors "
27  "based on SamplerPostprocessorTransfer.");
28  return params;
29 }
30 
32 
33 void
35 {
36  if (_current_task == "declare_stochastic_results_vectors")
37  {
38  for (std::shared_ptr<Transfer> & transfer_ptr :
39  _problem->getTransfers(Transfer::DIRECTION::FROM_MULTIAPP))
40  {
41  auto ptr = std::dynamic_pointer_cast<SamplerPostprocessorTransfer>(transfer_ptr);
42  if (ptr != nullptr)
43  {
44  const auto & result_name =
45  ptr->getParam<VectorPostprocessorName>("to_vector_postprocessor");
46  const std::vector<VectorPostprocessorName> & vpp_names = ptr->vectorNames();
47 
48  // Get the StochasticResults storage object, get it by base class to allow for better
49  // type check error message
50  auto & uo = _problem->getUserObject<UserObject>(result_name);
51  auto * results = dynamic_cast<StochasticResults *>(&uo);
52  if (!results)
53  mooseError("The object prescribed by the 'to_vector_postprocessor' parameter in ",
54  ptr->name(),
55  " must be a 'StochasticResults' object.");
56  for (const auto & vpp_name : vpp_names)
57  results->initVector(vpp_name);
58  }
59  }
60  }
61 }
Transfer Postprocessor from sub-applications to a VectorPostprocessor on the master application...
virtual void act() override
static InputParameters validParams()
static InputParameters validParams()
A tool for output Sampler data.
registerMooseAction("StochasticToolsApp", StochasticResultsAction, "declare_stochastic_results_vectors")
const T & getParam(const std::string &name) const
const std::string & _current_task
StochasticResultsAction(const InputParameters &params)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
This action is a crutch that gets around a construction and initialSetup execution order of operation...