ODE.h

00001 #ifndef gridripper_amr1d_odesolver_ODE_h
00002 #define gridripper_amr1d_odesolver_ODE_h
00003 
00004 #include <gridripper/amr1d/FieldArray.h>
00005 #include <gridripper/amr1d/InitCond.h>
00006 #include <gridripper/amr1d/PDE.h>
00007 #include <gridripper/tvalarray.h>
00008 #include <string>
00009 
00010 namespace gridripper { namespace odesolver {
00011 
00012 using namespace gridripper::amr1d;
00013 using namespace std;
00014 
00022 class ODE
00023 {
00024 private:
00025     int numComponents;
00026 
00027     const string* componentNames;
00028 
00029     const InitCond* thePDEInitCond;
00030 
00031     const PDE* thePDE;
00032 
00033 protected:
00039     ODE(int nc, const string* compnames) {
00040         numComponents = nc;
00041         componentNames = compnames;
00042     }
00043 
00044 public: 
00045     virtual ~ODE() { }
00046 
00052     virtual bool isNumericalConstraintSettingPassedToPDE() const {
00053         return true;
00054     }
00055 
00061     virtual bool isConstrainedInInit() const {
00062         return true;
00063     }
00064 
00070     virtual void constrain(tvalarray<GReal_t>& mesh) {
00071     }
00072 
00080     virtual void eval(const GReal_t* f, int offset, GReal_t x, GReal_t* df) =0;
00081 
00082     virtual int getMatrixFieldOrder(int i) const {
00083         return i;
00084     }
00085 
00086     virtual bool hasExactSolution() const {
00087         return false;
00088     }
00089 
00090     virtual void getExactSolution(tvalarray<GReal_t>& F, GReal_t x) const {
00091     }
00092 
00097     virtual GReal_t getMinX() const =0;
00098 
00103     virtual GReal_t getMaxX() const =0;
00104 
00113     virtual bool isValid(const GReal_t* F, int nc, GReal_t x) const {
00114         return true;
00115     }
00116 
00130     virtual bool dRHS(const GReal_t* f, int offset, GReal_t x, GReal_t* drhs);
00131 
00137     virtual tvalarray<GReal_t> getInitialValuesForRelaxation(int nx) const;
00138 
00143     virtual tvalarray<GReal_t> getInitialX() const;
00144 
00149     virtual FieldArray getInitialValuesForShooting() const;
00150 
00162     virtual GReal_t averageShootingResults(int np, int ip, GReal_t x, int ic,
00163                                            GReal_t f0, GReal_t f1) const {
00164         return 0.5*(f0 + f1);
00165     }
00166 
00173     virtual void getPhysicalField(GReal_t x, GReal_t* f) const {
00174     }
00175 
00180     const PDE& getPDE() const {
00181         return *thePDE;
00182     }
00183 
00188     const InitCond& getPDEInitCond() const {
00189         return *thePDEInitCond;
00190     }
00191 
00198     void setPDE(const PDE* pde, const InitCond* init) {
00199         thePDE = pde;
00200         thePDEInitCond = init;
00201     }
00202 
00209     virtual void initPDE(GReal_t x, const GReal_t* fode, FieldWrapper& fpde);
00210 
00219     virtual void initPDE(GReal_t x, const GReal_t* fode,
00220                          FieldWrapper& fpde, const GReal_t* data, int ndata) {
00221         initPDE(x, fode, fpde);
00222     }
00223 
00228     int getNumComponents() const {
00229         return numComponents;
00230     }
00231 
00237     string getComponentName(int k) const {
00238         return componentNames[k];
00239     }
00240 };
00241 
00242 } } // namespace gridripper::odesolver
00243 
00244 #endif /* gridripper_amr1d_odesolver_ODE_h */

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