Constraint.h 2.14 KB
Newer Older
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15
// Constraint.h
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
//
////////////////////////////////////////////////////////////////////////////////

#ifndef CONSTRAINT_H
#define CONSTRAINT_H

#include <string>
#include <vector>
#include <cassert>

class AtomSet;

class Constraint
{
  protected:
31

32 33
  std::string name_;          // constraint name
  std::vector<std::string> names_; // names of atoms involved in the constraint
34

35
  public:
36

37
  virtual ~Constraint(void){}
38
  virtual std::string type(void) const = 0;
39 40
  virtual double value(void) const = 0;
  virtual double velocity(void) const = 0;
Francois Gygi committed
41 42
  virtual double force(void) const = 0;
  virtual double weight(void) const = 0;
43 44 45
  virtual double tolerance(void) const = 0;
  virtual void set_value(double value) = 0;
  virtual void set_velocity(double velocity) = 0;
46 47 48 49 50 51
  virtual bool enforce_r(const std::vector<std::vector<double> > &r0,
                         std::vector<std::vector<double> > &rp) const = 0;
  virtual bool enforce_v(const std::vector<std::vector<double> > &r0,
                         std::vector<std::vector<double> > &v0) const = 0;
  virtual void compute_force(const std::vector<std::vector<double> > &r0,
                             const std::vector<std::vector<double> > &f) = 0;
52 53
  virtual void update(double dt) = 0;
  virtual void setup(const AtomSet& atoms) = 0;
54
  virtual int dofs(void) const = 0;
55 56 57
  virtual std::ostream& print(std::ostream &os) = 0;
  std::string name(void) const { return name_; }
  std::string names(int i) const
58 59 60 61 62
  {
    assert( i >= 0 && i < names_.size() );
    return names_[i];
  }
};
63
std::ostream& operator << ( std::ostream &os, Constraint &c );
64
#endif
65 66