Fix potential problem in Messenger related to MPI window
[hoomd-blue.git] / libhoomd / data_structures / IntegratorData.h
blobe5f10ce52ff6efcad37a7fb6fe8a8166f787517f
1 /*
2 Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 (HOOMD-blue) Open Source Software License Copyright 2009-2014 The Regents of
4 the University of Michigan All rights reserved.
6 HOOMD-blue may contain modifications ("Contributions") provided, and to which
7 copyright is held, by various Contributors who have granted The Regents of the
8 University of Michigan the right to modify and/or distribute such Contributions.
10 You may redistribute, use, and create derivate works of HOOMD-blue, in source
11 and binary forms, provided you abide by the following conditions:
13 * Redistributions of source code must retain the above copyright notice, this
14 list of conditions, and the following disclaimer both in the code and
15 prominently in any materials provided with the distribution.
17 * Redistributions in binary form must reproduce the above copyright notice, this
18 list of conditions, and the following disclaimer in the documentation and/or
19 other materials provided with the distribution.
21 * All publications and presentations based on HOOMD-blue, including any reports
22 or published results obtained, in whole or in part, with HOOMD-blue, will
23 acknowledge its use according to the terms posted at the time of submission on:
24 http://codeblue.umich.edu/hoomd-blue/citations.html
26 * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
27 http://codeblue.umich.edu/hoomd-blue/
29 * Apart from the above required attributions, neither the name of the copyright
30 holder nor the names of HOOMD-blue's contributors may be used to endorse or
31 promote products derived from this software without specific prior written
32 permission.
34 Disclaimer
36 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
37 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
39 WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
41 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 // Maintainer: joaander
52 /*! \file IntegratorData.h
53 \brief Contains declarations for IntegratorData.
56 #ifdef NVCC
57 #error This header cannot be compiled by nvcc
58 #endif
60 #ifndef __INTEGRATORDATA_H__
61 #define __INTEGRATORDATA_H__
63 #include "ParticleData.h"
64 #include <string>
67 //! Stores integrator variables
68 /*! The integration state is necessary for exact restarts. Extended systems
69 integrators in the spirit of Nose-Hoover store the positions, velocities,
70 etc. of the fictitious variables. Other integrators store a random number
71 seed.
72 \ingroup data_structs
74 struct IntegratorVariables
76 std::string type; //!<The type of integrator (NVT, NPT, etc.)
77 std::vector<Scalar> variable; //!<Variables that define the integration state
80 //! Stores all integrator variables in the simulation
81 /*! IntegratorData keeps track of the parameters for all of the integrators
82 defined in the simulation, so that they can be saved and reloaded from data files.
84 Each integrator must register with IntegratorData by calling registerIntegrator(), which returns an unsinged int
85 to be used to access the variables for that integrator. The same sequence of registerIntegrator() calls will produce
86 the same set of handles, so they can be used to read existing state values after loading data from a file.
88 The state of current registered integrators is reset when a new IntegratorData is constructed. This is consistent
89 with the above use-case, as the construction of a new IntegratorData means the construction of a new SystemData, and
90 hence a new series of constructed Integrators, which will then re-register.
92 \ingroup data_structs
94 class IntegratorData
96 public:
97 //! Constructs an empty list with no integrator variables
98 IntegratorData() : m_num_registered(0) {}
100 //! Constructs an IntegratorData from a given set of IntegratorVariables
101 IntegratorData(const std::vector<IntegratorVariables>& variables)
102 : m_num_registered(0)
104 m_integrator_variables = variables;
107 //! Destructor
108 ~IntegratorData() {}
110 //! Register an integrator (should occur during integrator construction)
111 unsigned int registerIntegrator();
113 //! Get the number of integrator variables
114 /*! \return Number of integrator variables present
116 unsigned int getNumIntegrators() const
118 return (unsigned int)m_integrator_variables.size();
121 //! Load a number of integrator variables
122 /*! \param n Number of variables to load
123 When loading from a file, a given number of integrator variables must be preloaded without registering them.
124 This method does that. After calling load(n), setIntegratorVariables() can be called for \a i up to \a n-1
126 void load(unsigned int n)
128 m_integrator_variables.resize(n);
131 //! Get a collection of integrator variables
132 /*! \param i access integrator variables for integrator i
134 const IntegratorVariables& getIntegratorVariables(unsigned int i) const
136 assert(i < m_integrator_variables.size()); return m_integrator_variables[i];
139 //! Set a collection of integrator variables
140 /*! \param i set integrator variables for integrator i
141 \param v Variables to set
143 void setIntegratorVariables(unsigned int i, const IntegratorVariables& v)
145 assert(i < m_integrator_variables.size()); m_integrator_variables[i] = v;
148 private:
149 unsigned int m_num_registered; //!< Number of integrators that have registered
150 std::vector<IntegratorVariables> m_integrator_variables; //!< List of the integrator variables defined
154 //! Exports IntegratorData to python
155 void export_IntegratorData();
157 #endif