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 ReporterName & name () 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 MooseObject & getProducer () const
 
const ReporterProducerEnum & getProducerModeEnum () 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 99 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 206 of file PolynomialChaosReporter.C.

211 : ReporterGeneralContext<std::pair<std::vector<OutType>, std::vector<std::vector<OutType>>>>(
212 other, producer, state),
213 _pc(pc)
214{
215}
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 219 of file PolynomialChaosReporter.C.

220{
221 const unsigned int nparam = _pc.getNumberOfParameters();
222 std::vector<OutType> & val = this->_state.value().first;
223 val.clear();
224
225 // Compute variance
226 auto var = _pc.computeStandardDeviation();
227 var *= var;
228
229 // First order
230 for (const auto & i : make_range(nparam))
231 val.push_back(_pc.computeSobolIndex({i}) / var);
232 // Total
233 for (const auto & i : make_range(nparam))
234 val.push_back(_pc.computeSobolTotal(i) / var);
235 // Second order
236 for (const auto & i : make_range(nparam))
237 for (const auto & j : make_range(i + 1, nparam))
238 val.push_back(_pc.computeSobolIndex({i, j}) / var);
239}
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 110 of file PolynomialChaosReporter.h.

111 {
112 return "SobolIndices<" + MooseUtils::prettyCppType<OutType>() + ">";
113 }

Member Data Documentation

◆ _pc

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

Polynomial chaos surrogate object.

Definition at line 120 of file PolynomialChaosReporter.h.


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