LCOV - code coverage report
Current view: top level - core - MDAtoms.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 2 2 100.0 %
Date: 2018-12-19 07:49:13 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2018 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.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       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             : */
      48        1451 : class MDAtomsBase
      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        1451 :   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             : 
      80             :   virtual Vector getMDforces(const unsigned index)const=0;
      81             : /// Retrieve box as a plumed Tensor
      82             :   virtual void getBox(Tensor &)const=0;
      83             : /// Retrieve selected positions.
      84             : /// The operation is done in such a way that p[index[i]] is equal to the coordinates of atom i
      85             :   virtual void getPositions(const std::vector<int>&index,std::vector<Vector>&p)const=0;
      86             : /// Retrieve all atom positions from index i to index j.
      87             :   virtual void getPositions(unsigned i,unsigned j,std::vector<Vector>&p)const=0;
      88             : /// Retrieve selected masses.
      89             : /// The operation is done in such a way that m[index[i]] is equal to the mass of atom i
      90             :   virtual void getMasses(const std::vector<int>&index,std::vector<double>&m)const=0;
      91             : /// Retrieve selected charges.
      92             : /// The operation is done in such a way that c[index[i]] is equal to the charge of atom i
      93             :   virtual void getCharges(const std::vector<int>&index,std::vector<double>&c)const=0;
      94             : /// Retrieve local positions.
      95             :   virtual void getLocalPositions(std::vector<Vector>&p)const=0;
      96             : /// Increment the virial by an amount v
      97             :   virtual void updateVirial(const Tensor&v)const=0;
      98             : /// Increment the force on selected atoms.
      99             : /// The operation is done in such a way that f[index[i]] is added to the force on atom i
     100             :   virtual void updateForces(const std::vector<int>&index,const std::vector<Vector>&f)=0;
     101             : /// Rescale all the forces, including the virial.
     102             : /// It is applied to all atoms with local index going from 0 to index.size()-1
     103             :   virtual void rescaleForces(const std::vector<int>&index,double factor)=0;
     104             : };
     105             : 
     106             : }
     107             : 
     108             : 
     109             : #endif

Generated by: LCOV version 1.13