Grad.h

00001 #ifndef gridripper_amr1d_Grad_h
00002 #define gridripper_amr1d_Grad_h
00003 
00004 #include <gridripper/tvalarray.h>
00005 #include <gridripper/lang/IllegalArgumentException.h>
00006 #include "FieldWrapper.h"
00007 #include <string>
00008 
00009 namespace gridripper { namespace amr1d {
00010 
00011 using namespace std;
00012 class Grid;
00013 class PDE;
00014 class FieldWrapper;
00015 
00022 class Grad
00023 {
00024 public:
00025     virtual ~Grad() { }
00026 
00028     void d(const Grid& g, PDE* pde, int i, FieldWrapper& result) {
00029         d(g, pde, i, result.data(), result.size());
00030     }
00031 
00033     void d(const Grid& g, PDE* pde, int i, tvalarray<GReal_t>& result) {
00034         d(g, pde, i, (GReal_t*)result, result.size());
00035     }
00036 
00038     void d2(Grid& g, PDE* pde, int i, FieldWrapper& result) {
00039         d2(g, pde, i, result.data(), result.size());
00040     }
00041 
00043     void d2(Grid& g, PDE* pde, int i, tvalarray<GReal_t>& result) {
00044         d2(g, pde, i, (GReal_t*)result, result.size());
00045     }
00046 
00048     virtual void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size)
00049                 =0;
00050 
00052     virtual void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size)
00053                 =0;
00054 
00056     virtual int getNumVelocity() =0;
00057 
00058     virtual Grad* create(const PDE& pde, int level) const =0;
00059 
00060     virtual string toString() const =0;
00061 
00062     static Grad* clone(const Grad* d);
00063 
00068     static void createPair(const string& name,
00069                            const PDE& pde, int level, Grad** d)
00070         throw(IllegalArgumentException&);
00071 
00072 protected:
00073     virtual Grad* clone() const =0;
00074 };
00075 
00077 // First order finite difference schemes
00079 
00081 class Grad_O1_shifted: public Grad
00082 {
00083 private:
00084     const PDE& thePDE;
00085     int theLevel;
00086     FieldWrapper& fw0;
00087     FieldWrapper& fw1;
00088 
00089 public:
00090     Grad_O1_shifted(const PDE& pde, int level);
00091     ~Grad_O1_shifted();
00092 
00093     int getNumVelocity() {
00094         return 1;
00095     }
00096 
00097     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00098 
00099     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00100 
00101     Grad* create(const PDE& pde, int level) const {
00102         return new Grad_O1_shifted(pde, level);
00103     }
00104 
00105     string toString() const {
00106         return "Grad_O1_shifted";
00107     }
00108 
00109 protected:
00110     Grad* clone() const {
00111         return new Grad_O1_shifted(thePDE, theLevel);
00112     }
00113 };
00114 
00119 class Grad_O1_shifted_2: public Grad
00120 {
00121 private:
00122     const PDE& thePDE;
00123     int theLevel;
00124     FieldWrapper& fw0;
00125     FieldWrapper& fw1;
00126 
00127 public:
00128     Grad_O1_shifted_2(const PDE& pde, int level);
00129     ~Grad_O1_shifted_2();
00130 
00131     int getNumVelocity() {
00132         return 2;
00133     }
00134 
00135     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00136 
00137     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00138 
00139     Grad* create(const PDE& pde, int level) const {
00140         return new Grad_O1_shifted_2(pde, level);
00141     }
00142 
00143     string toString() const {
00144         return "Grad_O1_shifted_2";
00145     }
00146 
00147 protected:
00148     Grad* clone() const {
00149         return new Grad_O1_shifted_2(thePDE, theLevel);
00150     }
00151 };
00152 
00154 // Second order finite difference schemes
00156 
00158 class Grad_O2: public Grad
00159 {
00160 private:
00161     const PDE& thePDE;
00162     int theLevel;
00163     FieldWrapper& fw0;
00164     FieldWrapper& fw1;
00165     FieldWrapper& fw2;
00166 
00167 public:
00168     Grad_O2(const PDE& pde, int level);
00169     ~Grad_O2();
00170 
00171     int getNumVelocity() {
00172         return 1;
00173     }
00174 
00175     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00176 
00177     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00178 
00179     Grad* create(const PDE& pde, int level) const {
00180         return new Grad_O2(pde, level);
00181     }
00182 
00183     string toString() const {
00184         return "Grad_O2";
00185     }
00186 
00187 protected:
00188     Grad* clone() const {
00189         return new Grad_O2(thePDE, theLevel);
00190     }
00191 };
00192 
00197 class Grad_O2_2: public Grad
00198 {
00199 private:
00200     const PDE& thePDE;
00201     int theLevel;
00202     FieldWrapper& fw0;
00203     FieldWrapper& fw1;
00204     FieldWrapper& fw2;
00205 
00206 public:
00207     Grad_O2_2(const PDE& pde, int level);
00208     ~Grad_O2_2();
00209 
00210     int getNumVelocity() {
00211         return 2;
00212     }
00213 
00214     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00215 
00216     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00217 
00218     Grad* create(const PDE& pde, int level) const {
00219         return new Grad_O2_2(pde, level);
00220     }
00221 
00222     string toString() const {
00223         return "Grad_O2_2";
00224     }
00225 
00226 protected:
00227     Grad* clone() const {
00228         return new Grad_O2_2(thePDE, theLevel);
00229     }
00230 };
00231 
00236 class Grad_O21: public Grad
00237 {
00238 private:
00239     const PDE& thePDE;
00240     int theLevel;
00241     FieldWrapper& fw0;
00242     FieldWrapper& fw1;
00243     FieldWrapper& fw2;
00244 
00245 public:
00246     Grad_O21(const PDE& pde, int level);
00247     ~Grad_O21();
00248 
00249     int getNumVelocity() {
00250         return 1;
00251     }
00252 
00253     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00254 
00255     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00256 
00257     Grad* create(const PDE& pde, int level) const {
00258         return new Grad_O21(pde, level);
00259     }
00260 
00261     string toString() const {
00262         return "Grad_O21";
00263     }
00264 
00265 protected:
00266     Grad* clone() const {
00267         return new Grad_O21(thePDE, theLevel);
00268     }
00269 };
00270 
00276 class Grad_O21_2: public Grad
00277 {
00278 private:
00279     const PDE& thePDE;
00280     int theLevel;
00281     FieldWrapper& fw0;
00282     FieldWrapper& fw1;
00283     FieldWrapper& fw2;
00284 
00285 public:
00286     Grad_O21_2(const PDE& pde, int level);
00287     ~Grad_O21_2();
00288 
00289     int getNumVelocity() {
00290         return 2;
00291     }
00292 
00293     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00294 
00295     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00296 
00297     Grad* create(const PDE& pde, int level) const {
00298         return new Grad_O21_2(pde, level);
00299     }
00300 
00301     string toString() const {
00302         return "Grad_O21_2";
00303     }
00304 
00305 protected:
00306     Grad* clone() const {
00307         return new Grad_O21_2(thePDE, theLevel);
00308     }
00309 };
00310 
00312 // Fourth order finite difference schemes
00314 
00316 class Grad_O4: public Grad
00317 {
00318 private:
00319     const PDE& thePDE;
00320     int theLevel;
00321     FieldWrapper& fw0;
00322     FieldWrapper& fw1;
00323     FieldWrapper& fw2;
00324     FieldWrapper& fw3;
00325     FieldWrapper& fw4;
00326 
00327 public:
00328     Grad_O4(const PDE& pde, int level);
00329     ~Grad_O4();
00330 
00331     int getNumVelocity() {
00332         return 2;
00333     }
00334 
00335     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00336 
00337     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00338 
00339     Grad* create(const PDE& pde, int level) const {
00340         return new Grad_O4(pde, level);
00341     }
00342 
00343     string toString() const {
00344         return "Grad_O4";
00345     }
00346 
00347 protected:
00348     Grad* clone() const {
00349         return new Grad_O4(thePDE, theLevel);
00350     }
00351 };
00352 
00357 class Grad_O4_2: public Grad
00358 {
00359 private:
00360     const PDE& thePDE;
00361     int theLevel;
00362     FieldWrapper& fw0;
00363     FieldWrapper& fw1;
00364     FieldWrapper& fw2;
00365     FieldWrapper& fw3;
00366     FieldWrapper& fw4;
00367 
00368 public:
00369     Grad_O4_2(const PDE& pde, int level);
00370     ~Grad_O4_2();
00371 
00372     int getNumVelocity() {
00373         return 4;
00374     }
00375 
00376     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00377 
00378     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00379 
00380     Grad* create(const PDE& pde, int level) const {
00381         return new Grad_O4_2(pde, level);
00382     }
00383 
00384     string toString() const {
00385         return "Grad_O4_2";
00386     }
00387 
00388 protected:
00389     Grad* clone() const {
00390         return new Grad_O4_2(thePDE, theLevel);
00391     }
00392 };
00393 
00398 class Grad_O421: public Grad
00399 {
00400 private:
00401     const PDE& thePDE;
00402     int theLevel;
00403     FieldWrapper& fw0;
00404     FieldWrapper& fw1;
00405     FieldWrapper& fw2;
00406     FieldWrapper& fw3;
00407     FieldWrapper& fw4;
00408 
00409 public:
00410     Grad_O421(const PDE& pde, int level);
00411     ~Grad_O421();
00412 
00413     int getNumVelocity() {
00414         return 2;
00415     }
00416 
00417     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00418 
00419     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00420 
00421     Grad* create(const PDE& pde, int level) const {
00422         return new Grad_O421(pde, level);
00423     }
00424 
00425     string toString() const {
00426         return "Grad_O421";
00427     }
00428 
00429 protected:
00430     Grad* clone() const {
00431         return new Grad_O421(thePDE, theLevel);
00432     }
00433 };
00434 
00440 class Grad_O421_2: public Grad
00441 {
00442 private:
00443     const PDE& thePDE;
00444     int theLevel;
00445     FieldWrapper& fw0;
00446     FieldWrapper& fw1;
00447     FieldWrapper& fw2;
00448     FieldWrapper& fw3;
00449     FieldWrapper& fw4;
00450 
00451 public:
00452     Grad_O421_2(const PDE& pde, int level);
00453     ~Grad_O421_2();
00454 
00455     int getNumVelocity() {
00456         return 4;
00457     }
00458 
00459     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00460 
00461     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00462 
00463     Grad* create(const PDE& pde, int level) const {
00464         return new Grad_O421_2(pde, level);
00465     }
00466 
00467     string toString() const {
00468         return "Grad_O421_2";
00469     }
00470 
00471 protected:
00472     Grad* clone() const {
00473         return new Grad_O421_2(thePDE, theLevel);
00474     }
00475 };
00476 
00478 // Sixth order finite difference schemes
00480 
00482 class Grad_O6: public Grad
00483 {
00484 private:
00485     const PDE& thePDE;
00486     int theLevel;
00487     FieldWrapper& fw0;
00488     FieldWrapper& fw1;
00489     FieldWrapper& fw2;
00490     FieldWrapper& fw3;
00491     FieldWrapper& fw4;
00492     FieldWrapper& fw5;
00493     FieldWrapper& fw6;
00494 
00495 public:
00496     Grad_O6(const PDE& pde, int level);
00497     ~Grad_O6();
00498 
00499     int getNumVelocity() {
00500         return 3;
00501     }
00502 
00503     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00504 
00505     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00506 
00507     Grad* create(const PDE& pde, int level) const {
00508         return new Grad_O6(pde, level);
00509     }
00510 
00511     string toString() const {
00512         return "Grad_O6";
00513     }
00514 
00515 protected:
00516     Grad* clone() const {
00517         return new Grad_O6(thePDE, theLevel);
00518     }
00519 };
00520 
00525 class Grad_O6_2: public Grad
00526 {
00527 private:
00528     const PDE& thePDE;
00529     int theLevel;
00530     FieldWrapper& fw0;
00531     FieldWrapper& fw1;
00532     FieldWrapper& fw2;
00533     FieldWrapper& fw3;
00534     FieldWrapper& fw4;
00535     FieldWrapper& fw5;
00536     FieldWrapper& fw6;
00537 
00538 public:
00539     Grad_O6_2(const PDE& pde, int level);
00540     ~Grad_O6_2();
00541 
00542     int getNumVelocity() {
00543         return 6;
00544     }
00545 
00546     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00547 
00548     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00549 
00550     Grad* create(const PDE& pde, int level) const {
00551         return new Grad_O6_2(pde, level);
00552     }
00553 
00554     string toString() const {
00555         return "Grad_O6_2";
00556     }
00557 
00558 protected:
00559     Grad* clone() const {
00560         return new Grad_O6_2(thePDE, theLevel);
00561     }
00562 };
00563 
00568 class Grad_O6421: public Grad
00569 {
00570 private:
00571     const PDE& thePDE;
00572     int theLevel;
00573     FieldWrapper& fw0;
00574     FieldWrapper& fw1;
00575     FieldWrapper& fw2;
00576     FieldWrapper& fw3;
00577     FieldWrapper& fw4;
00578     FieldWrapper& fw5;
00579     FieldWrapper& fw6;
00580 
00581 public:
00582     Grad_O6421(const PDE& pde, int level);
00583     ~Grad_O6421();
00584 
00585     int getNumVelocity() {
00586         return 3;
00587     }
00588 
00589     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00590 
00591     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00592 
00593     Grad* create(const PDE& pde, int level) const {
00594         return new Grad_O6(pde, level);
00595     }
00596 
00597     string toString() const {
00598         return "Grad_O6421";
00599     }
00600 
00601 protected:
00602     Grad* clone() const {
00603         return new Grad_O6421(thePDE, theLevel);
00604     }
00605 };
00606 
00613 class Grad_O6421_2: public Grad
00614 {
00615 private:
00616     const PDE& thePDE;
00617     int theLevel;
00618     FieldWrapper& fw0;
00619     FieldWrapper& fw1;
00620     FieldWrapper& fw2;
00621     FieldWrapper& fw3;
00622     FieldWrapper& fw4;
00623     FieldWrapper& fw5;
00624     FieldWrapper& fw6;
00625 
00626 public:
00627     Grad_O6421_2(const PDE& pde, int level);
00628     ~Grad_O6421_2();
00629 
00630     int getNumVelocity() {
00631         return 6;
00632     }
00633 
00634     void d(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00635 
00636     void d2(const Grid& g, PDE* pde, int i, GReal_t* result, int size);
00637 
00638     Grad* create(const PDE& pde, int level) const {
00639         return new Grad_O6_2(pde, level);
00640     }
00641 
00642     string toString() const {
00643         return "Grad_O6421_2";
00644     }
00645 
00646 protected:
00647     Grad* clone() const {
00648         return new Grad_O6421_2(thePDE, theLevel);
00649     }
00650 };
00651 
00652 } } // namespace gridripper::amr1d
00653 
00654 #endif /* gridripper_amr1d_Grad_h */

Generated on Wed Jun 17 18:46:47 2009 for GridRipper by  doxygen 1.5.6