4e27d513aee22f588607f27b70c5186f88ffcabb
[alexxy/gromacs.git] / include / 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 #ifndef POSITION_H
35 #define POSITION_H
36
37 #include "typedefs.h"
38
39 #include "indexutil.h"
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /*! \brief
46  * Stores a set of positions together with their origins.
47  */
48 typedef struct gmx_ana_pos_t
49 {
50     /*! \brief
51      * Number of positions.
52      */
53     int                 nr;
54     /*! \brief
55      * Array of positions.
56      */
57     rvec               *x;
58     /*! \brief
59      * Velocities (can be NULL).
60      */
61     rvec               *v;
62     /*! \brief
63      * Forces (can be NULL).
64      */
65     rvec               *f;
66     /*! \brief
67      * Mapping of the current positions to the original group.
68      *
69      * \see gmx_ana_indexmap_t
70      */
71     gmx_ana_indexmap_t  m;
72     /*! \brief
73      * Pointer to the current evaluation group.
74      */
75     gmx_ana_index_t    *g;
76     /*! \brief
77      * Number of elements allocated for \c x.
78      */
79     int                 nalloc_x;
80 } gmx_ana_pos_t;
81
82 /** Initializes an empty position structure. */
83 void
84 gmx_ana_pos_clear(gmx_ana_pos_t *pos);
85 /** Ensures that enough memory has been allocated to store positions. */
86 void
87 gmx_ana_pos_reserve(gmx_ana_pos_t *pos, int n, int isize);
88 /** Request memory allocation for velocities. */
89 void
90 gmx_ana_pos_reserve_velocities(gmx_ana_pos_t *pos);
91 /** Request memory allocation for forces. */
92 void
93 gmx_ana_pos_reserve_forces(gmx_ana_pos_t *pos);
94 /** Initializes a \c gmx_ana_pos_t to represent a constant position. */
95 void
96 gmx_ana_pos_init_const(gmx_ana_pos_t *pos, rvec x);
97 /** Frees the memory allocated for position storage. */
98 void
99 gmx_ana_pos_deinit(gmx_ana_pos_t *pos);
100 /** Frees the memory allocated for positions. */
101 void
102 gmx_ana_pos_free(gmx_ana_pos_t *pos);
103 /** Copies the evaluated positions to a preallocated data structure. */
104 void
105 gmx_ana_pos_copy(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, gmx_bool bFirst);
106
107 /** Sets the number of positions in a position structure. */
108 void
109 gmx_ana_pos_set_nr(gmx_ana_pos_t *pos, int n);
110 /** Sets the evaluation group of a position data structure. */
111 void
112 gmx_ana_pos_set_evalgrp(gmx_ana_pos_t *pos, gmx_ana_index_t *g);
113 /** Empties a position data structure with full initialization. */
114 void
115 gmx_ana_pos_empty_init(gmx_ana_pos_t *pos);
116 /** Empties a position data structure. */
117 void
118 gmx_ana_pos_empty(gmx_ana_pos_t *pos);
119 /** Appends a position to a preallocated data structure with full
120  * initialization. */
121 void
122 gmx_ana_pos_append_init(gmx_ana_pos_t *dest, gmx_ana_index_t *g,
123                         gmx_ana_pos_t *src, int i);
124 /** Appends a position to a preallocated data structure. */
125 void
126 gmx_ana_pos_append(gmx_ana_pos_t *dest, gmx_ana_index_t *g,
127                    gmx_ana_pos_t *src, int i, int refid);
128 /** Updates position data structure state after appends. */
129 void
130 gmx_ana_pos_append_finish(gmx_ana_pos_t *pos);
131
132 #ifdef __cplusplus
133 }
134 #endif
135
136 #endif