https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PolynomialChaosReporter.h
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#pragma once
11
12#include "GeneralReporter.h"
14
15#include "PolynomialChaos.h"
16#include "nlohmann/json.h"
17
19{
20public:
23
24 virtual void initialize() override {}
25 virtual void execute() override;
26 virtual void finalize() override {}
27
28private:
30 static std::vector<Real> computeLocalSensitivity(const PolynomialChaos & pc,
31 const std::vector<Real> & data);
32
34 const std::vector<std::vector<Real>> & _loc_point;
36 std::vector<Sampler *> _loc_sampler;
37
39 std::vector<const PolynomialChaos *> _pc;
40
42 std::vector<std::vector<std::vector<Real>> *> _loc_point_sense;
44 std::vector<std::vector<std::vector<Real>> *> _loc_sampler_sense;
45};
46
47void to_json(nlohmann::json & json, const PolynomialChaos * const & pc);
48
54template <>
55inline void
56dataStore(std::ostream &, const PolynomialChaos *&, void *)
57{
58}
59template <>
60inline void
61dataLoad(std::istream &, const PolynomialChaos *&, void *)
62{
63}
65
72template <typename OutType>
73class PCStatisticsContext : public ReporterGeneralContext<std::pair<OutType, std::vector<OutType>>>
74{
75public:
77 const MooseObject & producer,
78 ReporterState<std::pair<OutType, std::vector<OutType>>> & state,
79 const PolynomialChaos & pc,
80 const MooseEnumItem & stat);
81
82 virtual void finalize() override;
83 virtual void storeInfo(nlohmann::json & json) const override;
84
85private:
90};
91
98template <typename OutType>
100 std::pair<std::vector<OutType>, std::vector<std::vector<OutType>>>>
101{
102public:
104 const libMesh::ParallelObject & other,
105 const MooseObject & producer,
106 ReporterState<std::pair<std::vector<OutType>, std::vector<std::vector<OutType>>>> & state,
107 const PolynomialChaos & pc);
108
109 virtual void finalize() override;
110 virtual std::string type() const override
111 {
112 return "SobolIndices<" + MooseUtils::prettyCppType<OutType>() + ">";
113 }
114
115protected:
116 virtual void store(nlohmann::json & json) const override;
117
118private:
121};
void dataStore(std::ostream &, const PolynomialChaos *&, void *)
These methods are required since PolynomialChaos * is declared as a reporter value,...
void to_json(nlohmann::json &json, const PolynomialChaos *const &pc)
void dataLoad(std::istream &, const PolynomialChaos *&, void *)
const InputParameters & parameters() const
PCSobolContext is almost identical to SobolReporterContext with InType == Outype.
virtual std::string type() const override
virtual void store(nlohmann::json &json) const override
virtual void finalize() override
const PolynomialChaos & _pc
Polynomial chaos surrogate object.
PCStatisticsContext is almost identical to ReporterStatisticsContext with InType == Outype.
const PolynomialChaos & _pc
Polynomial chaos surrogate object.
const MooseEnumItem _stat
The stat to compute.
virtual void storeInfo(nlohmann::json &json) const override
virtual void finalize() override
static std::vector< Real > computeLocalSensitivity(const PolynomialChaos &pc, const std::vector< Real > &data)
Helper function for computing local sensitivity from a polynomial chaos model.
static InputParameters validParams()
virtual void execute() override
std::vector< Sampler * > _loc_sampler
Samplers for local sensitivity calculation.
std::vector< std::vector< std::vector< Real > > * > _loc_sampler_sense
Local sensitivity from sampled points.
const std::vector< std::vector< Real > > & _loc_point
Points for local sensitivity calculation.
virtual void initialize() override
std::vector< std::vector< std::vector< Real > > * > _loc_point_sense
Local sensitivity from specified points.
std::vector< const PolynomialChaos * > _pc
Polynomial chaos models.
virtual void finalize() override
Interface for objects that need to use samplers.