00001 #ifndef gridripper_phys_minkowski_ymh_moncrief_TwoFields_h
00002 #define gridripper_phys_minkowski_ymh_moncrief_TwoFields_h
00003
00004 #include <gridripper/amr1d/PDE.h>
00005 #include <gridripper/Parameters.h>
00006 #include <gridripper/lang/IllegalArgumentException.h>
00007
00008 namespace gridripper { namespace phys { namespace minkowski { namespace ymh {
00009 namespace moncrief {
00010
00011 using namespace gridripper;
00012 using namespace gridripper::util;
00013 using namespace gridripper::amr1d;
00014 using namespace std;
00015
00025 class TwoFields: public PDE
00026 {
00027 public:
00028
00029 enum {I_h = 0,
00030 I_w = 1,
00031 I_hT = 2,
00032 I_wT = 3,
00033 NUM_INDEP_COMPS = 4,
00034 NUM_COMPS = NUM_INDEP_COMPS + 2,
00035 I_hR = NUM_INDEP_COMPS,
00036 I_wR = NUM_INDEP_COMPS + 1};
00037
00038 private:
00039
00040 static const int F_h;
00041 static const int F_w;
00042 static const int F_hT;
00043 static const int F_wT;
00044 static const int F_ALL_INDEP;
00045 static const int F_hR;
00046 static const int F_wR;
00047 static const int F_ALL_DEP;
00048 static const int F_ALL;
00049
00050 static const string COMPNAMES[NUM_COMPS];
00051
00052 static const string CONSTRAINT_NAMES[2];
00053
00054 GReal_t kappa;
00055
00056 GReal_t kappaSq;
00057
00058 GReal_t lambda;
00059
00061 GReal_t Rmax;
00062
00063 GReal_t R0;
00064
00065 tvalarray<GReal_t> df;
00066
00067 class Energy: public DensityQuantity {
00068 private:
00069 const TwoFields& pde;
00070 public:
00071 Energy(const TwoFields* p): DensityQuantity(p), pde(*p) { }
00072 GReal_t density(GReal_t T, GReal_t R, const tvalarray<GReal_t>& F)
00073 const;
00074 GReal_t flow(GReal_t T, GReal_t R, const tvalarray<GReal_t>& F)
00075 const;
00076 DensityQuantity* cloneDensityQuantity() const {
00077 return new Energy(&pde);
00078 }
00079 } theEnergy;
00080
00081 public:
00082 TwoFields(const Parameters* p) throw(IllegalArgumentException&);
00083
00084 GReal_t getMinX() const {
00085 return 0;
00086 }
00087
00088 GReal_t getMaxX() const {
00089 return Rmax;
00090 }
00091
00092 GReal_t getPhysicalMaxX() const {
00093 return 1;
00094 }
00095
00096 int eval(GReal_t* dF, GReal_t T, GReal_t R,
00097 const GReal_t* F, const GReal_t* FR,
00098 const Grid& g, int i, Grad& d, GReal_t dT);
00099
00100 void evalConstrainedComponents(Grid& g, int i, FieldWrapper& fw);
00101
00102 FieldWrapper* createField(int level) const;
00103
00108 bool canBeExtended(int where) const {
00109 return where == LEFT;
00110 }
00111
00112 void mirrorLeft(GReal_t R, FieldWrapper& f) const {
00113 GReal_t* v = f.data();
00114 GReal_t Rsq = R*R;
00115 GReal_t Omega = kappa*(1-Rsq)/2;
00116 GReal_t Omegasq = Omega*Omega;
00117
00118 v[I_h] = v[I_h] + 2*R/Omega;
00119 v[I_hT] = v[I_hT];
00120 v[I_hR] = -v[I_hR] - kappa*(1+Rsq)/Omegasq;
00121
00122 v[I_w] = v[I_w];
00123 v[I_wT] = v[I_wT];
00124 v[I_wR] = -v[I_wR];
00125 }
00126
00134 bool hasExtendedRefinedFieldData(const Grid& g, int i) const;
00135
00136 PhysicalQuantityArray getPhysicalQuantities() const;
00137
00138 private:
00139 GReal_t energyMomentumT00(GReal_t T, GReal_t R, const tvalarray<GReal_t>& F)
00140 const;
00141
00142 GReal_t energyMomentumT01(GReal_t T, GReal_t R, const tvalarray<GReal_t>& F)
00143 const;
00144 };
00145
00146 } } } } }
00147
00148 #endif