851f2e8533d54f8e715d27eee114407ae101109a
[alexxy/gromacs-pyapi.git] / src / sip / trajectoryanalysis / analysismodule.sip
1 /*
2  * This file is part of the GROMACS-PyAPI package.
3  *
4  * Copyright (c) 2014,2015,
5  * by Maks Koltsov <maks@omrb.pnpi.spb.ru> and
6  * by Alexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
7  *
8  * GROMACS-PyAPI is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1
11  * of the License, or (at your option) any later version.
12  *
13  * GROMACS-PyAPI is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with GROMACS; if not, see
20  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
22  */
23
24 struct t_trxframe {
25
26     %TypeHeaderCode
27 #include <gromacs/trajectory/trajectoryframe.h>
28 #include "numpy_conv.h"
29     %End
30
31     int         not_ok;
32     bool         bDouble;
33     int          natoms;
34     bool         bTitle;
35     const char  *title;
36     bool         bStep;
37     int          step;
38     bool         bTime;
39     double       time;
40     bool         bLambda;
41     bool         bFepState;
42     double       lambda;
43     int          fep_state;
44     bool         bAtoms;
45     t_atoms     *atoms;
46     bool         bPrec;
47     double       prec;
48     bool         bX;
49
50     SIP_PYOBJECT x /NoSetter/ {
51         %GetCode
52         sipPy = array2dToNumpy(sipCpp->natoms, 3, sipCpp->x);
53         %End
54     };
55     bool         bV;
56     SIP_PYOBJECT v /NoSetter/ {
57         %GetCode
58         sipPy = array2dToNumpy(sipCpp->natoms, 3, sipCpp->v);
59         %End
60     };
61     bool         bF;
62     SIP_PYOBJECT f /NoSetter/ {
63         %GetCode
64         sipPy = array2dToNumpy(sipCpp->natoms, 3, sipCpp->f);
65         %End
66     };
67     bool         bBox;
68     SIP_PYOBJECT box /NoSetter/ {
69         %GetCode
70         sipPy = array2dToNumpy(3, 3, sipCpp->box);
71         %End
72     };
73     bool         bPBC;
74     int          ePBC;
75     bool         bIndex;
76     SIP_PYOBJECT index /NoSetter/ {
77         %GetCode
78         sipPy = array1dToNumpy(sipCpp->natoms, sipCpp->index);
79         %End
80     };
81 };
82
83 struct t_pbc {
84
85     %TypeHeaderCode
86 #include <gromacs/pbcutil/pbc.h>
87 #include "numpy_conv.h"
88     %End
89     int ePBC;
90     int          ndim_ePBC;
91     int          ePBCDX;
92     int          dim;
93     SIP_PYOBJECT box /NoSetter/ {
94         %GetCode
95         sipPy = array2dToNumpy(3, 3, sipCpp->box);
96         %End
97     };
98     SIP_PYOBJECT fbox_diag /NoSetter/ {
99         %GetCode
100         sipPy = array1dToNumpy(3, sipCpp->fbox_diag);
101         %End
102     };
103     SIP_PYOBJECT hbox_diag /NoSetter/ {
104         %GetCode
105         sipPy = array1dToNumpy(3, sipCpp->hbox_diag);
106         %End
107     };
108     SIP_PYOBJECT mhbox_diag /NoSetter/ {
109         %GetCode
110         sipPy = array1dToNumpy(3, sipCpp->mhbox_diag);
111         %End
112     };
113     double max_cutoff2;
114     int    ntric_vec;
115     /*ivec tric_shift[MAX_NTRICVEC];*/
116     /*rvec tric_vec[MAX_NTRICVEC];*/
117 };
118
119 class AnalysisDataParallelOptions /NoDefaultCtors/ {
120     %TypeHeaderCode
121 #include <gromacs/analysisdata/paralleloptions.h>
122     %End
123     public:
124         AnalysisDataParallelOptions();
125 };
126
127 class TrajectoryAnalysisModuleDataPointer;
128 class TrajectoryAnalysisModuleData /NoDefaultCtors/ {
129     %TypeHeaderCode
130 #include <gromacs/trajectoryanalysis/analysismodule.h>
131     using namespace gmx;
132     %End
133
134     public:
135         virtual void finish() = 0;
136 };
137
138 class TrajectoryAnalysisModulePointer;
139 class TrajectoryAnalysisModule /VirtualErrorHandler = vehandler/ {
140     %TypeHeaderCode
141 #include <gromacs/trajectoryanalysis/analysismodule.h>
142     using namespace gmx;
143     %End
144     public:
145         virtual void initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings) = 0;
146         virtual void optionsFinished(TrajectoryAnalysisSettings *settings);
147         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings, const TopologyInformation &top) = 0;
148         virtual void initAfterFirstFrame(const TrajectoryAnalysisSettings &settings, const t_trxframe &fr);
149         // Discarding the virtual for now
150         std::unique_ptr < TrajectoryAnalysisModuleData > startFrames (const AnalysisDataParallelOptions &opt, const SelectionCollection &selections);
151         virtual void analyzeFrame(int frnr, const t_trxframe &fr /NoCopy/, t_pbc *pbc, TrajectoryAnalysisModuleData *pdata ) = 0;
152         virtual void finishFrames(TrajectoryAnalysisModuleData *pdata);
153         virtual void finishAnalysis(int nframes) = 0;
154         virtual void writeOutput()               = 0;
155         int datasetCount() const;
156         void finishFrameSerial(int frameIndex);
157         AbstractAnalysisData &datasetFromIndex(int index) const;
158         AbstractAnalysisData &datasetFromName(const char *name) const;
159     protected:
160         TrajectoryAnalysisModule();
161     private:
162         TrajectoryAnalysisModule(const TrajectoryAnalysisModule &other);
163 };