LCOV - code coverage report
Current view: top level - vesselbase - ActionWithInputVessel.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 32 37 86.5 %
Date: 2020-11-18 11:20:57 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-2019 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 "ActionWithInputVessel.h"
      23             : #include "StoreDataVessel.h"
      24             : #include "BridgeVessel.h"
      25             : #include "core/PlumedMain.h"
      26             : #include "core/ActionSet.h"
      27             : 
      28             : namespace PLMD {
      29             : namespace vesselbase {
      30             : 
      31          22 : void ActionWithInputVessel::registerKeywords(Keywords& keys) {
      32          88 :   keys.add("compulsory","DATA","certain actions in plumed work by calculating a list of variables and summing over them. "
      33             :            "This particular action can be used to calculate functions of these base variables or prints "
      34             :            "them to a file. This keyword thus takes the label of one of those such variables as input.");
      35          88 :   keys.reserve("compulsory","GRID","the action that creates the input grid you would like to use");
      36          22 : }
      37             : 
      38          19 : ActionWithInputVessel::ActionWithInputVessel(const ActionOptions&ao):
      39             :   Action(ao),
      40             :   arguments(NULL),
      41          19 :   myBridgeVessel(NULL)
      42             : {
      43          19 : }
      44             : 
      45          19 : void ActionWithInputVessel::readArgument( const std::string& type ) {
      46             :   std::string mlab;
      47          76 :   if( keywords.exists("DATA") && type!="grid" ) parse("DATA",mlab);
      48          38 :   ActionWithVessel* mves= plumed.getActionSet().selectWithLabel<ActionWithVessel*>(mlab);
      49          19 :   if(!mves) error("action labelled " +  mlab + " does not exist or does not have vessels");
      50          19 :   addDependency(mves);
      51             : 
      52          19 :   ActionWithValue* aval=dynamic_cast<ActionWithValue*>( this );
      53          19 :   if(aval) {
      54           2 :     if( aval->checkNumericalDerivatives() ) {
      55           1 :       ActionWithValue* aval2=dynamic_cast<ActionWithValue*>( mves );
      56           1 :       plumed_assert( aval2 ); aval2->useNumericalDerivatives();
      57             :     }
      58             :   }
      59             : 
      60          19 :   if( type=="bridge" ) {
      61           2 :     ActionWithVessel* aves=dynamic_cast<ActionWithVessel*>( this );
      62           2 :     plumed_assert(aves); myBridgeVessel = mves->addBridgingVessel( aves );
      63           2 :     arguments = dynamic_cast<Vessel*>( myBridgeVessel );
      64          17 :   } else  if( type=="store" ) {
      65          17 :     arguments = dynamic_cast<Vessel*>( mves->buildDataStashes( NULL ) );
      66             :   } else {
      67           0 :     plumed_error();
      68             :   }
      69          19 : }
      70             : 
      71           5 : void ActionWithInputVessel::calculateNumericalDerivatives( ActionWithValue* a ) {
      72           5 :   if(!a) {
      73           5 :     a=dynamic_cast<ActionWithValue*>(this);
      74           5 :     plumed_massert(a,"cannot compute numerical derivatives for an action without values");
      75             :   }
      76           5 :   if( myBridgeVessel ) {
      77           5 :     myBridgeVessel->completeNumericalDerivatives();
      78             :   } else {
      79           0 :     error("numerical derivatives are not implemented");
      80             :   }
      81           5 : }
      82             : 
      83           0 : void ActionWithInputVessel::applyBridgeForces( const std::vector<double>& bb ) {
      84           0 :   plumed_dbg_assert( myBridgeVessel ); addBridgeForces( bb );
      85           0 : }
      86             : 
      87             : }
      88        4839 : }

Generated by: LCOV version 1.13