CombinedNumericPropagator.cpp

Go to the documentation of this file.
00001 
00002 
00008 /* 
00009 *
00010 */ 
00012 
00013 #include "CombinedNumericPropagator.h"
00014 namespace O_SESSAME {
00015 
00016 CombinedNumericPropagator::CombinedNumericPropagator()
00017 {
00018 
00019 }
00020 
00021 CombinedNumericPropagator::~CombinedNumericPropagator()
00022 {
00024     if(m_pOrbitIntegrator)
00025         delete m_pOrbitIntegrator;
00026     if(m_pAttitudeIntegrator)
00027         delete m_pAttitudeIntegrator;
00028 }
00029 
00030 void CombinedNumericPropagator::Propagate(const vector<ssfTime> &_propTime, const Vector &_orbitInitConditions, const Vector &_attInitConditions)
00031 {
00034     // Test to see if propagation is 'too long' & needs to be broken up
00035     
00036     
00037     // Propagate the orbit & attitude, store in the matrix of integration meshpoints
00038     if(m_pOrbitObject)
00039         if (m_pOrbitObject->IsIntegrateable())
00040             PropagateOrbit(_propTime, _orbitInitConditions);
00041     if(m_pAttitudeObject)
00042         if (m_pAttitudeObject->IsIntegrateable())
00043             PropagateAttitude(_propTime, _attInitConditions);
00044     
00045     return;
00046 }
00047 
00048 Matrix CombinedNumericPropagator::PropagateOrbit(const vector<ssfTime> &_propTime, const Vector &_initConditions)
00049 {
00050     // Create temporary orbit & attitude that have the same types (copy of) the current state objects
00051     //          the actual state vectors will be replaced, but we need to make sure to have the same 
00052     //          representation & frame types
00053     static OrbitState tempOrbit = m_pOrbitObject->GetStateObject();
00054     static vector<ssfTime> timeVector;          timeVector.clear(); // clear since static
00055     static vector<OrbitState> orbitVector;      orbitVector.clear(); // clear since static              
00056     
00059     m_OrbitStateMeshPoints.initialize(m_pOrbitIntegrator->Integrate(   
00060                                     _propTime, 
00061                                     m_pOrbitObject->GetDynamicsEq(),
00062                                     _initConditions, 
00063                                     m_pOrbitObject,
00064                                     m_pAttitudeObject,
00065                                     m_pOrbitObject->GetParameters(),
00066                                     m_pOrbitObject->GetEnvironmentForcesFunctor() 
00067                                 ));
00069     // Convert the meshpoints to stored objects and append them to the appropriate history.
00070     for (int ii = MatrixIndexBase; ii < m_OrbitStateMeshPoints[MatrixRowsIndex].getIndexBound() + MatrixIndexBase; ++ii)
00071     {
00072         (m_pOrbitObject->GetStateConversion())(m_OrbitStateMeshPoints(ii,_(MatrixIndexBase+1,m_OrbitStateMeshPoints[MatrixColsIndex].getIndexBound())), tempOrbit);
00073         timeVector.push_back(ssfTime(m_OrbitStateMeshPoints(ii,MatrixIndexBase)));
00074         orbitVector.push_back(tempOrbit);
00075     }
00076     
00077     // Store the new histories to the orbit & attitude objects
00078     if(m_pOrbitObject)
00079         m_pOrbitObject->GetHistoryObject().AppendHistory(timeVector, orbitVector);
00080         
00081     // Set the stored Attitude & Orbit
00083     m_pOrbitObject->SetStateObject(tempOrbit);
00084     
00085     return m_OrbitStateMeshPoints;
00086 }
00087 
00088 Matrix CombinedNumericPropagator::PropagateAttitude(const vector<ssfTime> &_propTime, const Vector &_initConditions)
00089 {
00090     // Create temporary orbit & attitude that have the same types (copy of) the current state objects
00091     //          the actual state vectors will be replaced, but we need to make sure to have the same 
00092     //          representation & frame types
00093     static AttitudeState tempAttitude = m_pAttitudeObject->GetStateObject();
00094     static vector<ssfTime> timeVector;                  timeVector.clear(); // clear since static
00095     static vector<AttitudeState> attitudeVector;        attitudeVector.clear(); // clear since static
00096      
00097     static OrbitState tempOrbit = m_pOrbitObject->GetStateObject();
00098 
00099     m_AttitudeStateMeshPoints.initialize(m_pAttitudeIntegrator->Integrate(   
00100                                     _propTime, 
00101                                     m_pAttitudeObject->GetDynamicsEq(),
00102                                     _initConditions, 
00103                                     m_pOrbitObject,
00104                                     m_pAttitudeObject,
00105                                     m_pAttitudeObject->GetParameters(),
00106                                     m_pAttitudeObject->GetEnvironmentForcesFunctor() 
00107                                 ));
00108                                 
00110     // Convert the meshpoints to stored objects and append them to the appropriate history.
00111     for (int ii = MatrixIndexBase; ii < m_AttitudeStateMeshPoints[MatrixRowsIndex].getIndexBound() + MatrixIndexBase; ++ii)
00112     {
00113         (m_pAttitudeObject->GetStateConversion())(m_AttitudeStateMeshPoints(ii,_(MatrixIndexBase+1,m_AttitudeStateMeshPoints[MatrixColsIndex].getIndexBound())), tempAttitude);
00114         timeVector.push_back(ssfTime(m_AttitudeStateMeshPoints(ii,MatrixIndexBase)));
00115         attitudeVector.push_back(tempAttitude);
00116     }
00117     
00118     // Store the new histories to the attitude object
00119     m_pAttitudeObject->GetHistoryObject().AppendHistory(timeVector, attitudeVector);
00120 
00121     // Set the stored Attitude
00122     m_pAttitudeObject->SetStateObject(tempAttitude);
00123     
00124     return m_AttitudeStateMeshPoints;
00125 }
00126 
00127 void CombinedNumericPropagator::SetOrbitIntegrator(Integrator* _pOrbitIntegrator)
00128 {
00129     m_pOrbitIntegrator = _pOrbitIntegrator;
00130     return;
00131 }
00132 void CombinedNumericPropagator::SetAttitudeIntegrator(Integrator* _pAttitudeIntegrator)
00133 {
00134     m_pAttitudeIntegrator = _pAttitudeIntegrator;
00135     return;
00136 }    
00137 Integrator* CombinedNumericPropagator::GetOrbitIntegrator() const
00138 {
00139     return m_pOrbitIntegrator;
00140 }
00141 Integrator* CombinedNumericPropagator::GetAttitudeIntegrator() const
00142 {
00143     return m_pAttitudeIntegrator;
00144 }
00145 } // close namespace O_SESSAME
00146 
00147 // Do not change the comments below - they will be added automatically by CVS
00148 /*****************************************************************************
00149 *       $Log: CombinedNumericPropagator.cpp,v $
00150 *       Revision 1.5  2003/06/10 02:24:03  nilspace
00151 *       Updated moving of StateConversion functions to Attitude and Orbit.
00152 *       
00153 *       Revision 1.4  2003/05/27 17:36:24  nilspace
00154 *       Updated to handle different integration stepsizes.
00155 *       
00156 *       Revision 1.3  2003/05/26 21:15:20  nilspace
00157 *       Fixed the static timevector and static attitude/orbitVec to be cleared on each propagate.
00158 *       
00159 *       Revision 1.2  2003/05/22 03:00:43  nilspace
00160 *       Updated to pass pointers of Orbit & Attitude objects rather than references.
00161 *       
00162 *       Revision 1.1  2003/05/20 17:56:24  nilspace
00163 *       Initial submission.
00164 *       
00165 *
00166 ******************************************************************************/

Generated on Wed Aug 6 12:58:43 2003 for Open-Sessame Framework by doxygen1.3