C++ mpi module for stochmagnet_main Package
SM_CycleLoader.h
1 #ifndef SM_CycleLoader_H
2 #define SM_CycleLoader_H
3 
4 //include the base class of the package
5 #include "CORE_Object.h"
6 
7 //cycle headers
8 #include "SM_BeamTemperatureRange.h"
9 #include "SM_BeamHysteresis.h"
10 #include "SM_BeamTimeStepRange.h"
11 
12 #include "SM_BeamRandomJRange.h"
13 
14 
20 class SM_CycleLoader : public CORE_Object { // class
21 
22 
23  // ASSOCIATION
24 
25 
26 
27  // ATTRIBUTES
28 
29 private:
30 
31 
32  // ASSOCIATIONS
33 
34 
35 
36  // METHODS
37 
38 
39 public:
40  // CONSTRUCTORS
44  }
45 
46 
47 
48 
49  // DESTRUCTORS
53  virtual ~SM_CycleLoader(void) {
54  }
55 
56 
57 
58 
59 
60 public:
61 
62 
63  //MEMORY
64 
78  virtual tMemSize getMemorySize() const override {
79  return sizeof(*this)+getContentsMemorySize();
80  }
81 
82 
83 
84 public:
85 
86 
87 
88  // OTHERS
93  template<class T>
94  static tBoolean LoadCycleFromOptions(SM_BeamCycle<T>& cycle,
95  const CORE_OptionsList& options) {
96  tBoolean isSeedUpdated;
97  if (options.getOptionValue("is-step-cycle-seed-updated",isSeedUpdated)) {
98  cycle.setIsSeedUpdatedPerCycleStep(isSeedUpdated);
99  }
100 
101  tLLInt seed=0;
102  if (options.getOptionValue("seed",seed)) {
103  if (seed>=0) {
104  cycle.setSeedPerCycleStep((tULLInt)seed);
105  }
106  }
107 
108 
109  tBoolean isRestoring=false;
110  options.getOptionValue("is-cycle-restoring",isRestoring);
111  cycle.setIsRestoring(isRestoring);
112 
113  tBoolean isStochasticOutputSavedAtCStep=true;
114  options.getOptionValue("is-stochastic-output-saved-at-each-cycle-step",isStochasticOutputSavedAtCStep);
115  cycle.setIsStochasticOutputSavedAtEachStep(isStochasticOutputSavedAtCStep);
116 
117  SM_BeamHysteresis* hys=dynamic_cast<SM_BeamHysteresis*>(&cycle);
118  if (hys!=null) {
119  return LoadHysteresisCycleFromOptions(*hys,options);
120  }
121  SM_BeamTemperatureRange* temps=dynamic_cast<SM_BeamTemperatureRange*>(&cycle);
122  if (temps!=null) {
123  return LoadTemperatureCycleFromOptions(*temps,options);
124  }
125  SM_BeamRandomJRange* js=dynamic_cast<SM_BeamRandomJRange*>(&cycle);
126  if (js!=null) {
127  return LoadRandomJCycleFromOptions(*js,options);
128  }
129  SM_BeamTimeStepRange* dts=dynamic_cast<SM_BeamTimeStepRange*>(&cycle);
130  if (dts!=null) {
131  return LoadTimeStepCycleFromOptions(*dts,options);
132  }
133  return false;
134  }
135 private:
136  static tBoolean LoadHysteresisCycleFromOptions(SM_BeamHysteresis& cycle,
137  const CORE_OptionsList& options);
138 
139  static tBoolean LoadTemperatureCycleFromOptions(SM_BeamTemperatureRange& cycle,
140  const CORE_OptionsList& options);
141 
142  static tBoolean LoadRandomJCycleFromOptions(SM_BeamRandomJRange& cycle,
143  const CORE_OptionsList& options);
144 
145  static tBoolean LoadTimeStepCycleFromOptions(SM_BeamTimeStepRange& cycle,
146  const CORE_OptionsList& options);
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 };
160 
161 #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
This class is an list of options.
Definition: CORE_OptionsList.h:36
tBoolean getOptionValue(const tString &optName, tString &optValue) const
get the option value
Definition: CORE_OptionsList.h:334
This class is an interface of Beam Cycle class for Stoch Microm package.
Definition: SM_BeamCycle.h:20
void setIsRestoring(const tBoolean &v)
set to true if the cycle is restoring
Definition: SM_BeamCycle.h:132
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 setSeedPerCycleStep(const tULLInt &seed)
set the seed per step of each step cycle
Definition: SM_BeamCycle.h:118
This class is an hysteresis cycle manager for running a cycle of a beam class for Stoch Microm packag...
Definition: SM_BeamHysteresis.h:28
This class is an temperature cycle manager for running a cycle of beam class for Stoch Microm package...
Definition: SM_BeamRandomJRange.h:14
This class is an temperature cycle manager for running a cycle of beam class for Stoch Microm package...
Definition: SM_BeamTemperatureRange.h:14
This class is a time step cycle manager for running a cycle of beam class for Stoch Microm package.
Definition: SM_BeamTimeStepRange.h:16
this class loads classes of the package
Definition: SM_CycleLoader.h:20
static tBoolean LoadCycleFromOptions(SM_BeamCycle< T > &cycle, const CORE_OptionsList &options)
load the cycle from options
Definition: SM_CycleLoader.h:94
SM_CycleLoader()
build a SM_CycleLoader
Definition: SM_CycleLoader.h:43
virtual tMemSize getMemorySize() const override
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_CycleLoader.h:78
virtual ~SM_CycleLoader(void)
destroy a SM_CycleLoader
Definition: SM_CycleLoader.h:53