Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DOF_Node.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/kinematics/DOF_Node.hh
11 /// @brief Kinematics
12 /// @author Phil Bradley
13 
14 
15 #ifndef INCLUDED_core_optimization_DOF_Node_hh
16 #define INCLUDED_core_optimization_DOF_Node_hh
17 
18 // Unit headers
20 
21 // Project headers
22 #include <core/id/TorsionID.hh>
23 #include <core/id/DOF_ID.hh>
24 
25 #include <core/types.hh> // Vector
26 
27 // // Numeric headers
28 #include <numeric/xyzVector.hh>
29 
30 // Utility headers
31 #include <utility/pointer/ReferenceCount.hh>
32 #include <utility/vector1.hh>
33 
34 
35 namespace core {
36 namespace optimization {
37 
38 
40 {
41 public:
42  //typedef numeric::xyzVector< Real > Vector;
43  typedef id::AtomID AtomID;
45  typedef id::DOF_ID DOF_ID;
48 
49 
50 public:
51  inline
52  Vector &
53  F1() { return F1_; };
54 
55  inline
56  Vector &
57  F2() { return F2_; }
58 
59  inline
60  Vector const &
61  F1() const { return F1_; };
62 
63  inline
64  Vector const &
65  F2() const { return F2_; }
66 
67  inline
68  int
69  rsd() const { return id.atom_id().rsd(); }
70 
71  inline
72  int
73  atomno() const { return id.atom_id().atomno(); }
74 
75  inline
76  AtomID const &
77  atom_id() const { return id.atom_id(); }
78 
79  inline
80  DOF_Type
81  type() const { return id.type(); }
82 
83  inline
84  DOF_ID const &
85  dof_id() const { return id; }
86 
87  inline
88  int depth() const;
89 
90  inline
91  AtomIDs const &
92  atoms() const
93  {
94  return atoms_;
95  }
96 
97  inline
99  parent() const
100  {
101  return parent_;
102  }
103 
104  inline
105  void
107  atoms_.clear(); // don't deallocate space -- makes DOF_Nodes reusable.
108  }
109 
110  ///
111  inline
112  void
113  add_atom( AtomID const & atom )
114  {
115  atoms_.push_back( atom );
116  }
117 
118 
119  /// get the rosetta torsion id for this DOF
120  /**
121  This may not exist, of course. But it's useful to know what it
122  is when calculating derivatives of terms like rama/dunbrack/paa
123  **/
124  TorsionID const &
125  torsion_id() const
126  {
127  return torsion_id_;
128  }
129 
130 
131  /// set the rosetta torsion id for this DOF
132  /**
133  This may not exist, of course. But it's useful to know what it
134  is when calculating derivatives of terms like rama/dunbrack/paa
135  **/
136  void
138  id::TorsionID const & id_in
139  )
140  {
141  torsion_id_ = id_in;
142  }
143 
144 
145  /// sum derivative contributions down the tree
146  inline
147  void
149  {
150  if ( parent_ ) {
151  parent_->F1() += F1_;
152  parent_->F2() += F2_;
153  }
154  }
155 
156  // constructor
158  DOF_ID const & id_in,
159  DOF_NodeOP parent_in
160  ):
161  utility::pointer::ReferenceCount(),
162  F1_(0.0),
163  F2_(0.0),
164  depth_(-1),
165  id( id_in ),
166  parent_( parent_in ),
168  {}
169 
170  void
171  set_id( DOF_ID const & setting ) {
172  id = setting;
173  }
174 
175  void
177  {
178  assert( setting() != this ); // an object in an OP should never point to itself
179  parent_ = setting;
180  }
181 
182 private:
185  mutable int depth_;
190 
191 
192  friend
193  inline
194  bool
195  operator< ( DOF_Node const & t1, DOF_Node const & t2 ) {
196  return ( t1.depth() > t2.depth() ); // check that this gives correct sort
197  }
198 
199 
200 }; // DOF_Node
201 
202 
203 inline
204 int
206 {
207  if ( parent_ == 0 ) {
208  depth_ = 0;
209  } else if ( depth_ < 0 ) {
210  depth_ = parent_->depth() + 1;
211  }
212  assert( depth_ >= 0 );
213  return depth_;
214 }
215 
216 
217 } // namespace kinematics
218 } // namespace core
219 
220 
221 #endif // INCLUDED_core_kinematics_min_HH