// ===================================================
// Set Methods
// ===================================================
void
BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::setData ( const dataPtr_Type& data )
{

#ifdef HAVE_LIFEV_DEBUG
    debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::setData" << "\n";
#endif

    //Set mapFunction
    std::map< std::string, FSIFunction > mapFunction;
    mapFunction["DerFluidLoadToFluid"]              = DerFluidLoadToFluid;
    mapFunction["DerFluidLoadToStructure"]          = DerFluidLoadToStructure;
    mapFunction["DerHarmonicExtensionVelToFluid"]   = DerHarmonicExtensionVelToFluid;
    mapFunction["DerStructureDispToSolid"]          = DerStructureDispToSolid;
    mapFunction["FluidInterfaceDisp"]               = FluidInterfaceDisp;
    mapFunction["FluidLoadToStructure"]             = FluidLoadToStructure;
    mapFunction["HarmonicExtensionVelToFluid"]      = HarmonicExtensionVelToFluid;
    mapFunction["SolidLoadToStructure"]             = SolidLoadToStructure;
    mapFunction["StructureDispToHarmonicExtension"] = StructureDispToHarmonicExtension;
    mapFunction["StructureDispToSolid"]             = StructureDispToSolid;
    mapFunction["StructureToFluid"]                 = StructureToFluid;
    mapFunction["RobinWall"]                        = RobinWall;

    // Retrieving the strings
    M_FSIFunction = mapFunction[ data->baseString() ];

    M_name = data->name();
    M_flag = data->flag();
    M_type = data->type();
    M_mode = data->mode();
    M_componentsVector = data->componentsVector();

    if ( M_FSIFunction == RobinWall )
    {
        factory_Type factory;
        M_vectorFunctionRobin.reserve (2);
        dataPtr_Type temporaryData ( new data_Type ( *data ) );

        // Create the mass term function
        temporaryData->setRobinBaseAlpha();
        M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );

        // Create the RHS
        temporaryData->setRobinBaseBeta();
        M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );
    }
}
// ===================================================
// Set Methods
// ===================================================
void
BCInterfaceFunctionSolverDefined< BCHandler, StructuralOperator<RegionMesh <LinearTetra> > >::setData ( const dataPtr_Type& data )
{

#ifdef HAVE_LIFEV_DEBUG
    debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::setData" << "\n";
#endif

    //Set mapFunction
    std::map< std::string, Solid3DFunction > mapFunction;
    mapFunction["RobinWall"] = RobinWall;

    // Retrieving the strings
    M_solid3DFunction = mapFunction[ data->baseString() ];

    M_name = data->name();
    M_flag = data->flag();
    M_type = data->type();
    M_mode = data->mode();
    M_componentsVector = data->componentsVector();

    if ( M_solid3DFunction == RobinWall )
    {
        factory_Type factory;
        M_vectorFunctionRobin.reserve (2);
        dataPtr_Type temporaryData ( new data_Type ( *data ) );

        // Create the mass term function
        temporaryData->setRobinBaseAlpha();
        M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );

        // Create the RHS
        temporaryData->setRobinBaseBeta();
        M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );
    }
}
inline void
BCInterfaceFunctionParserFile< BcHandlerType, PhysicalSolverType >::setData ( const dataPtr_Type& data )
{

#ifdef HAVE_LIFEV_DEBUG
    debugStream ( 5022 ) << "BCInterfaceFunctionFile::loadData            fileName: " << data->baseString() << "\n";
#endif

    std::vector< std::string > stringsVector;
    boost::split ( stringsVector, data->baseString(), boost::is_any_of ( "[" ) );

    //Load data from file
    GetPot dataFile ( stringsVector[0] );

    //Set variables
    UInt variablesNumber = dataFile.vector_variable_size ( "variables" );

    M_variables.clear();
    M_variables.reserve ( variablesNumber );

    std::vector< Real > scale;
    scale.reserve ( variablesNumber );

    for ( UInt j ( 0 ); j < variablesNumber; ++j )
    {
        M_variables.push_back ( dataFile ( "variables", "unknown", j ) );
        scale.push_back ( dataFile ( "scale", 1.0, j ) );
    }

#ifdef HAVE_LIFEV_DEBUG
    std::stringstream output;
    output << "BCInterfaceFunctionFile::loadData           variables: ";
    for ( UInt j (0); j < variablesNumber; ++j )
    {
        output << M_variables[j] << "  ";
    }

    output << "\n                                                           scale: ";
    for ( UInt j (0); j < variablesNumber; ++j )
    {
        output << scale[j] << "  ";
    }

    debugStream ( 5022 ) << output.str() << "\n";
#endif

    //Load loop flag
    M_loop = dataFile ( "loop", false );

    //Load data
    UInt dataLines = dataFile.vector_variable_size ( "data" ) / variablesNumber;

    M_data.clear();
    for ( UInt j ( 0 ); j < variablesNumber; ++j )
    {
        M_data[M_variables[j]].reserve ( dataLines );
    }

    for ( UInt i ( 0 ); i < dataLines; ++i )
        for ( UInt j ( 0 ); j < variablesNumber; ++j )
        {
            M_data[M_variables[j]].push_back ( scale[j] * dataFile ( "data", 0.0, i * variablesNumber + j ) );
        }

#ifdef HAVE_LIFEV_DEBUG
    output.str ("");
    output << "                                                 loop: " << M_loop << "\n";
    output << "                                                 data:";
    for ( UInt i (0); i < dataLines; ++i )
    {
        if (i > 0)
        {
            output << "                                                                 ";
        }

        for ( UInt j (0); j < variablesNumber; ++j )
        {
            output << " " << M_data[ M_variables[j] ][i];
        }
        output << "\n";
    }
    debugStream ( 5022 ) << output.str();
#endif

    //Initialize iterator
    M_dataIterator = M_data[M_variables[0]].begin();

    //Update the data container (IT IS A COPY!) with the correct base string for the BCInterfaceFunctionParser
    if ( stringsVector.size() < 2 )
    {
        data->setBaseString ( dataFile ( "function", "Undefined" ) );
    }
    else
    {
        boost::replace_all ( stringsVector[1], "]", "" );
        data->setBaseString ( dataFile ( ( "function" + stringsVector[1] ).c_str(), "Undefined" ) );
    }

    // Now data contains the real base string
    functionParser_Type::setData ( data );

#ifdef HAVE_LIFEV_DEBUG
    debugStream ( 5022 ) << "                                             function: " << data->baseString() << "\n";
#endif

}