C++ main module for stochmagnet Package  1.0
SM_ItoSystem.h
Go to the documentation of this file.
1 #ifndef SM_ItoSystem_H
2 #define SM_ItoSystem_H
3 
4 #include "SM_TemplatedSystem.h"
5 
12 class SM_ItoSystem : public SM_TemplatedSystem<SM_ItoSystem> {
13 
14  //attributes
15 private :
16 
17 
18 
19 public:
20  // CONSTRUCTORS
23  SM_ItoSystem(void) {
24 
25  }
26 
27  // DESTRUCTORS
30  virtual ~SM_ItoSystem(void) {
31  }
32 
33 
34 public :
35 
36 
37 
38 public:
39 
40 
41 
47  }
48 
49 
50  //MEMORY
51 
65  virtual tMemSize getMemorySize() const {
66  return sizeof(*this)+getContentsMemorySize();
67  }
68 
69 
70 public:
71 
82  inline tBoolean computeTemplatedMuAtNextTimeStep(const tReal& dt,const tReal& epsilon_t,
83  const tIndex nParticles,const tDimension& dim,
84  const tReal *mu_t,
85  tReal *mu_tpdt) const {
86 
87 
88  //inverse of norm of Mu
89  tReal invNormMu=0;
90 
91  //iterator on point
92  tIndex p;
93 
94  //iterator on dimension
95  tDimension k;
96 
97  //iterator on mu(t+dt)
98  tReal *mu_tpdt_p,*mu_tpdt_i=mu_tpdt;
99 
100  //iterator on mu(t)
101  const tReal *mu_t_i=mu_t;
102 
103 
104  for (p=0;p<nParticles;p++) {
105  //mu(t+dt) at particule p
106  mu_tpdt_p=mu_tpdt_i;
107  //inverse of norm of mu
108  invNormMu=0;
109 
110  for (k=0;k<dim;k++) {
111  //mu(t+dt) at element i=(p,k)
112  (*mu_tpdt_i)+=(*mu_t_i);
113  //norm of mu(t+dt) at p
114  invNormMu+=(*mu_tpdt_i)*(*mu_tpdt_i);
115 
116  //next element
117  mu_tpdt_i++;
118  mu_t_i++;
119 
120  }
121  if (invNormMu>EPSILON<tReal>) {
122  //normalize mu(t+dt) at p
123  invNormMu=1./sqrt(invNormMu);
124  mu_tpdt_i=mu_tpdt_p;
125  for (k=0;k<3;k++) {
126  (*mu_tpdt_i)*=invNormMu;
127  mu_tpdt_i++;
128  }
129  }
130 
131  }
132 
133  //because of nomalization the norm of mu is never greater than 1
134  return true;
135  }
136 
137 };
138 
139 
140 #endif
tUCInt tDimension
Definition: CORE_StdPtrField.h:567
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:94
This class is a simulation of one trajectory class for Stoch Microm package based on Ito system.
Definition: SM_ItoSystem.h:12
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_ItoSystem.h:65
tBoolean computeTemplatedMuAtNextTimeStep(const tReal &dt, const tReal &epsilon_t, const tIndex nParticles, const tDimension &dim, const tReal *mu_t, tReal *mu_tpdt) const
compute mu at time step
Definition: SM_ItoSystem.h:82
static CORE_UniquePointer< SM_ItoSystem > New()
build a new instance of a system
Definition: SM_ItoSystem.h:45
virtual ~SM_ItoSystem(void)
destroy the class
Definition: SM_ItoSystem.h:30
SM_ItoSystem(void)
create a class
Definition: SM_ItoSystem.h:23
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_System.h:140
Definition: SM_TemplatedSystem.h:19
typename std::unique_ptr< T, CORE_Object::Delete > CORE_UniquePointer
Definition: sp.h:8
#define tIndex
Definition: types.h:157
#define tMemSize
Definition: types.h:166
#define tBoolean
Definition: types.h:151
#define tReal
Definition: types.h:137