/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * 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.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-/*! \page page_module_selection_insolidangle Selection method: insolidangle
+/*! \internal
+ * \page page_module_selection_insolidangle Selection method: insolidangle
*
* This method selects a subset of particles that are located in a solid
* angle defined by a center and a set of points.
* point is in the solid angle if it lies within any of these cones.
* The width of the cones can be adjusted.
*
- * \internal
- *
* The method is implemented by partitioning the surface of the unit sphere
* into bins using the polar coordinates \f$(\theta, \phi)\f$.
* The partitioning is always uniform in the zenith angle \f$\theta\f$,
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
-#include <algorithm>
+#include "gmxpre.h"
#include <math.h>
-#include "gromacs/legacyheaders/macros.h"
-#include "gromacs/legacyheaders/maths.h"
-#include "gromacs/legacyheaders/pbc.h"
-#include "gromacs/legacyheaders/physics.h"
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/vec.h"
+#include <algorithm>
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
#include "gromacs/selection/indexutil.h"
#include "gromacs/selection/position.h"
#include "gromacs/selection/selection.h"
-#include "gromacs/selection/selmethod.h"
#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/smalloc.h"
#include "selelem.h"
+#include "selmethod.h"
using std::min;
using std::max;
-/*! \internal \brief
+/*! \internal
+ * \brief
* Internal data structure for the \p insolidangle selection method.
*
* \see \c t_partition
+ *
+ * \ingroup module_selection
*/
typedef struct
{
int bin;
} t_partition_item;
-/*! \internal \brief
+/*! \internal
+ * \brief
* Internal data structure for the \p insolidangle selection method.
*
* Describes the surface partitioning within one slice along the zenith angle.
* The slice from azimuthal angle \p p[i].left to \p p[i+1].left belongs to
* bin \p p[i].bin.
+ *
+ * \ingroup module_selection
*/
typedef struct
{
t_partition_item *p;
} t_partition;
-/*! \internal \brief
+/*! \internal
+ * \brief
* Internal data structure for the \p insolidangle selection method.
*
* Contains the reference points that partially cover a certain region on the
* surface of the unit sphere.
* If \p n is -1, the whole region described by the bin is covered.
+ *
+ * \ingroup module_selection
*/
typedef struct
{
rvec *x;
} t_spheresurfacebin;
-/*! \internal \brief
+/*! \internal
+ * \brief
* Data structure for the \p insolidangle selection method.
*
* All angle values are in the units of radians.
+ *
+ * \ingroup module_selection
*/
typedef struct
{
t_spheresurfacebin *bin;
} t_methoddata_insolidangle;
-/** Allocates data for the \p insolidangle selection method. */
+/*! \brief
+ * Allocates data for the \p insolidangle selection method.
+ *
+ * \param[in] npar Not used (should be 3).
+ * \param[in,out] param Method parameters (should point to
+ * \ref smparams_insolidangle).
+ * \returns Pointer to the allocated data (\ref t_methoddata_insolidangle).
+ *
+ * Allocates memory for a \ref t_methoddata_insolidangle structure and
+ * initializes the parameter as follows:
+ * - \p center defines the value for t_methoddata_insolidangle::center.
+ * - \p span defines the value for t_methoddata_insolidangle::span.
+ * - \p cutoff defines the value for t_methoddata_insolidangle::angcut.
+ */
static void *
init_data_insolidangle(int npar, gmx_ana_selparam_t *param);
-/** Initializes the \p insolidangle selection method. */
+/*! \brief
+ * Initializes the \p insolidangle selection method.
+ *
+ * \param top Not used.
+ * \param npar Not used.
+ * \param param Not used.
+ * \param data Pointer to \ref t_methoddata_insolidangle to initialize.
+ * \returns 0 on success, -1 on failure.
+ *
+ * Converts t_methoddata_insolidangle::angcut to radians and allocates
+ * and allocates memory for the bins used during the evaluation.
+ */
static void
-init_insolidangle(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_insolidangle(t_topology * top, int npar, gmx_ana_selparam_t * param, void *data);
/** Frees the data allocated for the \p insolidangle selection method. */
static void
free_data_insolidangle(void *data);
-/** Initializes the evaluation of the \p insolidangle selection method for a frame. */
+/*! \brief
+ * Initializes the evaluation of the \p insolidangle selection method for a frame.
+ *
+ * \param[in] top Not used.
+ * \param[in] fr Not used.
+ * \param[in] pbc PBC structure.
+ * \param data Should point to a \ref t_methoddata_insolidangle.
+ *
+ * Creates a lookup structure that enables fast queries of whether a point
+ * is within the solid angle or not.
+ */
static void
-init_frame_insolidangle(t_topology *top, t_trxframe *fr, t_pbc *pbc, void *data);
+init_frame_insolidangle(t_topology * top, t_trxframe * fr, t_pbc *pbc, void *data);
/** Internal helper function for evaluate_insolidangle(). */
static bool
accept_insolidangle(rvec x, t_pbc *pbc, void *data);
/** Evaluates the \p insolidangle selection method. */
static void
-evaluate_insolidangle(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_insolidangle(t_topology * /* top */, t_trxframe * /* fr */, t_pbc *pbc,
gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data);
/** Calculates the distance between unit vectors. */
/** Adds a single reference point and updates the surface bins. */
static void
store_surface_point(t_methoddata_insolidangle *surf, rvec x);
-/** Optimizes the surface bins for faster searching. */
+/*! \brief
+ * Optimizes the surface bins for faster searching.
+ *
+ * \param[in,out] surf Surface data structure.
+ *
+ * Currently, this function does nothing.
+ */
static void
optimize_surface_points(t_methoddata_insolidangle *surf);
/** Estimates the area covered by the reference cones. */
"of these cones. The cutoff determines the width of the cones.",
};
-/** \internal Selection method data for the \p insolidangle method. */
+/** Selection method data for the \p insolidangle method. */
gmx_ana_selmethod_t sm_insolidangle = {
"insolidangle", GROUP_VALUE, SMETH_DYNAMIC,
asize(smparams_insolidangle), smparams_insolidangle,
asize(help_insolidangle), help_insolidangle},
};
-/*!
- * \param[in] npar Not used (should be 3).
- * \param[in,out] param Method parameters (should point to
- * \ref smparams_insolidangle).
- * \returns Pointer to the allocated data (\ref t_methoddata_insolidangle).
- *
- * Allocates memory for a \ref t_methoddata_insolidangle structure and
- * initializes the parameter as follows:
- * - \p center defines the value for t_methoddata_insolidangle::center.
- * - \p span defines the value for t_methoddata_insolidangle::span.
- * - \p cutoff defines the value for t_methoddata_insolidangle::angcut.
- */
static void *
-init_data_insolidangle(int npar, gmx_ana_selparam_t *param)
+init_data_insolidangle(int /* npar */, gmx_ana_selparam_t *param)
{
- t_methoddata_insolidangle *data;
+ t_methoddata_insolidangle *data = new t_methoddata_insolidangle();
+ data->angcut = 5.0;
+ data->cfrac = 0.0;
+
+ data->distccut = 0.0;
+ data->targetbinsize = 0.0;
+
+ data->ntbins = 0;
+ data->tbinsize = 0.0;
+ data->tbin = NULL;
+ data->maxbins = 0;
+ data->nbins = 0;
+ data->bin = NULL;
- snew(data, 1);
- data->angcut = 5.0;
param[0].val.u.p = &data->center;
param[1].val.u.p = &data->span;
param[2].val.u.r = &data->angcut;
return data;
}
-/*!
- * \param top Not used.
- * \param npar Not used.
- * \param param Not used.
- * \param data Pointer to \ref t_methoddata_insolidangle to initialize.
- * \returns 0 on success, -1 on failure.
- *
- * Converts t_methoddata_insolidangle::angcut to radians and allocates
- * and allocates memory for the bins used during the evaluation.
- */
static void
-init_insolidangle(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_insolidangle(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
{
t_methoddata_insolidangle *surf = (t_methoddata_insolidangle *)data;
int i, c;
}
free_surface_points(d);
sfree(d->bin);
- sfree(d);
+ delete d;
}
-/*!
- * \param[in] top Not used.
- * \param[in] fr Current frame.
- * \param[in] pbc PBC structure.
- * \param data Should point to a \ref t_methoddata_insolidangle.
- *
- * Creates a lookup structure that enables fast queries of whether a point
- * is within the solid angle or not.
- */
static void
-init_frame_insolidangle(t_topology *top, t_trxframe *fr, t_pbc *pbc, void *data)
+init_frame_insolidangle(t_topology * /* top */, t_trxframe * /* fr */, t_pbc *pbc, void *data)
{
t_methoddata_insolidangle *d = (t_methoddata_insolidangle *)data;
rvec dx;
free_surface_points(d);
clear_surface_points(d);
- for (i = 0; i < d->span.nr; ++i)
+ for (i = 0; i < d->span.count(); ++i)
{
if (pbc)
{
* \c t_methoddata_insolidangle::center, and stores the result in \p out->u.g.
*/
static void
-evaluate_insolidangle(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_insolidangle(t_topology * /* top */, t_trxframe * /* fr */, t_pbc *pbc,
gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
{
- int b;
-
out->u.g->isize = 0;
- for (b = 0; b < pos->nr; ++b)
+ for (int b = 0; b < pos->count(); ++b)
{
if (accept_insolidangle(pos->x[b], pbc, data))
{
- gmx_ana_pos_append(NULL, out->u.g, pos, b, 0);
+ gmx_ana_pos_add_to_group(out->u.g, pos, b);
}
}
}
}
}
-/*!
- * \param[in,out] surf Surface data structure.
- *
- * Currently, this function does nothing.
- */
static void
-optimize_surface_points(t_methoddata_insolidangle *surf)
+optimize_surface_points(t_methoddata_insolidangle * /* surf */)
{
/* TODO: Implement */
}