Merge branch 'release-4-6'
[alexxy/gromacs.git] / src / gromacs / analysisdata / modules / displacement.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
33  * Declares gmx::AnalysisDataDisplacementModule.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \inpublicapi
37  * \ingroup module_analysisdata
38  */
39 #ifndef GMX_ANALYSISDATA_MODULES_DISPLACEMENT_H
40 #define GMX_ANALYSISDATA_MODULES_DISPLACEMENT_H
41
42 #include "../abstractdata.h"
43 #include "../datamodule.h"
44
45 namespace gmx
46 {
47
48 class AnalysisDataBinAverageModule;
49
50 /*! \brief
51  * Data module for calculating displacements.
52  *
53  * Output data contains a frame for each frame in the input data except the
54  * first one.  For each frame, there can be multiple points, each of which
55  * describes displacement for a certain time difference ending that that frame.
56  * The first column contains the time difference (backwards from the current
57  * frame), and the remaining columns the sizes of the displacements.
58  *
59  * Current implementation is not very generic, but should be easy to extend.
60  *
61  * \inpublicapi
62  * \ingroup module_analysisdata
63  */
64 class AnalysisDataDisplacementModule : public AbstractAnalysisData,
65                                        public AnalysisDataModuleInterface
66 {
67     public:
68         AnalysisDataDisplacementModule();
69         virtual ~AnalysisDataDisplacementModule();
70
71         /*! \brief
72          * Sets the largest displacement time to be calculated.
73          */
74         void setMaxTime(real tmax);
75         /*! \brief
76          * Sets an histogram module that will receive a MSD histogram.
77          *
78          * If this function is not called, no histogram is calculated.
79          */
80         void setMSDHistogram(boost::shared_ptr<AnalysisDataBinAverageModule> histm);
81
82         virtual int flags() const;
83
84         virtual void dataStarted(AbstractAnalysisData *data);
85         virtual void frameStarted(const AnalysisDataFrameHeader &header);
86         virtual void pointsAdded(const AnalysisDataPointSetRef &points);
87         virtual void frameFinished(const AnalysisDataFrameHeader &header);
88         virtual void dataFinished();
89
90     private:
91         virtual AnalysisDataFrameRef tryGetDataFrameInternal(int index) const;
92         virtual bool requestStorageInternal(int nframes);
93
94         class Impl;
95
96         PrivateImplPointer<Impl> _impl;
97 };
98
99 //! Smart pointer to manage an AnalysisDataDisplacementModule object.
100 typedef boost::shared_ptr<AnalysisDataDisplacementModule>
101         AnalysisDataDisplacementModulePointer;
102
103 } // namespace gmx
104
105 #endif