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 129 : void AnalysisBase::registerKeywords( Keywords& keys ) { 31 129 : Action::registerKeywords( keys ); ActionPilot::registerKeywords( keys ); 32 129 : ActionWithValue::registerKeywords( keys ); ActionAtomistic::registerKeywords( keys ); 33 129 : ActionWithArguments::registerKeywords( keys ); keys.remove("NUMERICAL_DERIVATIVES"); 34 387 : ActionWithVessel::registerKeywords( keys ); keys.remove("TOL"); keys.reset_style("TIMINGS","hidden"); keys.isAnalysis(); 35 387 : 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"); 36 129 : } 37 : 38 109 : AnalysisBase::AnalysisBase(const ActionOptions&ao): 39 : Action(ao), 40 : ActionPilot(ao), 41 : ActionWithValue(ao), 42 : ActionAtomistic(ao), 43 : ActionWithArguments(ao), 44 : ActionWithVessel(ao), 45 109 : my_input_data(NULL) 46 : { 47 : // We have an if statement here so that this doesn't break with READ_DISSIMILARITIES 48 218 : if( keywords.exists("USE_OUTPUT_DATA_FROM") ) { 49 78 : std::string datastr; parse("USE_OUTPUT_DATA_FROM",datastr); 50 156 : if( keywords.style("USE_OUTPUT_DATA_FROM","atoms") && datastr.length()==0 ) error("input analysis action was not specified use USE_OUTPUT_DATA_FROM"); 51 78 : if( datastr.length()>0 ) { 52 77 : my_input_data=plumed.getActionSet().selectWithLabel<AnalysisBase*>( datastr ); 53 77 : log.printf(" performing analysis on output from %s \n",datastr.c_str() ); 54 77 : if( !my_input_data ) error("could not find analysis action named " + datastr ); 55 77 : addDependency( my_input_data ); 56 : } 57 : } 58 109 : } 59 : 60 50 : std::vector<std::string> AnalysisBase::getArgumentNames() { 61 50 : std::vector<Value*> arg_p( getArgumentList() ); 62 50 : std::vector<std::string> argn( arg_p.size() ); 63 124 : for(unsigned i=0; i<arg_p.size(); ++i) { 64 74 : plumed_assert( i<argn.size() && i<arg_p.size() ); 65 74 : argn[i]=arg_p[i]->getName(); 66 : } 67 50 : return argn; 68 0 : } 69 : 70 39 : void AnalysisBase::update() { 71 39 : if( getStep()==0 || ( getStride()>0 && !onStep() ) ) return; 72 : // And do the analysis 73 30 : performAnalysis(); 74 : } 75 : 76 107 : void AnalysisBase::runFinalJobs() { 77 107 : if( getStride()>0 ) return; 78 69 : performAnalysis(); 79 : } 80 : 81 : } 82 : }