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


C++ Force::calculateForces方法代码示例

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


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

示例1: test_stretch


//.........这里部分代码省略.........
            r0(d, i) = r(d,i);
        }
    }

    //--------------------------------------------------------------------------
    // Setting particles parameters
    //--------------------------------------------------------------------------

    h = dxdydz[2];
    double c;

    if(dim == 3)
    {
        nu = 1./4.;
        k = E/(3.*(1. - 2.*nu));
        c = 18.*k/(M_PI*pow(delta, 4));
    }
    else if(dim == 2)
    {
        nu = 1./3.;
        k = E/(2.*(1. - nu));
        c = 12*k/(h*M_PI*pow(delta, 3));
    }
    else
    {
        cerr << "ERROR: dimension " << dim << " not supported" << endl;
        cerr << "use 2 or 3." << endl;
        exit(EXIT_FAILURE);
    }
    bool useS0fromCfg = false;
    if(m_cfg.lookupValue("s0", s0))
    {
        useS0fromCfg = true;
    }

    particles.registerParameter("rho", rho);
    particles.registerParameter("radius");

    bool calculateMicromodulus = m_cfg.lookupValue("calculateMicromodulus", calculateMicromodulus);

    if(calculateMicromodulus){
        particles.registerParameter("micromodulus", k);
        reCalculatePdMicromodulus(particles, dim);
    }
    else
    {
        particles.registerParameter("micromodulus", c);
    }
    calculateRadius(particles, dim, dxdydz[2]);
    reCalculatePdMicromodulus(particles, dim);

    //--------------------------------------------------------------------------
    // Setting the Forces
    //--------------------------------------------------------------------------
    Force * pdForce = new PD_bondForce(particles);

    //--------------------------------------------------------------------------
    // Testing the surface scaling
    //--------------------------------------------------------------------------
    vector<Force*> forces = {pdForce};
    surfaceCorrection(particles, forces, k, nu, dim);

    //--------------------------------------------------------------------------
    // Updating the stretch
    //--------------------------------------------------------------------------
    string save_path = save_folder;
    SavePdData *saveParticles = new SavePdData(saveParameters);
    saveParticles->setSavePath(save_path);
    saveParticles->setParticles(&particles);
    saveParticles->setForces(forces);
    saveParticles->initialize();

    //--------------------------------------------------------------------------
    // Stretching the system
    //--------------------------------------------------------------------------
    for(int i=0; i<particles.nParticles(); i++)
    {
        r(0,i) *= (1 + epsilon);
        r(1,i) *= (1 - nu*epsilon);
    }
    //--------------------------------------------------------------------------
    // Calculating the forces
    //--------------------------------------------------------------------------
#ifdef USE_OPENMP
# pragma omp parallel for
#endif
    for(int i=0; i<particles.nParticles(); i++)
    {
        pair<int, int> id(i, i);
        pdForce->calculateForces(id);
    }

    saveParticles->evaluate(1, 1);
    //--------------------------------------------------------------------------
    // Saving the results
    //--------------------------------------------------------------------------
    SaveParticles save_xyz("lmp");
    save_path = save_folder + "/" + to_string(n) + ".lmp";
    save_xyz.writeToFile(particles, save_path);
}
开发者ID:ttnghia,项目名称:PDtools,代码行数:101,代码来源:test_stretch.cpp


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