LCOV - code coverage report
Current view: top level - gridtools - EvaluateGridFunction.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 6 7 85.7 %
Date: 2024-10-18 14:00:25 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 { return 1; }
      46             :   void setup( ActionWithValue* action ) override;
      47             :   void calc( const ActionWithArguments* action, const std::vector<double>& args, std::vector<double>& vals, Matrix<double>& derivatives ) const override ;
      48             : /// Get the vector containing the minimum value of the grid in each dimension
      49             :   std::vector<std::string> getMin() const ;
      50             : /// Get the vector containing the maximum value of the grid in each dimension
      51             :   std::vector<std::string> getMax() const ;
      52             : /// Get the periodicity of the grid
      53             :   std::vector<bool> getPbc() const ;
      54             : /// Get the number of grid points in each direction
      55             :   std::vector<unsigned> getNbin() const ;
      56             : /// Get the grid spacing
      57             :   const std::vector<double>& getGridSpacing() const ;
      58             : /// This is used to apply forces in interpolate
      59             :   void applyForce( const ActionWithArguments* action, const std::vector<double>& args, const double& force, std::vector<double>& forcesToApply ) const ;
      60             : /// This gets the grid object
      61             :   const GridCoordinatesObject & getGridObject() const ;
      62             : };
      63             : 
      64             : inline
      65             : std::vector<std::string> EvaluateGridFunction::getMin() const {
      66         160 :   return gridobject.getMin();
      67             : }
      68             : 
      69             : inline
      70             : std::vector<std::string> EvaluateGridFunction::getMax() const {
      71         160 :   return gridobject.getMax();
      72             : }
      73             : 
      74             : inline
      75             : std::vector<unsigned> EvaluateGridFunction::getNbin() const {
      76         160 :   return gridobject.getNbin(false);
      77             : }
      78             : 
      79             : inline
      80             : const std::vector<double>& EvaluateGridFunction::getGridSpacing() const {
      81         160 :   return gridobject.getGridSpacing();
      82             : }
      83             : 
      84             : inline
      85             : const GridCoordinatesObject & EvaluateGridFunction::getGridObject() const {
      86        1702 :   return gridobject;
      87             : }
      88             : 
      89             : }
      90             : }
      91             : #endif

Generated by: LCOV version 1.16