LCOV - code coverage report
Current view: top level - gridtools - EvaluateGridFunction.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 6 8 75.0 %
Date: 2025-04-08 21:11:17 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-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_gridtools_EvaluateGridFunction_h
      23             : #define __PLUMED_gridtools_EvaluateGridFunction_h
      24             : 
      25             : #include "function/FunctionTemplateBase.h"
      26             : #include "Interpolator.h"
      27             : 
      28             : namespace PLMD {
      29             : namespace gridtools {
      30             : 
      31         272 : class EvaluateGridFunction : public function::FunctionTemplateBase {
      32             : private:
      33             : /// Holds the information on the grid
      34             :   GridCoordinatesObject gridobject;
      35             : /// How should we set the value of this function outside the range
      36             :   bool set_zero_outside_range;
      37             : /// How are we doing interpolation
      38             :   enum {spline,linear,floor,ceiling} interpolation_type;
      39             : /// This does the interpolating
      40             :   std::unique_ptr<Interpolator> spline_interpolator;
      41             : public:
      42             : /// This is used to setup the input gridobject's bounds with the grid data from values
      43             :   void registerKeywords( Keywords& keys ) override ;
      44             :   void read( ActionWithArguments* action ) override ;
      45           0 :   unsigned getArgStart() const override {
      46           0 :     return 1;
      47             :   }
      48             :   void setup( ActionWithValue* action ) override;
      49             :   void calc( const ActionWithArguments* action, const std::vector<double>& args, std::vector<double>& vals, Matrix<double>& derivatives ) const override ;
      50             : /// Get the vector containing the minimum value of the grid in each dimension
      51             :   std::vector<std::string> getMin() const ;
      52             : /// Get the vector containing the maximum value of the grid in each dimension
      53             :   std::vector<std::string> getMax() const ;
      54             : /// Get the periodicity of the grid
      55             :   std::vector<bool> getPbc() const ;
      56             : /// Get the number of grid points in each direction
      57             :   std::vector<unsigned> getNbin() const ;
      58             : /// Get the grid spacing
      59             :   const std::vector<double>& getGridSpacing() const ;
      60             : /// This is used to apply forces in interpolate
      61             :   void applyForce( const ActionWithArguments* action, const std::vector<double>& args, const double& force, std::vector<double>& forcesToApply ) const ;
      62             : /// This gets the grid object
      63             :   const GridCoordinatesObject & getGridObject() const ;
      64             : };
      65             : 
      66             : inline
      67             : std::vector<std::string> EvaluateGridFunction::getMin() const {
      68         160 :   return gridobject.getMin();
      69             : }
      70             : 
      71             : inline
      72             : std::vector<std::string> EvaluateGridFunction::getMax() const {
      73         160 :   return gridobject.getMax();
      74             : }
      75             : 
      76             : inline
      77             : std::vector<unsigned> EvaluateGridFunction::getNbin() const {
      78         160 :   return gridobject.getNbin(false);
      79             : }
      80             : 
      81             : inline
      82             : const std::vector<double>& EvaluateGridFunction::getGridSpacing() const {
      83         160 :   return gridobject.getGridSpacing();
      84             : }
      85             : 
      86             : inline
      87             : const GridCoordinatesObject & EvaluateGridFunction::getGridObject() const {
      88        1702 :   return gridobject;
      89             : }
      90             : 
      91             : }
      92             : }
      93             : #endif

Generated by: LCOV version 1.16