void
SelectionCollection::evaluate(t_trxframe *fr, t_pbc *pbc)
{
    if (_impl->hasFlag(Impl::efOwnPositionCollection))
    {
        gmx_ana_poscalc_init_frame(_impl->_sc.pcc);
    }

    SelectionEvaluator evaluator;
    evaluator.evaluate(this, fr, pbc);

    if (_impl->_debugLevel >= 3)
    {
        std::fprintf(stderr, "\n");
        printTree(stderr, true);
    }
}
示例#2
0
/*!
 * \param[in,out] d   Trajectory analysis data structure.
 * \param[in] flags   Combination of flags
 *      (currently, there are no flags defined).
 * \param[in] analyze Pointer to frame analysis function.
 * \param     data    User data to be passed to \p analyze.
 * \returns   0 on success, a non-zero error code on error.
 *
 * This function performs the actual analysis of the trajectory.
 * It loops through all the frames in the trajectory, and calls
 * \p analyze for each frame to perform the actual analysis.
 * Before calling \p analyze, selections are updated (if there are any).
 * See gmx_analysisfunc() for description of \p analyze parameters.
 *
 * This function also calculates the number of frames during the run.
 */
int
gmx_ana_do(gmx_ana_traj_t *d, int flags, gmx_analysisfunc analyze, void *data)
{
    t_pbc               pbc;
    t_pbc              *ppbc;
    int                 rc;

    rc = init_first_frame(d);
    if (rc != 0)
    {
        return rc;
    }

    ppbc = d->bPBC ? &pbc : 0;
    if (!d->top)
    {
        d->bRmPBC = FALSE;
    }

    d->nframes = 0;
    do
    {
        if (d->bRmPBC)
        {
            rm_pbc(&d->top->idef, d->ePBC, d->fr->natoms, d->fr->box,
                   d->fr->x, d->fr->x);
        }
        if (ppbc)
        {
            set_pbc(&pbc, d->ePBC, d->fr->box);
        }

        gmx_ana_poscalc_init_frame(d->pcc);
        rc = gmx_ana_selcollection_evaluate(d->sc, d->fr, ppbc);
        if (rc != 0)
        {
            close_trj(d->status);
            gmx_fatal(FARGS, "selection evaluation failed");
            return rc;
        }
        rc = analyze(d->top, d->fr, ppbc, d->ngrps, d->sel, data);
        if (rc != 0)
        {
            close_trj(d->status);
            return rc;
        }

        d->nframes++;
    }
    while (read_next_frame(d->status, d->fr));

    close_trj(d->status);

    fprintf(stderr, "Analyzed %d frames, last time %.3f\n",
            d->nframes, d->fr->time);

    /* Restore the maximal groups for dynamic selections */
    rc = gmx_ana_selcollection_evaluate_fin(d->sc, d->nframes);
    if (rc != 0)
    {
        gmx_fatal(FARGS, "selection evaluation failed");
    }

    return rc;
}