C++ mpi module for stochmagnet_main Package
SM_PlanarAnisotropyOperator.h
1 #ifndef SM_PlanarAnisotropyOperator_H
2 #define SM_PlanarAnisotropyOperator_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 
32 class SM_PlanarAnisotropyOperator : public SM_AnisotropyOperator<SM_PlanarAnisotropyOperator>,public SM_LinearSliceOperator {
33 
34  //attributes
35 private :
36 
37 
38 protected:
39  // CONSTRUCTORS
43  setName("PlanarAnisotropy");
44  }
45 
46  // DESTRUCTORS
50  }
51 
52 public :
53 
54  //Instance building
55  //=================
56 
60  inline static CORE_UniquePointer<SM_PlanarAnisotropyOperator> New() {
61  return CORE_UniquePointer<SM_PlanarAnisotropyOperator>(new SM_PlanarAnisotropyOperator(),
63  }
64 
68  virtual CORE_UniquePointer<SM_SliceOperator> NewInstance() const override {
69  return New();
70  }
71 public:
72 
73  //MEMORY
74 
88  virtual tMemSize getMemorySize() const {
89  return sizeof(*this)+getContentsMemorySize();
90  }
91 
100  virtual tMemSize getContentsMemorySize() const {
103  return mem;
104  }
105 
115  inline void computePhi(const tReal *U,const tReal *eU,
116  const tReal *S,const tReal * eS,
117  tReal& phi,tReal& W) const {
118  //phi=<S,U>
119  phi=0;
120  while (S!=eS) {
121  phi+=(*S)*(*U);
122  S++;
123  U++;
124  }
125 
126 
127  //phi=<S,U>^2
128  phi*=phi;
129  }
130 
131 
143  inline void computePhiDerivatives(const tReal *U,const tReal *eU,
144  const tReal*S,const tReal* eS,
145  tReal& phi,std::array<tReal,SM_Constants::DIM>& gradPhi,
146  tReal& W,tReal& W3) const {
147  //phi=<S,U>
148  phi=0;
149  while (S!=eS) {
150  phi+=(*S)*(*U);
151  S++;
152  U++;
153  }
154 
155  //S++;
156  //U++;
157  //restore U
159 
160 
161  //gradPhi=2<S,U>.U
162  for(auto& gradPhi_k:gradPhi) {
163  gradPhi_k=2*(*U)*phi;
164  U++;
165  }
166 
167 
168  //phi=<S,U>^2
169  phi*=phi;
170 
171 
172  }
173 
174 
175 
176 
177 };
178 
179 
180 #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
This class is describes the uniaxial anisotropy.
Definition: SM_PlanarAnisotropyOperator.h:32
SM_PlanarAnisotropyOperator(void)
create a network class
Definition: SM_PlanarAnisotropyOperator.h:42
virtual ~SM_PlanarAnisotropyOperator(void)
destroy
Definition: SM_PlanarAnisotropyOperator.h:49
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_PlanarAnisotropyOperator.h:143
static CORE_UniquePointer< SM_PlanarAnisotropyOperator > New()
build a new instance of the operator
Definition: SM_PlanarAnisotropyOperator.h:60
void computePhi(const tReal *U, const tReal *eU, const tReal *S, const tReal *eS, tReal &phi, tReal &W) const
compute the function
Definition: SM_PlanarAnisotropyOperator.h:115
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_PlanarAnisotropyOperator.h:100
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_PlanarAnisotropyOperator.h:88
virtual CORE_UniquePointer< SM_SliceOperator > NewInstance() const override
create a New instance of this
Definition: SM_PlanarAnisotropyOperator.h:68
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