LCOV - code coverage report
Current view: top level - ves - VesTools.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 35 38 92.1 %
Date: 2024-10-18 13:59:31 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             :   // plumed_massert(grid_pntr_orig!=NULL,"grid not defined");
      36             :   // plumed_massert(grid_pntr_copy!=NULL,"grid not defined");
      37           8 :   plumed_massert(grid_pntr_orig->getSize()==grid_pntr_copy->getSize(),"the two grids are not of the same size");
      38           8 :   plumed_massert(grid_pntr_orig->getDimension()==grid_pntr_copy->getDimension(),"the two grids are not of the same dimension");
      39             :   //
      40         808 :   for(Grid::index_t i=0; i<grid_pntr_orig->getSize(); i++) {
      41         800 :     double value = grid_pntr_orig->getValue(i);
      42         800 :     grid_pntr_copy->setValue(i,value);
      43             :   }
      44           8 : }
      45             : 
      46             : 
      47           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) {
      48             : 
      49           9 :   IFile ifile; ifile.open(filepath);
      50             :   std::vector<std::string> fields;
      51           9 :   ifile.scanFieldList(fields);
      52           9 :   ifile.allowIgnoredFields();
      53           9 :   ifile.scanField();
      54             : 
      55             :   unsigned int nargs=0;
      56          31 :   for(unsigned int i=0; i<fields.size(); i++) {
      57          31 :     if(fields[i]=="min_"+fields[0]) {
      58           9 :       derivatives = false;
      59           9 :       nargs = i-1;
      60           9 :       break;
      61             :     }
      62          22 :     else if(fields[i]=="der_"+fields[0]) {
      63           0 :       derivatives = true;
      64           0 :       nargs = i-1;
      65           0 :       break;
      66             :     }
      67             :   }
      68             : 
      69           9 :   grid_label = fields[nargs];
      70             : 
      71           9 :   arg_labels.assign(nargs,"");
      72           9 :   arg_min.assign(nargs,"");
      73          18 :   arg_max.assign(nargs,"");
      74             :   arg_periodic.assign(nargs,false);
      75           9 :   arg_nbins.assign(nargs,0);
      76          22 :   for(unsigned int i=0; i<nargs; i++) {
      77          13 :     arg_labels[i] = fields[i];
      78          26 :     ifile.scanField("min_"+arg_labels[i],arg_min[i]);
      79          26 :     ifile.scanField("max_"+arg_labels[i],arg_max[i]);
      80             :     std::string str_periodic;
      81          26 :     ifile.scanField("periodic_"+arg_labels[i],str_periodic);
      82          13 :     if(str_periodic=="true") {arg_periodic[i]=true;}
      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