KerrHiggs.h

00001 #ifndef gridripper_phys_gr_fixmp_kerrhiggs_KerrHiggs_h
00002 #define gridripper_phys_gr_fixmp_kerrhiggs_KerrHiggs_h
00003 
00004 
00005 #include <gridripper/Parameters.h>
00006 #include <gridripper/amr1d/PDE.h>
00007 #include <gridripper/lang/IllegalArgumentException.h>
00008 #include <gridripper/multipole/ScalarFieldMP.h>
00009 
00010 
00011 namespace gridripper { namespace phys { namespace gr { namespace fixmp {
00012 namespace kerrhiggs {
00013 
00014 
00015 using namespace gridripper;
00016 using namespace gridripper::multipole;
00017 using namespace std;
00018 
00019 
00072 class KerrHiggs: public PDE
00073 {
00074 public:
00075     static const GReal_t EPSILON=1e-8;
00076 
00077     /* Field component indices. */
00078     enum { ind_f=0, ind_ft=1, ind_frh=2 };
00079 
00081     const int maxOrder;
00087     const int arraySize;
00088 
00090     const int I_f;      // <- ind_f*arraySize
00091     const int I_ft;     // <- ind_ft*arraySize
00092     const int I_frh;    // <- ind_frh*arraySize
00094     static const int NUM_INDEP_COMPS=2;
00096     static const int NUM_CONSTRAINTS=1;
00098     static const int NUM_COMPS=NUM_INDEP_COMPS+NUM_CONSTRAINTS;
00099 
00101     static const string COMP_NAMES[NUM_COMPS];
00102     static const string CONSTRAINT_NAMES[NUM_CONSTRAINTS];
00103     static const string COORD_LABELS[2];
00104 
00105 private:
00106 
00108     tvalarray<GReal_t> df;
00109 
00111     GReal_t M;          // <- mass
00112     GReal_t a;          // <- angular momentum
00113     GReal_t e;          // <- charge
00114 
00116     GReal_t lambda;    // <- self coupling constant
00117     GReal_t phi0;      // <- equilibrium field value
00118     // (mass=2*sqrt(lambda)*phi0)
00120     bool selfInteraction;
00126     bool allmassive;
00127     // The field is f=(phi-phi0)*r in the simulation if selfinteration 
00128     // is on, otherwise f=phi*r.
00130     GReal_t q;
00131 
00133     GReal_t minrh;
00134     GReal_t maxrh;
00136     GReal_t minrhIntq;
00137     GReal_t maxrhIntq;
00138 
00140     mutable GReal_t r;
00141     mutable GReal_t Delta;
00142     mutable ScalarFieldMP<GComplex_t> Sigma;
00143     mutable ScalarFieldMP<GComplex_t> Gamma;
00144     mutable GComplex_t H2S2SigmaSigma;
00145     mutable GComplex_t H2S2GammaGamma;
00146     mutable GComplex_t scale;
00147     mutable ScalarFieldMP<GComplex_t> scaledSigma;
00148     mutable ScalarFieldMP<GComplex_t> scaledGamma;
00149     ScalarFieldMP<GComplex_t> Y00;
00150     GReal_t neumannTolerance;
00151     mutable GReal_t drhdr;
00152     mutable GReal_t d2rdrh2;
00153     mutable ScalarFieldMP<GComplex_t> physf;
00154     mutable ScalarFieldMP<GComplex_t> physft;
00155     mutable ScalarFieldMP<GComplex_t> physfr;
00156     mutable ScalarFieldMP<GComplex_t> physfperSigma;
00157 
00158     /* Start time. */
00159     GReal_t t0;
00161     GReal_t rh0;
00162 
00164     static GReal_t horizon;
00166     static bool isMinkowski;
00173     static int transformedR;
00174 
00176     bool isSommerfeld;
00177 
00179     int exclude;
00180 
00182     int thresholdIndex;
00183 
00185     GReal_t Theta;
00186     tvector< tvector< tvector<GReal_t> > > coeffstorage1;
00187     tvector< tvector< tvector<GReal_t> > > coeffstorage2;
00188 
00189 public:
00190 
00192     static GReal_t calc_rh(const GReal_t r);
00193     static GReal_t calc_r(const GReal_t rh);
00194     static GReal_t calc_drdrh(const GReal_t rh);
00195     static GReal_t calc_d2rdrh2(const GReal_t rh);
00196 
00197     KerrHiggs(const Parameters* p, const int maxorder, const int arraysize) throw(IllegalArgumentException&);
00198 
00199     ~KerrHiggs();
00200 
00201     GReal_t getMinX() const;
00202     GReal_t getMaxX() const;
00203     GReal_t getPhysicalMinX() const;
00204     GReal_t getPhysicalMaxX() const;
00205     bool isXPeriodic() const;
00206 
00208     int eval(GReal_t* dF, GReal_t t, GReal_t rh,
00209              const GReal_t* F, const GReal_t* F_rh,
00210              const Grid& G, int i, Grad& d, GReal_t dt);
00211 
00219     void evalConstrainedComponents(Grid& G, int i, FieldWrapper& v);
00220 
00221     FieldWrapper* createField(int level) const;
00222 
00223     GReal_t energyDensity(GReal_t t, GReal_t rh,
00224                           const tvalarray<GReal_t>& F) const;
00225 
00226     GReal_t energyFlow(GReal_t t, GReal_t rh,
00227                        const tvalarray<GReal_t>& F) const;
00228 
00229     // Limited to [0,theta]x[0,2pi[.
00230     GReal_t energyFlowLimited(GReal_t t, GReal_t rh, GReal_t theta, 
00231                        tvector< tvector< tvector<GReal_t> > > *coeffstorage, 
00232                        const tvalarray<GReal_t>& F) const;
00233 
00234     GReal_t angmomDensity(GReal_t t, GReal_t rh,
00235                           const tvalarray<GReal_t>& F) const;
00236 
00237     GReal_t angmomFlow(GReal_t t, GReal_t rh,
00238                        const tvalarray<GReal_t>& F) const;
00239 
00240     // Limited to [0,theta]x[0,2pi[.
00241     GReal_t angmomFlowLimited(GReal_t t, GReal_t rh, GReal_t theta, 
00242                        tvector< tvector< tvector<GReal_t> > > *coeffstorage, 
00243                        const tvalarray<GReal_t>& F) const;
00244 
00249     bool canBeExtended(int where) const;
00250 
00252     void mirrorLeft(GReal_t rh, FieldWrapper& f) const;
00253 
00255     void mirrorRight(GReal_t rh, FieldWrapper& f) const;
00256 
00264     bool hasExtendedRefinedFieldData(const Grid& G, int i) const;
00265 
00267     class Energy: public DensityQuantity {
00268     private:
00269         const KerrHiggs& pde;
00270     public:
00271         Energy(const KerrHiggs* p): DensityQuantity(p), pde(*p) { }
00272         GReal_t density(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F)
00273                         const {
00274             return pde.energyDensity(t, rh, F);
00275         }
00276         GReal_t flow(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F) const {
00277             return pde.energyFlow(t, rh, F);
00278         }
00279         DensityQuantity* cloneDensityQuantity() const {
00280             return new Energy(&pde);
00281         }
00282     };
00283     Energy theEnergy;
00284 
00286     class EnergyFlowLimited: public DensityQuantity {
00287     private:
00288         const KerrHiggs& pde;
00289         GReal_t theta;
00290         tvector< tvector< tvector<GReal_t> > > *coeffstorage;
00291     public:
00292         EnergyFlowLimited(const KerrHiggs* p, GReal_t Theta, tvector< tvector< tvector<GReal_t> > > *Coeffstorage): DensityQuantity(p), pde(*p), theta(Theta), coeffstorage(Coeffstorage) { }
00293         GReal_t density(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F)
00294                         const {
00295             return 0.0;
00296         }
00297         GReal_t flow(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F) const {
00298             return pde.energyFlowLimited(t, rh, theta, coeffstorage, F);
00299         }
00300         DensityQuantity* cloneDensityQuantity() const {
00301             return new EnergyFlowLimited(&pde, theta, coeffstorage);
00302         }
00303         GReal_t getTheta() const { return theta; }
00304         void setTheta(GReal_t Theta)
00305         {
00306             if ( coeffstorage!=NULL )
00307             {
00308                 if ( coeffstorage->size() )
00309                     throw IllegalArgumentException("Cannot change theta after initialized coefficient table!", "gridripper_phys_gr_fixmp_kerrhiggs::KerrHiggs::EnergyFlowLimited::setTheta");
00310             }
00311             theta=Theta;
00312         }
00313     };
00314     EnergyFlowLimited theEnergyFlowLimited1, theEnergyFlowLimited2;
00315 
00317     class Angmom: public DensityQuantity {
00318     private:
00319         const KerrHiggs& pde;
00320     public:
00321         Angmom(const KerrHiggs* p): DensityQuantity(p), pde(*p) { }
00322         GReal_t density(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F)
00323                         const {
00324             return pde.angmomDensity(t, rh, F);
00325         }
00326         GReal_t flow(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F)
00327                      const {
00328             return pde.angmomFlow(t, rh, F);
00329         }
00330         DensityQuantity* cloneDensityQuantity() const {
00331             return new Angmom(&pde);
00332         }
00333     };
00334     Angmom theAngmom;
00335 
00337     class AngmomFlowLimited: public DensityQuantity {
00338     private:
00339         const KerrHiggs& pde;
00340         GReal_t theta;
00341         tvector< tvector< tvector<GReal_t> > > *coeffstorage;
00342     public:
00343         AngmomFlowLimited(const KerrHiggs* p, GReal_t Theta, tvector< tvector< tvector<GReal_t> > > *Coeffstorage): DensityQuantity(p), pde(*p), theta(Theta), coeffstorage(Coeffstorage) { }
00344         GReal_t density(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F)
00345                         const {
00346             return 0.0;
00347         }
00348         GReal_t flow(GReal_t t, GReal_t rh, const tvalarray<GReal_t>& F)
00349                      const {
00350             return pde.angmomFlowLimited(t, rh, theta, coeffstorage, F);
00351         }
00352         DensityQuantity* cloneDensityQuantity() const {
00353             return new AngmomFlowLimited(&pde, theta, coeffstorage);
00354         }
00355         GReal_t getTheta() const { return theta; }
00356         void setTheta(GReal_t Theta)
00357         {
00358             if ( coeffstorage!=NULL )
00359             {
00360                 if ( coeffstorage->size() )
00361                     throw IllegalArgumentException("Cannot change theta after initialized coefficient table!", "gridripper_phys_gr_fixmp_kerrhiggs::KerrHiggs::AngmomFlowLimited::setTheta");
00362             }
00363             theta=Theta;
00364         }
00365     };
00366     AngmomFlowLimited theAngmomFlowLimited1, theAngmomFlowLimited2;
00367 
00369     PhysicalQuantityArray getPhysicalQuantities() const;
00370 
00372     class IntqBorder : public MarkerQuantity
00373     {
00374         private:
00375             const GReal_t position;
00376         public:
00377             IntqBorder(const PDE* eq, GReal_t positionarg)
00378              : MarkerQuantity(eq), position(positionarg)
00379             {  }
00380             ~IntqBorder() {  }
00381             std::string getQuantityName() const { return "IntqBorder"; }
00382             GReal_t eval(GReal_t t);
00383             MarkerQuantity* cloneMarkerQuantity() const
00384             { return new IntqBorder(&getPDE(), position); }
00385     };
00386 
00396     class Lightray : public MarkerQuantity
00397     {
00398         private:
00399             const GReal_t M;
00400             const GReal_t a;
00401             const GReal_t e;
00402             const GReal_t r0;
00403             const int direction;
00404             bool firststep;
00405             GReal_t r;
00406             GReal_t tprev;
00407         public:
00408             Lightray(const PDE* eq, GReal_t Marg, GReal_t aarg, GReal_t earg, GReal_t rh0arg, int directionarg)
00409              : MarkerQuantity(eq), M(Marg), a(aarg), e(earg), r0(calc_r(rh0arg)), direction(directionarg), firststep(true)
00410             {  }
00411             ~Lightray() {  }
00412             std::string getQuantityName() const { return "Lightray"; }
00413             GReal_t eval(GReal_t t);
00415             GReal_t rightside(GReal_t r) const;
00416             MarkerQuantity* cloneMarkerQuantity() const
00417             { return new Lightray(&getPDE(), M, a, e, calc_rh(r0), direction); }
00418     };
00419 
00421     MarkerQuantityArray getMarkerQuantities() const;
00422 
00423 };
00424 
00425 
00426 } } } } } // namespace gridripper::phys::gr::fixmp::kerrhiggs
00427 
00428 
00429 #endif /* gridripper_phys_gr_fixmp_kerrhiggs_KerrHiggs_h */

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