LCOV - code coverage report
Current view: top level - gridtools - ActionWithGrid.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 24 34 70.6 %
Date: 2026-11-05 10:19:04 Functions: 4 6 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2017 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             : 
      24             : namespace PLMD {
      25             : namespace gridtools {
      26             : 
      27      315308 : ActionWithGrid* ActionWithGrid::getInputActionWithGrid( Action* action ) {
      28      315308 :   ActionWithGrid* ag = dynamic_cast<ActionWithGrid*>( action );
      29      315308 :   if( !ag && action->getName()=="ACCUMULATE" ) {
      30         989 :     ActionWithArguments* aa=dynamic_cast<ActionWithArguments*>( action );
      31         989 :     plumed_assert( aa );
      32         989 :     ag = dynamic_cast<ActionWithGrid*>( (aa->getPntrToArgument(0))->getPntrToAction() );
      33             :   }
      34      315308 :   plumed_assert( ag );
      35      315308 :   return ag;
      36             : }
      37             : 
      38         889 : void ActionWithGrid::registerKeywords( Keywords& keys ) {
      39         889 :   ActionWithVector::registerKeywords( keys );
      40         889 : }
      41             : 
      42         329 : ActionWithGrid::ActionWithGrid(const ActionOptions&ao):
      43             :   Action(ao),
      44         329 :   ActionWithVector(ao) {
      45         329 : }
      46             : 
      47        7135 : void ActionWithGrid::transferStashToValues( const std::vector<unsigned>& partialTaskList, const std::vector<double>& stash ) {
      48        7135 :   unsigned ncomponents = getNumberOfComponents();
      49       14270 :   for(unsigned i=0; i<ncomponents; ++i) {
      50        7135 :     Value* myval = copyOutput(i);
      51        7135 :     std::size_t ngder = myval->getNumberOfGridDerivatives();
      52     1569066 :     for(unsigned j=0; j<myval->getNumberOfStoredValues(); ++j) {
      53     1561931 :       myval->set( j, stash[(j*ncomponents + i)*(1+ngder)] );
      54     4984372 :       for(unsigned k=0; k<ngder; ++k) {
      55     3422441 :         myval->setGridDerivatives( j, k, stash[(j*ncomponents + i)*(1+ngder)+1+k] );
      56             :       }
      57             :     }
      58             :   }
      59        7135 : }
      60             : 
      61           0 : void ActionWithGrid::transferStashToValues( const std::vector<unsigned>& partialTaskList, const std::vector<float>& stash ) {
      62           0 :   unsigned ncomponents = getNumberOfComponents();
      63           0 :   for(unsigned i=0; i<ncomponents; ++i) {
      64           0 :     Value* myval = copyOutput(i);
      65           0 :     std::size_t ngder = myval->getNumberOfGridDerivatives();
      66           0 :     for(unsigned j=0; j<myval->getNumberOfStoredValues(); ++j) {
      67           0 :       myval->set( j, stash[(j*ncomponents + i)*(1+ngder)] );
      68           0 :       for(unsigned k=0; k<ngder; ++k) {
      69           0 :         myval->setGridDerivatives( j, k, stash[(j*ncomponents + i)*(1+ngder)+1+k] );
      70             :       }
      71             :     }
      72             :   }
      73           0 : }
      74             : 
      75             : }
      76             : }

Generated by: LCOV version 1.16