LCOV - code coverage report
Current view: top level - gridtools - EvaluateGridFunction.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 2 2 100.0 %
Date: 2025-12-04 11:19:34 Functions: 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/FunctionSetup.h"
      26             : #include "ActionWithGrid.h"
      27             : #include "Interpolator.h"
      28             : 
      29             : namespace PLMD {
      30             : namespace gridtools {
      31             : 
      32          35 : class EvaluateGridFunction {
      33             : public:
      34             : /// Hold the function on the grid
      35             :   Value* function=NULL;
      36             : /// This is the grid that is used here
      37             :   ActionWithGrid* gridact=NULL;
      38             : /// How should we set the value of this function outside the range
      39             :   bool set_zero_outside_range;
      40             : /// How are we doing interpolation
      41             :   enum {spline,linear,floor,ceiling} interpolation_type;
      42             : /// This does the interpolating
      43             :   std::unique_ptr<Interpolator> spline_interpolator;
      44             : /// This is used to setup the input gridobject's bounds with the grid data from values
      45             :   static void registerKeywords( Keywords& keys );
      46             :   static void read( EvaluateGridFunction& func, ActionWithArguments* action, function::FunctionOptions& options );
      47             :   static void calc( const EvaluateGridFunction& func, bool noderiv, View<const double> args, function::FunctionOutput& funcout );
      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<std::size_t> getNbin() const ;
      56             : /// Get the grid spacing
      57             :   const std::vector<double>& getGridSpacing() const ;
      58             : /// This gets the grid object
      59             :   const GridCoordinatesObject & getGridObject() const ;
      60             :   EvaluateGridFunction& operator=( const EvaluateGridFunction& m ) {
      61             :     function = m.function;
      62             :     gridact = m.gridact;
      63             :     set_zero_outside_range = m.set_zero_outside_range;
      64             :     interpolation_type = m.interpolation_type;
      65             :     if( interpolation_type==spline ) {
      66             :       spline_interpolator = Tools::make_unique<Interpolator>( function, gridact->getGridCoordinatesObject() );
      67             :     }
      68             :     return *this;
      69             :   }
      70             : };
      71             : 
      72             : inline
      73             : std::vector<std::string> EvaluateGridFunction::getMin() const {
      74             :   return (gridact->getGridCoordinatesObject()).getMin();
      75             : }
      76             : 
      77             : inline
      78             : std::vector<std::string> EvaluateGridFunction::getMax() const {
      79             :   return (gridact->getGridCoordinatesObject()).getMax();
      80             : }
      81             : 
      82             : inline
      83             : std::vector<std::size_t> EvaluateGridFunction::getNbin() const {
      84             :   return (gridact->getGridCoordinatesObject()).getNbin(false);
      85             : }
      86             : 
      87             : inline
      88             : const std::vector<double>& EvaluateGridFunction::getGridSpacing() const {
      89             :   return (gridact->getGridCoordinatesObject()).getGridSpacing();
      90             : }
      91             : 
      92             : inline
      93             : const GridCoordinatesObject & EvaluateGridFunction::getGridObject() const {
      94      293997 :   return (gridact->getGridCoordinatesObject());
      95             : }
      96             : 
      97             : }
      98             : }
      99             : #endif

Generated by: LCOV version 1.16