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
00032
00033 #ifndef __GRID_H
00034 #define __GRID_H
00035
00036 #include <stdlib.h>
00037 #include <math.h>
00038 #include <string>
00039
00040 #include <iostream>
00041 using std::cout;
00042 using std::ostream;
00043 using std::endl;
00044
00045 #include <iomanip>
00046 using std::setw;
00047
00048 using std::string;
00049
00050 #include "OFELI_Config.h"
00051 #include "Point.h"
00052 #include "Point2D.h"
00053 #include "Node.h"
00054 #include "Element.h"
00055 #include "Side.h"
00056 #include "util.h"
00057
00058 namespace OFELI {
00059
00070 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00071 struct ErrorInGrid {
00072 void Message(const char *file, size_t line, int code, double p1, double p2);
00073 };
00074 #endif
00075
00076 class Grid
00077 {
00078 public:
00079
00081 Grid();
00082
00088 Grid(double xm, double xM, size_t npx);
00089
00098 Grid(double xm, double xM, double ym, double yM, size_t npx, size_t npy);
00099
00111 Grid(double xm, double xM, double ym, double yM, double zm, double zM,
00112 size_t npx, size_t npy, size_t npz);
00113
00116 void setXMin(const Point<double> &x) { _xmin = x; }
00117
00120 void setXMax(const Point<double> &x) { _xmax = x; }
00121
00126 void setDomain(double xmin, double xmax);
00127
00134 void setDomain(double xmin, double xmax, double ymin, double ymax);
00135
00144 void setDomain(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
00145
00147 const Point<double> &getXMin() const { return _xmin; }
00148
00150 const Point<double> &getXMax() const { return _xmax; }
00151
00153 void setNx(size_t nx) { _nx = nx; }
00154
00156 void setNy(size_t ny) { _ny = ny; }
00157
00159 void setNz(size_t nz) { _nz = nz; }
00160
00162 size_t getNx() const { return _nx; }
00163
00166 size_t getNy() const { return _ny; }
00167
00170 size_t getNz() const { return _nz; }
00171
00173 double getHx() const { return _hx; }
00174
00176 double getHy() const { return _hy; }
00177
00179 double getHz() const { return _hz; }
00180
00182 Point<double> getCoord(size_t i) const;
00183
00185 Point<double> getCoord(size_t i, size_t j) const;
00186
00188 Point<double> getCoord(size_t i, size_t j, size_t k) const;
00189
00191 double getX(size_t i) const;
00192
00194 double getY(size_t j) const;
00195
00197 double getZ(size_t k) const;
00198
00200 Point2D<double> getXY(size_t i, size_t j) const;
00201
00203 Point<double> getXYZ(size_t i, size_t j, size_t k) const;
00204
00210 void setCode(int side, int code);
00211
00216 int getCode(int side) const;
00217
00222 int getCode(size_t i, size_t j) const;
00223
00229 int getCode(size_t i, size_t j, size_t k) const;
00230
00231 private:
00232 int _cmx, _cMx, _cmy, _cMy, _cmz, _cMz;
00233 size_t _nx, _ny, _nz;
00234 double _hx, _hy, _hz;
00235 Point<double> _xmin, _xmax;
00236 ErrorInGrid _e;
00237 };
00238
00243 ostream& operator<<(ostream& s, const Grid &g);
00244
00245 }
00246
00247 #endif