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


C++ EquationSystems::read方法代码示例

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


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

示例1: read_output

void read_output(EquationSystems & es,
                 unsigned int t_step,
                 unsigned int a_step,
                 std::string solution_type,
                 FEMParameters & param)
{
    MeshBase & mesh = es.get_mesh();

    std::string file_name_mesh, file_name_soln;
    // Look for ASCII files first
    if (param.output_xda)
    {
        file_name_mesh = numbered_filename(t_step, a_step, solution_type, "mesh", "xda", param);
        file_name_soln = numbered_filename(t_step, a_step, solution_type, "soln", "xda", param);
    }
    else if (param.output_xdr)
    {
        file_name_mesh = numbered_filename(t_step, a_step, solution_type, "mesh", "xdr", param);
        file_name_soln = numbered_filename(t_step, a_step, solution_type, "soln", "xdr", param);
    }

    // Read in the mesh
    mesh.read(file_name_mesh);

    // And the stored solution
    es.read(file_name_soln, READ,
            EquationSystems::READ_HEADER |
            EquationSystems::READ_DATA |
            EquationSystems::READ_ADDITIONAL_DATA);

    // Put systems in a consistent state
    for (unsigned int i = 0; i != es.n_systems(); ++i)
        es.get_system<FEMSystem>(i).update();

    // Figure out the current time
    Real current_time = 0., current_timestep = 0.;

    if (param.timesolver_tolerance)
    {
        std::ifstream times ("out_time.m");
        std::ifstream timesteps ("out_timesteps.m");
        if (times.is_open() && timesteps.is_open())
        {
            // Read headers
            const unsigned int headersize = 25;
            char header[headersize];
            timesteps.getline (header, headersize);
            if (strcmp(header, "vector_timesteps = [") != 0)
                libmesh_error_msg("Bad header in out_timesteps.m:\n" << header);

            times.getline (header, headersize);
            if (strcmp(header, "vector_time = [") != 0)
                libmesh_error_msg("Bad header in out_time.m:\n" << header);

            // Read each timestep
            for (unsigned int i = 0; i != t_step; ++i)
            {
                if (!times.good())
                    libmesh_error_msg("Error: File out_time.m is in non-good state.");
                times >> current_time;
                timesteps >> current_timestep;
            }
            // Remember to increment the last timestep; out_times.m
            // lists each *start* time
            current_time += current_timestep;
        }
        else
开发者ID:rblake,项目名称:libmesh,代码行数:67,代码来源:adjoints_ex3.C


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