C++ mpi module for stochmagnet_main Package
SM_BeamCycle.h
1 #ifndef SM_BeamCycle_H
2 #define SM_BeamCycle_H
3 
4 //inherits header
5 #include "CORE_Object.h"
6 
7 //beam header
8 #include "SM_Beam.h"
9 
10 //stochastic output header
11 #include "SM_StochasticOutputComponent.h"
12 
19 template<class CYCLE_CLASS>
20 class SM_BeamCycle : public CORE_Object {
21 
22  //attributes
23 private :
24 
25  //class type
27  typedef CORE_Object SuperClass;
28 
29  tBoolean mIsSeedUpdated;
30  tULLInt mSeed;
31  tBoolean mIsRestoring;
32  tBoolean mIsOutputSavedAtEachStep;
33 
34 public:
35  // CONSTRUCTORS
38  SM_BeamCycle(void) {
39  mIsSeedUpdated=true;
40  mSeed=0;
41  mIsRestoring=false;
42  mIsOutputSavedAtEachStep=true;
43  }
44 
45  // DESTRUCTORS
48  virtual ~SM_BeamCycle(void) {
49  }
50 
51 
52 
53 public :
54  // CREATE class
55 
56 
57  //SET & GET methods
58 
59 
60 
61 
62  //MEMORY
63 
77  virtual tMemSize getMemorySize() const {
78  return sizeof(*this)+getContentsMemorySize();
79  }
80 
81 
82  // MAIN Method
83 
84 public:
85 
86 public:
87 
91  inline void setIsStochasticOutputSavedAtEachStep(const tBoolean& b) {
92  mIsOutputSavedAtEachStep=b;
93  }
97  inline const tBoolean& isStochasticOutputSavedAtEachStep() const {
98  return mIsOutputSavedAtEachStep;
99  }
100 
104  inline void setIsSeedUpdatedPerCycleStep(const tBoolean& b) {
105  mIsSeedUpdated=b;
106  }
107 
111  inline const tBoolean& isSeedUpdatedPerCycleStep() const {
112  return mIsSeedUpdated;
113  }
114 
118  inline void setSeedPerCycleStep(const tULLInt& seed) {
119  mSeed=seed;
120  }
121 
124  inline const tULLInt& getSeedPerCycleStep() const {
125  return mSeed;
126  }
127 
128 
132  inline void setIsRestoring(const tBoolean& v) {
133  mIsRestoring=v;
134  }
137  inline const tBoolean& isRestoring() const{
138  return mIsRestoring;
139  }
140 
141 public:
142 
143 
150  inline tBoolean open(SM_Beam& beam,
151  SM_StochasticOutputComponent& stochasticOutput,
152  const tInteger& outputId,
153  tIndex& iCycleStep) {
154  return static_cast< CYCLE_CLASS*>(this)->open(beam,stochasticOutput,outputId,iCycleStep);
155  }
156 
162  inline void nextCycleStep(const tIndex& iCycleStep,SM_Beam& beam,const SM_StochasticOutputComponent& output) {
163  return nextCycleStep(iCycleStep,beam,0,output);
164  }
171  inline void nextCycleStep(const tIndex& iCycleStep,SM_Beam& beam,const tInteger& outputId,const SM_StochasticOutputComponent& output) {
172  static_cast< CYCLE_CLASS*>(this)->nextCycleStep(iCycleStep,beam,outputId,output);
173  }
178  inline tBoolean isCycleFinished(const tIndex& iCycle,const SM_Beam& beam) {
179  return static_cast< CYCLE_CLASS*>(this)->isCycleFinished(iCycle,beam);
180  }
186  inline tBoolean close(const tIndex& iCycle,const SM_Beam& beam) {
187 
188  return static_cast<CYCLE_CLASS*>(this)->close(iCycle,beam);
189  }
190 
193  virtual tString toString() const override {
194  std::stringstream ret;
195  ret<<SuperClass::toString()<<"\n";
196  ret<<"\t is seed updated at each step of cycle:"<<((mIsSeedUpdated)?"true":"false")<<"\n";
197  ret<<"\t updated seed at each step of cycle:"<<mSeed<<"\n";
198  ret<<"\t is restoring:"<<mIsRestoring<<"\n";
199  ret<<"\t stochastic output saved at each step:"<<mIsOutputSavedAtEachStep<<"\n";
200  return ret.str();
201  }
202 
203 };
204 
205 
206 #endif
abstract base class for most classes.
Definition: CORE_Object.h:65
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.h:333
This class is an interface of Beam Cycle class for Stoch Microm package.
Definition: SM_BeamCycle.h:20
tBoolean close(const tIndex &iCycle, const SM_Beam &beam)
return true if the cycle is close without error
Definition: SM_BeamCycle.h:186
void nextCycleStep(const tIndex &iCycleStep, SM_Beam &beam, const SM_StochasticOutputComponent &output)
next step of the cycle of beam run
Definition: SM_BeamCycle.h:162
void setIsRestoring(const tBoolean &v)
set to true if the cycle is restoring
Definition: SM_BeamCycle.h:132
const tULLInt & getSeedPerCycleStep() const
get the seed
Definition: SM_BeamCycle.h:124
void setIsStochasticOutputSavedAtEachStep(const tBoolean &b)
set is the output is saved at each step
Definition: SM_BeamCycle.h:91
void setIsSeedUpdatedPerCycleStep(const tBoolean &b)
set if the seed is generated at each step of the cycle
Definition: SM_BeamCycle.h:104
void nextCycleStep(const tIndex &iCycleStep, SM_Beam &beam, const tInteger &outputId, const SM_StochasticOutputComponent &output)
next step of the cycle of beam run
Definition: SM_BeamCycle.h:171
virtual tString toString() const override
return the string representation of the class
Definition: SM_BeamCycle.h:193
const tBoolean & isRestoring() const
return true if the cycle starts at last computed cycle index
Definition: SM_BeamCycle.h:137
tBoolean open(SM_Beam &beam, SM_StochasticOutputComponent &stochasticOutput, const tInteger &outputId, tIndex &iCycleStep)
init the cycle of beam run
Definition: SM_BeamCycle.h:150
virtual ~SM_BeamCycle(void)
destroy
Definition: SM_BeamCycle.h:48
SM_BeamCycle(void)
create
Definition: SM_BeamCycle.h:38
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_BeamCycle.h:77
tBoolean isCycleFinished(const tIndex &iCycle, const SM_Beam &beam)
return true if the cycle is finished
Definition: SM_BeamCycle.h:178
const tBoolean & isStochasticOutputSavedAtEachStep() const
get if the output is saved at each step
Definition: SM_BeamCycle.h:97
void setSeedPerCycleStep(const tULLInt &seed)
set the seed per step of each step cycle
Definition: SM_BeamCycle.h:118
const tBoolean & isSeedUpdatedPerCycleStep() const
return true if the seed is generated at each cycle step
Definition: SM_BeamCycle.h:111
This class defines a general stochastic beam of trajectories of system.
Definition: SM_Beam.h:61
This class stores stochastic outpus computed for each trajectory of a simulation of trajectories of a...
Definition: SM_StochasticOutputComponent.h:36