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


C++ StopWatch::Clear方法代码示例

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


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

示例1: tic

void tic()
{
   tic_toc.Clear();
   tic_toc.Start();
}
开发者ID:YPCC,项目名称:mfem,代码行数:5,代码来源:tic_toc.cpp

示例2: main


//.........这里部分代码省略.........
    //
    //     Here we use Symmetric Gauss-Seidel to approximate the inverse of the
    //     pressure Schur Complement
    SparseMatrix *MinvBt = Transpose(B);
    Vector Md(M.Height());
    M.GetDiag(Md);
    for (int i = 0; i < Md.Size(); i++)
    {
        MinvBt->ScaleRow(i, 1./Md(i));
    }
    SparseMatrix *S = Mult(B, *MinvBt);

    Solver *invM, *invS;
    invM = new DSmoother(M);
#ifndef MFEM_USE_SUITESPARSE
    invS = new GSSmoother(*S);
#else
    invS = new UMFPackSolver(*S);
#endif

    invM->iterative_mode = false;
    invS->iterative_mode = false;

    BlockDiagonalPreconditioner darcyPrec(block_offsets);
    darcyPrec.SetDiagonalBlock(0, invM);
    darcyPrec.SetDiagonalBlock(1, invS);

    // 10. Solve the linear system with MINRES.
    //     Check the norm of the unpreconditioned residual.
    int maxIter(1000);
    double rtol(1.e-6);
    double atol(1.e-10);

    chrono.Clear();
    chrono.Start();
    MINRESSolver solver;
    solver.SetAbsTol(atol);
    solver.SetRelTol(rtol);
    solver.SetMaxIter(maxIter);
    solver.SetOperator(darcyMatrix);
    solver.SetPreconditioner(darcyPrec);
    solver.SetPrintLevel(1);
    x = 0.0;
    solver.Mult(rhs, x);
    chrono.Stop();

    if (solver.GetConverged())
        std::cout << "MINRES converged in " << solver.GetNumIterations()
                  << " iterations with a residual norm of " << solver.GetFinalNorm() << ".\n";
    else
        std::cout << "MINRES did not converge in " << solver.GetNumIterations()
                  << " iterations. Residual norm is " << solver.GetFinalNorm() << ".\n";
    std::cout << "MINRES solver took " << chrono.RealTime() << "s. \n";

    // 11. Create the grid functions u and p. Compute the L2 error norms.
    GridFunction u, p;
    u.Update(R_space, x.GetBlock(0), 0);
    p.Update(W_space, x.GetBlock(1), 0);

    int order_quad = max(2, 2*order+1);
    const IntegrationRule *irs[Geometry::NumGeom];
    for (int i=0; i < Geometry::NumGeom; ++i)
    {
        irs[i] = &(IntRules.Get(i, order_quad));
    }
开发者ID:martemyev,项目名称:mfem,代码行数:66,代码来源:ex5.cpp


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