Tudat/SimulationSetup/PropagationSetup/createTorqueModel.cpp
//! Function to create torque models from a map of bodies and torque model settings.
Function to create torque models from a map of bodies and torque model settings.
Function to create torque models from a map of bodies and torque model settings .
basic_astrodynamics::TorqueModelMap createTorqueModelsMap(
        const NamedBodyMap& bodyMap,
        SelectedTorqueMap selectedTorquePerBody,
        const std::vector< std::string >& propagatedBodies )
{
    for( unsigned int i = 0; i < propagatedBodies.size( ); i++ )
    {
        if( selectedTorquePerBody.count( propagatedBodies.at( i ) ) == 0 )
        {
            selectedTorquePerBody[ propagatedBodies.at( i ) ] =
                    std::map< std::string, std::vector< std::shared_ptr< TorqueSettings > > >( );
        }
    }
    basic_astrodynamics::TorqueModelMap torqueModelMap;
    for( SelectedTorqueMap::const_iterator acceleratedBodyIterator = selectedTorquePerBody.begin( );
         acceleratedBodyIterator != selectedTorquePerBody.end( ); acceleratedBodyIterator++ )
    {
        if( bodyMap.count( acceleratedBodyIterator->first ) == 0 )
        {
            throw std::runtime_error(
                        "Error, could not find body " + acceleratedBodyIterator->first + " when making torque model map." );
        }
        else
        {
            torqueModelMap[ acceleratedBodyIterator->first ][ acceleratedBodyIterator->first ].push_back(
                        createTorqueModel(
                        bodyMap.at( acceleratedBodyIterator->first ), bodyMap.at( acceleratedBodyIterator->first ),
                        std::make_shared< TorqueSettings >( basic_astrodynamics::inertial_torque ),
                        acceleratedBodyIterator->first, acceleratedBodyIterator->first ) );
            for( std::map< std::string, std::vector< std::shared_ptr< TorqueSettings > > >::const_iterator
                 acceleratingBodyIterator = acceleratedBodyIterator->second.begin( );
                 acceleratingBodyIterator != acceleratedBodyIterator->second.end( ); acceleratingBodyIterator++ )
            {
                if( bodyMap.count( acceleratingBodyIterator->first ) == 0 )
                {
                    throw std::runtime_error(
                                "Error, could not find body " + acceleratingBodyIterator->first + " when making torque model map." );
                }
                for( unsigned int i = 0; i < acceleratingBodyIterator->second.size( ); i++ )
                {
                    torqueModelMap[ acceleratedBodyIterator->first ][ acceleratingBodyIterator->first ].push_back(
                                createTorqueModel(
                                bodyMap.at( acceleratedBodyIterator->first ), bodyMap.at( acceleratingBodyIterator->first ),
                                acceleratingBodyIterator->second.at( i ),
                                acceleratedBodyIterator->first, acceleratingBodyIterator->first ) );
                }
            }
        }
    }
    return torqueModelMap;
}
basic_astrodynamics :: TorqueModelMap createTorqueModelsMap ( const NamedBodyMap & bodyMap , SelectedTorqueMap selectedTorquePerBody , const std :: vector < std :: string > & propagatedBodies ) { for ( unsigned int i = 0 ; i < propagatedBodies . size ( ) ; i ++ ) { if ( selectedTorquePerBody . count ( propagatedBodies . at ( i ) ) == 0 ) { selectedTorquePerBody [ propagatedBodies . at ( i ) ] = std :: map < std :: string , std :: vector < std :: shared_ptr < TorqueSettings > > > ( ) ; } } basic_astrodynamics :: TorqueModelMap torqueModelMap ; for ( SelectedTorqueMap :: const_iterator acceleratedBodyIterator = selectedTorquePerBody . begin ( ) ; acceleratedBodyIterator != selectedTorquePerBody . end ( ) ; acceleratedBodyIterator ++ ) { if ( bodyMap . count ( acceleratedBodyIterator -> first ) == 0 ) { throw std :: runtime_error ( " " + acceleratedBodyIterator -> first + " " ) ; } else { torqueModelMap [ acceleratedBodyIterator -> first ] [ acceleratedBodyIterator -> first ] . push_back ( createTorqueModel ( bodyMap . at ( acceleratedBodyIterator -> first ) , bodyMap . at ( acceleratedBodyIterator -> first ) , std :: make_shared < TorqueSettings > ( basic_astrodynamics :: inertial_torque ) , acceleratedBodyIterator -> first , acceleratedBodyIterator -> first ) ) ; for ( std :: map < std :: string , std :: vector < std :: shared_ptr < TorqueSettings > > > :: const_iterator acceleratingBodyIterator = acceleratedBodyIterator -> second . begin ( ) ; acceleratingBodyIterator != acceleratedBodyIterator -> second . end ( ) ; acceleratingBodyIterator ++ ) { if ( bodyMap . count ( acceleratingBodyIterator -> first ) == 0 ) { throw std :: runtime_error ( " " + acceleratingBodyIterator -> first + " " ) ; } for ( unsigned int i = 0 ; i < acceleratingBodyIterator -> second . size ( ) ; i ++ ) { torqueModelMap [ acceleratedBodyIterator -> first ] [ acceleratingBodyIterator -> first ] . push_back ( createTorqueModel ( bodyMap . at ( acceleratedBodyIterator -> first ) , bodyMap . at ( acceleratingBodyIterator -> first ) , acceleratingBodyIterator -> second . at ( i ) , acceleratedBodyIterator -> first , acceleratingBodyIterator -> first ) ) ; } } } } return torqueModelMap ; }
Function to create torque models from a map of bodies and torque model settings.
Function to create torque models from a map of bodies and torque model settings .