00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __FIELD_H
00032 #define __FIELD_H
00033
00034 #include <math.h>
00035 #include <float.h>
00036 #include <stdlib.h>
00037 #include <assert.h>
00038 #include <iostream>
00039 using std::ostream;
00040
00041 #include "OFELI_Config.h"
00042 #include "Point.h"
00043
00044
00045 namespace OFELI {
00046
00070 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00071 template<class T_>
00072 class Field
00073 {
00074
00075 public:
00076
00079 Field()
00080 {
00081 x_ = 0;
00082 #ifdef _OFELI_DEBUG
00083 std::clog << "An instance of class Field is constructed.\n";
00084 std::clog << "File : " << __FILE__ << ", Line : " << __LINE__ << endl;
00085 #endif
00086 }
00087
00089 Field(T_ x)
00090 {
00091 x_ = x;
00092 #ifdef _OFELI_DEBUG
00093 std::clog << "An instance of class Field is constructed.\n";
00094 std::clog << "File : " << __FILE__ << ", Line : " << __LINE__ << endl;
00095 #endif
00096 }
00097
00099 Field(const Field<T_> &x)
00100 {
00101 x_ = x.x_;
00102 #ifdef _OFELI_DEBUG
00103 std::clog << "An instance of class Field is constructed.\n";
00104 std::clog << "File : " << __FILE__ << ", Line : " << __LINE__ << endl;
00105 #endif
00106 }
00107
00109 ~Field()
00110 {
00111 #ifdef _OFELI_DEBUG
00112 std::clog << "An instance of class Field is destructed.\n";
00113 std::clog << "File : " << __FILE__ << ", Line : " << __LINE__ << endl;
00114 #endif
00115 }
00116
00118 Field<T_> & operator=(const Field<T_> &x) { x_ = x.x_; return *this; }
00119
00122 Field<T_> & operator+=(const Field<T_> &x) { x_ += x; return *this; }
00123
00126 Field<T_> & operator+=(T_ x) { x_ += x; return *this; }
00127
00130 Field<T_> & operator-=(const Field<T_> &x) { x_ -= x; return *this; }
00131
00134 Field<T_> & operator-=(T_ x) { x_ -= x; return *this; }
00135
00138 Field & operator*=(T_ x) { x_ *= x; return *this; }
00139
00142 Field & operator/=(T_ x) { x_ /= x; return *this; }
00143
00144 operator T_() const { return x_; }
00145
00146 T_ x_;
00147 };
00148
00149
00151
00152
00153
00158 class Temperature : public Field<double>
00159 {
00160 public:
00161
00164 Temperature() { }
00165
00167 Temperature(double x) : Field<double>(x) { }
00168
00169
00171 friend ostream& operator<<(ostream& s, const Temperature &v) { s << v.x_; return s; }
00172 };
00173
00174
00179 class Enthalpy : public Field<double>
00180 {
00181 public:
00182
00185 Enthalpy() { }
00186
00188 Enthalpy(double x) : Field<double>(x) { }
00189
00191 friend ostream& operator<<(ostream& s, const Enthalpy &v) { s << v.x_; return s; }
00192 };
00193
00198 class Pressure : public Field<double>
00199 {
00200 public:
00201
00204 Pressure() { x_ = 0; }
00205
00207 Pressure(const double &x) { x_ = x; }
00208
00210 friend ostream& operator<<(ostream& s, const Pressure &v) { s << v.x_; return s; }
00211 };
00212
00213
00218 class Displacement : public Field<Point<double> >
00219 {
00220 public:
00221
00224 Displacement() { x_ = 0; }
00225
00227 Displacement(const Point<double> &x) { x_ = x; }
00228
00230 Displacement(double x, double y=0, double z=0) { x_.x = x; x_.y = y; x_.z = z; }
00231
00233 friend ostream& operator<<(ostream& s, const Displacement &v) { s << v.x_; return s; }
00234 };
00235
00236
00241 class Velocity : public Field<Point<double> >
00242 {
00243 public:
00244
00247 Velocity() { x_ = 0; }
00248
00250 Velocity(const Point<double> &x) { x_ = x; }
00251
00253 Velocity(double x, double y=0, double z=0) { x_.x = x; x_.y = y; x_.z = z; }
00254
00256 friend ostream& operator<<(ostream& s, const Velocity &v) { s << v.x_; return s; }
00257 };
00258
00259
00264 class MagneticField : public Field<Point<double> >
00265 {
00266 public:
00267
00270 MagneticField() { x_ = 0; }
00271
00273 MagneticField(const Point<double> &x) { x_ = x; }
00274
00276 MagneticField(double x, double y=0, double z=0) { x_.x = x; x_.y = y; x_.z = z; }
00277
00279 friend ostream& operator<<(ostream& s, const MagneticField &v) { s << v.x_; return s; }
00280 };
00281
00282
00287 class ElectricField : public Field<Point<double> >
00288 {
00289 public:
00290
00293 ElectricField() { x_ = 0; }
00294
00296 ElectricField(const Point<double> &x) { x_ = x; }
00297
00299 ElectricField(double x, double y=0, double z=0) { x_.x = x; x_.y = y; x_.z = z; }
00300
00302 friend ostream& operator<<(ostream& s, const ElectricField &v) { s << v.x_; return s; }
00303 };
00304 #endif
00305
00306 }
00307
00308 #endif