LCOV - code coverage report
Current view: top level - core - ActionWithVector.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 6 8 75.0 %
Date: 2025-12-04 11:19:34 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-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             : #ifndef __PLUMED_core_ActionWithVector_h
      23             : #define __PLUMED_core_ActionWithVector_h
      24             : 
      25             : #include "ActionWithValue.h"
      26             : #include "ActionAtomistic.h"
      27             : #include "ActionWithArguments.h"
      28             : #include <limits>
      29             : #include <vector>
      30             : 
      31             : namespace PLMD {
      32             : 
      33             : class ActionWithVector:
      34             :   public ActionAtomistic,
      35             :   public ActionWithValue,
      36             :   public ActionWithArguments {
      37             :   friend class Value;
      38             : private:
      39             :   static constexpr int NoMasksUsed =-1;
      40             : /// Check if there is a mask value
      41             :   int nmask=NoMasksUsed;
      42             : /// The list of active tasks
      43             :   std::vector<unsigned> active_tasks;
      44             : protected:
      45             : /// Turn off the flag that says this action has a masked input
      46             :   void ignoreMaskArguments();
      47             : /// Accumulate the forces from the Values
      48             :   bool checkForForces();
      49             : public:
      50             :   static void registerKeywords( Keywords& keys );
      51             :   explicit ActionWithVector(const ActionOptions&);
      52        3268 :   virtual ~ActionWithVector() {}
      53             :   void lockRequests() override;
      54             :   void unlockRequests() override;
      55             :   virtual void prepare() override;
      56             : /// Check if a mask has been set
      57             :   int getNumberOfMasks() const ;
      58             :   void calculateNumericalDerivatives(ActionWithValue* av) override;
      59             : /// Get the list of tasks that are active
      60             :   virtual std::vector<unsigned>& getListOfActiveTasks( ActionWithVector* action );
      61             : /// Find out how many tasks we need to perform in this loop
      62             :   virtual void getNumberOfTasks( unsigned& ntasks );
      63             : /// Determine if a particular task is active based on the values of the input argument
      64             :   virtual int checkTaskIsActive( const unsigned& itask ) const ;
      65             : /// This is so we can parallelize with GPU
      66             :   virtual void getInputData( std::vector<double>& inputdata ) const ;
      67             : /// This is so we an transfer data gathered in the parallel task manager to the underlying values
      68             :   virtual void transferStashToValues( const std::vector<unsigned>& partialTaskList, const std::vector<double>& stash );
      69             : /// This is so we can transfer forces from the values to the parallel task manager
      70             :   virtual void transferForcesToStash( const std::vector<unsigned>& partialTaskList, std::vector<double>& stash ) const ;
      71             : /// Get the number of forces to use
      72             :   unsigned getNumberOfForceDerivatives() const ;
      73             : /// Apply the forces on this data
      74             :   void apply() override;
      75             : /// Apply the forces on non-zero rank objects
      76           0 :   virtual void applyNonZeroRankForces( std::vector<double>& outforces ) {
      77           0 :     plumed_error();
      78             :   }
      79             : };
      80             : 
      81             : inline
      82             : int ActionWithVector::getNumberOfMasks() const {
      83     1166172 :   return nmask;
      84             : }
      85             : 
      86             : inline
      87         365 : void ActionWithVector::ignoreMaskArguments() {
      88         365 :   plumed_assert( nmask<=0 );
      89         365 :   nmask=NoMasksUsed;
      90         365 : }
      91             : 
      92             : }
      93             : 
      94             : #endif

Generated by: LCOV version 1.16