C++ main module for emicrom Package  1.0
EMMG_RealField.h
Go to the documentation of this file.
1 #ifndef EMMG_RealField_H
2 #define EMMG_RealField_H
3 
4 #include "EMM_RealField.h"
5 
6 #include "EMM_RealArray.h"
7 
17 class EMMG_RealField : public EMM_RealField {
18 
20  // ATTRIBUTES
21 
22 public:
23 
24 
25 
26 private:
27 
29 
30 
31 public:
32  // METHODS
33 
34  // CONSTRUCTORS
35 
39 
40 
41 
42  // DESTRUCTORS
43 
44 
47  virtual ~EMMG_RealField(void);
48 
52  static inline SP::EMMG_RealField New() {
53  SP::EMMG_RealField p(new EMMG_RealField(),
55  p->setThis(p);
56  return p;
57  }
58 
62  virtual SP::EMM_RealField NewInstance() const {
63  SP::EMMG_RealField p=New();
64  p->setDimension(getDimension());
65  p->setSize(getSize());
66  return p;
67  }
68 private:
69 
70 
71 
72 public:
73 
79  inline tReal& operator()(const tUIndex& i,const tDimension& d) {
80  return mArray[getDimension()*i+d];
81  }
87  inline const tReal& operator()(const tUIndex& i,const tDimension& d) const {
88  return mArray[getDimension()*i+d];
89  }
94  inline tReal& operator[](const tUIndex& i) {
95  return mArray[i];
96  }
101  inline const tReal& operator[](const tUIndex& i) const {
102  return mArray[i];
103  }
104 
105 
106  // SET methods
110  virtual void setSize(const tUIndex& s) {
111  mArray.setSize(s*getDimension());
112  }
116  virtual void copy(const EMM_RealField& f);
117 
122  virtual void initField(const tReal& alpha,const EMM_RealField& f);
123 
130  virtual void initField(const EMM_RealArray& alpha,const EMM_RealField& f);
131 
132 
140  virtual void initField(const tUIndex& from,const tUIndex& to,const tReal& fx,const tReal& fy,const tReal& fz);
141 
148  virtual void initField(const tUIndex& from,const tUIndex& to,const EMM_RealField& C);
152  virtual void initField(const tReal& f);
153 
157  virtual tBoolean initField(const tString& fileName) {
158  return loadFromFile(fileName);
159  }
168  virtual void initField(const tReal& s,const EMM_RealArray& alpha,const tSInt& p,const EMM_RealField& f);
169 
174  virtual void unmagnetized(const EMM_Grid3D& mesh);
175 
182  virtual void setValue(const tUIndex& i,const tReal& v) {
183  (*this)[i]=v;
184  }
191  virtual void setValue(const tUIndex& i,const tReal v[]) {
192  const tDimension& dim=getDimension();
193  tReal *vs=&(*this)[i*dim];
194  const tReal *vi=v;
195  for (tDimension k=0;k<dim;k++) {
196  *vs=*vi;
197  vs++;
198  vi++;
199  }
200  }
201 
204  virtual void fitToSize() {
205  mArray.fitToSize();
206  }
209  virtual void setFieldByReference(const tUIndex& from,const tUIndex& to, EMM_RealField& X);
210 
216  virtual void wedge(const EMM_RealField& X,
217  EMM_RealField& Y) const;
218 
225  virtual void wedge(const tReal& alpha,
226  const EMM_RealField& X,
227  EMM_RealField& Y) const;
228 
229 
230 
231 
238  virtual tReal dot(const EMM_RealField& F,const EMM_RealField& G) const;
239 
247  virtual tReal dot(const EMM_RealArray& sigma, const EMM_RealField& F,const EMM_RealField& G) const;
254  virtual tReal dot(const tUInt& q,
255  const EMM_RealField& F,const EMM_RealField& G) const;
263  virtual tReal dot( const tUInt& q,
264  const EMM_RealArray& w,
265  const EMM_RealField& F,const EMM_RealField& G) const;
266 
274  virtual void dotArray( const EMM_RealArray& w,
275  const EMM_RealField& F,const EMM_RealField& G,
276  EMM_RealArray& R) const;
284  virtual void dotArray( const tUInt& q,
285  const EMM_RealField& F,const EMM_RealField& G,
286  EMM_RealArray& R) const;
287 
294  virtual void dotArray(const EMM_RealField& F,const EMM_RealField& G,
295  EMM_RealArray& R) const;
296 
305  virtual void dotArray( const tUInt& q,
306  const EMM_RealArray& w,
307  const EMM_RealField& F,const EMM_RealField& G,
308  EMM_RealArray& R) const;
309 
310 
311 
312 private:
313 
314 
315 public:
316 
317 
318 
321  virtual void normalize();
322 
327  virtual void mean(tReal* mean) const;
328 
334  virtual void mean(const EMM_RealArray& w,tReal* mean) const;
335 
336  // GET methods
337 public:
341  virtual tULLInt getMemorySize() const {
342  return mArray.getMemorySize();
343  }
347  inline const EMM_RealArray& getArray() const {
348  return mArray;
349  }
354  return mArray;
355  }
356 
357 public:
358 
362  virtual tUIndex getSize() const {
363  return mArray.getSize()/getDimension();
364  }
370  virtual tReal getValue(const tUIndex& i) const {
371  return (*this)[i];
372  }
378  virtual void getValue(const tUIndex& i,tReal vs[]) const {
379  const tDimension& dim=getDimension();
380  const tReal *v=&(*this)[i*dim];
381  tReal *vi=vs;
382  for (tDimension i=0;i<dim;i++) {
383  *vi=*v;
384  v++;
385  vi++;
386  }
387  }
391  virtual tString getTypeToString() const {
392  return mArray.getTypeToString();
393  }
399  virtual tBoolean getValues(tUIndex& size,const float*& values) const {
400  if (getTypeToString().compare(CORE_Object::getTypeName<float>())==0) {
401  size=getSize();
402 
403  if (size>0) values=(const float*) &mArray[0];
404  else values=null;
405 
406  size*=getDimension();
407  return true;
408  }
409  return false;
410  }
416  virtual tBoolean getValues(tUIndex& size,const double*& values) const {
417  if (getTypeToString().compare(CORE_Object::getTypeName<double>())==0) {
418  size=getSize();
419  if (size>0) values=(const double*) &mArray[0];
420  else values=null;
421  size*=getDimension();
422  return true;
423  }
424  return false;
425  }
431  virtual tBoolean getValues(tUIndex& size,const long double*& values) const {
432  if (getTypeToString().compare(CORE_Object::getTypeName<long double>())==0) {
433  size=getSize();
434  if (size>0) values=(const long double*) &mArray[0];
435  else values=null;
436  size*=getDimension();
437  return true;
438  }
439  return false;
440  }
446  virtual tBoolean getValues(tUIndex& size,float*& values) {
447  if (getTypeToString().compare(CORE_Object::getTypeName<float>())==0) {
448  size=getSize();
449  if (size>0) values=( float*) &mArray[0];
450  else values=null;
451  size*=getDimension();
452  return true;
453  }
454  return false;
455  }
461  virtual tBoolean getValues(tUIndex& size,double*& values) {
462  if (getTypeToString().compare(CORE_Object::getTypeName<double>())==0) {
463  size=getSize();
464  if (size>0) values=( double*) &mArray[0];
465  else values=null;
466  size*=getDimension();
467  return true;
468  }
469  return false;
470  }
476  virtual tBoolean getValues(tUIndex& size,long double*& values) {
477  if (getTypeToString().compare(CORE_Object::getTypeName<long double>())==0) {
478  size=getSize();
479  if (size>0) values=(long double*) &mArray[0];
480  else values=null;
481  size*=getDimension();
482  return true;
483  }
484  return false;
485 
486  }
487  //OTHERS method
492  virtual void add(const tReal& alpha,const EMM_RealField& X);
493 
498  virtual void add(const EMM_RealArray& alpha,const EMM_RealField& X);
502  virtual void add(const EMM_RealField& f);
503 
504 
511  virtual void add(const tReal& s,
512  const EMM_RealArray& alphas,
513  const tSInt& p,
514  const EMM_RealField& X);
515 
519  virtual void sub(const EMM_RealField& f);
523  virtual void divideBy(const tReal& f);
527  virtual void divideBy(const EMM_RealArray& f);
531  virtual void multiplyBy(const tReal& f);
535  virtual void multiplyBy(const EMM_RealArray& f);
536 
537 
538 
543  virtual tReal norm(const tUIndex& index) const;
544 
549  virtual void norm(EMM_RealArray& mod) const;
550 
555  virtual tReal normMax(tUIndex& k) const;
556 
562  virtual tReal distanceMax(const EMM_RealField& B,tUIndex& k) const;
563 
568  virtual tBoolean cellDataToPointData(const EMM_Grid3D& mesh);
569 
574  virtual tBoolean pointDataToCellData(const EMM_Grid3D& mesh);
575 
582  virtual tBoolean loadFromStream(ifstream& f,const tUSInt& d) {
583  return mArray.loadFromStream(f,d);
584  }
591  virtual tBoolean loadFromStream(ifstream& f,vector<EMM_RealArray*>& indics);
592 
599  virtual tBoolean saveToStream(ofstream& f) const {
600  return mArray.saveToStream(f,getDimension());
601  }
608  virtual tBoolean saveToStream(ofstream& f,const vector<const EMM_RealArray*>& indics) const;
609 
616  virtual tBoolean saveToVTKStream(ofstream& file,EMM_VTK& vtk,const tString& name) const;
624  virtual tBoolean saveToVTKStream(ofstream& file,EMM_VTK& vtk,const EMM_RealArray& weight,const tString& name) const;
625 
630  virtual tString toString(const tUIndex& n) const;
631 
632 
633 
634 private:
635 
636 
637 
638 };
639 
640 #endif
virtual void divideBy(const tReal &f)
compute This/=f
Definition: EMMG_RealField.cpp:561
EMM_RealArray mArray
Definition: EMMG_RealField.h:28
This class describes a grid3d mesh.
Definition: EMM_Grid3D.h:48
const tUIndex & getSize() const
return the size of the array for reading
Definition: CORE_Array.h:1018
DEFINE_SPTR(EMMG_RealField)
EMM_RealArray & getArray()
get the array for writing
Definition: EMMG_RealField.h:353
virtual void add(const tReal &alpha, const EMM_RealField &X)
compute This += alpha. X
Definition: EMMG_RealField.cpp:748
virtual void dotArray(const EMM_RealArray &w, const EMM_RealField &F, const EMM_RealField &G, EMM_RealArray &R) const
compute the array
Definition: EMMG_RealField.cpp:1947
static const tDimension Y
Definition: EMM_Object.h:34
EMMG_RealField()
create
Definition: EMMG_RealField.cpp:9
tBoolean loadFromStream(ifstream &f, const vector< tUSInt > &dims, const vector< EMM_Array< T > * > &arrays) const
load the values to indicators from the stream
Definition: EMM_Array.hpp:235
virtual void copy(const EMM_RealField &f)
copy the real vector
Definition: EMMG_RealField.cpp:17
virtual tBoolean getValues(tUIndex &size, const double *&values) const
get the values
Definition: EMMG_RealField.h:416
tString getTypeToString() const
get the type name of the array
Definition: CORE_Array.h:570
This class describes a generic real field.
Definition: EMMG_RealField.h:17
virtual void sub(const EMM_RealField &f)
compute This-=f
Definition: EMMG_RealField.cpp:1155
virtual tString getTypeToString() const
get the string type
Definition: EMMG_RealField.h:391
static const tDimension X
Definition: EMM_Object.h:33
const tReal & operator()(const tUIndex &i, const tDimension &d) const
get the value at point i for coordinate d
Definition: EMMG_RealField.h:87
virtual tBoolean getValues(tUIndex &size, double *&values)
get the values
Definition: EMMG_RealField.h:461
This class is a I/O output class for VTK / Paraviwe file.
Definition: EMM_VTK.h:25
const EMM_RealArray & getArray() const
get the array for reading
Definition: EMMG_RealField.h:347
virtual tBoolean saveToStream(ofstream &f) const
save the steady array into stream the steam will contain the values of the field. One value per line ...
Definition: EMMG_RealField.h:599
#define tUSInt
Definition: types.h:28
virtual void mean(tReal *mean) const
compute the mean of each direction
Definition: EMMG_RealField.cpp:2434
#define tBoolean
Definition: types.h:139
virtual tReal distanceMax(const EMM_RealField &B, tUIndex &k) const
compute the Max_i ||this[i]-B[i]||
Definition: EMMG_RealField.cpp:2554
tReal & operator()(const tUIndex &i, const tDimension &d)
get the value at point i for coordinate d
Definition: EMMG_RealField.h:79
void setSize(const tUIndex &n)
set the size
Definition: CORE_Array.h:292
tBoolean loadFromFile(const tString &fileName)
load the steady array from file
Definition: EMM_RealField.cpp:313
virtual void fitToSize()
fit the memory size to the size
Definition: EMMG_RealField.h:204
virtual void normalize()
normalize the field
Definition: EMMG_RealField.cpp:2502
#define null
Definition: types.h:144
#define tDimension
Definition: EMM_Types.h:10
virtual void setSize(const tUIndex &s)
set the size
Definition: EMMG_RealField.h:110
static SP::EMMG_RealField New()
constructor with a shared pointer
Definition: EMMG_RealField.h:52
virtual tString toString() const
return the string representation of the field
Definition: EMM_RealField.h:725
virtual tBoolean cellDataToPointData(const EMM_Grid3D &mesh)
turn the field from cell data to point data
Definition: EMMG_RealField.cpp:3057
virtual tReal dot(const EMM_RealField &F, const EMM_RealField &G) const
compute the scalar product <F,G>
Definition: EMMG_RealField.cpp:1235
virtual void initField(const tReal &alpha, const EMM_RealField &f)
init the field to the field multiplied by alpha This=alpha.f
Definition: EMMG_RealField.cpp:151
tBoolean saveToStream(ofstream &f) const
save the values of the array into the stream with 1 value per line
Definition: EMM_Array.h:208
virtual void setValue(const tUIndex &i, const tReal v[])
set the value of the element at index i
Definition: EMMG_RealField.h:191
#define tSInt
Definition: types.h:30
virtual tReal getValue(const tUIndex &i) const
get the value of the element at index i
Definition: EMMG_RealField.h:370
virtual void setValue(const tUIndex &i, const tReal &v)
set the value of the element at index i
Definition: EMMG_RealField.h:182
virtual void fitToSize()
fit the array alocation exactly to size fit the allocation of the array to its size ...
Definition: CORE_Array.hpp:128
#define tUInt
Definition: types.h:33
virtual tBoolean pointDataToCellData(const EMM_Grid3D &mesh)
turn the field from point data to cll data
Definition: EMMG_RealField.cpp:3279
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: CORE_Array.h:545
virtual void unmagnetized(const EMM_Grid3D &mesh)
unmagnetized the field in the mesh
Definition: EMMG_RealField.cpp:507
#define tUIndex
Definition: types.h:126
virtual tBoolean getValues(tUIndex &size, float *&values)
get the values
Definition: EMMG_RealField.h:446
This class describes a real array.
Definition: EMM_RealArray.h:16
const tDimension & getDimension() const
get the dimension
Definition: EMM_RealField.h:553
const tReal & operator[](const tUIndex &i) const
get the value at index
Definition: EMMG_RealField.h:101
virtual ~EMMG_RealField(void)
destroy
Definition: EMMG_RealField.cpp:14
virtual tBoolean loadFromStream(ifstream &f, const tUSInt &d)
load the steady array from stream the steam contains the values of the field. One value per line ...
Definition: EMMG_RealField.h:582
tReal & operator[](const tUIndex &i)
get the value at index
Definition: EMMG_RealField.h:94
virtual tBoolean saveToVTKStream(ofstream &file, EMM_VTK &vtk, const tString &name) const
save the field in vtk
Definition: EMMG_RealField.cpp:3020
#define tString
Definition: types.h:135
virtual SP::EMM_RealField NewInstance() const
create a new instance of real field with the smae dimension and size
Definition: EMMG_RealField.h:62
virtual void wedge(const EMM_RealField &X, EMM_RealField &Y) const
compute the vectorial product of two fields This & X Y=alpha this ^ X
Definition: EMMG_RealField.cpp:2687
virtual void multiplyBy(const tReal &f)
compute This*=f
Definition: EMMG_RealField.cpp:600
virtual void getValue(const tUIndex &i, tReal vs[]) const
get the vector value at point i of size dim
Definition: EMMG_RealField.h:378
SP_OBJECT(EMMG_RealField)
#define tULLInt
Definition: types.h:45
virtual void setFieldByReference(const tUIndex &from, const tUIndex &to, EMM_RealField &X)
set the field by reference
Definition: EMMG_RealField.cpp:476
This class describes a real field.
Definition: EMM_RealField.h:21
virtual tBoolean getValues(tUIndex &size, long double *&values)
get the values
Definition: EMMG_RealField.h:476
virtual tULLInt getMemorySize() const
return the memory size in bytes
Definition: EMMG_RealField.h:341
#define tReal
Definition: types.h:118
virtual tBoolean getValues(tUIndex &size, const long double *&values) const
get the values
Definition: EMMG_RealField.h:431
virtual tReal norm(const tUIndex &index) const
compute the norm at point at index
Definition: EMMG_RealField.cpp:2329
DEFINE_SVPTR(EMMG_RealField)
virtual tBoolean getValues(tUIndex &size, const float *&values) const
get the values
Definition: EMMG_RealField.h:399
virtual tBoolean initField(const tString &fileName)
init the field by the file name
Definition: EMMG_RealField.h:157
virtual tUIndex getSize() const
return the size of the field
Definition: EMMG_RealField.h:362
virtual tReal normMax(tUIndex &k) const
compute the point where the norm of the field is maximum
Definition: EMMG_RealField.cpp:2384
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141