当前位置: 首页>>代码示例>>C++>>正文


C++ dataPtr_Type::setBaseString方法代码示例

本文整理汇总了C++中dataPtr_Type::setBaseString方法的典型用法代码示例。如果您正苦于以下问题:C++ dataPtr_Type::setBaseString方法的具体用法?C++ dataPtr_Type::setBaseString怎么用?C++ dataPtr_Type::setBaseString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dataPtr_Type的用法示例。


在下文中一共展示了dataPtr_Type::setBaseString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dataFile

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 );
//.........这里部分代码省略.........
开发者ID:Danniel-UCAS,项目名称:lifev,代码行数:101,代码来源:BCInterfaceFunctionParserFile.hpp


注:本文中的dataPtr_Type::setBaseString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。