/*
+ * This file is part of the GROMACS molecular simulation package.
*
- * This source code is part of
+ * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
*
- * G R O M A C S
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
*
- * GROningen MAchine for Chemical Simulations
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \internal \file
* \brief
* Implements position evaluation selection methods.
*
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
+ * \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <macros.h>
-#include <smalloc.h>
-#include <string2.h>
+#include "gmxpre.h"
+#include "gromacs/legacyheaders/macros.h"
#include "gromacs/selection/indexutil.h"
-#include "gromacs/selection/poscalc.h"
#include "gromacs/selection/position.h"
-#include "gromacs/selection/selmethod.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/smalloc.h"
#include "keywords.h"
+#include "poscalc.h"
#include "selelem.h"
+#include "selmethod.h"
/*! \internal \brief
* Data structure for position keyword evaluation.
/** Position calculation collection to use. */
gmx::PositionCalculationCollection *pcc;
/** Index group for which the center should be evaluated. */
- gmx_ana_index_t g;
+ gmx_ana_index_t g;
/** Position evaluation data structure. */
- gmx_ana_poscalc_t *pc;
+ gmx_ana_poscalc_t *pc;
/** true if periodic boundary conditions should be used. */
- bool bPBC;
+ bool bPBC;
/** Type of positions to calculate. */
- char *type;
+ char *type;
/** Flags for the position calculation. */
- int flags;
+ int flags;
} t_methoddata_pos;
/** Allocates data for position evaluation selection methods. */
/** Sets the position calculation collection for position evaluation selection methods. */
static void
set_poscoll_pos(gmx::PositionCalculationCollection *pcc, void *data);
-/** Initializes position evaluation keywords. */
+/*! \brief
+ * Initializes position evaluation keywords.
+ *
+ * \param[in] top Not used.
+ * \param[in] npar Not used.
+ * \param[in] param Not used.
+ * \param[in,out] data Should point to \c t_methoddata_pos.
+ * \returns 0 on success, a non-zero error code on error.
+ *
+ * The \c t_methoddata_pos::type field should have been initialized
+ * externally using _gmx_selelem_set_kwpos_type().
+ */
static void
init_kwpos(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
-/** Initializes the \p cog selection method. */
+/*! \brief
+ * Initializes the \p cog selection method.
+ *
+ * \param[in] top Topology data structure.
+ * \param[in] npar Not used.
+ * \param[in] param Not used.
+ * \param[in,out] data Should point to \c t_methoddata_pos.
+ * \returns 0 on success, a non-zero error code on error.
+ */
static void
init_cog(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
-/** Initializes the \p cog selection method. */
+/*! \brief
+ * Initializes the \p cog selection method.
+ *
+ * \param[in] top Topology data structure.
+ * \param[in] npar Not used.
+ * \param[in] param Not used.
+ * \param[in,out] data Should point to \c t_methoddata_pos.
+ * \returns 0 on success, a non-zero error code on error.
+ */
static void
init_com(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
-/** Initializes output for position evaluation selection methods. */
+/*! \brief
+ * Initializes output for position evaluation selection methods.
+ *
+ * \param[in] top Topology data structure.
+ * \param[in,out] out Pointer to output data structure.
+ * \param[in,out] data Should point to \c t_methoddata_pos.
+ * \returns 0 for success.
+ */
static void
init_output_pos(t_topology *top, gmx_ana_selvalue_t *out, void *data);
/** Frees the data allocated for position evaluation selection methods. */
free_data_pos(void *data);
/** Evaluates position evaluation selection methods. */
static void
-evaluate_pos(t_topology *top, t_trxframe *fr, t_pbc *pbc,
- gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
+evaluate_pos(t_topology * /* top */, t_trxframe *fr, t_pbc *pbc, gmx_ana_index_t * /* g */, gmx_ana_selvalue_t *out, void *data);
/** Parameters for position keyword evaluation. */
static gmx_ana_selparam_t smparams_keyword_pos[] = {
{"pbc", {NO_VALUE, 0, {NULL}}, NULL, 0},
};
-/** \internal Selection method data for position keyword evaluation. */
+/** Selection method data for position keyword evaluation. */
gmx_ana_selmethod_t sm_keyword_pos = {
- "kw_pos", POS_VALUE, SMETH_DYNAMIC | SMETH_VARNUMVAL,
+ "kw_pos", POS_VALUE, SMETH_DYNAMIC | SMETH_VARNUMVAL | SMETH_ALLOW_UNSORTED,
asize(smparams_keyword_pos), smparams_keyword_pos,
&init_data_pos,
&set_poscoll_pos,
&init_kwpos,
&init_output_pos,
&free_data_pos,
- NULL,
+ NULL,
&evaluate_pos,
- NULL,
+ NULL,
{NULL, 0, NULL},
};
-/** \internal Selection method data for the \p cog method. */
+/** Selection method data for the \p cog method. */
gmx_ana_selmethod_t sm_cog = {
"cog", POS_VALUE, SMETH_DYNAMIC | SMETH_SINGLEVAL,
asize(smparams_com), smparams_com,
&init_cog,
&init_output_pos,
&free_data_pos,
- NULL,
+ NULL,
&evaluate_pos,
- NULL,
+ NULL,
{"cog of ATOM_EXPR [pbc]", 0, NULL},
};
-/** \internal Selection method data for the \p com method. */
+/** Selection method data for the \p com method. */
gmx_ana_selmethod_t sm_com = {
"com", POS_VALUE, SMETH_REQTOP | SMETH_DYNAMIC | SMETH_SINGLEVAL,
asize(smparams_com), smparams_com,
&init_com,
&init_output_pos,
&free_data_pos,
- NULL,
+ NULL,
&evaluate_pos,
- NULL,
+ NULL,
{"com of ATOM_EXPR [pbc]", 0, NULL},
};
* are neglected.
*/
void
-_gmx_selelem_set_kwpos_type(t_selelem *sel, const char *type)
+_gmx_selelem_set_kwpos_type(gmx::SelectionTreeElement *sel, const char *type)
{
t_methoddata_pos *d = (t_methoddata_pos *)sel->u.expr.mdata;
}
if (!d->type && type)
{
- d->type = strdup(type);
+ d->type = gmx_strdup(type);
/* FIXME: It would be better not to have the string here hardcoded. */
if (type[0] != 'a')
{
* are neglected.
*/
void
-_gmx_selelem_set_kwpos_flags(t_selelem *sel, int flags)
+_gmx_selelem_set_kwpos_flags(gmx::SelectionTreeElement *sel, int flags)
{
t_methoddata_pos *d = (t_methoddata_pos *)sel->u.expr.mdata;
}
}
-/*!
- * \param[in] top Not used.
- * \param[in] npar Not used.
- * \param[in] param Not used.
- * \param[in,out] data Should point to \c t_methoddata_pos.
- * \returns 0 on success, a non-zero error code on error.
- *
- * The \c t_methoddata_pos::type field should have been initialized
- * externally using _gmx_selelem_set_kwpos_type().
- */
static void
-init_kwpos(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_kwpos(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
gmx_ana_poscalc_set_maxindex(d->pc, &d->g);
}
-/*!
- * \param[in] top Topology data structure.
- * \param[in] npar Not used.
- * \param[in] param Not used.
- * \param[in,out] data Should point to \c t_methoddata_pos.
- * \returns 0 on success, a non-zero error code on error.
- */
static void
-init_cog(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_cog(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
d->flags = (param[0].flags & SPAR_DYNAMIC) ? POS_DYNAMIC : 0;
- d->pc = d->pcc->createCalculation(d->bPBC ? POS_ALL_PBC : POS_ALL, d->flags);
+ d->pc = d->pcc->createCalculation(d->bPBC ? POS_ALL_PBC : POS_ALL, d->flags);
gmx_ana_poscalc_set_maxindex(d->pc, &d->g);
}
-/*!
- * \param[in] top Topology data structure.
- * \param[in] npar Not used.
- * \param[in] param Not used.
- * \param[in,out] data Should point to \c t_methoddata_pos.
- * \returns 0 on success, a non-zero error code on error.
- */
static void
-init_com(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_com(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
d->flags = (param[0].flags & SPAR_DYNAMIC) ? POS_DYNAMIC : 0;
d->flags |= POS_MASS;
- d->pc = d->pcc->createCalculation(d->bPBC ? POS_ALL_PBC : POS_ALL, d->flags);
+ d->pc = d->pcc->createCalculation(d->bPBC ? POS_ALL_PBC : POS_ALL, d->flags);
gmx_ana_poscalc_set_maxindex(d->pc, &d->g);
}
-/*!
- * \param[in] top Topology data structure.
- * \param[in,out] out Pointer to output data structure.
- * \param[in,out] data Should point to \c t_methoddata_pos.
- * \returns 0 for success.
- */
static void
-init_output_pos(t_topology *top, gmx_ana_selvalue_t *out, void *data)
+init_output_pos(t_topology * /* top */, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
gmx_ana_poscalc_init_pos(d->pc, out->u.p);
- gmx_ana_pos_set_evalgrp(out->u.p, &d->g);
}
/*!
sfree(d->type);
gmx_ana_poscalc_free(d->pc);
+ sfree(d);
}
/*!
* in \c t_methoddata_pos::g and stores the results in \p out->u.p.
*/
static void
-evaluate_pos(t_topology *top, t_trxframe *fr, t_pbc *pbc,
- gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
+evaluate_pos(t_topology * /* top */, t_trxframe *fr, t_pbc *pbc,
+ gmx_ana_index_t * /* g */, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;