1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2009 The Regents of the University of California
4 //
5 // This file is part of Qbox
6 //
7 // Qbox is distributed under the terms of the GNU General Public License
8 // as published by the Free Software Foundation, either version 2 of
9 // the License, or (at your option) any later version.
10 // See the file COPYING in the root directory of this distribution
11 // or <http://www.gnu.org/licenses/>.
12 //
13 ////////////////////////////////////////////////////////////////////////////////
14 //
15 // ExtForce.h
16 //
17 ////////////////////////////////////////////////////////////////////////////////
18 
19 #ifndef EXTFORCE_H
20 #define EXTFORCE_H
21 
22 #include <string>
23 #include <vector>
24 #include <cassert>
25 #include "D3vector.h"
26 
27 class AtomSet;
28 
29 class ExtForce
30 {
31   protected:
32 
33   std::string name_;               // extforce name
34   std::vector<std::string> names_; // names of atoms involved in the extforce
35 
36   public:
37 
~ExtForce(void)38   virtual ~ExtForce(void){}
39   virtual std::string type(void) const = 0;
40   virtual void set_value(std::vector<double> f) = 0;
41   virtual double energy(const std::vector<std::vector<double> > &r,
42                         std::vector<std::vector<double> > &f) = 0;
43   virtual void setup(const AtomSet& atoms) = 0;
44   virtual std::ostream& print(std::ostream &os) = 0;
45   virtual D3vector sum_contrib(void) = 0;
name(void)46   std::string name(void) const { return name_; }
47   virtual double magnitude(void) = 0;
names(int i)48   std::string names(int i) const
49   {
50     assert( i >= 0 && i < names_.size() );
51     return names_[i];
52   }
53 };
54 std::ostream& operator << ( std::ostream &os, ExtForce &xf );
55 #endif
56