LCOV - code coverage report
Current view: top level - generic - Time.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 5 17 29.4 %
Date: 2025-03-25 09:33:27 Functions: 1 6 16.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2023 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             : namespace PLMD {
      28             : namespace generic {
      29             : 
      30             : //+PLUMEDOC GENERIC TIME
      31             : /*
      32             : retrieve the time of the simulation to be used elsewhere
      33             : 
      34             : To retrieve and print the time you can use an input similar to the one shown below:
      35             : 
      36             : ```plumed
      37             : t1: TIME
      38             : PRINT ARG=t1
      39             : ```
      40             : 
      41             : */
      42             : //+ENDPLUMEDOC
      43             : 
      44             : class Time : public ActionWithValue {
      45             : public:
      46             :   static void registerKeywords( Keywords& keys );
      47             :   explicit Time(const ActionOptions&);
      48             : // active methods:
      49             :   void calculate() override;
      50           0 :   void apply() override {}
      51           0 :   unsigned getNumberOfDerivatives() override {
      52           0 :     return 0;
      53             :   }
      54             : };
      55             : 
      56             : PLUMED_REGISTER_ACTION(Time,"TIME")
      57             : 
      58           2 : void Time::registerKeywords( Keywords& keys ) {
      59           2 :   Action::registerKeywords( keys );
      60           2 :   ActionWithValue::registerKeywords( keys );
      61           4 :   keys.setValueDescription("scalar","the time since the start of the trajectory");
      62           2 : }
      63             : 
      64           0 : Time::Time(const ActionOptions&ao):
      65           0 :   Action(ao),ActionWithValue(ao) {
      66           0 :   addValueWithDerivatives();
      67           0 :   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             : }

Generated by: LCOV version 1.16