C++ main module for emicrom Package  1.0
EMM_RealField.h
Go to the documentation of this file.
1 #ifndef EMM_RealField_H
2 #define EMM_RealField_H
3 
4 
5 #include "EMM_Object.h"
6 
7 #include "EMM_RealArray.h"
8 
9 class EMM_VTK;
10 class EMM_Grid3D;
11 
21 class EMM_RealField : public EMM_Object {
22 
24  // ATTRIBUTES
25 
26 public:
27 
28 
29 private:
30 
32 
33 public:
34  // METHODS
35 
36  // CONSTRUCTORS
37 
40  EMM_RealField();
41 
42 
43 
44 
45 
46  // DESTRUCTORS
47 
48 
51  virtual ~EMM_RealField(void);
52 
53 private:
54 
55 
56 
57 public:
58 
59  //copy operator
60  //=============
61 
65  inline EMM_RealField& operator=(const tReal& f) {
66  initField(f);
67  return (*this);
68  }
69 
73  inline EMM_RealField& operator=(const tReal f[4]) {
74  initField(f[0],f[1],f[2]);
75  return (*this);
76  }
77 
78 
82  copy(f);
83  return (*this);
84  }
85 
86  //Arithmetic operators
87  //====================
88 
94  add(f);
95  return (*this);
96  }
102  sub(f);
103  return (*this);
104  }
105 
110  inline EMM_RealField& operator/=(const tReal& f) {
111  divideBy(f);
112  return (*this);
113  }
118  inline EMM_RealField& operator*=(const tReal& f) {
119  multiplyBy(f);
120  return (*this);
121  }
128  multiplyBy(f);
129  return (*this);
130  }
131  /* \brief multiply a vector field by a scalar field to obtain a real field :
132  * for all i in [0,N[ for all d in [0,3[, This[i][d]/=f[i]
133  * @param f : the divisor array
134  * @return this
135  */
137  divideBy(f);
138  return (*this);
139  }
140 
141 
145  virtual SP::EMM_RealField NewInstance() const=0;
146 
147 
148  // SET methods
149 
150 
153  virtual void copy(const EMM_RealField& f)=0;
154 
158  inline void setDimension(const tDimension& d) {
159  mDimension=d;
160  }
164  virtual void setSize(const tUIndex& n)=0;
167  virtual void fitToSize()=0;
168 
169 
173  virtual void initField(const tReal& f)=0;
174 
178  inline void initField(const EMM_RealField& f) {
179  copy(f);
180  };
181 
185  virtual tBoolean initField(const tString& fileName)=0;
186 
191  virtual void initField(const tReal& v,const EMM_RealField& f)=0;
192 
199  virtual void initField(const EMM_RealArray& alpha,const EMM_RealField& f)=0;
200 
209  virtual void initField(const tReal& s,const EMM_RealArray& alpha,const tSInt& p,const EMM_RealField& f)=0;
210 
217  virtual void initField(const tUIndex& from,const tUIndex& to,const EMM_RealField& C)=0;
218 
224  inline void initField(const tReal &fx,const tReal& fy,const tReal& fz) {
225  initField(0,getSize(),fx,fy,fz);
226  }
227 
228 
236  virtual void initField(const tUIndex& from,const tUIndex& to,const tReal &fx,const tReal& fy,const tReal& fz)=0;
237 
238 
239 
244  virtual void unmagnetized(const EMM_Grid3D& mesh)=0;
245 
253  inline void setValue(const tUIndex& i,const tDimension& k,const tReal& v) {
254  setValue(getDimension()*i+k,v);
255  }
256 
263  virtual void setValue(const tUIndex& i,const tReal& v)=0;
264 
270  virtual void setValue(const tUIndex& i,const tReal vs[])=0;
271 
286  virtual void setFieldByReference(const tUIndex& from,const tUIndex& to, EMM_RealField& X)=0;
287 
288 
294  virtual void wedge(const EMM_RealField& X,
295  EMM_RealField& Y) const=0;
296 
303  virtual void wedge(const tReal& alpha,
304  const EMM_RealField& X,
305  EMM_RealField& Y) const=0;
306 
307 
308 
309 
315  virtual tReal dot(const EMM_RealField& F) const{
316  return dot(*this,F);
317  }
324  virtual tReal dot(const EMM_RealArray& sigma,const EMM_RealField& F) const{
325  return dot(sigma,*this,F);
326  }
333  virtual tReal dot(const EMM_RealField& F,const EMM_RealField& G) const=0;
341  virtual tReal dot(const EMM_RealArray& sigma, const EMM_RealField& F,const EMM_RealField& G) const=0;
342 
348  inline tReal dot(const tUInt& q,
349  const EMM_RealField& G) const {
350  if (q==1) return dot(*this,G);
351  if (q==0) return getSize();
352  return dot(q,*this,G);
353  }
360  virtual tReal dot(const tUInt& q,
361  const EMM_RealField& F,const EMM_RealField& G) const=0;
362 
369  virtual tReal dot(const tUInt& q,
370  const EMM_RealArray& w,
371  const EMM_RealField& G) const {
372  if (q==1) return dot(w,*this,G);
373  return dot(q,w,*this,G);
374  }
375 
383  virtual tReal dot( const tUInt& q,
384  const EMM_RealArray& w,
385  const EMM_RealField& F,const EMM_RealField& G) const=0;
386 
395  virtual void dotArray( const tUInt& q,
396  const EMM_RealArray& w,
397  const EMM_RealField& F,
398  const EMM_RealField& G,
399  EMM_RealArray& R) const=0;
407  virtual void dotArray(const EMM_RealArray& w,
408  const EMM_RealField& F,const EMM_RealField& G,
409  EMM_RealArray& R) const=0;
416  virtual void dotArray(const EMM_RealField& F,const EMM_RealField& G,
417  EMM_RealArray& R) const=0;
418 
426  virtual void dotArray( const tUInt& q,
427  const EMM_RealField& F,const EMM_RealField& G,
428  EMM_RealArray& R) const=0;
429 
437  inline void dotArray( const tUInt& q,
438  const EMM_RealArray& w,
439  const EMM_RealField& G,
440  EMM_RealArray& R) const {
441  dotArray(q,w,*this,G,R);
442  }
449  inline void dotArray( const tUInt& q,
450  const EMM_RealField& G,
451  EMM_RealArray& R) const {
452  dotArray(q,*this,G,R);
453  }
460  inline void dotArray( const EMM_RealArray& w,
461  const EMM_RealField& G,
462  EMM_RealArray& R) const {
463  dotArray(w,*this,G,R);
464  }
470  inline void dotArray(const EMM_RealField& G,
471  EMM_RealArray& R) const {
472  dotArray(*this,G,R);
473  }
474 
475 
480  virtual void add(const tReal& alpha,
481  const EMM_RealField& X)=0;
487  virtual void add(const EMM_RealArray& alphas,
488  const EMM_RealField& X)=0;
489 
496  virtual void add(const tReal& s,
497  const EMM_RealArray& alphas,
498  const tSInt& p,
499  const EMM_RealField& X)=0;
500 
503  virtual void normalize()=0;
504 
509  virtual void mean(tReal* mean) const=0;
510 
516  virtual void mean(const EMM_RealArray& w,tReal* mean) const=0;
517 
524  static void mean(const tUIndex& nCells,
525  const tDimension& dim,
526  const tReal * vs, tReal* mean);
527 
535  static void mean(const tUIndex& nCells,const tDimension& dim,
536  const tReal* ws,const tReal * vs, tReal* mean);
537 
538  // GET methods
542  virtual tULLInt getMemorySize() const=0;
543 
544 
548  virtual tUIndex getSize() const=0;
549 
553  inline const tDimension& getDimension() const {
554  return mDimension;
555  }
556 
563  inline tReal getValue(const tUIndex& i,const tDimension& k) const {
564  return getValue(getDimension()*i+k);
565  }
571  virtual void getValue(const tUIndex& i,tReal vs[]) const=0;
572 
578  virtual tReal getValue(const tUIndex& i) const=0;
579 
585  virtual tBoolean getValues(tUIndex& size,const float*& values) const {
586  size=0;
587  return false;
588  }
594  virtual tBoolean getValues(tUIndex& size,const double*& values) const {
595  size=0;
596  return false;
597  }
603  virtual tBoolean getValues(tUIndex& size,const long double*& values) const {
604  size=0;
605  return false;
606  }
612  virtual tBoolean getValues(tUIndex& size,float*& values) {
613  size=0;
614  return false;
615  }
621  virtual tBoolean getValues(tUIndex& size,double*& values) {
622  size=0;
623  return false;
624  }
630  virtual tBoolean getValues(tUIndex& size,long double*& values) {
631  size=0;
632  return false;
633  }
634 
641  virtual tString getTypeToString() const=0;
642 
643 
644 public:
645  // OTHERS methods
646 
647 
653  virtual void add(const EMM_RealField& f)=0;
657  virtual void sub(const EMM_RealField& f)=0;
658 
662  virtual void divideBy(const tReal& f)=0;
666  virtual void multiplyBy(const tReal& f)=0;
667 
671  virtual void multiplyBy(const EMM_RealArray& f)=0;
672 
676  virtual void divideBy(const EMM_RealArray& f)=0;
677 
682  virtual tReal norm(const tUIndex& index) const=0;
683 
687  virtual void norm(EMM_RealArray& module) const=0;
688 
693  virtual tReal normMax(tUIndex& index) const=0;
694 
695 
701  virtual tReal distanceMax(const EMM_RealField& B,tUIndex& k) const=0;
702 
707  virtual tBoolean cellDataToPointData(const EMM_Grid3D& mesh)=0;
708 
713  virtual tBoolean pointDataToCellData(const EMM_Grid3D& mesh)=0;
714 
715 
720  virtual tString toString(const tUIndex& n) const=0;
721 
725  virtual tString toString() const {
726  return toString(10);
727  }
728 
738  tBoolean loadFromFile(const tString& fileName);
739 
750  virtual tBoolean loadFromStream(ifstream& f,const tUSInt& dim)=0;
751 
758  virtual tBoolean loadFromStream(ifstream& f,vector<EMM_RealArray*>& indics) =0;
759 
769  tBoolean saveToFile(const tString& fileName) const;
770 
776  virtual tBoolean saveToStream(ofstream& stream) const =0;
777 
786  virtual tBoolean saveToStream(ofstream& f,const vector<const EMM_RealArray*>& indics) const =0;
787 
795  virtual tBoolean saveToVTKStream(ofstream& file,EMM_VTK& vtk,const EMM_RealArray& weight,const tString& name) const=0;
802  virtual tBoolean saveToVTKStream(ofstream& file,EMM_VTK& vtk,const tString& name) const=0;
803 
804 
805 
806 };
807 
808 #endif
This class is a base class of E-MicromM core package.
Definition: EMM_Object.h:21
virtual tBoolean pointDataToCellData(const EMM_Grid3D &mesh)=0
turn the field from point data to cll data
virtual tBoolean cellDataToPointData(const EMM_Grid3D &mesh)=0
turn the field from cell data to point data
This class describes a grid3d mesh.
Definition: EMM_Grid3D.h:48
virtual tUIndex getSize() const =0
return the size of the field
virtual tBoolean saveToStream(ofstream &stream) const =0
save the array into stream and indicators the stream will contain the values of the field...
static const tDimension Y
Definition: EMM_Object.h:34
tDimension mDimension
Definition: EMM_RealField.h:31
virtual void fitToSize()=0
fit the memory size to the size
virtual tReal dot(const tUInt &q, const EMM_RealArray &w, const EMM_RealField &G) const
compute the
Definition: EMM_RealField.h:369
virtual void wedge(const EMM_RealField &X, EMM_RealField &Y) const =0
compute the vectorial product of two fields This & X Y=This ^ X
static const tDimension X
Definition: EMM_Object.h:33
virtual tReal norm(const tUIndex &index) const =0
compute the norm at point at index i
virtual tReal distanceMax(const EMM_RealField &B, tUIndex &k) const =0
compute the Max_i ||this[i]-B[i]||
DEFINE_SPTR(EMM_RealField)
EMM_RealField & operator-=(const EMM_RealField &f)
sub a field This-=f
Definition: EMM_RealField.h:101
EMM_RealField & operator=(const EMM_RealField &f)
copy the real steady field
Definition: EMM_RealField.h:81
EMM_RealField & operator=(const tReal f[4])
init the field to the vector f
Definition: EMM_RealField.h:73
virtual void setFieldByReference(const tUIndex &from, const tUIndex &to, EMM_RealField &X)=0
set the field by reference
EMM_RealField & operator*=(const EMM_RealArray &f)
multiply a vector field by a scalar field to obtain a real field : for all i in [0,N[ for all d in [0,3[, This[i][d]*=f[i]
Definition: EMM_RealField.h:127
virtual tBoolean getValues(tUIndex &size, const long double *&values) const
get the values
Definition: EMM_RealField.h:603
This class is a I/O output class for VTK / Paraviwe file.
Definition: EMM_VTK.h:25
#define tUSInt
Definition: types.h:28
#define tBoolean
Definition: types.h:139
void dotArray(const tUInt &q, const EMM_RealField &G, EMM_RealArray &R) const
compute the array
Definition: EMM_RealField.h:449
virtual void dotArray(const tUInt &q, const EMM_RealArray &w, const EMM_RealField &F, const EMM_RealField &G, EMM_RealArray &R) const =0
compute the array
virtual tReal normMax(tUIndex &index) const =0
compute the point where the norm is max
tBoolean loadFromFile(const tString &fileName)
load the steady array from file
Definition: EMM_RealField.cpp:313
virtual void mean(tReal *mean) const =0
compute the mean of each direction
tBoolean saveToFile(const tString &fileName) const
save the steady array into file
Definition: EMM_RealField.cpp:288
#define tDimension
Definition: EMM_Types.h:10
void dotArray(const EMM_RealArray &w, const EMM_RealField &G, EMM_RealArray &R) const
compute the array
Definition: EMM_RealField.h:460
virtual ~EMM_RealField(void)
destroy the interface
Definition: EMM_RealField.cpp:13
virtual tBoolean getValues(tUIndex &size, double *&values)
get the values
Definition: EMM_RealField.h:621
virtual tBoolean getValues(tUIndex &size, long double *&values)
get the values
Definition: EMM_RealField.h:630
void dotArray(const EMM_RealField &G, EMM_RealArray &R) const
compute the array
Definition: EMM_RealField.h:470
virtual tString toString() const
return the string representation of the field
Definition: EMM_RealField.h:725
virtual SP::EMM_RealField NewInstance() const =0
create a new instance of real field with the same dimension and size
virtual tReal dot(const EMM_RealField &F) const
compute the scalar product
Definition: EMM_RealField.h:315
virtual tBoolean getValues(tUIndex &size, float *&values)
get the values
Definition: EMM_RealField.h:612
virtual tBoolean saveToVTKStream(ofstream &file, EMM_VTK &vtk, const EMM_RealArray &weight, const tString &name) const =0
save the field in vtk
#define tSInt
Definition: types.h:30
virtual void initField(const tReal &f)=0
init the field to uniform value in each direction
DEFINE_SVPTR(EMM_RealField)
virtual void divideBy(const tReal &f)=0
compute This/=f
#define tUInt
Definition: types.h:33
EMM_RealField()
create the interface
Definition: EMM_RealField.cpp:7
virtual tBoolean getValues(tUIndex &size, const float *&values) const
get the values
Definition: EMM_RealField.h:585
#define tUIndex
Definition: types.h:126
This class describes a real array.
Definition: EMM_RealArray.h:16
const tDimension & getDimension() const
get the dimension
Definition: EMM_RealField.h:553
EMM_RealField & operator/=(const tReal &f)
divide with respect of a real
Definition: EMM_RealField.h:110
virtual void unmagnetized(const EMM_Grid3D &mesh)=0
unmagnetized the field in the mesh
virtual tBoolean loadFromStream(ifstream &f, const tUSInt &dim)=0
load the steady array from stream
virtual tReal dot(const EMM_RealArray &sigma, const EMM_RealField &F) const
compute the scalar product
Definition: EMM_RealField.h:324
virtual void multiplyBy(const tReal &f)=0
compute This*=f
virtual void copy(const EMM_RealField &f)=0
copy the real vector
tReal dot(const tUInt &q, const EMM_RealField &G) const
compute the
Definition: EMM_RealField.h:348
#define tString
Definition: types.h:135
void dotArray(const tUInt &q, const EMM_RealArray &w, const EMM_RealField &G, EMM_RealArray &R) const
compute the array
Definition: EMM_RealField.h:437
EMM_RealField & operator+=(const EMM_RealField &f)
add a field This+=f
Definition: EMM_RealField.h:93
virtual tULLInt getMemorySize() const =0
return the memory size in bytes
virtual void normalize()=0
normalize the field
void setValue(const tUIndex &i, const tDimension &k, const tReal &v)
set the value at point i and for coordinate k
Definition: EMM_RealField.h:253
EMM_RealField & operator*=(const tReal &f)
multiply the field by f
Definition: EMM_RealField.h:118
virtual void sub(const EMM_RealField &f)=0
compute This-=f
virtual tString getTypeToString() const =0
return the pointer to the values
void initField(const EMM_RealField &f)
init the field to uniform value in each direction
Definition: EMM_RealField.h:178
tReal getValue(const tUIndex &i, const tDimension &k) const
get the value at point i and for coordinate k
Definition: EMM_RealField.h:563
void setDimension(const tDimension &d)
set the dimension
Definition: EMM_RealField.h:158
SP_OBJECT(EMM_RealField)
#define tULLInt
Definition: types.h:45
EMM_RealField & operator=(const tReal &f)
init the field to uniform value in each direction
Definition: EMM_RealField.h:65
This class describes a real field.
Definition: EMM_RealField.h:21
virtual tBoolean getValues(tUIndex &size, const double *&values) const
get the values
Definition: EMM_RealField.h:594
virtual void setSize(const tUIndex &n)=0
set the size
EMM_RealField & operator/=(const EMM_RealArray &f)
Definition: EMM_RealField.h:136
#define tReal
Definition: types.h:118
void initField(const tReal &fx, const tReal &fy, const tReal &fz)
init the field to the 3D vector
Definition: EMM_RealField.h:224
virtual void add(const tReal &alpha, const EMM_RealField &X)=0
compute This += alpha. X