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 42798 : StochasticResultsAction::validParams() 24 : { 25 42798 : InputParameters params = Action::validParams(); 26 42798 : params.addClassDescription("Action for performing initialization of StochasticResults vectors " 27 : "based on SamplerPostprocessorTransfer."); 28 42798 : return params; 29 0 : } 30 : 31 42798 : StochasticResultsAction::StochasticResultsAction(const InputParameters & params) : Action(params) {} 32 : 33 : void 34 42650 : StochasticResultsAction::act() 35 : { 36 42650 : if (_current_task == "declare_stochastic_results_vectors") 37 : { 38 42650 : for (std::shared_ptr<Transfer> & transfer_ptr : 39 94991 : _problem->getTransfers(Transfer::DIRECTION::FROM_MULTIAPP)) 40 : { 41 9695 : auto ptr = std::dynamic_pointer_cast<SamplerPostprocessorTransfer>(transfer_ptr); 42 9695 : if (ptr != nullptr) 43 : { 44 : const auto & result_name = 45 1695 : ptr->getParam<VectorPostprocessorName>("to_vector_postprocessor"); 46 1695 : 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 1695 : auto & uo = _problem->getUserObject<UserObject>(result_name); 51 1695 : auto * results = dynamic_cast<StochasticResults *>(&uo); 52 1695 : if (!results) 53 4 : mooseError("The object prescribed by the 'to_vector_postprocessor' parameter in ", 54 : ptr->name(), 55 : " must be a 'StochasticResults' object."); 56 3484 : for (const auto & vpp_name : vpp_names) 57 1793 : results->initVector(vpp_name); 58 : } 59 42646 : } 60 : } 61 42646 : }