Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2012-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 : #include "core/ActionWithValue.h"
23 : #include "core/ActionRegister.h"
24 : #include <string>
25 : #include <cmath>
26 :
27 : using namespace std;
28 :
29 : namespace PLMD {
30 : namespace generic {
31 :
32 : //+PLUMEDOC GENERIC TIME
33 : /*
34 : retrieve the time of the simulation to be used elsewere
35 :
36 : \par Examples
37 :
38 : \plumedfile
39 : TIME LABEL=t1
40 : PRINT ARG=t1
41 : \endplumedfile
42 :
43 : */
44 : //+ENDPLUMEDOC
45 :
46 0 : class Time : public ActionWithValue {
47 : public:
48 : static void registerKeywords( Keywords& keys );
49 : explicit Time(const ActionOptions&);
50 : // active methods:
51 : virtual void calculate();
52 0 : virtual void apply() {}
53 0 : unsigned getNumberOfDerivatives() { return 0; }
54 : };
55 :
56 6452 : PLUMED_REGISTER_ACTION(Time,"TIME")
57 :
58 1 : void Time::registerKeywords( Keywords& keys ) {
59 1 : Action::registerKeywords( keys );
60 1 : ActionWithValue::registerKeywords( keys );
61 1 : }
62 :
63 0 : Time::Time(const ActionOptions&ao):
64 0 : Action(ao),ActionWithValue(ao)
65 : {
66 0 : addValueWithDerivatives(); setNotPeriodic();
67 : // resize derivative by hand to a nonzero value
68 0 : getPntrToValue()->resizeDerivatives(1);
69 0 : }
70 :
71 0 : void Time::calculate() {
72 0 : setValue (getTime());
73 0 : }
74 :
75 : }
76 :
77 :
78 :
79 :
80 :
81 4839 : }
|