C++ mpi module for stochmagnet_main Package
SM_StochasticOutputComponent.h
1 #ifndef SM_StochasticOutputComponent_H
2 #define SM_StochasticOutputComponent_H
3 
4 //stochastic data
5 #include "SM_Object.h"
6 
7 class SM_Beam;
8 class SM_System;
9 
10 
11 #include "SM_Material.h"
12 #include "SM_Field.h"
13 
36 class SM_StochasticOutputComponent : public virtual SM_Object {
37 
38  // ATTRIBUTES
39 
40 public:
41 
42 
43 
44 private:
45 
46 
47  //output path
48  tString mOutputPath;
49  //output prefix
50  tString mPrefix;
51 
52  //drawn number register
53  tInteger mDrawnStepsNumber;
54 
55  //index of the packed simulations
56  tInteger mPackedSimulationsIndex;
57 
58  //number of the packed simulations
59  tInteger mPackedSimulationsNumber;
60 
61  //indicates if the statistic has log per packed simulations
62  tBoolean mHasLogPerPackedSimulations;
63 
64  //number of packed rw values
65  tIndex mPackedRawValuesNumber;
66 
67  //packed raw values
68  std::valarray<tReal> mPackedRawValues;
69 
70  //output value of the stochastic
71  std::valarray<tReal> mOutput;
72  std::vector<tString> mOutputDescription;
73 
74  //index of stochastic output components
75  //mRootIndex=index of the main stochastic output in [0,mIndicesNumber]
76  //mRootIndex>=mIndicesNumber ;: no root index
77  //mIndex: index of the stochatic output in [0,mIndicesNumber[
78  int mRootIndex,mIndex,mIndicesNumber;
79 
80 public:
81  // METHODS
82 
83  // CONSTRUCTORS
84 
88 
89 
90  mOutputPath="";
91  mPrefix="";
92  mDrawnStepsNumber=0;
93  mPackedSimulationsNumber=1;
94  mPackedSimulationsIndex=0;
95  mHasLogPerPackedSimulations=true;
96  mPackedRawValues.resize(1);
97  mPackedRawValues[0]=0;
98  mPackedRawValuesNumber=0;
99  mRootIndex=-1;
100  mIndex=0;
101  mIndicesNumber=1;
102  }
103 
104 
105 
106  // DESTRUCTORS
107 public:
108 
112  }
113 
114 
115 
116 public:
117  //MEMORY
118 
132  virtual tMemSize getMemorySize() const {
133  return sizeof(*this)+getContentsMemorySize();
134  }
135 
144  virtual tMemSize getContentsMemorySize() const {
145  tMemSize mem=SM_Object::getContentsMemorySize();
146  mem+=mOutputPath.size()*sizeof(tChar);
147  mem+=mPrefix.size()*sizeof(tChar);
148  mem+=sizeof(tReal)*mPackedRawValues.size();
149  mem+=mOutput.size()*sizeof(tReal);
150  for(const auto& d: mOutputDescription) mem+=sizeof(tChar)*d.length();
151  return mem;
152  }
153 
154 
155 
156  //SET & GET Methods
157  //=================
158 
162  virtual void copy(const SM_StochasticOutputComponent& c) {
163  mOutputPath=c.getOutputPath();
164  mPrefix=c.getPrefix();
165  mDrawnStepsNumber=c.getDrawnStepsNumber();
166  }
167 
168 
172  virtual void setOutputPath(const tString& path) {
173  mOutputPath=path;
174  }
178  inline const tString& getOutputPath() const {
179  return mOutputPath;
180  }
184  virtual void setPrefix(const tString& prefix) {
185  mPrefix=prefix;
186  }
190  inline const tString& getPrefix() const {
191  return mPrefix;
192  }
193 
199  virtual void setIndex(const int& index,
200  const int& rootIndex,
201  const int& n) {
202  mIndex=index;
203  mRootIndex=rootIndex;
204  mIndicesNumber=n;
205  }
210  inline void setIndex(const int& index,
211  const int& n) {
212 
213  setIndex(index,0,n);
214  }
217  inline const int& getIndex() const {
218  return mIndex;
219  }
222  inline const int& getRootIndex() const {
223  return mRootIndex;
224  }
227  inline const int& getIndicesNumber() const {
228  return mIndicesNumber;
229  }
230 
237  inline void setDrawnStepsNumber(const tInteger& n) {
238  mDrawnStepsNumber=n;
239  }
243  inline const tInteger& getDrawnStepsNumber() const {
244  return mDrawnStepsNumber;
245  }
246 
247 
251  inline void setPackedSimulationsIndex(const tInteger& i) {
252  mPackedSimulationsIndex=i;
253  }
257  inline const tInteger& getPackedSimulationsIndex() const {
258  return mPackedSimulationsIndex;
259  }
263  inline void setPackedSimulationsNumber(const tInteger& n) {
264  mPackedSimulationsNumber=n;
265  }
269  inline const tInteger& getPackedSimulationsNumber() const {
270  return mPackedSimulationsNumber;
271  }
274  inline const tBoolean & hasLogPerPackedSimulations() const {
275  return mHasLogPerPackedSimulations;
276  }
280  inline void setHasLogPerPackedSimulations(const tBoolean & v) {
281  mHasLogPerPackedSimulations=v;
282  }
286  inline const tIndex& getPackedRawValuesNumber() const {
287  return mPackedRawValuesNumber;
288  }
292  inline tIndex& getPackedRawValuesNumber() {
293  return mPackedRawValuesNumber;
294  }
295 
296 
297 
301  inline std::valarray<tReal>& getPackedRawValues() {
302  return mPackedRawValues;
303  }
304 
308  inline const std::valarray<tReal>& getPackedRawValues() const {
309  return mPackedRawValues;
310  }
311 
312 
316  inline const std::vector<tString>& getOutputDescription() const {
317  return mOutputDescription;
318  }
323  inline void setOutputDescription(const std::vector<tString>& v) {
324  mOutputDescription=v;
325  }
326 
330  inline const std::valarray<tReal>& getOutputValues() const {
331  return mOutput;
332  }
333 
337  inline std::valarray<tReal>& getOutputValues() {
338  return mOutput;
339  }
340 
341 public:
342 
343  //implemented templated methods
344  //=============================
348  virtual tBoolean openComponent(const SM_Beam& beam)=0;
349 
354  virtual tBoolean openComponent(const tIndex& s,const SM_System& system)=0;
355 
356 
360  virtual tBoolean storeComponent(const SM_System& system)=0;
361 
367  virtual tBoolean closeComponent(const tIndex& s,const SM_System& system,const tBoolean& hasSucceeded)=0;
368 
372  virtual tBoolean closeComponent(const SM_Beam& beam)=0;
373 
381  virtual void closePackedSimulations(const SM_Beam& beam,
382  const tIndex& rawValuesNumber,
383  const std::valarray<tReal>& rawValues)=0;
384 
385 
389  virtual void adimensionize(const SM_Material& material)=0;
390 
391 
392 public:
393  // OTHERS methods
394 
395 
398  virtual tString toString() const override {
399  std::stringstream ret;
400  ret<<SM_Object::toString()<<"\n";
401  ret<<"\t outputPath:"<<mOutputPath<<"\n";
402  ret<<"\t prefix:"<<mPrefix<<"\n";
403  ret<<"\t drawn steps number:"<<mDrawnStepsNumber<<"\n";
404  ret<<"\t output size: "<<mOutput.size()<<"\n";
405  ret<<"\t pack:"<<mPackedSimulationsIndex<<"/"<<mPackedSimulationsNumber<<"\n";
406  ret<<"\t output description: ";
407  for(const auto& d:mOutputDescription) ret<<d<<"\t";
408  ret<<"\n";
409  ret<<"\t has log per packed simulations:"<<mHasLogPerPackedSimulations<<"\n";
410  return ret.str();
411  }
412 
413 
414 };
415 
416 #endif
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 defines a general stochastic beam of trajectories of system.
Definition: SM_Beam.h:61
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
This class is a base class for Stoch Microm package.
Definition: SM_Object.h:36
This class stores stochastic outpus computed for each trajectory of a simulation of trajectories of a...
Definition: SM_StochasticOutputComponent.h:36
const std::valarray< tReal > & getPackedRawValues() const
get the packed raw values
Definition: SM_StochasticOutputComponent.h:308
const int & getRootIndex() const
get the root index of the output component
Definition: SM_StochasticOutputComponent.h:222
std::valarray< tReal > & getPackedRawValues()
get the packed raw values
Definition: SM_StochasticOutputComponent.h:301
void setOutputDescription(const std::vector< tString > &v)
et the output description
Definition: SM_StochasticOutputComponent.h:323
virtual void closePackedSimulations(const SM_Beam &beam, const tIndex &rawValuesNumber, const std::valarray< tReal > &rawValues)=0
close the raws values for packed simulations
void setPackedSimulationsNumber(const tInteger &n)
set packed simulations number
Definition: SM_StochasticOutputComponent.h:263
virtual tBoolean closeComponent(const SM_Beam &beam)=0
close stochastic data at the end of all simulations
virtual tBoolean closeComponent(const tIndex &s, const SM_System &system, const tBoolean &hasSucceeded)=0
close the stochastic data for the simulation s
SM_StochasticOutputComponent(void)
create
Definition: SM_StochasticOutputComponent.h:87
virtual tBoolean openComponent(const SM_Beam &beam)=0
open the stochastic data
std::valarray< tReal > & getOutputValues()
get the output values of the stochastic output for writing
Definition: SM_StochasticOutputComponent.h:337
void setIndex(const int &index, const int &n)
set index of the output component
Definition: SM_StochasticOutputComponent.h:210
const tString & getPrefix() const
return the prefix
Definition: SM_StochasticOutputComponent.h:190
const tInteger & getPackedSimulationsIndex() const
get packed simulations index
Definition: SM_StochasticOutputComponent.h:257
const std::vector< tString > & getOutputDescription() const
get the string representation of the output values
Definition: SM_StochasticOutputComponent.h:316
void setDrawnStepsNumber(const tInteger &n)
set the number of steps for drawn for the stochastic output
Definition: SM_StochasticOutputComponent.h:237
tIndex & getPackedRawValuesNumber()
get the packed raw values number
Definition: SM_StochasticOutputComponent.h:292
virtual tString toString() const override
return the string representation of the class
Definition: SM_StochasticOutputComponent.h:398
const tIndex & getPackedRawValuesNumber() const
get the packed raw values number
Definition: SM_StochasticOutputComponent.h:286
virtual void copy(const SM_StochasticOutputComponent &c)
copy
Definition: SM_StochasticOutputComponent.h:162
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_StochasticOutputComponent.h:132
const tBoolean & hasLogPerPackedSimulations() const
return true if the stochastic output has log per pack of simulations
Definition: SM_StochasticOutputComponent.h:274
virtual tBoolean storeComponent(const SM_System &system)=0
store the stochastic data during the relation method of the system
const tInteger & getDrawnStepsNumber() const
get the drawn number to compute the stochastic output
Definition: SM_StochasticOutputComponent.h:243
virtual void setOutputPath(const tString &path)
set the output path
Definition: SM_StochasticOutputComponent.h:172
const tInteger & getPackedSimulationsNumber() const
get packed simulations number
Definition: SM_StochasticOutputComponent.h:269
virtual void setIndex(const int &index, const int &rootIndex, const int &n)
set index of the output component
Definition: SM_StochasticOutputComponent.h:199
virtual tBoolean openComponent(const tIndex &s, const SM_System &system)=0
open the stochastic data for simulation s
virtual void setPrefix(const tString &prefix)
set the prefix of generated files
Definition: SM_StochasticOutputComponent.h:184
const std::valarray< tReal > & getOutputValues() const
get the output values of the stochastic output for reading
Definition: SM_StochasticOutputComponent.h:330
const int & getIndex() const
get the index of the output component
Definition: SM_StochasticOutputComponent.h:217
void setHasLogPerPackedSimulations(const tBoolean &v)
set to true if the stochastic output has log per pack of simulations
Definition: SM_StochasticOutputComponent.h:280
const tString & getOutputPath() const
return the output path
Definition: SM_StochasticOutputComponent.h:178
virtual void adimensionize(const SM_Material &material)=0
adimensionize the output compoent with material characteristic
void setPackedSimulationsIndex(const tInteger &i)
set packed simulations index
Definition: SM_StochasticOutputComponent.h:251
virtual ~SM_StochasticOutputComponent(void)
destroy
Definition: SM_StochasticOutputComponent.h:111
const int & getIndicesNumber() const
get the number of output components
Definition: SM_StochasticOutputComponent.h:227
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_StochasticOutputComponent.h:144
This class is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53