https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
18registerMooseAction("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
33void
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}
registerMooseAction("StochasticToolsApp", StochasticResultsAction, "declare_stochastic_results_vectors")
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
const std::string & _current_task
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
This action is a crutch that gets around a construction and initialSetup execution order of operation...
virtual void act() override
StochasticResultsAction(const InputParameters &params)
static InputParameters validParams()
A tool for output Sampler data.