LCOV - code coverage report
Current view: top level - ves - VesTools.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 37 40 92.5 %
Date: 2026-11-05 10:19:04 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2016-2021 The VES code team
       3             :    (see the PEOPLE-VES file at the root of this folder for a list of names)
       4             : 
       5             :    See http://www.ves-code.org for more information.
       6             : 
       7             :    This file is part of VES code module.
       8             : 
       9             :    The VES code module 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             :    The VES code module 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 the VES code module.  If not, see <http://www.gnu.org/licenses/>.
      21             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      22             : 
      23             : #include "VesTools.h"
      24             : 
      25             : #include "tools/Grid.h"
      26             : #include "tools/IFile.h"
      27             : #include "tools/Exception.h"
      28             : 
      29             : 
      30             : namespace PLMD {
      31             : namespace ves {
      32             : 
      33             : 
      34           8 : void VesTools::copyGridValues(GridBase* grid_pntr_orig, GridBase* grid_pntr_copy) {
      35           8 :   plumed_massert(grid_pntr_orig->getSize()==grid_pntr_copy->getSize(),"the two grids are not of the same size");
      36           8 :   plumed_massert(grid_pntr_orig->getDimension()==grid_pntr_copy->getDimension(),"the two grids are not of the same dimension");
      37             :   //
      38         808 :   for(Grid::index_t i=0; i<grid_pntr_orig->getSize(); i++) {
      39         800 :     double value = grid_pntr_orig->getValue(i);
      40         800 :     grid_pntr_copy->setValue(i,value);
      41             :   }
      42           8 : }
      43             : 
      44             : 
      45           9 : unsigned int VesTools::getGridFileInfo(const std::string& filepath, std::string& grid_label, std::vector<std::string>& arg_labels, std::vector<std::string>& arg_min, std::vector<std::string>& arg_max, std::vector<bool>& arg_periodic, std::vector<unsigned int>& arg_nbins, bool& derivatives) {
      46             : 
      47           9 :   IFile ifile;
      48           9 :   ifile.open(filepath);
      49           9 :   std::vector<std::string> fields;
      50           9 :   ifile.scanFieldList(fields);
      51           9 :   ifile.allowIgnoredFields();
      52           9 :   ifile.scanField();
      53             : 
      54             :   unsigned int nargs=0;
      55          31 :   for(unsigned int i=0; i<fields.size(); i++) {
      56          31 :     if(fields[i]=="min_"+fields[0]) {
      57           9 :       derivatives = false;
      58           9 :       nargs = i-1;
      59           9 :       break;
      60          22 :     } else if(fields[i]=="der_"+fields[0]) {
      61           0 :       derivatives = true;
      62           0 :       nargs = i-1;
      63           0 :       break;
      64             :     }
      65             :   }
      66             : 
      67           9 :   grid_label = fields[nargs];
      68             : 
      69           9 :   arg_labels.assign(nargs,"");
      70           9 :   arg_min.assign(nargs,"");
      71          18 :   arg_max.assign(nargs,"");
      72             :   arg_periodic.assign(nargs,false);
      73           9 :   arg_nbins.assign(nargs,0);
      74          22 :   for(unsigned int i=0; i<nargs; i++) {
      75          13 :     arg_labels[i] = fields[i];
      76          26 :     ifile.scanField("min_"+arg_labels[i],arg_min[i]);
      77          26 :     ifile.scanField("max_"+arg_labels[i],arg_max[i]);
      78             :     std::string str_periodic;
      79          13 :     ifile.scanField("periodic_"+arg_labels[i],str_periodic);
      80          13 :     if(str_periodic=="true") {
      81             :       arg_periodic[i]=true;
      82             :     }
      83             :     int nbins;
      84          13 :     ifile.scanField("nbins_"+arg_labels[i],nbins);
      85          13 :     arg_nbins[i] = static_cast<unsigned int>(nbins);
      86             :   }
      87           9 :   ifile.scanField();
      88           9 :   ifile.close();
      89           9 :   return nargs;
      90           9 : }
      91             : 
      92             : 
      93             : }
      94             : }

Generated by: LCOV version 1.16