C++ mpi module for stochmagnet_main Package
SM_MacroCellsMagnetizationField.h
1 #ifndef SM_MacroCellsMagnetizationField_H
2 #define SM_MacroCellsMagnetizationField_H
3 
4 //base classes
5 #include "SM_Object.h"
6 
7 //macro cells network header
8 #include "SM_MacroCellsNetwork.h"
9 
10 //storage matrix header
11 #include "SM_PackedBlockSymmetricMatrix.h"
12 
13 
24 
25 
26 public:
27 
28 private :
29 
30  //type class
31  typedef SM_Object SuperClass;
33 
34  //single attributes
35  //-----------------
36 
37 
38  //index of the step when M is last computed
39  tIndex mMStepIndex;
40 
41 
42 
43 
44  //magnetisation field M at each macro cell at local index m of its SM_MacroCellsNetwork
45  SM_RealField mM;
46 
47 
48 
49  //multiple associations
50  //---------------------
51 
52 
53 
54 protected:
55  // CONSTRUCTORS
59  mMStepIndex=functions_numeric::getMax<tIndex>();
60 
61  }
62 
63  // DESTRUCTORS
67  }
68 
69 
70 public :
71 
72  //Instance building
73  //=================
74 
75 
89  virtual tMemSize getMemorySize() const {
90  return sizeof(*this)+this->getContentsMemorySize();
91  }
92 
101  virtual tMemSize getContentsMemorySize() const {
102  tMemSize mem=SuperClass::getContentsMemorySize();
103  mem+=mM.getContentsMemorySize();
104  return mem;
105  }
106 public:
107 
108 
112  virtual CORE_UniquePointer<SM_MacroCellsMagnetizationField> newInstance() const=0;
113 
114 public:
115 
116 
117  //discretize the field
118  //======================
119 public:
124  virtual void discretize(const SM_Material& material,const SM_MacroCellsNetwork& network) {
126  mM=0;
127  }
128 
129 
130 public:
131 
132 
133 
134 
135  //MAGNETIZATION Field
136  //===================
137 
141  inline const SM_RealField& getField() const {
142  return mM;
143  }
144 
145 
148  inline SM_RealField& getField() {
149  return mM;
150  }
151 
152 
155  inline const tIndex& getStepIndex() const {
156  return mMStepIndex;
157  }
158 protected:
161  inline void setStepIndex(const tIndex& index) {
162  mMStepIndex=index;
163  }
164 
165 public:
166 
173  inline void computeField(const tIndex& stepIndex,
174  const SM_Material& material,
175  const SM_MacroCellsNetwork& network,
176  const SM_RealField& S) {
177  setStepIndex(stepIndex);
178  computeField(material,network,S,mM);
179  }
180 
181 
190  virtual void computeField(const SM_Material& material,
191  const SM_MacroCellsNetwork& network,
192  const SM_RealField& S,
193  SM_RealField& M);
194 
195 protected:
203  void computeFieldSlice(const tReal& mu_s,
204  const tIndex& n,
205  const tInteger* iMacroCellsList,
206  const tReal *iS,
207  tReal* vM) const;
216  void computeFieldSlice(const tReal& mu_s,
217  const tInteger& n,
218  const tInteger* iParticlesMCList,
219  const tInteger *iParticlesMCListOffset,
220  const tReal *iS,
221  tReal* vM) const;
222 public:
223 
224  // String representation
225  // =======================
226 public:
227 
228 
231  virtual tString toString() const override {
232  std::stringstream ret;
233  ret<<SuperClass::toString()<<"\n";
234  ret<<"M:";
235  tIndex s=mM.getElementsNumber()/10;
236  s=(s==0)?1:s;
237  for(tIndex i=0;i<mM.getElementsNumber();i+=s) {
238  ret<<"\t ["<<i<<"]="<<functions_array::toString(SM_Constants::DIM,mM(i))<<"\n";
239  }
240  return ret.str();
241  }
242 
243 public:
244 
245 
246 
247 };
248 
249 
250 #endif
virtual tMemSize getContentsMemorySize() const override
return the memory size of the included associations
Definition: CORE_Field.h:102
tIndex getElementsNumber() const
return the number values of the container
Definition: CORE_Field.h:135
void setElementsNumber(const tInteger &n)
set the number of element of the container
Definition: CORE_Field.h:121
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
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
This class is describes a Magnetization field.
Definition: SM_MacroCellsMagnetizationField.h:23
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_MacroCellsMagnetizationField.h:101
const tIndex & getStepIndex() const
return the step of the last magnetization field computed
Definition: SM_MacroCellsMagnetizationField.h:155
virtual ~SM_MacroCellsMagnetizationField(void)
destroy
Definition: SM_MacroCellsMagnetizationField.h:66
SM_MacroCellsMagnetizationField(void)
create a network class
Definition: SM_MacroCellsMagnetizationField.h:58
virtual void discretize(const SM_Material &material, const SM_MacroCellsNetwork &network)
discretize the field It does :
Definition: SM_MacroCellsMagnetizationField.h:124
void setStepIndex(const tIndex &index)
set the step of the last magnetization field computed
Definition: SM_MacroCellsMagnetizationField.h:161
void computeField(const tIndex &stepIndex, const SM_Material &material, const SM_MacroCellsNetwork &network, const SM_RealField &S)
compute the magnetization field from S
Definition: SM_MacroCellsMagnetizationField.h:173
virtual tString toString() const override
return string representaton of the operator
Definition: SM_MacroCellsMagnetizationField.h:231
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_MacroCellsMagnetizationField.h:89
const SM_RealField & getField() const
get magnetization field on macro cells
Definition: SM_MacroCellsMagnetizationField.h:141
void computeFieldSlice(const tReal &mu_s, const tIndex &n, const tInteger *iMacroCellsList, const tReal *iS, tReal *vM) const
computes the magnetization field M[0,nMCCells[ from S defined on network
Definition: SM_MacroCellsMagnetizationField.cpp:47
virtual CORE_UniquePointer< SM_MacroCellsMagnetizationField > newInstance() const =0
create a New instance of this
SM_RealField & getField()
get the magnetization field for writing
Definition: SM_MacroCellsMagnetizationField.h:148
This class is describes a macro cell network.
Definition: SM_MacroCellsNetwork.h:25
const tInteger & getMacroCellsNumber() const
get the number of macro cells
Definition: SM_MacroCellsNetwork.h:188
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