Update instructions in containers.rst
[gromacs.git] / src / gromacs / trajectoryanalysis / analysissettings.h
blobe3ac3799a8e1c74e4d9d7e26deeada5dde124ebf
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2010-2018, The GROMACS development team.
5 * Copyright (c) 2019, by the GROMACS development team, led by
6 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 * and including many others, as listed in the AUTHORS file in the
8 * top-level source directory and at http://www.gromacs.org.
10 * GROMACS is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * GROMACS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with GROMACS; if not, see
22 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * If you want to redistribute modifications to GROMACS, please
26 * consider that scientific software is very special. Version
27 * control is crucial - bugs must be traceable. We will be happy to
28 * consider code for inclusion in the official distribution, but
29 * derived work must not be called official GROMACS. Details are found
30 * in the README & COPYING files - if they are missing, get the
31 * official version at http://www.gromacs.org.
33 * To help us fund GROMACS development, we humbly ask that you cite
34 * the research papers on the package. Check out http://www.gromacs.org.
36 /*! \file
37 * \brief
38 * Declares gmx::TrajectoryAnalysisSettings.
40 * \author Teemu Murtola <teemu.murtola@gmail.com>
41 * \inpublicapi
42 * \ingroup module_trajectoryanalysis
44 #ifndef GMX_TRAJECTORYANALYSIS_ANALYSISSETTINGS_H
45 #define GMX_TRAJECTORYANALYSIS_ANALYSISSETTINGS_H
47 #include <string>
49 #include "gromacs/options/timeunitmanager.h"
50 #include "gromacs/utility/classhelpers.h"
52 namespace gmx
55 template<typename T>
56 class ArrayRef;
58 class AnalysisDataPlotSettings;
59 class ICommandLineOptionsModuleSettings;
60 class Options;
61 class TrajectoryAnalysisRunnerCommon;
63 /*! \brief
64 * Trajectory analysis module configuration object.
66 * This class is used by trajectory analysis modules to inform the caller
67 * about the requirements they have on the input (e.g., whether a topology is
68 * required, or whether PBC removal makes sense). It is also used to pass
69 * similar information back to the analysis module after parsing user input.
71 * Having this functionality as a separate class makes the
72 * TrajectoryAnalysisModule interface much cleaner, and also reduces the need to
73 * change existing code when new options are added.
75 * Methods in this class do not throw, except for the constructor, which may
76 * throw an std::bad_alloc.
78 * \todo
79 * Remove plain flags from the public interface.
81 * \inpublicapi
82 * \ingroup module_trajectoryanalysis
84 class TrajectoryAnalysisSettings
86 public:
87 //! Recognized flags.
88 enum
90 /*! \brief
91 * Forces loading of a topology file.
93 * If this flag is not specified, the topology file is loaded only
94 * if it is provided on the command line explicitly.
96 efRequireTop = 1 << 0,
97 /*! \brief
98 * Requests topology coordinates.
100 * If this flag is specified, the position coordinates loaded from the
101 * topology can be accessed, otherwise they are not loaded.
103 * \see TopologyInformation
105 efUseTopX = 1 << 1,
106 /*! \brief
107 * Requests topology coordinates.
109 * If this flag is specified, the velocity coordinates loaded from the
110 * topology can be accessed, otherwise they are not loaded.
112 * \see TopologyInformation
114 efUseTopV = 1 << 2,
115 /*! \brief
116 * Disallows the user from changing PBC handling.
118 * If this option is not specified, the analysis module (see
119 * TrajectoryAnalysisModule::analyzeFrame()) may be passed a NULL
120 * PBC structure, and it should be able to handle such a situation.
122 * \see setPBC()
124 efNoUserPBC = 1 << 4,
125 /*! \brief
126 * Disallows the user from changing PBC removal.
128 * \see setRmPBC()
130 efNoUserRmPBC = 1 << 5,
133 //! Initializes default settings.
134 TrajectoryAnalysisSettings();
135 ~TrajectoryAnalysisSettings();
137 //! Injects command line options module settings for some methods to use.
138 void setOptionsModuleSettings(ICommandLineOptionsModuleSettings* settings);
140 //! Returns the time unit the user has requested.
141 TimeUnit timeUnit() const;
142 //! Returns common settings for analysis data plot modules.
143 const AnalysisDataPlotSettings& plotSettings() const;
145 //! Returns the currently set flags.
146 unsigned long flags() const;
147 //! Tests whether a flag has been set.
148 bool hasFlag(unsigned long flag) const;
149 /*! \brief
150 * Returns whether PBC should be used.
152 * Returns the value set with setPBC() and/or overridden by the user.
153 * The user-provided value can be accessed in
154 * TrajectoryAnalysisModule::optionsFinished(), and can be overridden
155 * with a call to setPBC().
157 bool hasPBC() const;
158 /*! \brief
159 * Returns whether molecules should be made whole.
161 * See hasPBC() for information on accessing or overriding the
162 * user-provided value.
164 bool hasRmPBC() const;
165 //! Returns the currently set frame flags.
166 int frflags() const;
168 /*! \brief
169 * Sets flags.
171 * Overrides any earlier set flags.
172 * By default, no flags are set.
174 void setFlags(unsigned long flags);
175 //! Sets or clears an individual flag.
176 void setFlag(unsigned long flag, bool bSet = true);
177 /*! \brief
178 * Sets whether PBC are used.
180 * \param[in] bPBC true if PBC should be used.
182 * If called in TrajectoryAnalysisModule::initOptions(), this function
183 * sets the default for whether PBC are used in the analysis.
184 * If \ref efNoUserPBC is not set, a command-line option is provided
185 * for the user to override the default value.
186 * If called later, it overrides the setting provided by the user or an
187 * earlier call.
189 * If this function is not called, the default is to use PBC.
191 * If PBC are not used, the \p pbc pointer passed to
192 * TrajectoryAnalysisModule::analyzeFrame() is NULL.
193 * The value of the flag can also be accessed with hasPBC().
195 * \see efNoUserPBC
197 void setPBC(bool bPBC);
198 /*! \brief
199 * Sets whether molecules are made whole.
201 * \param[in] bRmPBC true if molecules should be made whole.
203 * If called in TrajectoryAnalysisModule::initOptions(), this function
204 * sets the default for whether molecules are made whole.
205 * If \ref efNoUserRmPBC is not set, a command-line option is provided
206 * for the user to override the default value.
207 * If called later, it overrides the setting provided by the user or an
208 * earlier call.
210 * If this function is not called, the default is to make molecules
211 * whole.
213 * The main use of this function is to call it with \c false if your
214 * analysis program does not require whole molecules as this can
215 * increase the performance.
216 * In such a case, you can also specify \ref efNoUserRmPBC to not to
217 * confuse the user with an option that would only slow the program
218 * down.
220 * \see efNoUserRmPBC
222 void setRmPBC(bool bRmPBC);
223 /*! \brief
224 * Sets flags that determine what to read from the trajectory.
226 * \param[in] frflags Flags for what to read from the trajectory file.
228 * If this function is not called, the flags default to TRX_NEED_X.
229 * If the analysis module needs some other information (velocities,
230 * forces), it can call this function to load additional information
231 * from the trajectory.
233 void setFrameFlags(int frflags);
235 //! \copydoc ICommandLineOptionsModuleSettings::setHelpText()
236 void setHelpText(const ArrayRef<const char* const>& help);
238 private:
239 class Impl;
241 PrivateImplPointer<Impl> impl_;
243 friend class TrajectoryAnalysisRunnerCommon;
246 } // namespace gmx
248 #endif