Tudat/SimulationSetup/EnvironmentSetup/createRadiationPressureInterface.cpp
//! Function to create a radiation pressure interface.

Function to create a radiation pressure interface.
Function to create a radiation pressure interface .
std::shared_ptr< electro_magnetism::RadiationPressureInterface > createRadiationPressureInterface(
        const std::shared_ptr< RadiationPressureInterfaceSettings > radiationPressureInterfaceSettings,
        const std::string& bodyName, const NamedBodyMap& bodyMap )
{
    std::shared_ptr< electro_magnetism::RadiationPressureInterface > radiationPressureInterface;
    switch( radiationPressureInterfaceSettings->getRadiationPressureType( ) )
    {
    case cannon_ball:
    {
        std::shared_ptr< CannonBallRadiationPressureInterfaceSettings > cannonBallSettings =
                std::dynamic_pointer_cast< CannonBallRadiationPressureInterfaceSettings >(
                    radiationPressureInterfaceSettings );
        if( cannonBallSettings == nullptr )
        {
            throw std::runtime_error( "Error when making cannon ball radiation interface, type does not match object" );
        }
        if( bodyMap.count( radiationPressureInterfaceSettings->getSourceBody( ) ) == 0 )
        {
            throw std::runtime_error( "Error when making cannon ball radiation interface, source not found.");
        }
        std::shared_ptr< Body > sourceBody =
                bodyMap.at( radiationPressureInterfaceSettings->getSourceBody( ) );
        std::vector< std::string > occultingBodies = cannonBallSettings->getOccultingBodies( );
        std::vector< std::function< Eigen::Vector3d( ) > > occultingBodyPositions;
        std::vector< double > occultingBodyRadii;
        getOccultingBodiesInformation(
                    bodyMap, occultingBodies, occultingBodyPositions, occultingBodyRadii );
        double sourceRadius;
        if( occultingBodyPositions.size( ) > 0 )
        {
            std::shared_ptr< basic_astrodynamics::BodyShapeModel > sourceShapeModel =
                    sourceBody->getShapeModel( );
            if( sourceShapeModel == nullptr )
            {
                throw std::runtime_error( "Error when making occulted body, source body " +
                                          radiationPressureInterfaceSettings->getSourceBody( ) +
                                          " does not have a shape" );
            }
            else
            {
                sourceRadius = sourceShapeModel->getAverageRadius( );
            }
        }
        else
        {
            sourceRadius = 0.0;
        }
        std::function< double( ) > radiatedPowerFunction;
        if( defaultRadiatedPowerValues.count(
                    radiationPressureInterfaceSettings->getSourceBody( ) ) == 0 )
        {
            throw std::runtime_error( "Error, no radiated power found for " +
                                      radiationPressureInterfaceSettings->getSourceBody( ) );
        }
        else
        {
            radiatedPowerFunction = [ = ]( ){ return
                        defaultRadiatedPowerValues.at(
                            radiationPressureInterfaceSettings->getSourceBody( ) ); };
        }
        radiationPressureInterface =
                std::make_shared< electro_magnetism::RadiationPressureInterface >(
                    radiatedPowerFunction,
                    std::bind( &Body::getPosition, sourceBody ),
                    std::bind( &Body::getPosition, bodyMap.at( bodyName ) ),
                    cannonBallSettings->getRadiationPressureCoefficient( ),
                    cannonBallSettings->getArea( ), occultingBodyPositions, occultingBodyRadii,
                    sourceRadius );
        break;
    }
    default:
        throw std::runtime_error(
                    "Error, radiation pressure type" + std::to_string(
                        radiationPressureInterfaceSettings->getRadiationPressureType( ) ) +
                    "not recognized for body" + bodyName );
    }
    return radiationPressureInterface;
}
std :: shared_ptr < electro_magnetism :: RadiationPressureInterface > createRadiationPressureInterface ( const std :: shared_ptr < RadiationPressureInterfaceSettings > radiationPressureInterfaceSettings , const std :: string & bodyName , const NamedBodyMap & bodyMap ) { std :: shared_ptr < electro_magnetism :: RadiationPressureInterface > radiationPressureInterface ; switch ( radiationPressureInterfaceSettings -> getRadiationPressureType ( ) ) { case cannon_ball : { std :: shared_ptr < CannonBallRadiationPressureInterfaceSettings > cannonBallSettings = std :: dynamic_pointer_cast < CannonBallRadiationPressureInterfaceSettings > ( radiationPressureInterfaceSettings ) ; if ( cannonBallSettings == nullptr ) { throw std :: runtime_error ( " " ) ; } if ( bodyMap . count ( radiationPressureInterfaceSettings -> getSourceBody ( ) ) == 0 ) { throw std :: runtime_error ( " " ) ; } std :: shared_ptr < Body > sourceBody = bodyMap . at ( radiationPressureInterfaceSettings -> getSourceBody ( ) ) ; std :: vector < std :: string > occultingBodies = cannonBallSettings -> getOccultingBodies ( ) ; std :: vector < std :: function < Eigen :: Vector3d ( ) > > occultingBodyPositions ; std :: vector < double > occultingBodyRadii ; getOccultingBodiesInformation ( bodyMap , occultingBodies , occultingBodyPositions , occultingBodyRadii ) ; double sourceRadius ; if ( occultingBodyPositions . size ( ) > 0 ) { std :: shared_ptr < basic_astrodynamics :: BodyShapeModel > sourceShapeModel = sourceBody -> getShapeModel ( ) ; if ( sourceShapeModel == nullptr ) { throw std :: runtime_error ( " " + radiationPressureInterfaceSettings -> getSourceBody ( ) + " " ) ; } else { sourceRadius = sourceShapeModel -> getAverageRadius ( ) ; } } else { sourceRadius = 0.0 ; } std :: function < double ( ) > radiatedPowerFunction ; if ( defaultRadiatedPowerValues . count ( radiationPressureInterfaceSettings -> getSourceBody ( ) ) == 0 ) { throw std :: runtime_error ( " " + radiationPressureInterfaceSettings -> getSourceBody ( ) ) ; } else { radiatedPowerFunction = [ = ] ( ) { return defaultRadiatedPowerValues . at ( radiationPressureInterfaceSettings -> getSourceBody ( ) ) ; } ; } radiationPressureInterface = std :: make_shared < electro_magnetism :: RadiationPressureInterface > ( radiatedPowerFunction , std :: bind ( & Body :: getPosition , sourceBody ) , std :: bind ( & Body :: getPosition , bodyMap . at ( bodyName ) ) , cannonBallSettings -> getRadiationPressureCoefficient ( ) , cannonBallSettings -> getArea ( ) , occultingBodyPositions , occultingBodyRadii , sourceRadius ) ; break ; } default : throw std :: runtime_error ( " " + std :: to_string ( radiationPressureInterfaceSettings -> getRadiationPressureType ( ) ) + " " + bodyName ) ; } return radiationPressureInterface ; }
Function to create a radiation pressure interface.
Function to create a radiation pressure interface .
// Check type of radiation pressure interface
 // Check type consistency.
 // Retrieve source body and check consistency.
 // Get reqruied data for occulting bodies.
 // Retrive radius of source if occultations are used.
 // Create function returning radiated power.
 // Create radiation pressure interface.
