https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
PCSobolContext< OutType > Class Template Reference

PCSobolContext is almost identical to SobolReporterContext with InType == Outype. More...

#include <PolynomialChaosReporter.h>

Inheritance diagram for PCSobolContext< OutType >:
[legend]

Public Types

enum  AutoOperation
 

Public Member Functions

 PCSobolContext (const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< std::pair< std::vector< OutType >, std::vector< std::vector< OutType > > > > &state, const PolynomialChaos &pc)
 
virtual void finalize () override
 
virtual std::string type () const override
 
virtual void declareClone (ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const override
 
virtual void declareVectorClone (ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const override
 
virtual void resize (dof_id_type local_size) final
 
virtual void clear () final
 
virtual void vectorSum () final
 
virtual std::string contextType () const override
 
const ReporterNamename () const override final
 
const ReporterState< T > & state () const
 
virtual void transfer (ReporterData &r_data, const ReporterName &r_name, unsigned int time_index=0) const override
 
virtual void transferToVector (ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const override
 
virtual void transferFromVector (ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const override
 
void init (const ReporterMode &mode)
 
const MooseObjectgetProducer () const
 
const ReporterProducerEnumgetProducerModeEnum () const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

virtual void store (nlohmann::json &json) const override
 
void broadcast ()
 
virtual void storeInfo (nlohmann::json &json) const override
 
virtual void copyValuesBack () override
 
virtual bool restoreState () override
 
void requiresConsumerModes (const ReporterStateBase &state, const std::set< ReporterMode > &modes) const
 

Protected Attributes

ReporterState< T > & _state
 
const MooseObject_producer
 
ReporterProducerEnum _producer_enum
 
const Parallel::Communicator & _communicator
 

Private Attributes

const PolynomialChaos_pc
 Polynomial chaos surrogate object.
 

Detailed Description

template<typename OutType>
class PCSobolContext< OutType >

PCSobolContext is almost identical to SobolReporterContext with InType == Outype.

Unfortunately, we cannot derive from SobolReporterContext since that class relies on the construction of a Calculator object, something that is unnecessary for calculating statistics with polynomial chaos.

Definition at line 82 of file PolynomialChaosReporter.h.

Constructor & Destructor Documentation

◆ PCSobolContext()

template<typename OutType >
PCSobolContext< OutType >::PCSobolContext ( const libMesh::ParallelObject other,
const MooseObject producer,
ReporterState< std::pair< std::vector< OutType >, std::vector< std::vector< OutType > > > > &  state,
const PolynomialChaos pc 
)

Definition at line 205 of file PolynomialChaosReporter.C.

210 : ReporterGeneralContext<std::pair<std::vector<OutType>, std::vector<std::vector<OutType>>>>(
211 other, producer, state),
212 _pc(pc)
213{
214}
const PolynomialChaos & _pc
Polynomial chaos surrogate object.

Member Function Documentation

◆ finalize()

template<typename OutType >
void PCSobolContext< OutType >::finalize ( )
overridevirtual

Reimplemented from ReporterGeneralContext< std::pair< std::vector< OutType >, std::vector< std::vector< OutType > > > >.

Definition at line 218 of file PolynomialChaosReporter.C.

219{
220 const unsigned int nparam = _pc.getNumberOfParameters();
221 std::vector<OutType> & val = this->_state.value().first;
222 val.clear();
223
224 // Compute variance
225 auto var = _pc.computeStandardDeviation();
226 var *= var;
227
228 // First order
229 for (const auto & i : make_range(nparam))
230 val.push_back(_pc.computeSobolIndex({i}) / var);
231 // Total
232 for (const auto & i : make_range(nparam))
233 val.push_back(_pc.computeSobolTotal(i) / var);
234 // Second order
235 for (const auto & i : make_range(nparam))
236 for (const auto & j : make_range(i + 1, nparam))
237 val.push_back(_pc.computeSobolIndex({i, j}) / var);
238}
for(PetscInt i=0;i< nvars;++i)
std::size_t getNumberOfParameters() const
Access number of dimensions/parameters.
virtual Real computeStandardDeviation() const
Evaluate standard deviation: \sigma = sqrt(E[(u-\mu)^2])
T & value(const std::size_t time_index=0)
IntRange< T > make_range(T beg, T end)

◆ store()

template<typename OutType >
void PCSobolContext< OutType >::store ( nlohmann::json &  json) const
overrideprotectedvirtual

◆ type()

template<typename OutType >
virtual std::string PCSobolContext< OutType >::type ( ) const
inlineoverridevirtual

Reimplemented from ReporterGeneralContext< std::pair< std::vector< OutType >, std::vector< std::vector< OutType > > > >.

Definition at line 93 of file PolynomialChaosReporter.h.

94 {
95 return "SobolIndices<" + MooseUtils::prettyCppType<OutType>() + ">";
96 }

Member Data Documentation

◆ _pc

template<typename OutType >
const PolynomialChaos& PCSobolContext< OutType >::_pc
private

Polynomial chaos surrogate object.

Definition at line 103 of file PolynomialChaosReporter.h.


The documentation for this class was generated from the following files: