Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2013-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_vesselbase_BridgeVessel_h
23 : #define __PLUMED_vesselbase_BridgeVessel_h
24 :
25 : #include <string>
26 : #include <cstring>
27 : #include <vector>
28 : #include "Vessel.h"
29 : #include "core/Value.h"
30 :
31 : namespace PLMD {
32 : namespace vesselbase {
33 :
34 : /**
35 : \ingroup TOOLBOX
36 : This class allows you to calculate the vessel in one ActionWithVessel. The user thinks
37 : it is created in a different Action however. At the moment this is used for region
38 : */
39 :
40 90 : class BridgeVessel : public Vessel {
41 : private:
42 : unsigned inum;
43 : // bool in_normal_calculate;
44 : std::vector<double> mynumerical_values;
45 : ActionWithVessel* myOutputAction;
46 : ActionWithValue* myOutputValues;
47 : public:
48 : explicit BridgeVessel( const VesselOptions& );
49 : /// Does this have derivatives
50 : bool hasDerivatives();
51 : /// Resize the quantities in the vessel
52 : void resize();
53 : /// Get the action that reads the command in
54 : ActionWithVessel* getOutputAction();
55 : /// Setup the action we are outputting to
56 : void setOutputAction( ActionWithVessel* myOutputAction );
57 : /// Apply some force
58 : bool applyForce( std::vector<double>& forces );
59 : /// Should not be called
60 : std::string description();
61 : /// Jobs to do before the task list starts
62 : void prepare();
63 : /// Set the start of the buffer
64 : void setBufferStart( unsigned& start );
65 : /// This transforms the derivatives using the output value
66 : MultiValue& transformDerivatives( const unsigned& current, MultiValue& invals, MultiValue& outvals );
67 : /// Actually do the calculation
68 : void calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_index ) const ;
69 : /// Finish the calculation
70 : void finish( const std::vector<double>& buffer );
71 : /// Calculate numerical derivatives
72 : void completeNumericalDerivatives();
73 : /// Set the task flags in the bridged class the same as in the original class
74 : void copyTaskFlags();
75 : };
76 :
77 : inline
78 28 : ActionWithVessel* BridgeVessel::getOutputAction() {
79 28 : return myOutputAction;
80 : }
81 :
82 : }
83 : }
84 : #endif
85 :
86 :
|