LCOV - code coverage report
Current view: top level - gridtools - ActionWithIntegral.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 22 22 100.0 %
Date: 2024-10-11 08:09:47 Functions: 4 5 80.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2016-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 "ActionWithIntegral.h"
      23             : 
      24             : namespace PLMD {
      25             : namespace gridtools {
      26             : 
      27           5 : void ActionWithIntegral::registerKeywords( Keywords& keys ) {
      28           5 :   ActionWithInputGrid::registerKeywords( keys );
      29          10 :   keys.remove("KERNEL"); keys.remove("BANDWIDTH");
      30          15 :   keys.remove("CLEAR"); keys.add("compulsory","CLEAR","1","the frequency with which to clear all the accumulated data.");
      31           5 : }
      32             : 
      33           4 : ActionWithIntegral::ActionWithIntegral(const ActionOptions&ao):
      34             :   Action(ao),
      35           4 :   ActionWithInputGrid(ao)
      36             : {
      37           4 :   plumed_assert( ingrid->getNumberOfComponents()==1 );
      38             :   // Retrieve the volume of the grid (for integration)
      39           4 :   volume = ingrid->getCellVolume();
      40             :   // Create something that is going to calculate the sum of all the values
      41             :   // at the various grid points - this is going to be the integral
      42           8 :   std::string fake_input; addVessel( "SUM", fake_input, -1 ); readVesselKeywords();
      43             :   // Now create task list - number of tasks is equal to the number of grid points
      44             :   // as we have to evaluate the function at each grid points
      45        1145 :   for(unsigned i=0; i<ingrid->getNumberOfPoints(); ++i) addTaskToList(i);
      46             :   // And activate all tasks
      47           4 :   deactivateAllTasks();
      48        1145 :   for(unsigned i=0; i<ingrid->getNumberOfPoints(); ++i) taskFlags[i]=1;
      49           4 :   lockContributors();
      50           4 : }
      51             : 
      52           8 : void ActionWithIntegral::turnOnDerivatives() {
      53           8 :   ActionWithGrid::turnOnDerivatives();
      54           8 :   forcesToApply.resize( ingrid->getNumberOfPoints() );
      55           8 : }
      56             : 
      57          20 : void ActionWithIntegral::apply() {
      58          20 :   if( getForcesFromVessels( forcesToApply ) ) ingrid->setForce( forcesToApply );
      59          20 : }
      60             : 
      61             : }
      62             : }

Generated by: LCOV version 1.15