Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2012-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 : #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 : \verbatim
39 : TIME LABEL=t1
40 : PRINT ARG=t1
41 : \endverbatim
42 : (See also \ref PRINT).
43 :
44 : */
45 : //+ENDPLUMEDOC
46 :
47 0 : class Time : public ActionWithValue {
48 : public:
49 : static void registerKeywords( Keywords& keys );
50 : explicit Time(const ActionOptions&);
51 : // active methods:
52 : virtual void calculate();
53 0 : virtual void apply() {}
54 0 : unsigned getNumberOfDerivatives() { return 0; }
55 : };
56 :
57 2523 : PLUMED_REGISTER_ACTION(Time,"TIME")
58 :
59 1 : void Time::registerKeywords( Keywords& keys ) {
60 1 : Action::registerKeywords( keys );
61 1 : ActionWithValue::registerKeywords( keys );
62 1 : }
63 :
64 0 : Time::Time(const ActionOptions&ao):
65 0 : Action(ao),ActionWithValue(ao)
66 : {
67 0 : addValueWithDerivatives(); setNotPeriodic();
68 : // resize derivative by hand to a nonzero value
69 0 : getPntrToValue()->resizeDerivatives(1);
70 0 : }
71 :
72 0 : void Time::calculate() {
73 0 : setValue (getTime());
74 0 : }
75 :
76 : }
77 :
78 :
79 :
80 :
81 :
82 2523 : }
|