LCOV - code coverage report
Current view: top level - gridtools - ActionWithGrid.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 29 30 96.7 %
Date: 2018-12-19 07:49:13 Functions: 6 7 85.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2016-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 "ActionWithGrid.h"
      23             : #include "core/PlumedMain.h"
      24             : #include "core/ActionSet.h"
      25             : 
      26             : namespace PLMD {
      27             : namespace gridtools {
      28             : 
      29          46 : void ActionWithGrid::registerKeywords( Keywords& keys ) {
      30          46 :   vesselbase::ActionWithAveraging::registerKeywords( keys );
      31          46 :   keys.add("compulsory","BANDWIDTH","the bandwidths for kernel density esimtation");
      32             :   keys.add("compulsory","KERNEL","gaussian","the kernel function you are using.  More details on  the kernels available "
      33          46 :            "in plumed plumed can be found in \\ref kernelfunctions.");
      34          46 : }
      35             : 
      36          38 : ActionWithGrid::ActionWithGrid( const ActionOptions& ao):
      37             :   Action(ao),
      38             :   ActionWithAveraging(ao),
      39          38 :   mygrid(NULL)
      40             : {
      41          38 : }
      42             : 
      43          36 : void ActionWithGrid::createGrid( const std::string& type, const std::string& inputstr ) {
      44             :   // Start creating the input for the grid
      45          36 :   std::string vstring = inputstr;
      46          36 :   if( keywords.exists("KERNEL") ) {
      47          28 :     std::string kstring; parse("KERNEL",kstring);
      48          28 :     if( kstring=="DISCRETE" ) vstring += " KERNEL=" + kstring;
      49          24 :     else vstring += " KERNEL=" + kstring + " " + getKeyword("BANDWIDTH");
      50             :   }
      51             : 
      52          72 :   vesselbase::VesselOptions da("mygrid","",-1,vstring,this);
      53          72 :   Keywords keys; gridtools::AverageOnGrid::registerKeywords( keys );
      54          72 :   vesselbase::VesselOptions dar( da, keys );
      55          36 :   if( type=="histogram" ) {
      56          20 :     mygrid = new HistogramOnGrid(dar);
      57          16 :   } else if( type=="average" ) {
      58           8 :     mygrid = new AverageOnGrid(dar);
      59           8 :   } else if( type=="grid" ) {
      60           8 :     mygrid = new GridVessel(dar);
      61             :   } else {
      62           0 :     plumed_merror("no way to create grid of type " + type );
      63          36 :   }
      64          36 : }
      65             : 
      66       36950 : void ActionWithGrid::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const {
      67             :   // Set the weight of this point
      68       36950 :   myvals.setValue( 0, cweight ); compute( current, myvals );
      69       36950 : }
      70             : 
      71             : }
      72        2523 : }

Generated by: LCOV version 1.13