C++ main module for emicrom Package  1.0
EMM_MatterField.h
Go to the documentation of this file.
1 #ifndef EMM_MatterIndexField_H
2 #define EMM_MatterIndexField_H
3 
4 #include "EMM_Object.h"
5 
6 #include "EMM_Array.h"
7 #include "EMM_RealArray.h"
8 #include "EMM_Matter.h"
9 
10 #include "CORE_MorseArray.h"
12 
14 
15 
17 
34 class EMM_MatterField : public virtual EMM_Object {
35 
37  // ATTRIBUTES
38 
39 public:
40  static const tUIndex NO_MATTER;
41 
42 private:
46 
50 
53  SV::EMM_Matter mMatters;
54 
55  //common adiemnsionized parameters for all matters
56  tReal mL;//refrence length
57  tReal mLe;//elastic reference length
58  tReal mMsat;//reference magnetization at saturation
59  tReal mTm;//characteristic magnetic time
60  tReal mTed;//adimensionized characteristic elastic time
61  tReal mEd;//adimensionized energy
62  tReal mRhoVs2;//adimensionized factor for elasticity tensor
63 
64 protected:
65  // METHODS
66 
67  // CONSTRUCTORS
68 
71  EMM_MatterField(void);
72 
73 
74  // DESTRUCTORS
75 
78  virtual ~EMM_MatterField(void);
79  // NEW method
80 
81 public:
85  inline static SP::EMM_MatterField New() {
86  SP::EMM_MatterField p(new EMM_MatterField(),
88  p->setThis(p);
89  return p;
90  };
91 
92 
93 
94 public:
95 
96  // OPERATOR
101  inline const tUIndex& operator[](const tUIndex& i) const {
102  return mMatterIndices[i];
103  }
108  inline tUIndex& operator[](const tUIndex& i) {
109  return mMatterIndices[i];
110  }
111 
112 
113 
114  // SET methods
115  // ===========
116 
120  inline void setElasticTensorAdimensionizedParameter(const tReal& rhoVs2) {
121  mRhoVs2=rhoVs2;
122  }
129  if (mRhoVs2==0) return EMM_Object::Mu0*mMsat*mMsat;
130  else return mRhoVs2;
131  }
134  inline void clear(){
135  mMatterIndices.setSize(0);
136  mMatters.clear();
137  }
138 
139 
140 
144  inline void setSize(const tUIndex& n){
145  mMatterIndices.setSize(n);
146  }
147 
151  inline void addMatter(const SP::EMM_Matter matter){
152  mMatters.add(matter);
153  }
154 
157  inline void initIndices() {
158  mMatterIndices.initArray(NO_MATTER);
159  }
160 
164  inline void setMatters(const SV::EMM_Matter& matters) {
165  mMatters=matters;
166  }
167 
168 
172  inline void setAnisotropyDirectionsFile(const tString& fn) {
173  mAnisotropyDirectionsFile=fn;
174  }
175 
176  // GET methods
177  // ==========
178 
179 
180 
181 public:
184  inline const tString& getAnisotropyDirectionsFile() const {
186  }
190  inline tUIndex getSize() const {
191  return mMatterIndices.getSize();
192  }
195  inline tBoolean isUniform() const {
196  return (mMatterIndices.getSize()==1);
197  }
198 
202  inline tUIndex getMattersNumber() const {
203  return mMatters.getSize();
204  }
205 
206 
210  inline const SV::EMM_Matter& getMatters() const {
211  return mMatters;
212  }
216  inline SV::EMM_Matter& getMatters() {
217  return mMatters;
218  }
219 
224  inline const EMM_Matter& getMatter(const tUIndex& i) const {
225  if (i>=mMatters.getSize()) throw EMM_Exception("EMM_MatterField::getMatter("+CORE_Integer::toString(i)+")",
226  "index out of bound");
227  const EMM_Matter* mat=mMatters.get(i);
228  if (mat==null) throw EMM_Exception("EMM_MatterField::getMatter("+CORE_Integer::toString(i)+")",
229  "null matter");
230  return *mat;
231  }
236  inline EMM_Matter& getMatter(const tUIndex& i) {
237  if (i>=mMatters.getSize()) throw EMM_Exception("EMM_MatterField::getMatter("+CORE_Integer::toString(i)+")",
238  "index out of bound");
239  EMM_Matter* mat=mMatters.get(i);
240  if (mat==null) throw EMM_Exception("EMM_MatterField::getMatter("+CORE_Integer::toString(i)+")",
241  "null matter");
242  return *mat;
243  }
244 
248  inline const EMM_UIndexArray& getMatterIndices() const {
249  return mMatterIndices;
250  }
251 
259  template<class T>
261 
271  template<class T>
273 
274 
275 
281  void adimensionize(const tReal& dmin,const tReal& dmax);
282 
287  return mMsat;
288  }
292  inline const tReal& getReferenceLength() const {
293  return mL;
294  }
298  inline const tReal& getReferenceElasticLength() const {
299  return mLe;
300  }
304  inline const tReal& getCharacteristicMagneticTime() const {
305  return mTm;
306  }
310  inline const tReal& getAdimensionizedElasticTime() const {
311  return mTed;
312  }
316  inline const tReal& getAdimensionizedEnergy() const {
317  return mEd;
318  }
319 
320 private:
325  vector<SP::EMM_Matter>::const_iterator iMatter=mMatters.begin();
326  tReal Msi,Ms=1.;
327  if (iMatter!=mMatters.end()) {
328  Ms=(*iMatter)->getMagnetizationAtSaturation();
329  iMatter++;
330  }
331  while (iMatter!=mMatters.end()) {
332  Msi=(*iMatter)->getMagnetizationAtSaturation();
333  //Ms=sup(Ms,Msi)
334  Ms=(Ms<Msi)?Msi:Ms;
335  iMatter++;
336  }
337  return Ms;
338  }
339 public:
345 
346 
350  SP::EMM_MagneticExcitationOperator createAnisotropyOperator() const;
351 
352 
353 
354 public:
355  // IO Methods
356  // ==========
357 
358 
369  tBoolean loadFromFile(const tString& fileName);
370 
371 
372 private:
383  tBoolean loadFromLOCFile(const tString& fileName);
384 
395  tBoolean loadFromANIFile(const tString& fileName);
396 
397 public:
408  static tBoolean saveToFile(const tString& fileName,
409  const EMM_UIndexArray& matterIndices);
410 
420  inline tBoolean saveToFile(const tString& fileName) const {
421  return saveToFile(fileName,mMatterIndices);
422  }
423 
424 
425 
426 public:
427 
430  virtual tString toString() const;
431 
432 
433 
434 };
435 
436 
437 #include "EMM_MatterField.hpp"
438 
439 #endif
const SV::EMM_Matter & getMatters() const
get the list of matters
Definition: EMM_MatterField.h:210
tUIndex getMattersNumber() const
get the number of matters
Definition: EMM_MatterField.h:202
SV::EMM_Matter & getMatters()
get the list of matters
Definition: EMM_MatterField.h:216
This class is a base class of E-MicromM core package.
Definition: EMM_Object.h:21
EMM_UIndexArray mMatterIndices
list of indices of matters element index -> index of matter in mMatters list (NO_MATTER if no matter)...
Definition: EMM_MatterField.h:49
const tUIndex & getSize() const
return the size of the array for reading
Definition: CORE_Array.h:1018
static const tReal Mu0
Definition: EMM_Object.h:28
EMM_Matter & getMatter(const tUIndex &i)
get the matter at index
Definition: EMM_MatterField.h:236
void setElasticTensorAdimensionizedParameter(const tReal &rhoVs2)
set the adiemensionized parameter for the elastic tensor
Definition: EMM_MatterField.h:120
const tReal & getReferenceMagnetizationAtSaturation() const
get the magnetization at saturation of reference
Definition: EMM_MatterField.h:286
tReal mRhoVs2
Definition: EMM_MatterField.h:62
const tReal & getAdimensionizedEnergy() const
get the adimensionized energy
Definition: EMM_MatterField.h:316
tBoolean getMatterParameterDistribution(const tFlag &k, EMM_Array< T > &vs) const
get the values of a parameter of matters in a field for each cell
Definition: EMM_MatterField.hpp:7
const tReal & getReferenceLength() const
get the reference length
Definition: EMM_MatterField.h:292
const tReal & getCharacteristicMagneticTime() const
get the characteristic magnetic time
Definition: EMM_MatterField.h:304
void initIndices()
init indices to NO_MATTER
Definition: EMM_MatterField.h:157
This class describes a general morse array of size N. A morse array is composed by.
Definition: CORE_MorseArray.h:31
void addMatter(const SP::EMM_Matter matter)
add a matter
Definition: EMM_MatterField.h:151
tUIndex getSize() const
get the size of the field of indices
Definition: EMM_MatterField.h:190
tReal computeReferenceMagnetizationAtSaturation() const
get the reference magnetization at saturation
Definition: EMM_MatterField.h:324
const tString & getAnisotropyDirectionsFile() const
set the anisotropy dirtection file
Definition: EMM_MatterField.h:184
tBoolean loadFromFile(const tString &fileName)
load the direction of anisotropy and the index of matters for cells
Definition: EMM_MatterField.cpp:144
#define tBoolean
Definition: types.h:139
tBoolean saveToFile(const tString &fileName) const
write the matters index into a file
Definition: EMM_MatterField.h:420
DEFINE_SPTR(EMM_MagneticExcitationOperator)
void setAnisotropyDirectionsFile(const tString &fn)
set the anisotropy dirtection file
Definition: EMM_MatterField.h:172
tReal mLe
Definition: EMM_MatterField.h:57
void setSize(const tUIndex &n)
set the size
Definition: CORE_Array.h:292
virtual ~EMM_MatterField(void)
destroy
Definition: EMM_MatterField.cpp:30
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:106
SP_OBJECT(EMM_MatterField)
#define null
Definition: types.h:144
void setMatters(const SV::EMM_Matter &matters)
set the matters list
Definition: EMM_MatterField.h:164
tUIndex & operator[](const tUIndex &i)
get the matter index in the matters list of the matter at cell i
Definition: EMM_MatterField.h:108
tReal mMsat
Definition: EMM_MatterField.h:58
tReal getElasticTensorAdimensionizedParameter() const
get the adiemensionized parameter for the elastic tensor
Definition: EMM_MatterField.h:128
This class describes the field of directions of anisotropy This fields contains 2 arrays : ...
Definition: EMM_AnisotropyDirectionsField.h:35
This class describes a matter for E-MicroM package.
Definition: EMM_Matter.h:34
static SP::EMM_MatterField New()
create a shared pointer to the field of anisotropy direction
Definition: EMM_MatterField.h:85
tBoolean isUniform() const
return true if the field is uniform
Definition: EMM_MatterField.h:195
void setSize(const tUIndex &n)
set the size of matter index
Definition: EMM_MatterField.h:144
tBoolean computeAnisotropyDirectionsField(EMM_AnisotropyDirectionsField &dirF) const
compute the anisotropy directions field
Definition: EMM_MatterField.cpp:32
const EMM_UIndexArray & getMatterIndices() const
get the array of the index of the matter for all cell
Definition: EMM_MatterField.h:248
This class describes the field of matters.
Definition: EMM_MatterField.h:34
virtual tString toString() const
return a string representation
Definition: EMM_MatterField.cpp:464
const tUIndex & operator[](const tUIndex &i) const
get the matter index in the matters list of the matter at cell i
Definition: EMM_MatterField.h:101
tReal mTm
Definition: EMM_MatterField.h:59
SV::EMM_Matter mMatters
list of matters
Definition: EMM_MatterField.h:53
const EMM_Matter & getMatter(const tUIndex &i) const
get the matter at index
Definition: EMM_MatterField.h:224
#define tUIndex
Definition: types.h:126
SP::EMM_MagneticExcitationOperator createAnisotropyOperator() const
create the anisotropy operator corresponding to the crytal type of the field
Definition: EMM_MatterField.cpp:102
tReal mEd
Definition: EMM_MatterField.h:61
void clear()
clear matters
Definition: EMM_MatterField.h:134
#define tString
Definition: types.h:135
tReal mL
Definition: EMM_MatterField.h:56
const tReal & getReferenceElasticLength() const
get the reference elastic length
Definition: EMM_MatterField.h:298
this class describes the exceptions raised for E-MicromM package
Definition: EMM_Exception.h:14
EMM_MatterField(void)
create
Definition: EMM_MatterField.cpp:15
tString mAnisotropyDirectionsFile
the file descrbing the directions of anisotropy
Definition: EMM_MatterField.h:45
This class is an operator of a E-MicromM package wich compute a magnetic excitation operator...
Definition: EMM_MagneticExcitationOperator.h:15
tBoolean loadFromLOCFile(const tString &fileName)
load the matter index per cell in a .loc file of the form comment
Definition: EMM_MatterField.cpp:159
static tBoolean saveToFile(const tString &fileName, const EMM_UIndexArray &matterIndices)
write the matters index into a file
Definition: EMM_MatterField.cpp:436
#define tReal
Definition: types.h:118
void adimensionize(const tReal &dmin, const tReal &dmax)
adimensionize all the matters
Definition: EMM_MatterField.cpp:49
tReal mTed
Definition: EMM_MatterField.h:60
static const tUIndex NO_MATTER
Definition: EMM_MatterField.h:40
tBoolean loadFromANIFile(const tString &fileName)
load the matter index per cell in a .ani file of the form comment
Definition: EMM_MatterField.cpp:288
void initArray(const Q &f)
init the array to uniform value
Definition: CORE_Array.h:316
const tReal & getAdimensionizedElasticTime() const
get the adimenionized elastic time
Definition: EMM_MatterField.h:310
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74