Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2014-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_multicolvar_BridgedMultiColvarFunction_h
23 : #define __PLUMED_multicolvar_BridgedMultiColvarFunction_h
24 :
25 : #include "vesselbase/BridgeVessel.h"
26 : #include "MultiColvarBase.h"
27 :
28 : namespace PLMD {
29 : namespace multicolvar {
30 :
31 43 : class BridgedMultiColvarFunction : public MultiColvarBase {
32 : friend class MultiColvarBase;
33 : friend class MultiColvarFunction;
34 : private:
35 : /// This is used for storing positions properly
36 : Vector tmp_p;
37 : /// The action that is calculating the colvars of interest
38 : MultiColvarBase* mycolv;
39 : /// The vessel that bridges
40 : vesselbase::BridgeVessel* myBridgeVessel;
41 : /// Everything for controlling the updating of neighbor lists
42 : bool firsttime;
43 : int updateFreq;
44 : protected:
45 : /// Deactivate all the atoms in the list
46 : void deactivateAllAtoms();
47 : /// Activate the nth atom in the list
48 : void setAtomActive( const unsigned& n );
49 : public:
50 : static void registerKeywords( Keywords& keys );
51 : explicit BridgedMultiColvarFunction(const ActionOptions&);
52 : /// Get a pointer to the base multicolvar
53 : MultiColvarBase* getPntrToMultiColvar() const ;
54 : /// Don't actually clear the derivatives when this is called from plumed main.
55 : /// They are calculated inside another action and clearing them would be bad
56 764 : void clearDerivatives() {}
57 : /// Check nothing impossible being done with derivatives
58 : virtual void turnOnDerivatives();
59 : /// Get the number of derivatives for this action
60 : unsigned getNumberOfDerivatives();
61 : /// Get the size of the atoms with derivatives array
62 : unsigned getSizeOfAtomsWithDerivatives();
63 : /// Is the output quantity periodic
64 : bool isPeriodic();
65 : /// Routines that have to be defined so as not to have problems with virtual methods
66 : void deactivate_task( const unsigned& taskno );
67 704 : void calculate() {}
68 : /// This does the task
69 : void transformBridgedDerivatives( const unsigned& current, MultiValue& invals, MultiValue& outvals ) const ;
70 : void performTask( const unsigned&, const unsigned&, MultiValue& ) const ;
71 : virtual void completeTask( const unsigned& curr, MultiValue& invals, MultiValue& outvals ) const=0;
72 : /// Get the central atom position
73 : Vector retrieveCentralAtomPos();
74 : /// Get the index of the central atom
75 : AtomNumber getAbsoluteIndexOfCentralAtom( const unsigned& i ) const ;
76 : /// Get indicecs involved in this colvar
77 : const std::vector<AtomNumber> & getAbsoluteIndexes()const ;
78 : /// We need our own calculate numerical derivatives here
79 : void calculateNumericalDerivatives( ActionWithValue* a=NULL );
80 764 : void apply() {};
81 : /// Is this atom currently being copied
82 : bool isCurrentlyActive( const unsigned& );
83 : /// This should not be called
84 : Vector calculateCentralAtomPosition() { plumed_error(); }
85 0 : double compute( const unsigned& tindex, AtomValuePack& myvals ) const { plumed_error(); }
86 : Vector getPositionOfAtomForLinkCells( const unsigned& iatom ) const ;
87 : void getIndexList( const unsigned& ntotal, const unsigned& jstore, const unsigned& maxder, std::vector<unsigned>& indices );
88 : void applyBridgeForces( const std::vector<double>& bb );
89 : Vector getCentralAtomPos( const unsigned& curr );
90 : CatomPack getCentralAtomPack( const unsigned& basn, const unsigned& curr );
91 : };
92 :
93 : inline
94 5 : const std::vector<AtomNumber> & BridgedMultiColvarFunction::getAbsoluteIndexes() const {
95 5 : return mycolv->getAbsoluteIndexes();
96 : }
97 :
98 : inline
99 713266 : MultiColvarBase* BridgedMultiColvarFunction::getPntrToMultiColvar() const {
100 713266 : return mycolv;
101 : }
102 :
103 : inline
104 127831 : unsigned BridgedMultiColvarFunction::getNumberOfDerivatives() {
105 127831 : return mycolv->getNumberOfDerivatives() + 3*getNumberOfAtoms();
106 : }
107 :
108 : inline
109 0 : bool BridgedMultiColvarFunction::isCurrentlyActive( const unsigned& code ) {
110 0 : return mycolv->isCurrentlyActive( code );
111 : }
112 :
113 : inline
114 : unsigned BridgedMultiColvarFunction::getSizeOfAtomsWithDerivatives() {
115 : return mycolv->getNumberOfAtoms();
116 : }
117 :
118 : inline
119 0 : Vector BridgedMultiColvarFunction::getPositionOfAtomForLinkCells( const unsigned& iatom ) const {
120 0 : return mycolv->getPositionOfAtomForLinkCells(iatom);
121 : }
122 :
123 : inline
124 78336 : Vector BridgedMultiColvarFunction::getCentralAtomPos( const unsigned& curr ) {
125 78336 : return mycolv->getCentralAtomPos( curr );
126 : }
127 :
128 : inline
129 156 : AtomNumber BridgedMultiColvarFunction::getAbsoluteIndexOfCentralAtom(const unsigned& i) const {
130 156 : return mycolv->getAbsoluteIndexOfCentralAtom(i);
131 : }
132 :
133 : }
134 : }
135 : #endif
|