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


C++ Options::SaveMovie方法代码示例

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


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

示例1: solve_vs_exact

double solve_vs_exact(Options options, Mesh* mesh, std::vector<Element2D*> &elements) {
    PetscFunctionBegin;
    // Setup values.
    int it          = 0;
    double time     = 0.0;
    double timeStep = options.TimeStep();
    double duration = options.Duration();
    
    if(options.SaveMovie()) mesh->setUpMovie(options.OutputMovieFile());

    // Over-allocate matrices to avoid re-allocations.
    int max_dims = 3;
    int int_pnts = elements[0]->NumberIntegrationPoints();
    Eigen::MatrixXd f(int_pnts, max_dims);
    Eigen::MatrixXd u(int_pnts, max_dims);
    Eigen::MatrixXd ku(int_pnts, max_dims);
    Eigen::MatrixXd fMinusKu(int_pnts, max_dims);
    Eigen::MatrixXd fMinusKu_boundary(int_pnts, max_dims);

    double max_error = 0.0;    

    while (time < duration) {

        // Collect all global fields to the local partitions.
        for (auto &field : elements[0]->PullElementalFields()) {
            mesh->checkOutField(field);
        }

        // Zero all fields to which we will sum.
        for (auto &field : elements[0]->PushElementalFields()) {
            mesh->zeroFields(field);
        }

        for (auto &element : elements) {

            // Get fields on element, store in successive rows. (e.g.,
            // "u" for acoustic, "ux, uz" for elastic)
            int fitr = 0;
            for (auto &field : element->PullElementalFields()) {
                u.col(fitr) = mesh->getFieldOnElement(field, element->Number(),
                                                       element->ElementClosure());
                fitr++;
            }
            
            double element_error = element->checkTest(mesh, options, u.block(0,0,int_pnts,fitr), time);
            
            if(element_error > max_error) { max_error = element_error; }

            // Compute stiffness, only passing those rows which are occupied.
            ku.block(0,0,int_pnts,fitr) = element->computeStiffnessTerm(
                                                                        u.block(0,0,int_pnts,fitr));

            // Compute acceleration.
            fMinusKu.block(0,0,int_pnts,fitr) = -1 * ku.block(0,0,int_pnts,fitr).array();

            
            // Sum fields into local partition.
            fitr = 0;
            for (auto &field : element->PushElementalFields()) {
                mesh->addFieldFromElement(field, element->Number(),
                                           element->ElementClosure(),
                                           fMinusKu.col(fitr));
                fitr++;
            }

        }

        // boundary condition happens after full Ku
        for( auto &element : elements) {
            // we can now apply boundary conditions (after fields are set)
            if(element->OnBoundary()) {
                // apply boundary condition
                element->applyBoundaryConditions(mesh,
                                                 options,
                                                 "a");
            }
        }

        // Sum fields into global partitions.
        for (auto &field : elements[0]->PushElementalFields()) {
            mesh->checkInFieldBegin(field);
            mesh->checkInFieldEnd(field);
        }

        // Take a time step.
        mesh->applyInverseMassMatrix();
        mesh->advanceField(timeStep);
        
        if(options.SaveMovie() && (it%options.SaveFrameEvery()==0 || it == 0) ) {
            // GlobalFields[0] == "u" for acoustic and == "ux" for elastic
            mesh->saveFrame(mesh->GlobalFields()[0], it);
            // mesh->setLocalFieldToGlobal("u_exact");
            // mesh->saveFrame("u_exact", it);
            if(max_error > 5) {
                std::cerr << "ERROR: Solution blowing up!\n";
                exit(1);
            }
            PRINT_ROOT() << "TIME: " << time;
        }
        
//.........这里部分代码省略.........
开发者ID:krischer,项目名称:salvus,代码行数:101,代码来源:test_exactsolution.cpp


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