C++ main module for stochmagnet Package  1.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
SM_Beam Class Reference

This class is a simulation of a beam of trajectories class for Stoch Microm package. More...

#include <SM_Beam.h>

Inheritance diagram for SM_Beam:
Inheritance graph
[legend]
Collaboration diagram for SM_Beam:
Collaboration graph
[legend]

Public Member Functions

virtual tMemSize getMemorySize () const
 return the memory size of the class and the memory size of all its attributes/associations More...
 
virtual tMemSize getContentsMemorySize () const
 return the memory size of the included associations More...
 
void setIsTemplatedSimulateVersion (const tBoolean &v)
 set true if the templated simulate method is called More...
 
void setBeamSize (const tIndex &n)
 set the beam size More...
 
const tIndexgetBeamSize () const
 get the beam size More...
 
void setStochasticFunction (CORE_UniquePointer< SM_StochasticFunction > &f)
 set the stochastic function More...
 
const SM_StochasticFunctiongetStochasticFunction () const
 get the stochastic function More...
 
void setSystem (CORE_UniquePointer< SM_System > &sys)
 set the system More...
 
virtual const SM_SystemgetSystem () const
 return the system for reading More...
 
virtual SM_SystemgetSystem ()
 return the system for writing More...
 
const std::valarray< tReal > & getMagneticMoment () const
 return the mu array More...
 
std::valarray< tReal > & getMagneticMoment ()
 return the mu array More...
 
const std::valarray< tReal > & getEnergies () const
 return the Energy array More...
 
std::valarray< tReal > & getEnergies ()
 return the energies array More...
 
void discretize ()
 discretize the system More...
 
const std::valarray< tReal > & getDeterministicEnergies () const
 return the deterministic energies More...
 
tIndex runSimulations ()
 run the simulations More...
 
virtual tString toString () const override
 turn the class into a string representation More...
 
void computeL2Convergence (std::valarray< tReal > &L2conv) const
 compute the L2 convergence for mu More...
 
template<class T >
std::shared_ptr< T > getSharedPointer ()
 return the shared pointer for this More...
 
template<class T >
std::shared_ptr< const T > getConstSharedPointer () const
 return a const shared pointer for this More...
 
template<class T >
tBoolean isInstanceOf () const
 test if the clas T is an instance of this class More...
 
tString getClassName () const
 return the name of the class More...
 
tString getPointerString () const
 retrun the pointer of the class as a string More...
 
tString getIdentityString () const
 retrun the string identification of the class More...
 

Static Public Member Functions

static CORE_UniquePointer< SM_BeamNew ()
 build a new instance of a SM_Beam More...
 
static tBoolean EnableMemoryStack (const tBoolean &isMemoryChecked)
 enable the memory stack More...
 
static void EnableMemoryStack ()
 enable the memory stack More...
 
static void DisableMemoryStack ()
 disable the memory stack More...
 
static tBoolean IsMemoryStackEnabled ()
 return trur if the memory stack is enabled More...
 
static tString MemoryStackToString ()
 get the memory stack in string More...
 
static tIndex GetRegisteredClassesNumber ()
 get the memory stack in string More...
 

Protected Member Functions

 SM_Beam (void)
 create More...
 
virtual ~SM_Beam (void)
 destroy More...
 

Private Member Functions

tIndex simulate ()
 simulate a beam by computing mu field by calling only virtual methods More...
 
tIndex templatedSimulate ()
 simulate a beam by computing mu field by calling only templated methods More...
 
template<class SystemImpl , class NoiseImpl >
tIndex templatedSimulate (SystemImpl &system, const NoiseImpl &noise)
 simulate a beam by computing mu field by calling only templated methods More...
 
template<class T >
std::shared_ptr< T > setThis (std::unique_ptr< T, CORE_Object::Delete > &up)
 set the shared pointer from an unique pointer More...
 

Private Attributes

tIndex mBeamSize
 
std::valarray< tRealmMu
 
std::valarray< tRealmEs
 
tBoolean mIsTemplatedSimulateVersion
 
CORE_UniquePointer< SM_StochasticFunctionmStochasticFunction
 
CORE_UniquePointer< SM_SystemmSystem
 
CORE_UniquePointer< SM_SystemmDeterministicSystem
 
std::valarray< tRealmDMu
 
std::valarray< tRealmDEs
 
std::weak_ptr< CORE_ObjectmThis
 

Detailed Description

This class is a simulation of a beam of trajectories class for Stoch Microm package.

The simulation of a beam follows the algorithm:

image html beamAlgorithm.png

Author
Stephane Despreaux
Version
2.0

Constructor & Destructor Documentation

◆ SM_Beam()

SM_Beam::SM_Beam ( void  )
inlineprotected

create

References mBeamSize, and mIsTemplatedSimulateVersion.

Referenced by New().

Here is the caller graph for this function:

◆ ~SM_Beam()

virtual SM_Beam::~SM_Beam ( void  )
inlineprotectedvirtual

destroy

Member Function Documentation

◆ computeL2Convergence()

void SM_Beam::computeL2Convergence ( std::valarray< tReal > &  L2conv) const

◆ DisableMemoryStack()

static void CORE_Object::DisableMemoryStack ( )
inlinestaticinherited

disable the memory stack

Referenced by CORE_Object::EnableMemoryStack().

Here is the caller graph for this function:

◆ discretize()

void SM_Beam::discretize ( )
inline

◆ EnableMemoryStack() [1/2]

static void CORE_Object::EnableMemoryStack ( )
inlinestaticinherited

enable the memory stack

Referenced by CORE_Object::EnableMemoryStack(), and CORE_Run::SetDebugOptions().

Here is the caller graph for this function:

◆ EnableMemoryStack() [2/2]

static tBoolean CORE_Object::EnableMemoryStack ( const tBoolean isMemoryChecked)
inlinestaticinherited

enable the memory stack

Parameters
[in]isMemoryChecked: true to verify memory allocation of CORE_Object classes
Returns
true if the memroy is checked

References CORE_Object::DisableMemoryStack(), CORE_Object::EnableMemoryStack(), and CORE_Object::IsMemoryStackEnabled().

Here is the call graph for this function:

◆ getBeamSize()

const tIndex& SM_Beam::getBeamSize ( ) const
inline

get the beam size

Returns
the number of trajectories to compute

References mBeamSize.

Referenced by computeL2Convergence(), SM_Output::generateOutput(), SM_Output::saveStochasticIndicators(), simulate(), and templatedSimulate().

Here is the caller graph for this function:

◆ getClassName()

tString CORE_Object::getClassName ( ) const
inlineinherited

return the name of the class

Returns
the string name of the class

Referenced by CORE_Object::getIdentityString(), and CORE_Test::testTypes().

Here is the caller graph for this function:

◆ getConstSharedPointer()

template<class T >
std::shared_ptr<const T> CORE_Object::getConstSharedPointer ( ) const
inlineinherited

return a const shared pointer for this

Returns
the shared pointer as a type T

References CORE_Object::mThis.

◆ getContentsMemorySize()

virtual tMemSize SM_Beam::getContentsMemorySize ( ) const
inlinevirtual

return the memory size of the included associations

Returns
the memory size of the storage in bytes 1 Kb = 1024 bytes 1 Mb = 1024 Kb 1 Gb = 1024 Mb 1 Tb = 1024 Gb 1 Hb = 1024 Tb

Reimplemented from CORE_Object.

References CORE_Object::getContentsMemorySize(), mDEs, mDeterministicSystem, mDMu, mEs, mMu, mStochasticFunction, mSystem, tMemSize, and tReal.

Referenced by getMemorySize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDeterministicEnergies()

const std::valarray<tReal>& SM_Beam::getDeterministicEnergies ( ) const
inline

return the deterministic energies

Returns
the deterministic energies

References mDEs.

Referenced by SM_Output::saveStochasticIndicators().

Here is the caller graph for this function:

◆ getEnergies() [1/2]

std::valarray<tReal>& SM_Beam::getEnergies ( )
inline

return the energies array

Returns
the Energies array for writing

References mEs.

◆ getEnergies() [2/2]

const std::valarray<tReal>& SM_Beam::getEnergies ( ) const
inline

return the Energy array

Returns
the Energy array for reading

References mEs.

Referenced by SM_Output::saveStochasticIndicators(), simulate(), and templatedSimulate().

Here is the caller graph for this function:

◆ getIdentityString()

tString CORE_Object::getIdentityString ( ) const
inlineinherited

retrun the string identification of the class

Returns
the string identity of the class

References CORE_Object::getClassName(), and core_functions::pointerToString().

Referenced by CORE_Test::testArray(), CORE_Test::testField(), CORE_Test::testTypes(), CORE_Object::toString(), CORE_ClassFactory::toString(), and CORE_Field< T, K, D, S, I >::toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMagneticMoment() [1/2]

std::valarray<tReal>& SM_Beam::getMagneticMoment ( )
inline

return the mu array

Returns
the mu array for writing

References mMu.

◆ getMagneticMoment() [2/2]

const std::valarray<tReal>& SM_Beam::getMagneticMoment ( ) const
inline

return the mu array

Returns
the mu array for reading

References mMu.

Referenced by computeL2Convergence(), SM_VTK::save(), simulate(), templatedSimulate(), and SM_Test::validate().

Here is the caller graph for this function:

◆ getMemorySize()

virtual tMemSize SM_Beam::getMemorySize ( ) const
inlinevirtual

return the memory size of the class and the memory size of all its attributes/associations

Returns
the memory size of the class and the memory size of its attributes/associations in bytes The mamory size is :
  • the added size of the base classes which contains:
    • the primary attributes size depends on the order: (first delare the smallest attributes size
    • all virtual functions costs <pointer-size> (4 32xor 8 64x) bytes by virtual function
    • virtual inherihtance will increase of (4 or 8) bytes
  • we add the size of the contains values of the attributes : for example the size of a string is the length of the string 1 octet = 1 byte 1 Ko = 1024 bytes 1 Mo = 1024 Ko 1 Go = 1024 Mo

Reimplemented from SM_Object.

References getContentsMemorySize().

Here is the call graph for this function:

◆ getPointerString()

tString CORE_Object::getPointerString ( ) const
inlineinherited

retrun the pointer of the class as a string

Returns
the pointer of the calss as a string

References core_functions::pointerToString().

Here is the call graph for this function:

◆ GetRegisteredClassesNumber()

static tIndex CORE_Object::GetRegisteredClassesNumber ( )
inlinestaticinherited

get the memory stack in string

Returns
the string representation of the memory stack

◆ getSharedPointer()

template<class T >
std::shared_ptr<T> CORE_Object::getSharedPointer ( )
inlineinherited

return the shared pointer for this

Returns
the shared pointer as a type T

References CORE_Object::mThis.

◆ getStochasticFunction()

const SM_StochasticFunction& SM_Beam::getStochasticFunction ( ) const
inline

get the stochastic function

Returns
the stochastic function

References mStochasticFunction.

Referenced by simulate(), and templatedSimulate().

Here is the caller graph for this function:

◆ getSystem() [1/2]

virtual SM_System& SM_Beam::getSystem ( )
inlinevirtual

return the system for writing

Returns
the system for writing

References mSystem.

◆ getSystem() [2/2]

virtual const SM_System& SM_Beam::getSystem ( ) const
inlinevirtual

◆ isInstanceOf()

template<class T >
tBoolean CORE_Object::isInstanceOf ( ) const
inlineinherited

test if the clas T is an instance of this class

Returns
true if the object is an instance of T

Referenced by templatedSimulate().

Here is the caller graph for this function:

◆ IsMemoryStackEnabled()

static tBoolean CORE_Object::IsMemoryStackEnabled ( )
inlinestaticinherited

return trur if the memory stack is enabled

Referenced by CORE_Object::EnableMemoryStack(), and main().

Here is the caller graph for this function:

◆ MemoryStackToString()

static tString CORE_Object::MemoryStackToString ( )
inlinestaticinherited

get the memory stack in string

Returns
the string representation of the memory stack

Referenced by main().

Here is the caller graph for this function:

◆ New()

static CORE_UniquePointer<SM_Beam> SM_Beam::New ( )
inlinestatic

build a new instance of a SM_Beam

Returns
an unique pointer of SM_Beam

References SM_Beam().

Referenced by SM_ClassFactory::NewInstance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runSimulations()

tIndex SM_Beam::runSimulations ( )
inline

run the simulations

Returns
the number of effective simulations without error

References mDEs, mDeterministicSystem, mDMu, mIsTemplatedSimulateVersion, simulate(), and templatedSimulate().

Referenced by SM_Test::grid3DParticlesTestCase(), and SM_Test::linedParticlesTestCase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBeamSize()

void SM_Beam::setBeamSize ( const tIndex n)
inline

set the beam size

Parameters
[in]nnumber of trajectories to compute

References mBeamSize.

Referenced by SM_Test::grid3DParticlesTestCase(), SM_Test::linedParticlesTestCase(), SM_Run::loadBeamFromOptions(), and SM_Test::testOperators().

Here is the caller graph for this function:

◆ setIsTemplatedSimulateVersion()

void SM_Beam::setIsTemplatedSimulateVersion ( const tBoolean v)
inline

set true if the templated simulate method is called

Parameters
[in]vtrue to call templated simulate method

References mIsTemplatedSimulateVersion.

Referenced by SM_Test::grid3DParticlesTestCase(), SM_Test::linedParticlesTestCase(), and SM_Run::loadBeamFromOptions().

Here is the caller graph for this function:

◆ setStochasticFunction()

void SM_Beam::setStochasticFunction ( CORE_UniquePointer< SM_StochasticFunction > &  f)
inline

set the stochastic function

Parameters
[in,out]fstochastic funtion. Points to nothing at end

References mStochasticFunction.

Referenced by SM_Test::grid3DParticlesTestCase(), SM_Test::linedParticlesTestCase(), SM_Run::loadBeamFromOptions(), and SM_Test::testOperators().

Here is the caller graph for this function:

◆ setSystem()

void SM_Beam::setSystem ( CORE_UniquePointer< SM_System > &  sys)
inline

set the system

Parameters
[in,out]syssystem to set

References mSystem.

Referenced by SM_Test::grid3DParticlesTestCase(), SM_Test::linedParticlesTestCase(), SM_Run::loadBeamFromOptions(), and SM_Test::testOperators().

Here is the caller graph for this function:

◆ setThis()

template<class T >
std::shared_ptr<T> CORE_Object::setThis ( std::unique_ptr< T, CORE_Object::Delete > &  up)
inlineprivateinherited

set the shared pointer from an unique pointer

Parameters
[in,out]upunique pointer of the class at input, points to null pointer at output
Returns
the shared pointer of the class

Method only calledby the friend class CORE_ClassFactory::NewSharedInstance()

References CORE_Object::mThis.

◆ simulate()

tIndex SM_Beam::simulate ( )
private

simulate a beam by computing mu field by calling only virtual methods

Returns
the number of effective simulations without error

References getBeamSize(), getEnergies(), getMagneticMoment(), getStochasticFunction(), mSystem, tIndex, and tReal.

Referenced by runSimulations(), and templatedSimulate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ templatedSimulate() [1/2]

tIndex SM_Beam::templatedSimulate ( )
inlineprivate

simulate a beam by computing mu field by calling only templated methods

Returns
the number of effective simulations without error

References SM_System::getNoiseRateFunction(), getSystem(), CORE_Object::isInstanceOf(), and simulate().

Referenced by runSimulations().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ templatedSimulate() [2/2]

template<class SystemImpl , class NoiseImpl >
tIndex SM_Beam::templatedSimulate ( SystemImpl &  system,
const NoiseImpl &  noise 
)
private

simulate a beam by computing mu field by calling only templated methods

References getBeamSize(), getEnergies(), getMagneticMoment(), getStochasticFunction(), CORE_Object::isInstanceOf(), tIndex, and tReal.

Here is the call graph for this function:

◆ toString()

virtual tString SM_Beam::toString ( ) const
inlineoverridevirtual

turn the class into a string representation

Returns
a string representation of the class

Reimplemented from CORE_Object.

References mBeamSize, mStochasticFunction, mSystem, and CORE_Object::toString().

Here is the call graph for this function:

Member Data Documentation

◆ mBeamSize

tIndex SM_Beam::mBeamSize
private

◆ mDEs

std::valarray<tReal> SM_Beam::mDEs
private

◆ mDeterministicSystem

CORE_UniquePointer<SM_System> SM_Beam::mDeterministicSystem
private

◆ mDMu

std::valarray<tReal> SM_Beam::mDMu
private

◆ mEs

std::valarray<tReal> SM_Beam::mEs
private

◆ mIsTemplatedSimulateVersion

tBoolean SM_Beam::mIsTemplatedSimulateVersion
private

◆ mMu

std::valarray<tReal> SM_Beam::mMu
private

◆ mStochasticFunction

CORE_UniquePointer<SM_StochasticFunction> SM_Beam::mStochasticFunction
private

◆ mSystem

CORE_UniquePointer<SM_System> SM_Beam::mSystem
private

◆ mThis

std::weak_ptr<CORE_Object> CORE_Object::mThis
privateinherited

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