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 : #include "StochasticResultsAction.h" 11 : #include "ActionWarehouse.h" 12 : #include "ActionFactory.h" 13 : #include "Transfer.h" 14 : #include "SetupMeshAction.h" 15 : #include "SamplerPostprocessorTransfer.h" 16 : #include "StochasticResults.h" 17 : 18 : registerMooseAction("StochasticToolsApp", 19 : StochasticResultsAction, 20 : "declare_stochastic_results_vectors"); 21 : 22 : InputParameters 23 39276 : StochasticResultsAction::validParams() 24 : { 25 39276 : InputParameters params = Action::validParams(); 26 39276 : params.addClassDescription("Action for performing initialization of StochasticResults vectors " 27 : "based on SamplerPostprocessorTransfer."); 28 39276 : return params; 29 0 : } 30 : 31 39276 : StochasticResultsAction::StochasticResultsAction(const InputParameters & params) : Action(params) {} 32 : 33 : void 34 39128 : StochasticResultsAction::act() 35 : { 36 39128 : if (_current_task == "declare_stochastic_results_vectors") 37 : { 38 39128 : for (std::shared_ptr<Transfer> & transfer_ptr : 39 87184 : _problem->getTransfers(Transfer::DIRECTION::FROM_MULTIAPP)) 40 : { 41 8932 : auto ptr = std::dynamic_pointer_cast<SamplerPostprocessorTransfer>(transfer_ptr); 42 8932 : if (ptr != nullptr) 43 : { 44 : const auto & result_name = 45 1572 : ptr->getParam<VectorPostprocessorName>("to_vector_postprocessor"); 46 1572 : 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 1572 : auto & uo = _problem->getUserObject<UserObject>(result_name); 51 1572 : auto * results = dynamic_cast<StochasticResults *>(&uo); 52 1572 : if (!results) 53 4 : mooseError("The object prescribed by the 'to_vector_postprocessor' parameter in ", 54 4 : ptr->name(), 55 : " must be a 'StochasticResults' object."); 56 3232 : for (const auto & vpp_name : vpp_names) 57 1664 : results->initVector(vpp_name); 58 : } 59 39124 : } 60 : } 61 39124 : }