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; }
NBodyStatus nbStepSystem(const NBodyCtx* ctx, NBodyState* st) { #if NBODY_OPENCL if (st->usesCL) { return nbStepSystemCL(ctx, st); } #endif return nbStepSystemPlain(ctx, st); }
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; #ifdef NBODY_BLENDER_OUTPUT mkdir("./frames", S_IRWXU | S_IRWXG); deleteOldFiles(st); mwvector startCmPos; mwvector perpendicularCmPos; mwvector nextCmPos; nbFindCenterOfMass(&startCmPos, st); perpendicularCmPos=startCmPos; printf("Total frames: %d\n", (int)(ctx->nStep)); #endif while (st->step < ctx->nStep) { #ifdef NBODY_BLENDER_OUTPUT nbFindCenterOfMass(&nextCmPos, st); blenderPossiblyChangePerpendicularCmPos(&nextCmPos,&perpendicularCmPos,&startCmPos); #endif rc |= nbStepSystemPlain(ctx, st); if (nbStatusIsFatal(rc)) /* advance N-body system */ return rc; rc |= nbCheckpoint(ctx, st); if (nbStatusIsFatal(rc)) return rc; /* We report the progress at step + 1. 0 is the original center of mass. */ nbReportProgress(ctx, st); nbUpdateDisplayedBodies(ctx, st); } #ifdef NBODY_BLENDER_OUTPUT blenderPrintMisc(st, ctx, startCmPos, perpendicularCmPos); #endif return nbWriteFinalCheckpoint(ctx, st); }