00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef COMP_GNUOLD
00024 #include <iostream.h>
00025 #include <fstream.h>
00026 #include <time.h>
00027 #include <math.h>
00028 #else
00029 #include <iostream>
00030 #include <fstream>
00031 #include <ctime>
00032 #include <cmath>
00033 #endif
00034
00035
00036
00037 #include "../parser.h"
00038
00039
00040 #include "../paramete.h"
00041 #include "../abbrevi.h"
00042 #include "../math_lib/math_lib.h"
00043
00044
00045 #include "../basic/basic.h"
00046
00047
00048 #include "../domain/domain.h"
00049
00050
00051 #include "../formulas/boundy.h"
00052 #include "../formulas/loc_sten.h"
00053
00054
00055 #include "../grid/gpar.h"
00056 #include "../grid/parallel.h"
00057 #include "../grid/mgcoeff.h"
00058 #include "../grid/sto_man.h"
00059 #include "../grid/gridbase.h"
00060 #include "../grid/grid.h"
00061 #include "../grid/input.h"
00062
00063
00064 #include "../evpar/evpar.h"
00065
00066
00067
00068 #include "variable.h"
00069 #include "eleme.h"
00070
00072
00073
00074
00075
00077
00079
00080
00081 DExpr<CoordinateX> X() {
00082 typedef CoordinateX ExprT;
00083 return DExpr<ExprT>(ExprT());
00084 }
00085
00086 DExpr<CoordinateY> Y() {
00087 typedef CoordinateY ExprT;
00088 return DExpr<ExprT>(ExprT());
00089 }
00090
00091 DExpr<CoordinateZ> Z() {
00092 typedef CoordinateZ ExprT;
00093 return DExpr<ExprT>(ExprT());
00094 }
00095
00096
00097
00099
00100
00101
00102
00104
00105
00106
00107 Subgrid operator&(Subgrid a, Subgrid b) {
00108 if(a.run_boundary()==true || b.run_boundary()==true) {
00109 return Subgrid(a.run_interior() || b.run_interior(),
00110 a.run_nearb() || b.run_nearb(),true);
00111 }
00112 if(a.run_boundary()<false && b.run_boundary()<false) {
00113 int r_boundary;
00114 r_boundary = -a.grid->Give_number_label_bo();
00115 a.grid->Put_union_label(-r_boundary,-a.run_boundary(),-b.run_boundary());
00116
00117 if(a.static_grid==false) a.Free();
00118 if(b.static_grid==false) b.Free();
00119
00120 return Subgrid(a.run_interior() || b.run_interior(),
00121 a.run_nearb() || b.run_nearb(),
00122 r_boundary,a.grid);
00123 }
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 if(a.run_boundary()<false) {
00137 return Subgrid(a.static_grid,
00138 a.run_interior() || b.run_interior(),
00139 a.run_nearb() || b.run_nearb(),
00140 a.run_boundary(),a.grid);
00141 }
00142
00143
00144 return Subgrid(b.static_grid,
00145 a.run_interior() || b.run_interior(),
00146 a.run_nearb() || b.run_nearb(),
00147 b.run_boundary(),b.grid);
00148
00149 }
00150
00151
00152 DExpr<DExprResP<DExprLIT, Subgrid> >
00153 operator|(double x, const Subgrid& r)
00154 {
00155 typedef DExprResP<DExprLIT, Subgrid> ExprT;
00156 return DExpr<ExprT>(ExprT(x,r));
00157 }
00158
00159 DExprResVarP<Subgrid>
00160 operator|(Variable &a, const Subgrid& r)
00161 {
00162 typedef DExprResVarP<Subgrid> ExprT;
00163 return ExprT(ExprT(a,r));
00164 }
00165
00166 FunctionClass
00167 operator|(double (*formula)(double x,double y, double z), const Subgrid& r)
00168 {
00169 return FunctionClass(formula,r);
00170 }
00171
00173
00174
00175 DExprResDomain<DExprLIT>
00176 operator|(double x, const Domain& dom)
00177 {
00178 typedef DExprResDomain<DExprLIT> ExprT;
00179 return ExprT(x,dom);
00180 }
00181
00182
00184
00185
00186
00187
00188 DExpr<DExprBinOp<DExprLIT, DExprVAR, DApMul> >
00189 operator*(double x, Variable& a)
00190 {
00191 typedef DExprBinOp<DExprLIT, DExprVAR, DApMul> ExprT;
00192 return DExpr<ExprT>(ExprT(DExprLIT(x),DExprVAR(a)));
00193 }
00194
00195
00196 DExpr<DExprBinOp<Local_var, DExprVAR, DApMul> >
00197 operator*( Local_var& x,Variable& a)
00198 {
00199 typedef DExprBinOp<Local_var, DExprVAR, DApMul> ExprT;
00200 return DExpr<ExprT>(ExprT(x,DExprVAR(a)));
00201 }
00202
00203
00204 DExpr<DExprBinOp<DExprVAR, DExprLIT, DApMul> >
00205 operator*(Variable& a,double x)
00206 {
00207 typedef DExprBinOp<DExprVAR, DExprLIT, DApMul> ExprT;
00208 return DExpr<ExprT>(ExprT(DExprVAR(a),DExprLIT(x)));
00209 }
00210
00211
00212 DExpr<DExprBinOp<DExprVAR, Local_var, DApMul> >
00213 operator*(Variable& a,Local_var& x)
00214 {
00215 typedef DExprBinOp<DExprVAR, Local_var, DApMul> ExprT;
00216 return DExpr<ExprT>(ExprT(DExprVAR(a),x));
00217 }
00218
00219
00220 DExpr<DExprBinOp<DExprVAR, DExprVAR, DApMul> >
00221 operator*(Variable& b, Variable& a)
00222 {
00223 typedef DExprBinOp<DExprVAR, DExprVAR, DApMul> ExprT;
00224 return DExpr<ExprT>(ExprT(DExprVAR(b),DExprVAR(a)));
00225 }
00226
00227
00228
00229 DExpr<DExprBinOp<Local_var, DExprLIT, DApMul> >
00230 operator*(Local_var& a,double x)
00231 {
00232 typedef DExprBinOp<Local_var, DExprLIT, DApMul> ExprT;
00233 return DExpr<ExprT>(ExprT(a,DExprLIT(x)));
00234 }
00235
00236 DExpr<DExprBinOp<DExprLIT, Local_var, DApMul> >
00237 operator*(double x, Local_var& a)
00238 {
00239 typedef DExprBinOp<DExprLIT, Local_var, DApMul> ExprT;
00240 return DExpr<ExprT>(ExprT(DExprLIT(x),a));
00241 }
00242
00243 DExpr<DExprBinOp<Local_var, Local_var, DApMul> >
00244 operator*(Local_var& b, Local_var& a)
00245 {
00246 typedef DExprBinOp<Local_var, Local_var, DApMul> ExprT;
00247 return DExpr<ExprT>(ExprT(b,a));
00248 }
00249
00250
00251
00252
00253
00254
00255 DExpr<DExprBinOp<DExprLIT, DExprVAR, DApAdd> >
00256 operator+(double x,Variable& a)
00257 {
00258 typedef DExprBinOp<DExprLIT, DExprVAR, DApAdd> ExprT;
00259 return DExpr<ExprT>(ExprT(DExprLIT(x),DExprVAR(a)));
00260 }
00261
00262
00263 DExpr<DExprBinOp<Local_var, DExprVAR, DApAdd> >
00264 operator+( Local_var& x,Variable& a)
00265 {
00266 typedef DExprBinOp<Local_var, DExprVAR, DApAdd> ExprT;
00267 return DExpr<ExprT>(ExprT(x,DExprVAR(a)));
00268 }
00269
00270
00271 DExpr<DExprBinOp<DExprVAR, DExprLIT, DApAdd> >
00272 operator+(Variable& a,double x)
00273 {
00274 typedef DExprBinOp<DExprVAR, DExprLIT, DApAdd> ExprT;
00275 return DExpr<ExprT>(ExprT(DExprVAR(a),DExprLIT(x)));
00276 }
00277
00278
00279
00280 DExpr<DExprBinOp<DExprVAR, Local_var, DApAdd> >
00281 operator+(Variable& a,Local_var& x)
00282 {
00283 typedef DExprBinOp<DExprVAR, Local_var, DApAdd> ExprT;
00284 return DExpr<ExprT>(ExprT(DExprVAR(a),x));
00285 }
00286
00287
00288
00289 DExpr<DExprBinOp<DExprVAR, DExprVAR, DApAdd> >
00290 operator+(Variable& b, Variable& a)
00291 {
00292 typedef DExprBinOp<DExprVAR, DExprVAR, DApAdd> ExprT;
00293 return DExpr<ExprT>(ExprT(DExprVAR(b),DExprVAR(a)));
00294 }
00295
00296
00297 DExpr<DExprBinOp<Local_var, DExprLIT, DApAdd> >
00298 operator+(Local_var& a,double x)
00299 {
00300 typedef DExprBinOp<Local_var, DExprLIT, DApAdd> ExprT;
00301 return DExpr<ExprT>(ExprT(a,DExprLIT(x)));
00302 }
00303
00304 DExpr<DExprBinOp<DExprLIT, Local_var, DApAdd> >
00305 operator+(double x, Local_var& a)
00306 {
00307 typedef DExprBinOp<DExprLIT, Local_var, DApAdd> ExprT;
00308 return DExpr<ExprT>(ExprT(DExprLIT(x),a));
00309 }
00310
00311 DExpr<DExprBinOp<Local_var, Local_var, DApAdd> >
00312 operator+(Local_var& b, Local_var& a)
00313 {
00314 typedef DExprBinOp<Local_var, Local_var, DApAdd> ExprT;
00315 return DExpr<ExprT>(ExprT(b,a));
00316 }
00317
00318
00319 DExpr<DExprBinOp<DExprLIT, DExprVAR, DApSub> >
00320 operator-(double x,Variable& a)
00321 {
00322 typedef DExprBinOp<DExprLIT, DExprVAR, DApSub> ExprT;
00323 return DExpr<ExprT>(ExprT(DExprLIT(x),DExprVAR(a)));
00324 }
00325
00326
00327 DExpr<DExprBinOp<Local_var, DExprVAR, DApSub> >
00328 operator-( Local_var& x,Variable& a)
00329 {
00330 typedef DExprBinOp<Local_var, DExprVAR, DApSub> ExprT;
00331 return DExpr<ExprT>(ExprT(x,DExprVAR(a)));
00332 }
00333
00334
00335 DExpr<DExprBinOp<DExprVAR, DExprLIT, DApSub> >
00336 operator-(Variable& a,double x)
00337 {
00338 typedef DExprBinOp<DExprVAR, DExprLIT, DApSub> ExprT;
00339 return DExpr<ExprT>(ExprT(DExprVAR(a),DExprLIT(x)));
00340 }
00341
00342
00343 DExpr<DExprBinOp<DExprVAR, Local_var, DApSub> >
00344 operator-(Variable& a,Local_var& x)
00345 {
00346 typedef DExprBinOp<DExprVAR, Local_var, DApSub> ExprT;
00347 return DExpr<ExprT>(ExprT(DExprVAR(a),x));
00348 }
00349
00350
00351
00352 DExpr<DExprBinOp<DExprVAR, DExprVAR, DApSub> >
00353 operator-(Variable& b, Variable& a)
00354 {
00355 typedef DExprBinOp<DExprVAR, DExprVAR, DApSub> ExprT;
00356 return DExpr<ExprT>(ExprT(DExprVAR(b),DExprVAR(a)));
00357 }
00358
00359
00360 DExpr<DExprBinOp<Local_var, DExprLIT, DApSub> >
00361 operator-(Local_var& a,double x)
00362 {
00363 typedef DExprBinOp<Local_var, DExprLIT, DApSub> ExprT;
00364 return DExpr<ExprT>(ExprT(a,DExprLIT(x)));
00365 }
00366
00367 DExpr<DExprBinOp<DExprLIT, Local_var, DApSub> >
00368 operator-(double x, Local_var& a)
00369 {
00370 typedef DExprBinOp<DExprLIT, Local_var, DApSub> ExprT;
00371 return DExpr<ExprT>(ExprT(DExprLIT(x),a));
00372 }
00373
00374
00375 DExpr<DExprBinOp<Local_var, Local_var, DApSub> >
00376 operator-(Local_var& b, Local_var& a)
00377 {
00378 typedef DExprBinOp<Local_var, Local_var, DApSub> ExprT;
00379 return DExpr<ExprT>(ExprT(b,a));
00380 }
00381
00382
00383 DExpr<DExprBinOp<DExprLIT, DExprVAR, DApDivide> >
00384 operator/(double x,Variable& a)
00385 {
00386 typedef DExprBinOp<DExprLIT, DExprVAR, DApDivide> ExprT;
00387 return DExpr<ExprT>(ExprT(DExprLIT(x),DExprVAR(a)));
00388 }
00389
00390
00391 DExpr<DExprBinOp<Local_var, DExprVAR, DApDivide> >
00392 operator/( Local_var& x,Variable& a)
00393 {
00394 typedef DExprBinOp<Local_var, DExprVAR, DApDivide> ExprT;
00395 return DExpr<ExprT>(ExprT(x,DExprVAR(a)));
00396 }
00397
00398
00399
00400 DExpr<DExprBinOp<DExprVAR, DExprLIT, DApDivide> >
00401 operator/(Variable& a,double x)
00402 {
00403 typedef DExprBinOp<DExprVAR, DExprLIT, DApDivide> ExprT;
00404 return DExpr<ExprT>(ExprT(DExprVAR(a),DExprLIT(x)));
00405 }
00406
00407
00408 DExpr<DExprBinOp<DExprVAR, Local_var, DApDivide> >
00409 operator/(Variable& a,Local_var& x)
00410 {
00411 typedef DExprBinOp<DExprVAR, Local_var, DApDivide> ExprT;
00412 return DExpr<ExprT>(ExprT(DExprVAR(a),x));
00413 }
00414
00415 DExpr<DExprBinOp<DExprVAR, DExprVAR, DApDivide> >
00416 operator/(Variable& b, Variable& a)
00417 {
00418 typedef DExprBinOp<DExprVAR, DExprVAR, DApDivide> ExprT;
00419 return DExpr<ExprT>(ExprT(DExprVAR(b),DExprVAR(a)));
00420 }
00421
00422
00423 DExpr<DExprBinOp<Local_var, DExprLIT, DApDivide> >
00424 operator/(Local_var& a,double x)
00425 {
00426 typedef DExprBinOp<Local_var, DExprLIT, DApDivide> ExprT;
00427 return DExpr<ExprT>(ExprT(a,DExprLIT(x)));
00428 }
00429
00430 DExpr<DExprBinOp<DExprLIT, Local_var, DApDivide> >
00431 operator/(double x, Local_var& a)
00432 {
00433 typedef DExprBinOp<DExprLIT, Local_var, DApDivide> ExprT;
00434 return DExpr<ExprT>(ExprT(DExprLIT(x),a));
00435 }
00436
00437 DExpr<DExprBinOp<Local_var, Local_var, DApDivide> >
00438 operator/(Local_var& b, Local_var& a)
00439 {
00440 typedef DExprBinOp<Local_var, Local_var, DApDivide> ExprT;
00441 return DExpr<ExprT>(ExprT(b,a));
00442 }
00443
00444
00446
00447
00448
00449
00450 DExpr<DExprMinusUnaOp<Local_var> >
00451 operator-(Local_var& x)
00452 {
00453 typedef DExprMinusUnaOp<Local_var> ExprT;
00454 return DExpr<ExprT>(ExprT(x));
00455 }
00456
00457 DExpr<DExprMinusUnaOp<DExprVAR> >
00458 operator-(Variable& v)
00459 {
00460 typedef DExprMinusUnaOp<DExprVAR> ExprT;
00461 return DExpr<ExprT>(ExprT(DExprVAR(v)));
00462 }
00463
00464