https://mooseframework.inl.gov
Loading...
Searching...
No Matches
StochasticResults.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
10// Stocastic Tools Includes
11#include "StochasticResults.h"
12
13// MOOSE includes
14#include "Sampler.h"
16
18
19StochasticResultsData::StochasticResultsData(const VectorPostprocessorName & name,
21 : name(name), vector(vpp)
22{
23}
24
27{
30 "Storage container for stochastic simulation results coming from a Postprocessor.");
31
32 params.addDeprecatedParam<std::vector<SamplerName>>(
33 "samplers",
34 "A list of sampler names of associated data.",
35 "This parameter is no longer needed, please remove it from your input file.");
36
37 // If 'parallel_type = REPLICATED' broadcast the vector automatically
38 params.set<bool>("_auto_broadcast") = true;
39 return params;
40}
41
46
47void
49{
50 // Clear any existing data, unless the complete history is desired
52 for (auto & data : _sample_vectors)
53 data.vector->clear();
54}
55
56void
58{
59 if (!isDistributed())
60 {
61 for (auto & data : _sample_vectors)
62 _communicator.gather(0, data.current);
63 }
64
65 for (auto & data : _sample_vectors)
66 {
67 data.vector->insert(data.vector->end(), data.current.begin(), data.current.end());
68 data.current.clear();
69 }
70}
71
72void
74 const std::string & vector_name, const VectorPostprocessorValue && current)
75{
76 auto data_ptr = std::find_if(_sample_vectors.begin(),
77 _sample_vectors.end(),
78 [&vector_name](StochasticResultsData & data)
79 { return data.name == vector_name; });
80
81 mooseAssert(data_ptr != _sample_vectors.end(),
82 "Unable to locate a vector with the supplied name of '" << vector_name << "'.");
83 data_ptr->current = current;
84}
85
86void
87StochasticResults::initVector(const std::string & vector_name)
88{
89 _sample_vectors.emplace_back(vector_name, &declareVector(vector_name));
90}
std::vector< Real > VectorPostprocessorValue
const std::string name
Definition Setup.h:21
registerMooseObject("StochasticToolsApp", StochasticResults)
static InputParameters validParams()
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
A tool for output Sampler data.
virtual void finalize() override
std::vector< StochasticResultsData > _sample_vectors
Storage for declared vectors.
void setCurrentLocalVectorPostprocessorValue(const std::string &vector_name, const VectorPostprocessorValue &&current)
static InputParameters validParams()
void initVector(const std::string &vector_name)
Create a VPP vector for results data for a given Sampler, see StochasticResultsAction for more detail...
StochasticResults(const InputParameters &parameters)
virtual void initialize() override
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
bool containsCompleteHistory() const
VectorPostprocessorValue & declareVector(const std::string &vector_name)
const Parallel::Communicator & _communicator
Storage helper for managing data being assigned to this VPP by a Transfer object.
StochasticResultsData(const VectorPostprocessorName &name, VectorPostprocessorValue *)