C++ mpi module for stochmagnet_main Package
SM_Operator.h
1 #ifndef SM_Operator_H
2 #define SM_Operator_H
3 
4 #include "SM_Object.h"
5 
6 
7 //system class
8 class SM_System;
9 
10 //network class
11 #include "SM_Network.h"
12 
13 //material class
14 #include "SM_Material.h"
15 
16 //slice operator
17 #include "SM_SliceOperator.h"
18 
19 //linear slice operator
20 #include "SM_LinearSliceOperator.h"
21 
43 class SM_Operator : public virtual SM_Object {
44 
45  //attributes
46 private :
47 
48 
49  //association
50  CORE_UniquePointer<SM_SliceOperator> mSliceOperator;
51 
52 
53 protected:
54  // CONSTRUCTORS
57  SM_Operator(void) {
58 
59  }
60 
61  // DESTRUCTORS
64  virtual ~SM_Operator(void) {
65  }
66 
67 public :
68 
69  //Instance building
70  //=================
71 
74  virtual CORE_UniquePointer<SM_Operator> NewInstance() const=0;
75 
76  //MEMORY
77 
91  virtual tMemSize getMemorySize() const {
92  return sizeof(*this)+getContentsMemorySize();
93  }
102  virtual tMemSize getContentsMemorySize() const {
103  tMemSize mem=SM_Object::getContentsMemorySize();
104  return mem;
105  }
106 
107 
108 
109  //SET & GET
110  //=========
111 protected:
112 
113 
114 
118  inline void setSliceOperator(CORE_UniquePointer<SM_SliceOperator> sliceOperator) {
119  mSliceOperator=std::move(sliceOperator);
120  }
121 
122 public:
123 
128  return *mSliceOperator.get();
129  }
133  inline const SM_SliceOperator& getSliceOperator() const {
134  return *mSliceOperator.get();
135  }
136 
140  virtual void copy(const SM_Operator& op) {
142  }
143 
147  inline tString getName() const {
148  return getSliceOperator().getName();
149  }
150 
153  inline tBoolean isLinear() const {
154  return (dynamic_cast<const SM_LinearSliceOperator*>(&getSliceOperator())!=null);
155  }
156 
160  inline void adimensionize(const tReal& cH) {
161  mSliceOperator->adimensionize(cH);
162  }
163 
168  inline void discretize(const SM_Network& network, const SM_Material& material) {
169  mSliceOperator->discretize(network,material);
170  }
171 
172 
173  //state update
174  //============
181  inline void updateState(const tIndex& timeIndex,
182  const SM_Network& network,
183  const SM_Material& material,
184  const SM_RealField& S) {
185  mSliceOperator->updateState(timeIndex,network,material,S);
186  }
187 
188  //Fields computation
189  //==================
190 
191 
192 
203  virtual void computeMagneticField(const tIndex& timeIndex,
204  const SM_Network& network,
205  const SM_Material& material,
206  const SM_RealField& S,
207  const tBoolean& alpha,
208  SM_RealField& H) const=0;
209 
210  //Spin energy computation
211  //=======================
212 
221  virtual tReal computeSpinEnergy(const tIndex& i,
222  const tIndex& timeIndex,
223  const SM_Network& network,
224  const SM_Material& material,
225  const SM_RealField& S) const {
226  return mSliceOperator->computeSpinEnergy(i,timeIndex,network,material,S);
227  }
228 
229 
230  //Total energy computation
231  //========================
232 
233 
240  inline tReal computeEnergy(const SM_Network& network,
241  const SM_Material& material,
242  const SM_RealField& S) const {
243  return computeEnergy(0,network,material,S);
244  }
245 
253  virtual tReal computeEnergy(const tIndex& timeIndex,
254  const SM_Network& network,
255  const SM_Material& material,
256  const SM_RealField& S) const=0;
257 
265  virtual tReal computeEnergy(const SM_Network& network,
266  const SM_Material& material,
267  const SM_RealField& S,
268  const SM_RealField& H) const=0;
269 
270 
271 
274  virtual tString toString() const override {
275  std::stringstream ss;
276  ss<<getIdentityString();
277  ss<<" slice Operator:"<<mSliceOperator->toString()<<"\n";
278  return ss.str();
279 
280  }
281 };
282 
283 
284 #endif
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
tString getIdentityString() const
retrun the string identification of the class
Definition: CORE_Object.h:321
This class is describes a linear operator interface in a slice of particles of a network.
Definition: SM_LinearSliceOperator.h:17
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
This class is describes a network composed by.
Definition: SM_Network.h:66
This class is a base class for Stoch Microm package.
Definition: SM_Object.h:36
This class is describes an operator.
Definition: SM_Operator.h:43
void discretize(const SM_Network &network, const SM_Material &material)
discretize the operator on the network
Definition: SM_Operator.h:168
const SM_SliceOperator & getSliceOperator() const
get the slice operator for reading
Definition: SM_Operator.h:133
void updateState(const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S)
update the stae of the operator at time index
Definition: SM_Operator.h:181
virtual tReal computeEnergy(const SM_Network &network, const SM_Material &material, const SM_RealField &S, const SM_RealField &H) const =0
compute the energy as linear by virtual method
tBoolean isLinear() const
Definition: SM_Operator.h:153
tString getName() const
get the name of the operator
Definition: SM_Operator.h:147
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_Operator.h:91
tReal computeEnergy(const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
compute the energy by virtual method
Definition: SM_Operator.h:240
virtual void computeMagneticField(const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S, const tBoolean &alpha, SM_RealField &H) const =0
compute the magnetic field by virtual method
virtual tString toString() const override
return string representaton of the operator
Definition: SM_Operator.h:274
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: SM_Operator.h:102
virtual void copy(const SM_Operator &op)
copy
Definition: SM_Operator.h:140
SM_SliceOperator & getSliceOperator()
get the slice operator for writing
Definition: SM_Operator.h:127
virtual CORE_UniquePointer< SM_Operator > NewInstance() const =0
create a new instance of this
void adimensionize(const tReal &cH)
adimensionize operator with characteric field value in J
Definition: SM_Operator.h:160
SM_Operator(void)
create a network class
Definition: SM_Operator.h:57
virtual tReal computeSpinEnergy(const tIndex &i, const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
compute the spin energy by virtual method
Definition: SM_Operator.h:221
virtual ~SM_Operator(void)
destroy
Definition: SM_Operator.h:64
void setSliceOperator(CORE_UniquePointer< SM_SliceOperator > sliceOperator)
set the slice operator
Definition: SM_Operator.h:118
virtual tReal computeEnergy(const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const =0
compute the energy by virtual method
This class is describes an operator operating on slice of particles of a network SM_Network.
Definition: SM_SliceOperator.h:32
const tString & getName() const
return the operator name
Definition: SM_SliceOperator.h:119
virtual void copy(const SM_SliceOperator &op)
copy
Definition: SM_SliceOperator.h:129
This class is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53