|
odesolve.h00001 /* 00002 Dynamics/Kinematics modeling and simulation library. 00003 Copyright (C) 1999 by Michael Alexander Ewert 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 */ 00020 #ifndef __CTODESOLVER_H__ 00021 #define __CTODESOLVER_H__ 00022 00023 // this code was adapted from an ode solver by Brian Mirtich 00024 00025 #include <assert.h> 00026 #include "csphyzik/phyztype.h" 00027 00028 #define ODE_INITIAL_STATE_SIZE 1024 00029 00030 00031 typedef void (*dydt_function)(real t, const real statev[], real delta_statev[] ); 00032 00033 00034 // virtual base-class on which concrete ode solver algorithms are built 00035 // NOTE: don't derive any classes from any classes derived from this one. 00036 class OdeSolver 00037 { 00038 public: 00039 00040 OdeSolver(); 00041 virtual ~OdeSolver(); 00042 00047 virtual void calc_step (real y0[], real y1[], unsigned int len, 00048 real t0, real t1, dydt_function dydt) = 0; 00049 00050 protected: 00051 00052 virtual void ode_realloc (int new_size); 00053 00055 unsigned int state_size; 00056 00058 real *dy; 00059 real *Iy; 00060 }; 00061 00067 class OdeRungaKutta4 : public OdeSolver 00068 { 00069 public: 00070 00071 OdeRungaKutta4 (); 00072 virtual ~OdeRungaKutta4 (); 00073 00074 void calc_step (real y0[], real y1[], unsigned int len, 00075 real t0, real t1, dydt_function dydt); 00076 00077 private: 00078 00079 void ode_realloc (int new_size); 00080 00082 real *k1; 00083 real *k2; 00084 real *k3; 00085 real *k4; 00086 }; 00087 00093 class OdeEuler : public OdeSolver 00094 { 00095 public: 00096 00097 OdeEuler (); 00098 00099 void calc_step (real y0[], real y1[], unsigned int len, 00100 real t0, real t1, dydt_function dydt); 00101 00102 }; 00103 00104 00111 class OdeMidPoint : public OdeSolver 00112 { 00113 public: 00114 00115 OdeMidPoint(); 00116 00117 void calc_step (real y0[], real y1[], unsigned int len, 00118 real t0, real t1, dydt_function dydt); 00119 00120 }; 00121 00122 #endif // __CTODESOLVER_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |