Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / selection / position.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11  * Copyright (c) 2001-2009, The GROMACS development team,
12  * check out http://www.gromacs.org for more information.
13
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * If you want to redistribute modifications, please consider that
20  * scientific software is very special. Version control is crucial -
21  * bugs must be traceable. We will be happy to consider code for
22  * inclusion in the official distribution, but derived work must not
23  * be called official GROMACS. Details are found in the README & COPYING
24  * files - if they are missing, get the official version at www.gromacs.org.
25  *
26  * To help us fund GROMACS development, we humbly ask that you cite
27  * the papers on the package - you can find them in the top README file.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \file
32  * \brief API for handling positions.
33  *
34  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
35  * \ingroup module_selection
36  */
37 #ifndef GMX_SELECTION_POSITION_H
38 #define GMX_SELECTION_POSITION_H
39
40 #include "../legacyheaders/types/simple.h"
41
42 #include "indexutil.h"
43
44 /*! \brief
45  * Stores a set of positions together with their origins.
46  */
47 typedef struct gmx_ana_pos_t
48 {
49     /*! \brief
50      * Number of positions.
51      */
52     int                 nr;
53     /*! \brief
54      * Array of positions.
55      */
56     rvec               *x;
57     /*! \brief
58      * Velocities (can be NULL).
59      */
60     rvec               *v;
61     /*! \brief
62      * Forces (can be NULL).
63      */
64     rvec               *f;
65     /*! \brief
66      * Mapping of the current positions to the original group.
67      *
68      * \see gmx_ana_indexmap_t
69      */
70     gmx_ana_indexmap_t  m;
71     /*! \brief
72      * Pointer to the current evaluation group.
73      */
74     gmx_ana_index_t    *g;
75     /*! \brief
76      * Number of elements allocated for \c x.
77      */
78     int                 nalloc_x;
79 } gmx_ana_pos_t;
80
81 /** Initializes an empty position structure. */
82 void
83 gmx_ana_pos_clear(gmx_ana_pos_t *pos);
84 /** Ensures that enough memory has been allocated to store positions. */
85 void
86 gmx_ana_pos_reserve(gmx_ana_pos_t *pos, int n, int isize);
87 /** Request memory allocation for velocities. */
88 void
89 gmx_ana_pos_reserve_velocities(gmx_ana_pos_t *pos);
90 /** Request memory allocation for forces. */
91 void
92 gmx_ana_pos_reserve_forces(gmx_ana_pos_t *pos);
93 /** Initializes a \c gmx_ana_pos_t to represent a constant position. */
94 void
95 gmx_ana_pos_init_const(gmx_ana_pos_t *pos, rvec x);
96 /** Frees the memory allocated for position storage. */
97 void
98 gmx_ana_pos_deinit(gmx_ana_pos_t *pos);
99 /** Frees the memory allocated for positions. */
100 void
101 gmx_ana_pos_free(gmx_ana_pos_t *pos);
102 /** Copies the evaluated positions to a preallocated data structure. */
103 void
104 gmx_ana_pos_copy(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, bool bFirst);
105
106 /** Sets the number of positions in a position structure. */
107 void
108 gmx_ana_pos_set_nr(gmx_ana_pos_t *pos, int n);
109 /** Sets the evaluation group of a position data structure. */
110 void
111 gmx_ana_pos_set_evalgrp(gmx_ana_pos_t *pos, gmx_ana_index_t *g);
112 /** Empties a position data structure with full initialization. */
113 void
114 gmx_ana_pos_empty_init(gmx_ana_pos_t *pos);
115 /** Empties a position data structure. */
116 void
117 gmx_ana_pos_empty(gmx_ana_pos_t *pos);
118 /** Appends a position to a preallocated data structure with full
119  * initialization. */
120 void
121 gmx_ana_pos_append_init(gmx_ana_pos_t *dest, gmx_ana_index_t *g,
122                         gmx_ana_pos_t *src, int i);
123 /** Appends a position to a preallocated data structure. */
124 void
125 gmx_ana_pos_append(gmx_ana_pos_t *dest, gmx_ana_index_t *g,
126                    gmx_ana_pos_t *src, int i, int refid);
127 /** Updates position data structure state after appends. */
128 void
129 gmx_ana_pos_append_finish(gmx_ana_pos_t *pos);
130
131 #endif