LCOV - code coverage report
Current view: top level - vesselbase - ActionWithInputVessel.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 34 39 87.2 %
Date: 2018-12-19 07:49:13 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-2018 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          19 : void ActionWithInputVessel::registerKeywords(Keywords& keys) {
      32             :   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          19 :            "them to a file. This keyword thus takes the label of one of those such variables as input.");
      35          19 :   keys.reserve("compulsory","GRID","the action that creates the input grid you would like to use");
      36          19 : }
      37             : 
      38          17 : ActionWithInputVessel::ActionWithInputVessel(const ActionOptions&ao):
      39             :   Action(ao),
      40             :   arguments(NULL),
      41          17 :   myBridgeVessel(NULL)
      42             : {
      43          17 : }
      44             : 
      45          17 : void ActionWithInputVessel::readArgument( const std::string& type ) {
      46          17 :   std::string mlab;
      47          17 :   if( keywords.exists("DATA") && type!="grid" ) parse("DATA",mlab);
      48          17 :   ActionWithVessel* mves= plumed.getActionSet().selectWithLabel<ActionWithVessel*>(mlab);
      49          17 :   if(!mves) error("action labelled " +  mlab + " does not exist or does not have vessels");
      50          17 :   addDependency(mves);
      51             : 
      52          17 :   ActionWithValue* aval=dynamic_cast<ActionWithValue*>( this );
      53          17 :   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          17 :   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          15 :   } else  if( type=="store" ) {
      65          15 :     arguments = dynamic_cast<Vessel*>( mves->buildDataStashes( NULL ) );
      66             :   } else {
      67           0 :     plumed_error();
      68          17 :   }
      69          17 : }
      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        2523 : }

Generated by: LCOV version 1.13