Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2015-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 "AnalysisBase.h" 23 : #include "ReadAnalysisFrames.h" 24 : #include "core/PlumedMain.h" 25 : #include "core/ActionSet.h" 26 : 27 : namespace PLMD { 28 : namespace analysis { 29 : 30 189 : void AnalysisBase::registerKeywords( Keywords& keys ) { 31 189 : Action::registerKeywords( keys ); 32 189 : ActionPilot::registerKeywords( keys ); 33 189 : ActionWithValue::registerKeywords( keys ); 34 189 : ActionAtomistic::registerKeywords( keys ); 35 189 : ActionWithArguments::registerKeywords( keys ); 36 189 : keys.remove("NUMERICAL_DERIVATIVES"); 37 189 : ActionWithVessel::registerKeywords( keys ); 38 189 : keys.remove("TOL"); 39 378 : keys.reset_style("TIMINGS","hidden"); 40 : keys.isAnalysis(); 41 378 : keys.add("atoms-2","USE_OUTPUT_DATA_FROM","use the output of the analysis performed by this object as input to your new analysis object"); 42 189 : } 43 : 44 109 : AnalysisBase::AnalysisBase(const ActionOptions&ao): 45 : Action(ao), 46 : ActionPilot(ao), 47 : ActionWithValue(ao), 48 : ActionAtomistic(ao), 49 : ActionWithArguments(ao), 50 : ActionWithVessel(ao), 51 109 : my_input_data(NULL) { 52 : // We have an if statement here so that this doesn't break with READ_DISSIMILARITIES 53 218 : if( keywords.exists("USE_OUTPUT_DATA_FROM") ) { 54 : std::string datastr; 55 78 : parse("USE_OUTPUT_DATA_FROM",datastr); 56 156 : if( keywords.style("USE_OUTPUT_DATA_FROM","atoms") && datastr.length()==0 ) { 57 0 : error("input analysis action was not specified use USE_OUTPUT_DATA_FROM"); 58 : } 59 78 : if( datastr.length()>0 ) { 60 77 : my_input_data=plumed.getActionSet().selectWithLabel<AnalysisBase*>( datastr ); 61 77 : log.printf(" performing analysis on output from %s \n",datastr.c_str() ); 62 77 : if( !my_input_data ) { 63 0 : error("could not find analysis action named " + datastr ); 64 : } 65 77 : addDependency( my_input_data ); 66 : } 67 : } 68 109 : } 69 : 70 50 : std::vector<std::string> AnalysisBase::getArgumentNames() { 71 50 : std::vector<Value*> arg_p( getArgumentList() ); 72 50 : std::vector<std::string> argn( arg_p.size() ); 73 124 : for(unsigned i=0; i<arg_p.size(); ++i) { 74 74 : plumed_assert( i<argn.size() && i<arg_p.size() ); 75 74 : argn[i]=arg_p[i]->getName(); 76 : } 77 50 : return argn; 78 0 : } 79 : 80 39 : void AnalysisBase::update() { 81 39 : if( getStep()==0 || ( getStride()>0 && !onStep() ) ) { 82 9 : return; 83 : } 84 : // And do the analysis 85 30 : performAnalysis(); 86 : } 87 : 88 107 : void AnalysisBase::runFinalJobs() { 89 107 : if( getStride()>0 ) { 90 : return; 91 : } 92 69 : performAnalysis(); 93 : } 94 : 95 : } 96 : }