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


C++ Solver::addForce方法代码示例

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


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

示例1: grid

TEST_F(PD_SOLVER_FIXTURE, TEST_ADR_BUNNY)
{
    using namespace std;
    using namespace arma;

    double dt = 1.0;
    int nSteps = 10;
    int dim = 3;

    int saveFreq = 10;
    double vMag = -1e-11;
    double s0 = 0.00158377370467;
    double rho = 2140.0;

    double alpha = 0.25;
    double delta = 0.018*2;
    double gridspacing = 1.1*delta;

    double E =  15200000000.0;
    double nu = 1./3.;
    double k = E/(2.*(1. - nu));
    double micromodulus = k;
    double error = 1e-4;

    double G0 = 0.1; // Fracture energy release rate

    vector<string> saveParameters = {"id", "x", "y", "z", "potential_energy", "kinetic_energy", "stress", "damage"};
    //--------------------------------------------------------------------------
    // Initialization
    //--------------------------------------------------------------------------
    PD_Particles particles;
    particles = load_pd(geometries[1]);
    particles.initializeADR();
    particles.registerParameter("rho", rho);
    particles.registerParameter("micromodulus", micromodulus);
    particles.registerParameter("s0", s0);
    particles.registerParameter("radius", s0);

    vector<pair<double,double>> boundaries;

    // Bunny - geometry[1]
    pair<double,double> x_limits(0., 1.);
    pair<double,double> y_limits(0., 0.9);
    pair<double,double> z_limits(0., 1.);

    boundaries = {x_limits, y_limits, z_limits};

    Grid grid(boundaries, gridspacing);
    grid.initialize();
    grid.placeParticlesInGrid(particles);

    setPdConnections(particles, grid, delta, gridspacing);
    reCalculatePdMicromodulus(particles, dim);
    reCalculatePdFractureCriterion(particles, G0, delta);
    calculateRadius(particles, 3);
    //--------------------------------------------------------------------------
    // Setting the initial position
    //--------------------------------------------------------------------------
    mat &r0 = particles.r0();
    mat &r = particles.r();

    for(int i=0; i<particles.nParticles(); i++)
    {
        for(int d=0; d<3; d++)
        {
            r0(d, i) = r(d,i);
        }
    }
    //--------------------------------------------------------------------------
    // Setting the Forces
    //--------------------------------------------------------------------------
    Force * pdForce = new PD_bondForce(particles);
    Force * contactForce = new ContactForce(particles, grid, delta/1.21);
    Modifier *fracture= new PmbFracture(alpha);
    fracture->setParticles(particles);
    //--------------------------------------------------------------------------
    // Setting the boundary conditions
    //--------------------------------------------------------------------------
    double d = 1.3;

    pair<double, double> bound1(x_limits.first - d*delta, x_limits.first + d*delta);
    Modifier *boundaryLeft= new MoveParticles(-vMag, 0, bound1, 0,  1, 0);
    boundaryLeft->setParticles(particles);

    pair<double, double> bound2(x_limits.second - 2*d*delta, x_limits.second + d*delta);
    Modifier *boundaryRight = new MoveParticles(vMag, 0, bound2, 0,  1, 0);
    boundaryRight->setParticles(particles);

    boundaryLeft->initialize();
    boundaryRight->initialize();

    fracture->initialize();
    //--------------------------------------------------------------------------
    // Setting the integrator
    //--------------------------------------------------------------------------
    Solver *solver = new ADR();
    solver->setErrorThreshold(error);
    solver->setMainGrid(grid);
    solver->setParticles(particles);
    solver->addForce(pdForce);
//.........这里部分代码省略.........
开发者ID:ttnghia,项目名称:PDtools,代码行数:101,代码来源:test_solver.cpp


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