All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MDAtoms.h
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 The plumed team
3  (see the PEOPLE file at the root of the distribution for a list of names)
4 
5  See http://www.plumed-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
8 
9  plumed is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  plumed is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 #ifndef __PLUMED_core_MDAtoms_h
23 #define __PLUMED_core_MDAtoms_h
24 
25 #include "tools/Tensor.h"
26 #include "tools/Vector.h"
27 #include <vector>
28 #include "tools/Units.h"
29 
30 namespace PLMD {
31 
32 /**
33 Class containing interface to MDAtomsTyped
34 
35 This class is used to translate from reals of the type used in MD to
36 plumed (doubles), and also to rearrange atoms list according to specific
37 ordering indexes (to deal with domain decomposition codes) and layout
38 (to allow passing xx[] yy[] zz[] arrays from the MD code).
39 
40 The class is abstract, but it is possible to allocate a new pointer with
41 create(n), where n is the actual size of MD-reals e.g.
42 \verbatim
43  MDAtomsBase mdatoms=MDAtomsBase::create(sizeof(float));
44 // ...
45  delete mdatoms;
46 \endverbatim
47 */
49 {
50 public:
51 /// Creates an MDAtomsTyped<T> object such that sizeof(T)==n
52  static MDAtomsBase* create(unsigned n);
53 /// Virtual destructor, just to allow inheritance.
54  virtual ~MDAtomsBase(){}
55 /// Get the size of MD-real
56  virtual unsigned getRealPrecision()const=0;
57 /// Set a pointer to the mass array in the MD code
58  virtual void setm(void*m)=0;
59 /// Set a pointer to the charge array in the MD code
60  virtual void setc(void*m)=0;
61 /// Set a pointer to the box array (3x3) in the MD code
62  virtual void setBox(void*)=0;
63 /// Set a pointer to the positions array in the MD code
64  virtual void setp(void*p)=0;
65 /// Set a pointer to the virial array (3x3) in the MD code
66  virtual void setVirial(void*)=0;
67 /// Set a pointer to the forces array in the MD code
68  virtual void setf(void*f)=0;
69 /// Set a pointer to the position array in the MD code
70  virtual void setp(void*p,int i)=0;
71 /// Set a pointer to the force array in the MD code
72  virtual void setf(void*f,int i)=0;
73 /// Set internal and MD units
74  virtual void setUnits(const Units& units,const Units& MDUnits)=0;
75 /// Convert a pointer to an MD-real to a double
76  virtual void MD2double(const void*,double&)const=0;
77 /// Convert a double to a pointer to an MD-real
78  virtual void double2MD(const double&,void*)const=0;
79 /// Retrieve box as a plumed Tensor
80  virtual void getBox(Tensor &)const=0;
81 /// Retrieve selected positions.
82 /// The operation is done in such a way that p[index[i]] is equal to the coordinates of atom i
83  virtual void getPositions(const std::vector<int>&index,std::vector<Vector>&p)const=0;
84 /// Retrieve selected masses.
85 /// The operation is done in such a way that m[index[i]] is equal to the mass of atom i
86  virtual void getMasses(const std::vector<int>&index,std::vector<double>&m)const=0;
87 /// Retrieve selected charges.
88 /// The operation is done in such a way that c[index[i]] is equal to the charge of atom i
89  virtual void getCharges(const std::vector<int>&index,std::vector<double>&c)const=0;
90 /// Increment the virial by an amount v
91  virtual void updateVirial(const Tensor&v)const=0;
92 /// Increment the force on selected atoms.
93 /// The operation is done in such a way that f[index[i]] is added to the force on atom i
94  virtual void updateForces(const std::vector<int>&index,const std::vector<Vector>&f)=0;
95 /// Rescale all the forces, including the virial.
96 /// It is applied to all atoms with local index going from 0 to index.size()-1
97 /// \attention the virial is not scaled indeed... is it a bug??
98  virtual void rescaleForces(const std::vector<int>&index,double factor)=0;
99 };
100 
101 }
102 
103 
104 #endif
virtual void setf(void *f)=0
Set a pointer to the forces array in the MD code.
virtual unsigned getRealPrecision() const =0
Get the size of MD-real.
Class implementing fixed size matrices of doubles.
Definition: Tensor.h:70
virtual void getMasses(const std::vector< int > &index, std::vector< double > &m) const =0
Retrieve selected masses.
virtual void MD2double(const void *, double &) const =0
Convert a pointer to an MD-real to a double.
virtual ~MDAtomsBase()
Virtual destructor, just to allow inheritance.
Definition: MDAtoms.h:54
virtual void setm(void *m)=0
Set a pointer to the mass array in the MD code.
void const char const char int * n
Definition: Matrix.h:42
Class containing interface to MDAtomsTyped.
Definition: MDAtoms.h:48
virtual void setUnits(const Units &units, const Units &MDUnits)=0
Set internal and MD units.
Small utility class that contains information about units.
Definition: Units.h:41
virtual void setc(void *m)=0
Set a pointer to the charge array in the MD code.
virtual void rescaleForces(const std::vector< int > &index, double factor)=0
Rescale all the forces, including the virial.
virtual void double2MD(const double &, void *) const =0
Convert a double to a pointer to an MD-real.
virtual void setBox(void *)=0
Set a pointer to the box array (3x3) in the MD code.
virtual void updateVirial(const Tensor &v) const =0
Increment the virial by an amount v.
void const char const char int double int double double int int double int * m
Definition: Matrix.h:42
virtual void getPositions(const std::vector< int > &index, std::vector< Vector > &p) const =0
Retrieve selected positions.
virtual void setVirial(void *)=0
Set a pointer to the virial array (3x3) in the MD code.
virtual void getBox(Tensor &) const =0
Retrieve box as a plumed Tensor.
virtual void setp(void *p)=0
Set a pointer to the positions array in the MD code.
virtual void updateForces(const std::vector< int > &index, const std::vector< Vector > &f)=0
Increment the force on selected atoms.
virtual void getCharges(const std::vector< int > &index, std::vector< double > &c) const =0
Retrieve selected charges.
static MDAtomsBase * create(unsigned n)
Creates an MDAtomsTyped object such that sizeof(T)==n.
Definition: MDAtoms.cpp:224