![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsODESolverEuler.cpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (07/10/2005) 00009 UPDATE (08/18/2010) 00010 ******************************************************************************/ 00011 #include "TAPsODESolverEuler.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 ODESolverEuler<T, T_SET>::ODESolverEuler () : ODESolver<T, T_SET>() {} 00022 //------------------------------------------------------------------- 00023 template <typename T, typename T_SET> 00024 ODESolverEuler<T, T_SET>::~ODESolverEuler () {} 00025 //------------------------------------------------------------------- 00026 template <typename T, typename T_SET> 00027 void ODESolverEuler<T, T_SET>::SetSize ( int vectorSize ) 00028 { vStart.resize( vectorSize ); } 00029 //------------------------------------------------------------------- 00030 template <typename T, typename T_SET> 00031 void ODESolverEuler<T, T_SET>::Solve ( 00032 VectorSet<T_SET> &x0, // i/p: x(t_0) an initial state vector 00033 VectorSet<T_SET> &xEnd, // o/p: x(t_1) an end state vector 00034 T t0, T t1, // i/p: starting and ending times 00035 DerivFunc dxdt, // i/p: a derivative function 00036 void *userData // o/p: array of user data 00037 ) 00038 { 00039 bool restartNotRequired = true; 00040 T h = t1 - t0; 00041 // Euler's method 00042 restartNotRequired = dxdt( t0, x0, vStart, userData ); 00043 assert( restartNotRequired ); 00044 // Update the state 00045 xEnd = x0 + h * vStart; 00046 } 00047 //------------------------------------------------------------------- 00048 //template <typename T, typename T_SET> 00049 //void ODESolverEuler<T, T_SET>::Solve_ForPtrData ( 00050 // VectorSetPtr<T_SET,T> &x0, // i/p: x(t_0) an initial state vector 00051 // VectorSetPtr<T_SET,T> &xEnd, // o/p: x(t_1) an end state vector 00052 // T t0, T t1, // i/p: starting and ending times 00053 // DerivFunc_ForPtrData dxdt, // i/p: a derivative function 00054 // void *userData // o/p: array of user data 00055 //) 00056 //{ 00057 //} 00058 //----------------------------------------------------------------------------- 00059 //============================================================================= 00060 END_NAMESPACE_TAPs__Simulation 00061 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00062 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----