TwoFieldsODE.h

00001 #ifndef gridripper_phys_minkowski_ymh_moncrief_TwoFieldsODE_h
00002 #define gridripper_phys_minkowski_ymh_moncrief_TwoFieldsODE_h
00003 
00004 #include <gridripper/Parameters.h>
00005 #include <gridripper/amr1d/FieldArray.h>
00006 #include <gridripper/odesolver/ODE.h>
00007 #include <gridripper/lang/IllegalArgumentException.h>
00008 
00009 namespace gridripper { namespace phys { namespace minkowski { namespace ymh {
00010 namespace moncrief {
00011 
00012 using namespace gridripper;
00013 using namespace gridripper::odesolver;
00014 using namespace gridripper::amr1d;
00015 using namespace std;
00016 
00026 class TwoFieldsODE: public ODE
00027 {
00028 private:
00029     // Field indices:
00030     enum {I_h  = 0,
00031           I_w  = 1,
00032           I_hR = 2,
00033           I_wR = 3,
00034           NUM_COMPS = 4};
00035 
00036     // Order of fields in the derivative matrix: h_R, w_R, h, w
00037     static const int MATORD[4];
00038 
00039     static const string COMPNAMES[NUM_COMPS];
00040 
00041     GReal_t kappa;
00042     GReal_t lambda;
00043     GReal_t wwR0;
00044     GReal_t hhR0;
00045     GReal_t hhRR0;
00046     GReal_t hh1;
00047     GReal_t hhR1;
00048 
00049     tvalarray<GReal_t> df;
00050 
00051 public:
00052     TwoFieldsODE(const Parameters* p) throw(IllegalArgumentException&);
00053 
00054     FieldArray getInitialValuesForShooting() const;
00055 
00056     tvalarray<GReal_t> getInitialValuesForRelaxation(int nx) const;
00057 
00058     tvalarray<GReal_t> getInitialX() const {
00059         return tvalarray<GReal_t>(0.0, 1);
00060     }
00061 
00062     GReal_t getMinX() const {
00063         return 0;
00064     }
00065 
00066     GReal_t getMaxX() const {
00067         return 1;
00068     }
00069 
00076     void getPhysicalField(GReal_t R, GReal_t* f) const {
00077         GReal_t hh = f[I_h];
00078         GReal_t hhR = f[I_hR];
00079         GReal_t ww = f[I_w];
00080         GReal_t wwR = f[I_wR];
00081         f[I_h] = R*(hh - 2/kappa);
00082         f[I_hR] = R*hhR + hh - 2/kappa;
00083         f[I_w] = R*ww + 1;
00084         f[I_wR] = R*wwR + ww;
00085     }
00086 
00087     void initPDE(GReal_t R, const GReal_t* fode, GReal_t* fpde);
00088 
00089     void constrain(tvalarray<GReal_t>& F);
00090 
00091     void eval(const GReal_t* F, int offset, GReal_t R, GReal_t* dF);
00092 
00093     int getMatrixFieldOrder(int i) const {
00094         return MATORD[i];
00095     }
00096 
00097     bool dRHS(const GReal_t* F, int offset, GReal_t R, GReal_t* drhs);
00098 
00099 private:
00100 
00101     static GReal_t interpolate_f(GReal_t f0, GReal_t fx0,
00102                                GReal_t f1, GReal_t fx1, GReal_t x);
00103 
00104     static GReal_t interpolate_fx(GReal_t f0, GReal_t fx0,
00105                                 GReal_t f1, GReal_t fx1, GReal_t x);
00106 };
00107 
00108 } } } } } // namespace gridripper::phys::minkowski::ymh::moncrief;
00109 
00110 #endif /* gridripper_phys_minkowski_ymh_moncrief_TwoFieldsODE_h */