00001 #ifndef WSPR_H
00002 #define WSPR_H
00003
00004
00005 #include "general.h"
00006
00007
00014 class WSpr{
00015
00016
00017
00018
00019 public:
00020
00021 WSpr(char *configFileName);
00022 WSpr(int numberOfElementsX,int numberOfElementsY,
00023 double threshold=0.001, int minLevel=3, int interpOrder=4,
00024 int boundaryCodeSpr=1111, char *initialConditionFileName="InitialCondition.cfg");
00025
00026 ~WSpr(void);
00027
00028
00029 void testLocalDerivate(void);
00030
00031 void testSprWithBoundaries(void);
00032
00033 void testViewMeshTransforms(void);
00034 void testTransformTimeLocalPoints(void);
00035 void testTransformsTime(void);
00036
00037 void testExtendMesh(void);
00038
00039 void testTimeEvolution(void);
00040 void testMaxwellTimeEvolution(void);
00041
00042 void drawPhi(void);
00043
00044
00045
00046 Array2D computeRK4(double dt, Array2D &u, Array2D (WSpr::*rhsEval)( Array2D &fu,double dX ,double dY));
00047
00048 void compute_RK4(double dt, Array2D &u, Array2D &v, Array2D &w,
00049 Array2D (WSpr::*rhsEval1)( Array2D &w,double epsilon0),
00050 Array2D (WSpr::*rhsEval2)( Array2D &w,double epsilon0),
00051 Array2D (WSpr::*rhsEval3)( Array2D &u, double epsilon0, Array2D &v, double mu0),
00052 double epsilon0, double mu0);
00053
00054
00055 void WSpr::compute_RK4Complete(double dt, Array2D &u, Array2D &v, Array2D &w, Array2D &sigma,
00056 Array2D (WSpr::*rhsEval1)( Array2D &w,Array2D &u, Array2D &v,double par1),
00057 Array2D (WSpr::*rhsEval2)( Array2D &w,Array2D &u, Array2D &v,double par2),
00058 Array2D (WSpr::*rhsEval3)( Array2D &u, double par1, Array2D &v, double par3),
00059 double par1, double par2);
00060
00061
00062 double computeRKFCashKarp45 (
00063 double timeStep, int numberOfSteps,
00064 Array2D &u,
00065 Array2D(WSpr::*rhsEval)( Array2D &f,double dX ,double dY));
00066
00067
00068 double WSpr::computeRKFCashKarp45(
00069 double timeStep, int numberOfSteps,
00070 Array2D &u, Array2D &v, Array2D &w,
00071 Array2D (WSpr::*rhsEval1)( Array2D &w,double par1),
00072 Array2D (WSpr::*rhsEval2)( Array2D &w,double par2),
00073 Array2D (WSpr::*rhsEval3)( Array2D &u, double par1, Array2D &v, double par3), double par1, double par2);
00074
00075
00076 double computeRKCashKarp45(
00077 double dt,
00078 Array2D &u,
00079 Array2D(WSpr::*rhsEval)( Array2D &f,double dX ,double dY) ) ;
00080
00081
00082 double computeRKCashKarp45(
00083 double dt,
00084 Array2D &u, Array2D &v, Array2D &w,
00085 Array2D (WSpr::*rhsEval1)( Array2D &w,double par1),
00086 Array2D (WSpr::*rhsEval2)( Array2D &w,double par2),
00087 Array2D (WSpr::*rhsEval3)( Array2D &u, double par1, Array2D &v, double par3), double par1, double par2);
00088
00089
00090
00091 Array2D advRHS(Array2D &u, double dx, double dy);
00092 Array2D WSpr::exRHS(Array2D &u, double epsilon0);
00093 Array2D WSpr::eyRHS(Array2D &u, double epsilon0);
00094 Array2D WSpr::hzRHS(Array2D &u, double epsilon0, Array2D &v, double mu0);
00095
00096
00097 Array2D exRHS(Array2D &hz, Array2D &ex, Array2D &sigma, double epsilon);
00098 Array2D eyRHS(Array2D &hz, Array2D &ey, Array2D &sigma, double epsilon);
00099
00100
00101
00102
00103
00104
00105
00106 Array2D _mat, _matDer;
00107
00108 void dataToSparse(void);
00109 void sparseToData(void);
00110
00111 void dataToSparseInnerGrid(int numberOfBorderPoints);
00112
00113 void extendMesh(int numberOfNeighbors=1, int numberOfGenerations=1);
00114 void applyConeCondition(void);
00115
00116 void verifySpr(void);
00117 void verifySprInnerGrid(int numberOfBordersPoints);
00118
00119
00120 void plotDataGnuplot(char* title);
00121 void plotDataGnuplot( char* title, char* grfFileNameOutput);
00122 void plotDataGnuplot( char* title, char* grfFileName,char* grfFileNameCfg);
00123
00124 void plotGridGnuplot( char* title);
00125 void plotGridGnuplot( char* title, char* grfFileNameOutput);
00126 void plotGridGnuplot( char* title, char* grfFileName,char* grfFileNameCfg);
00127
00128 void computeSameMesh(WSpr &U, WSpr &V);
00129
00130
00131 void initArray(void);
00132 void infoNAN(void);
00133
00134 long getNumberOfNANs(void);
00135
00136 Array2D computeFirstDerivativeInSpr(int direction,int kind);
00137 Array2D computeFirstDerivativeInSpr(Array2D &u, int direction,int kind);
00138
00139 int getNumberOfElements(int dimension);
00140 double getThreshold(void);
00141
00142 inline void WSpr::forceSprFlag(bool flag){
00143 _isInSpr=flag;
00144 }
00145
00146 protected:
00147
00148
00149 void setWSpr(void);
00150
00151 void setWaveletFilter(void);
00152 void setBoundarySpr(void);
00153 void setDerivativeCoefficients(void);
00154
00155 bool _isInSpr,
00156 _isLocalDerivative;
00157
00158 char _initialConditionFileName[301], _functionName[301];
00159
00160 int _minLevel, _maxLevel,
00161 _interpOrder,
00162 _boundaryCodeSpr,
00163 _numberOfElementsX,
00164 _numberOfElementsY,
00165 _meshLevel;
00166
00167 double _threshold;
00168
00169
00170
00171 Array1D _waveletFilter,
00172
00173 _interpFilterRigidBoundary,
00174 _interpFilterSymmetricBoundary,
00175 _interpFilterAntiSymmetricBoundary,
00176
00177 _coefFirstDerivative;
00178
00179
00180 int logTwo(int n);
00181 int powerTwo(int n);
00182 int getNumberOfLevels(int n);
00183
00184 void recoverGrid(Array2D &tmp);
00185 void interpGrid(Array2D &tmp);
00186
00187 double interpPoint(Array2D &u, int m, int n, bool isToUseOrigMeshPoints=true);
00188 void interpInnerCol(Array2D &u);
00189 void interpInnerRow(Array2D &u);
00190
00191 void interpLowerColRigid(Array2D &u);
00192 void interpUpperColRigid(Array2D &u);
00193 void interpLowerRowRigid(Array2D &u);
00194 void interpUpperRowRigid(Array2D &u);
00195
00196 void interpLowerColSymmetric(Array2D &u);
00197 void interpUpperColSymmetric(Array2D &u);
00198 void interpLowerRowSymmetric(Array2D &u);
00199 void interpUpperRowSymmetric(Array2D &u);
00200
00201 void interpLowerColAntisymmetric(Array2D &u);
00202 void interpUpperColAntisymmetric(Array2D &u);
00203 void interpLowerRowAntisymmetric(Array2D &u);
00204 void interpUpperRowAntisymmetric(Array2D &u);
00205
00206
00207 void recoverInnerCol(Array2D &u);
00208 void recoverInnerRow(Array2D &u);
00209
00210 void recoverLowerColRigid(Array2D &u);
00211 void recoverUpperColRigid(Array2D &u);
00212 void recoverLowerRowRigid(Array2D &u);
00213 void recoverUpperRowRigid(Array2D &u);
00214
00215 void recoverLowerColSymmetric(Array2D &u);
00216 void recoverUpperColSymmetric(Array2D &u);
00217 void recoverLowerRowSymmetric(Array2D &u);
00218 void recoverUpperRowSymmetric(Array2D &u);
00219
00220 void recoverLowerColAntisymmetric(Array2D &u);
00221 void recoverUpperColAntisymmetric(Array2D &u);
00222 void recoverLowerRowAntisymmetric(Array2D &u);
00223 void recoverUpperRowAntisymmetric(Array2D &u);
00224
00225 double interpInnerColPoint(Array2D &u, int m, int n);
00226 double interpInnerRowPoint(Array2D &u, int m, int n);
00227
00228 double interpLowerColPointRigid(Array2D &u, int m, int n);
00229 double interpUpperRowPointRigid(Array2D &u, int m, int n);
00230 double interpUpperColPointRigid(Array2D &u, int m, int n);
00231 double interpLowerRowPointRigid(Array2D &u, int m, int n);
00232
00233 double interpLowerColPointSymmetric(Array2D &u, int m, int n);
00234 double interpUpperRowPointSymmetric(Array2D &u, int m, int n);
00235 double interpUpperColPointSymmetric(Array2D &u, int m, int n);
00236 double interpLowerRowPointSymmetric(Array2D &u, int m, int n);
00237
00238 double interpLowerColPointAntisymmetric(Array2D &u, int m, int n);
00239 double interpUpperRowPointAntisymmetric(Array2D &u, int m, int n);
00240 double interpUpperColPointAntisymmetric(Array2D &u, int m, int n);
00241 double interpLowerRowPointAntisymmetric(Array2D &u, int m, int n);
00242
00243 void writeMessage(const char* message, const char* fileName,int ExiT=1, int App=0);
00244
00245
00246 double computeFirstDerivativeInfBoundary(Array2D &u, int m,int n, int stride,int direction, int kind);
00247 double computeFirstDerivativeSupBoundary(Array2D &u, int m,int n, int stride,int direction, int kind);
00248
00249 double computeFirstDerivativeLocalScaleX(Array2D &u, int m,int n,int kind);
00250 double computeFirstDerivativeLocalScaleY(Array2D &u, int m,int n,int kind);
00251 double computeFirstDerivativeInLocalScale(Array2D &u, int m,int n, int direction);
00252
00253 int computeDistanceOfNearestNeighbor(Array2D &u, int m,int n,int direction);
00254
00255 void dataToSparse(Array2D& u);
00256 void sparseToData(Array2D& u);
00257
00258
00259
00260 void extendMesh(Array2D &u, int numberOfNeighbors=1, int numberOfGenerations=1);
00261 void applyConeCondition(Array2D &u);
00262
00263 void verifySpr(Array2D &u);
00264 void verifySprInnerGrid(Array2D &u,int numberOfBordersPoints);
00265
00266 void computeSameMesh(Array2D &u, Array2D &v, Array2D &w);
00267
00268 void plotDataGnuplot(Array2D &u, char* title);
00269 void plotDataGnuplot(Array2D& u, char* title, char* grfFileNameOutput);
00270 void plotDataGnuplot(Array2D &u, char* title, char* grfFileName,char* grfFileNameCfg);
00271
00272 void plotGridGnuplot(Array2D &u, char* title);
00273 void plotGridGnuplot(Array2D& u, char* title, char* grfFileNameOutput);
00274 void plotGridGnuplot(Array2D &u, char* title, char* grfFileName,char* grfFileNameCfg);
00275
00276 int findLevel(int m, int n, int meshLevel);
00277 int findLevel(int m, int n, int meshLevel, int *mPosition, int *nPosition );
00278 int findLocalSpacing(int m, int n);
00279 int findStride(int m,int n);
00280 int findPointPosition(Array2D &u, int m, int n);
00281 int findPositionInMesh(int m, int n, int level, int *mPosition, int *nPosition );
00282 int findMaxDecompositionLevel(Array2D &u);
00283
00284 void initArray(Array2D &u, char* confFileName);
00285 void dataAsciiToBlitz(char *fileNameIn, char *fileNameOut, int sizeX, int sizeY);
00286 void infoNAN(Array2D &u);
00287 long countNAN(Array2D &u);
00288 };
00289
00290 #endif