Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / selection / sm_position.cpp
index 070ed80d340c98b62f187be6eb22fc4771bdb7d2..3a92f82d69edb8972e5f757fc4a59920de4de58b 100644 (file)
@@ -1,51 +1,56 @@
 /*
+ * 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
  */
-#include "gromacs/legacyheaders/macros.h"
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/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.
@@ -72,16 +77,50 @@ init_data_pos(int npar, gmx_ana_selparam_t *param);
 /** 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. */
@@ -89,8 +128,7 @@ static void
 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[] = {
@@ -103,9 +141,9 @@ static gmx_ana_selparam_t smparams_com[] = {
     {"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,
@@ -118,7 +156,7 @@ gmx_ana_selmethod_t sm_keyword_pos = {
     {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,
@@ -133,7 +171,7 @@ gmx_ana_selmethod_t sm_cog = {
     {"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,
@@ -208,7 +246,7 @@ _gmx_selelem_set_kwpos_type(gmx::SelectionTreeElement *sel, const char *type)
     }
     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')
         {
@@ -242,18 +280,8 @@ _gmx_selelem_set_kwpos_flags(gmx::SelectionTreeElement *sel, int flags)
     }
 }
 
-/*!
- * \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;
 
@@ -269,15 +297,8 @@ init_kwpos(t_topology *top, int npar, gmx_ana_selparam_t *param, void *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;
 
@@ -286,15 +307,8 @@ init_cog(t_topology *top, int npar, gmx_ana_selparam_t *param, void *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_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;
 
@@ -304,19 +318,12 @@ init_com(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
     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);
 }
 
 /*!
@@ -343,8 +350,8 @@ free_data_pos(void *data)
  * 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;