![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsODESolverMidpoint.cpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (07/10/2005) 00009 UPDATE (08/18/2010) 00010 ******************************************************************************/ 00011 #include "TAPsODESolverMidpoint.hpp" 00012 // Using Inclusion Model (i.e. definitions are included in declarations) 00013 // (this name.cpp is included in name.hpp) 00014 // Each friend is defined directly inside its declaration. 00015 00016 00017 BEGIN_NAMESPACE_TAPs__Simulation 00018 //============================================================================= 00019 //----------------------------------------------------------------------------- 00020 template <typename T, typename T_SET> 00021 ODESolverMidpoint<T, T_SET>::ODESolverMidpoint () : ODESolver<T, T_SET>() {} 00022 //------------------------------------------------------------------- 00023 template <typename T, typename T_SET> 00024 ODESolverMidpoint<T, T_SET>::~ODESolverMidpoint () {} 00025 //------------------------------------------------------------------- 00026 template <typename T, typename T_SET> 00027 void ODESolverMidpoint<T, T_SET>::SetSize ( int vectorSize ) 00028 { 00029 vStart.resize( vectorSize ); 00030 vMid.resize( vectorSize ); 00031 } 00032 //------------------------------------------------------------------- 00033 template <typename T, typename T_SET> 00034 void ODESolverMidpoint<T, T_SET>::Solve ( 00035 VectorSet<T_SET> &x0, // i/p: x(t_0) an initial state vector 00036 VectorSet<T_SET> &xEnd, // o/p: x(t_1) an end state vector 00037 T t0, T t1, // i/p: starting and ending times 00038 DerivFunc dxdt, // i/p: a derivative function 00039 void *userData // o/p: array of user data 00040 ) 00041 { 00042 bool restartNotRequired = true; 00043 T h = t1 - t0; 00044 // Midpoint Method 00045 restartNotRequired = dxdt( t0, x0, vStart, userData ); 00046 assert( restartNotRequired ); 00047 restartNotRequired = dxdt( t0 + h/2, x0 + h/2*vStart, vMid, userData ); 00048 assert( restartNotRequired ); 00049 // Update the state 00050 xEnd = x0 + h * vMid; 00051 } 00052 //------------------------------------------------------------------- 00053 //template <typename T, typename T_SET> 00054 //void ODESolverMidpoint<T, T_SET>::Solve_ForPtrData ( 00055 // VectorSetPtr<T_SET,T> &x0, // i/p: x(t_0) an initial state vector 00056 // VectorSetPtr<T_SET,T> &xEnd, // o/p: x(t_1) an end state vector 00057 // T t0, T t1, // i/p: starting and ending times 00058 // DerivFunc_ForPtrData dxdt, // i/p: a derivative function 00059 // void *userData // o/p: array of user data 00060 //) 00061 //{ 00062 //} 00063 //----------------------------------------------------------------------------- 00064 //============================================================================= 00065 END_NAMESPACE_TAPs__Simulation 00066 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00067 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----