https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
StochasticTools::Calculator< InType, OutType > Class Template Referenceabstract

#include <BootstrapCalculators.h>

Inheritance diagram for StochasticTools::Calculator< InType, OutType >:
[legend]

Public Member Functions

 Calculator (const libMesh::ParallelObject &other, const std::string &name)
 
virtual ~Calculator ()=default
 
OutType compute (const InType &, bool)
 Evaluate the calculator on the full vector of data. More...
 
void initializeCalculator ()
 Public function that must be called before updateCalculator and finalizeCalculator. More...
 
void updateCalculator (const typename InType::value_type &)
 Public function to update calculator with a piece of data. More...
 
void finalizeCalculator (bool)
 Public function to finalize the resulting calculator value. More...
 
OutType getValue () const
 Public function to return the calculated value _state must be FINALIZED. More...
 
const std::string & name () const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

virtual void initialize ()=0
 This function is used to reset the calculator to its initial state and prepare it for another evaluation. More...
 
virtual void update (const typename InType::value_type &)=0
 Updating the calculator with a piece of data. More...
 
virtual void finalize (bool)=0
 This is used to compute the resulting calculator value by performing necessary arithmetic and parallel communication. More...
 
virtual OutType get () const =0
 Returns the resulting calculator value. More...
 

Protected Attributes

const Parallel::Communicator & _communicator
 

Private Types

enum  CalculatorState { NONE, INITIALIZED, FINALIZED }
 

Private Attributes

const std::string _name
 
CalculatorState _state
 

Detailed Description

template<typename InType, typename OutType>
class StochasticTools::Calculator< InType, OutType >

Definition at line 35 of file BootstrapCalculators.h.

Member Enumeration Documentation

◆ CalculatorState

template<typename InType, typename OutType>
enum StochasticTools::Calculator::CalculatorState
private
Enumerator
NONE 
INITIALIZED 
FINALIZED 

Definition at line 125 of file Calculators.h.

Constructor & Destructor Documentation

◆ Calculator()

template<typename InType, typename OutType>
StochasticTools::Calculator< InType, OutType >::Calculator ( const libMesh::ParallelObject other,
const std::string &  name 
)
inline

Definition at line 65 of file Calculators.h.

66  : libMesh::ParallelObject(other), _name(name), _state(CalculatorState::NONE)
67  {
68  }
const std::string _name
Definition: Calculators.h:132
const std::string & name() const
Definition: Calculators.h:99

◆ ~Calculator()

template<typename InType, typename OutType>
virtual StochasticTools::Calculator< InType, OutType >::~Calculator ( )
virtualdefault

Member Function Documentation

◆ compute()

template<typename InType, typename OutType >
OutType StochasticTools::Calculator< InType, OutType >::compute ( const InType &  data,
bool  is_distributed 
)

Evaluate the calculator on the full vector of data.

This is basically a convenient wrapper around initializeCalculator, updateCalculator, finalizeCalculator, and getvalue.

Definition at line 288 of file Calculators.h.

289 {
291  for (const auto & val : data)
292  updateCalculator(val);
293  finalizeCalculator(is_distributed);
294  return getValue();
295 }
void updateCalculator(const typename InType::value_type &)
Public function to update calculator with a piece of data.
Definition: Calculators.h:307
void initializeCalculator()
Public function that must be called before updateCalculator and finalizeCalculator.
Definition: Calculators.h:299
OutType getValue() const
Public function to return the calculated value _state must be FINALIZED.
Definition: Calculators.h:325
void finalizeCalculator(bool)
Public function to finalize the resulting calculator value.
Definition: Calculators.h:315

◆ finalize()

template<typename InType, typename OutType>
virtual void StochasticTools::Calculator< InType, OutType >::finalize ( bool  )
protectedpure virtual

◆ finalizeCalculator()

template<typename InType , typename OutType >
void StochasticTools::Calculator< InType, OutType >::finalizeCalculator ( bool  is_distributed)

Public function to finalize the resulting calculator value.

_state must be INITLIALIZED Sets _state to FINALIZED

Definition at line 315 of file Calculators.h.

316 {
317  if (_state != CalculatorState::INITIALIZED)
318  ::mooseError("Calculator is in wrong state.");
319  finalize(is_distributed);
320  _state = CalculatorState::FINALIZED;
321 }
virtual void finalize(bool)=0
This is used to compute the resulting calculator value by performing necessary arithmetic and paralle...

◆ get()

template<typename InType, typename OutType>
virtual OutType StochasticTools::Calculator< InType, OutType >::get ( ) const
protectedpure virtual

◆ getValue()

template<typename InType , typename OutType >
OutType StochasticTools::Calculator< InType, OutType >::getValue ( ) const

Public function to return the calculated value _state must be FINALIZED.

Definition at line 325 of file Calculators.h.

326 {
327  if (_state != CalculatorState::FINALIZED)
328  ::mooseError("Calculator is in wrong state.");
329  return get();
330 }

◆ initialize()

template<typename InType, typename OutType>
virtual void StochasticTools::Calculator< InType, OutType >::initialize ( )
protectedpure virtual

◆ initializeCalculator()

template<typename InType , typename OutType >
void StochasticTools::Calculator< InType, OutType >::initializeCalculator ( )

Public function that must be called before updateCalculator and finalizeCalculator.

Sets _state to INITIALIZED

Definition at line 299 of file Calculators.h.

Referenced by StochasticTools::SobolCalculator< std::vector< InType >, std::vector< OutType > >::finalize(), and StochasticTools::SobolCalculator< std::vector< InType >, std::vector< OutType > >::update().

300 {
301  initialize();
302  _state = CalculatorState::INITIALIZED;
303 }
virtual void initialize()=0
This function is used to reset the calculator to its initial state and prepare it for another evaluat...

◆ name()

template<typename InType, typename OutType>
const std::string& StochasticTools::Calculator< InType, OutType >::name ( ) const
inline

Definition at line 99 of file Calculators.h.

99 { return _name; }
const std::string _name
Definition: Calculators.h:132

◆ update()

template<typename InType, typename OutType>
virtual void StochasticTools::Calculator< InType, OutType >::update ( const typename InType::value_type &  )
protectedpure virtual

◆ updateCalculator()

template<typename InType, typename OutType >
void StochasticTools::Calculator< InType, OutType >::updateCalculator ( const typename InType::value_type &  val)

Public function to update calculator with a piece of data.

_state mush be INITIALIZED

Definition at line 307 of file Calculators.h.

308 {
309  mooseAssert(_state == CalculatorState::INITIALIZED, "Calculator is in wrong state.");
310  update(val);
311 }
virtual void update(const typename InType::value_type &)=0
Updating the calculator with a piece of data.

Member Data Documentation

◆ _name

template<typename InType, typename OutType>
const std::string StochasticTools::Calculator< InType, OutType >::_name
private

◆ _state

template<typename InType, typename OutType>
CalculatorState StochasticTools::Calculator< InType, OutType >::_state
private

Definition at line 133 of file Calculators.h.


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