C++ main module for stochmagnet Package  1.0
SM_Operator.h
Go to the documentation of this file.
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 //network class
10 #include "SM_Network.h"
11 
18 class SM_Operator : public SM_Object {
19 
20  //attributes
21 private :
22 
23 
25 
26  //association
27 
28 
29 
30 protected:
31  // CONSTRUCTORS
34  SM_Operator(void) {
35  mName="";
36  }
37 
38  // DESTRUCTORS
41  virtual ~SM_Operator(void) {
42  }
43 
44 public :
45 
46  //Instance building
47  //=================
48 
53 
54  //MEMORY
55 
69  virtual tMemSize getMemorySize() const {
70  return sizeof(*this)+getContentsMemorySize();
71  }
80  virtual tMemSize getContentsMemorySize() const {
82  mem+=mName.size();
83  return mem;
84  }
85 
86 
87 
88  //SET & GET
89  //=========
90 protected:
91 
95  inline void setName(const tString& name) {
96  mName=name;
97  }
98 public:
102  inline const tString& getName() const {
103  return mName;
104  }
105 
106 
107 public:
108 
112  virtual void copy(const SM_Operator& op) {
113  mName=op.getName();
114  }
118  virtual void discretize(const SM_System& system) {
119 
120  }
121 
128  virtual void computeMagneticField(const tIndex& t,
129  const SM_Network& network,
130  const tReal *mu,
131  tReal *B) const=0;
139  virtual void computeMagneticFieldAndEnergy(const tIndex& t,
140  const SM_Network& network,
141  const tReal *mu,
142  tReal *B,
143  tReal& E) const=0;
144 
152  inline void computeMagneticField(const tIndex& t,
153  const SM_Network& network,
154  const SM_RealField& Mu,
155  SM_RealField& B) const {
156  const tIndex& N=Mu.getElementsNumber();
157  //set the output field dimension
158  B.setElementsNumber(N);
159  B=0;
160  computeMagneticField(t,network,&Mu[0],&B[0]);
161  }
162 
169  inline tReal computeEnergy(const tIndex& t,
170  const SM_Network& network,
171  const SM_RealField& mu) const {
172  return computeEnergy(t,network,&mu[0]);
173  }
174 
181  virtual tReal computeEnergy(const tIndex& t,
182  const SM_Network& network,
183  const tReal *mu) const=0;
184 
191  virtual tReal computeEnergy(const SM_Network& network,
192  const tReal *mu,
193  const tReal *H) const {
194  //get the size of the network
195  tIndex i,N=network.getParticlesNumber()*network.getDimension();
196  tReal E=0;
197  const tReal *mu_i=mu;
198  const tReal *H_i=H;
199  for (i=0;i<N;i++) {
200  E-=(*mu_i)*(*H_i);
201  mu_i++;
202  H_i++;
203  }
204  return E*0.5;
205  }
206 };
207 
208 
209 #endif
tIndex getElementsNumber() const
return the number values of the container
Definition: CORE_Field.h:118
void setElementsNumber(const tInteger &n)
set the number of element of the container
Definition: CORE_Field.h:112
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:259
This class is describes a a network.
Definition: SM_Network.h:18
tDimension getDimension() const
return the dimension
Definition: SM_Network.h:133
tInteger getParticlesNumber() const
return the particles number
Definition: SM_Network.h:146
This class is a base class for Stoch Microm package.
Definition: SM_Object.h:19
This class is describes an operator.
Definition: SM_Operator.h:18
tString mName
Definition: SM_Operator.h:24
tReal computeEnergy(const tIndex &t, const SM_Network &network, const SM_RealField &mu) const
compute the energy at time t by virtual method
Definition: SM_Operator.h:169
void setName(const tString &name)
set the name
Definition: SM_Operator.h:95
virtual tReal computeEnergy(const SM_Network &network, const tReal *mu, const tReal *H) const
compute the energy
Definition: SM_Operator.h:191
virtual void discretize(const SM_System &system)
discretize the operator : do nothing by default
Definition: SM_Operator.h:118
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_Operator.h:69
void computeMagneticField(const tIndex &t, const SM_Network &network, const SM_RealField &Mu, SM_RealField &B) const
compute the magnetic field at time t by virtual method
Definition: SM_Operator.h:152
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: SM_Operator.h:80
virtual void copy(const SM_Operator &op)
copy
Definition: SM_Operator.h:112
virtual CORE_UniquePointer< SM_Operator > NewInstance() const =0
create a New instance of this @retrun an unique pointer to the instance
virtual tReal computeEnergy(const tIndex &t, const SM_Network &network, const tReal *mu) const =0
compute the energy at time t by virtual method
const tString & getName() const
return the operator name
Definition: SM_Operator.h:102
virtual void computeMagneticFieldAndEnergy(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B, tReal &E) const =0
compute the magnetic field by virtual method
virtual void computeMagneticField(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B) const =0
compute the magnetic field by virtual method
SM_Operator(void)
create a network class
Definition: SM_Operator.h:34
virtual ~SM_Operator(void)
destroy
Definition: SM_Operator.h:41
This class is a simulation of one trajectory class for Stoch Microm package.
Definition: SM_System.h:51
typename std::unique_ptr< T, CORE_Object::Delete > CORE_UniquePointer
Definition: sp.h:8
#define tIndex
Definition: types.h:157
#define tString
Definition: types.h:147
#define tMemSize
Definition: types.h:166
#define tReal
Definition: types.h:137