All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Flush.cpp
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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/ActionRegister.h"
23 #include "core/ActionPilot.h"
24 #include "core/PlumedMain.h"
25 #include "core/ActionSet.h"
26 
27 namespace PLMD{
28 namespace generic{
29 
30 using namespace std;
31 
32 //+PLUMEDOC GENERIC FLUSH
33 /*
34 This command instructs plumed to flush all the open files with a user specified frequency.
35 Notice that all files are flushed anyway every 10000 steps.
36 
37 This
38 is useful for preventing data loss that would otherwise arrise as a consequence of the code
39 storing data for printing in the buffers. Notice that wherever it is written in the
40 plumed input file, it will flush all the open files.
41 
42 \par Examples
43 A command like this in the input will instruct plumed to flush all the output files every 100 steps
44 \verbatim
45 d1: DISTANCE ATOMS=1,10
46 PRINT ARG=d1 STRIDE=5 FILE=colvar1
47 
48 FLUSH STRIDE=100
49 
50 d2: DISTANCE ATOMS=2,11
51 # also this print is flushed every 100 steps:
52 PRINT ARG=d2 STRIDE=10 FILE=colvar2
53 \endverbatim
54 (see also \ref DISTANCE and \ref PRINT).
55 */
56 //+ENDPLUMEDOC
57 
58 class Flush:
59  public ActionPilot
60 {
61 public:
62  Flush(const ActionOptions&ao):
63  Action(ao),
64  ActionPilot(ao)
65  {
66  checkRead();
67  }
68  static void registerKeywords( Keywords& keys );
69  void calculate(){}
70  void apply(){
71  plumed.fflush();
72  log.flush();
73  const ActionSet & actionSet(plumed.getActionSet());
74  for(ActionSet::const_iterator p=actionSet.begin();p!=actionSet.end();++p)
75  (*p)->fflush();
76  }
77 };
78 
79 PLUMED_REGISTER_ACTION(Flush,"FLUSH")
80 
81 void Flush::registerKeywords( Keywords& keys ){
84  keys.add("compulsory","STRIDE","the frequency with which all the open files should be flushed");
85  keys.remove("LABEL");
86 }
87 
88 }
89 }
90 
91 
void calculate()
Calculate an Action.
Definition: Flush.cpp:69
void apply()
Apply an Action.
Definition: Flush.cpp:70
std::vector containing the sequence of Action to be done.
Definition: ActionSet.h:38
This is used to create PLMD::Action objects that are run with some set frequency. ...
Definition: ActionPilot.h:39
Provides the keyword FLUSH
Definition: Flush.cpp:58
STL namespace.
This class holds the keywords and their documentation.
Definition: Keywords.h:36
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
Base class for all the input Actions.
Definition: Action.h:60
static void registerKeywords(Keywords &keys)
Register all the relevant keywords for the action.
Definition: Action.cpp:49
static void registerKeywords(Keywords &keys)
Create the keywords for actionPilot.
Definition: ActionPilot.cpp:27
Main plumed object.
Definition: Plumed.h:201
Flush(const ActionOptions &ao)
Definition: Flush.cpp:62