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