C++ mpi module for stochmagnet_main Package
SM_UniaxialAnisotropyOperator.h
1 #ifndef SM_UniaxialAnisotropyOperator_H
2 #define SM_UniaxialAnisotropyOperator_H
3 
4 //base classes
5 #include "SM_AnisotropyOperator.h"
6 #include "SM_LinearSliceOperator.h"
7 
8 //network class
9 #include "SM_Network.h"
10 
11 
12 
13 
14 
40 class SM_UniaxialAnisotropyOperator : public SM_AnisotropyOperator<SM_UniaxialAnisotropyOperator>,public SM_LinearSliceOperator {
41 
42  //attributes
43 private :
44 
45 
46 protected:
47  // CONSTRUCTORS
51  setName("UniaxialAnisotropy");
52  }
53 
54  // DESTRUCTORS
58  }
59 
60 public :
61 
62  //Instance building
63  //=================
64 
68  inline static CORE_UniquePointer<SM_UniaxialAnisotropyOperator> New() {
69  return CORE_UniquePointer<SM_UniaxialAnisotropyOperator>(new SM_UniaxialAnisotropyOperator(),
71  }
72 
76  virtual CORE_UniquePointer<SM_SliceOperator> NewInstance() const override {
77  return New();
78  }
79 public:
80 
81  //MEMORY
82 
96  virtual tMemSize getMemorySize() const {
97  return sizeof(*this)+getContentsMemorySize();
98  }
99 
100 
109  virtual tMemSize getContentsMemorySize() const {
112  return mem;
113  }
114 
124  inline void computePhi(const tReal *U,const tReal *eU,
125  const tReal*S,const tReal *eS,
126  tReal& phi,tReal& W) const {
127  //phi=<S,U>
128  phi=0;
129  while (S!=eS) {
130  phi+=(*S)*(*U);
131  S++;
132  U++;
133  }
134 
135  //phi=-<S,U>^2
136  phi*=phi;
137  phi*=-1;
138  }
139 
151  inline void computePhiDerivatives(const tReal *U,const tReal *eU,
152  const tReal*S,const tReal* eS,
153  tReal& phi,std::array<tReal,SM_Constants::DIM>& gradPhi,
154  tReal& W,tReal& W3) const {
155  //phi=<S,U>
156  phi=0;
157  while (S!=eS) {
158  phi+=(*S)*(*U);
159  S++;
160  U++;
161  }
162 
163  //restore U pointer
165 
166  //gradPhi=-2<S,U>.U
167  for(auto& gradPhi_k:gradPhi) {
168  gradPhi_k=-2*(*U)*phi;
169  U++;
170  }
171 
172 
173  //phi=-<S,U>^2
174  phi*=phi;
175  phi*=-1;
176  }
177 
178 
179 
180 
181 };
182 
183 
184 #endif
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
This class is describes the general anisotropy operatoor.
Definition: SM_AnisotropyOperator.h:32
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
This class is describes a linear operator interface in a slice of particles of a network.
Definition: SM_LinearSliceOperator.h:17
void setName(const tString &name)
set the name
Definition: SM_SliceOperator.h:112
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: SM_SliceOperator.h:97
This class is describes the uniaxial anisotropy.
Definition: SM_UniaxialAnisotropyOperator.h:40
static CORE_UniquePointer< SM_UniaxialAnisotropyOperator > New()
build a new instance of the operator
Definition: SM_UniaxialAnisotropyOperator.h:68
virtual ~SM_UniaxialAnisotropyOperator(void)
destroy
Definition: SM_UniaxialAnisotropyOperator.h:57
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_UniaxialAnisotropyOperator.h:96
void computePhi(const tReal *U, const tReal *eU, const tReal *S, const tReal *eS, tReal &phi, tReal &W) const
compute the function
Definition: SM_UniaxialAnisotropyOperator.h:124
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_UniaxialAnisotropyOperator.h:109
virtual CORE_UniquePointer< SM_SliceOperator > NewInstance() const override
create a New instance of this
Definition: SM_UniaxialAnisotropyOperator.h:76
void computePhiDerivatives(const tReal *U, const tReal *eU, const tReal *S, const tReal *eS, tReal &phi, std::array< tReal, SM_Constants::DIM > &gradPhi, tReal &W, tReal &W3) const
compute the function
Definition: SM_UniaxialAnisotropyOperator.h:151
SM_UniaxialAnisotropyOperator(void)
create a network class
Definition: SM_UniaxialAnisotropyOperator.h:50