Exemplo n.º 1
0
NBodyStatus nbRunSystemPlain(const NBodyCtx* ctx, NBodyState* st)
{
    NBodyStatus rc = NBODY_SUCCESS;

    rc |= nbGravMap(ctx, st); /* Calculate accelerations for 1st step this episode */
    if (nbStatusIsFatal(rc))
        return rc;

    while (st->step < ctx->nStep)
    {
        nbAddTracePoint(ctx, st);
        nbUpdateDisplayedBodies(ctx, st);
        rc |= nbStepSystemPlain(ctx, st);
        if (nbStatusIsFatal(rc))   /* advance N-body system */
            return rc;

        rc |= nbCheckpoint(ctx, st);
        if (nbStatusIsFatal(rc))
            return rc;

        nbReportProgress(ctx, st);
    }

    if (BOINC_APPLICATION || ctx->checkpointT >= 0)
    {
        mw_report("Making final checkpoint\n");
        if (nbWriteCheckpoint(ctx, st))
        {
            mw_printf("Failed to write final checkpoint\n");
            return NBODY_CHECKPOINT_ERROR;
        }
    }

    return rc;
}
Exemplo n.º 2
0
/* stepSystem: advance N-body system one time-step. */
NBodyStatus nbStepSystemPlain(const NBodyCtx* ctx, NBodyState* st)
{
    NBodyStatus rc;
    const real dt = ctx->timestep;

    advancePosVel(st, st->nbody, dt);

    rc = nbGravMap(ctx, st);
    advanceVelocities(st, st->nbody, dt);

    st->step++;

    return rc;
}
Exemplo n.º 3
0
/* stepSystem: advance N-body system one time-step. */
NBodyStatus nbStepSystemPlain(const NBodyCtx* ctx, NBodyState* st)
{
    NBodyStatus rc;
    const real dt = ctx->timestep;

    advancePosVel(st, st->nbody, dt);

    rc = nbGravMap(ctx, st);
    apply_dynamical_friction(st,ctx);
    advanceVelocities(st, st->nbody, dt);

    st->step++;
    #ifdef NBODY_BLENDER_OUTPUT
        blenderPrintBodies(st, ctx);
//        printf("Frame: %d (%f%%)\n", (int)(st->step),100.0*st->step/ctx->nStep);
    #endif

    return rc;
}