LCOV - code coverage report
Current view: top level - core - ExchangePatterns.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 5 26 19.2 %
Date: 2024-10-18 14:00:25 Functions: 2 7 28.6 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-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             : #include "ExchangePatterns.h"
      23             : #include "tools/Random.h"
      24             : 
      25             : namespace PLMD {
      26             : 
      27      806698 : ExchangePatterns::ExchangePatterns():
      28      806698 :   PatternFlag(NONE),
      29      806698 :   NumberOfReplicas(1)
      30      806698 : {}
      31             : 
      32      806698 : ExchangePatterns::~ExchangePatterns() {}
      33             : 
      34           0 : void ExchangePatterns::setNofR(const int nrepl) {
      35           0 :   NumberOfReplicas=nrepl;
      36           0 : }
      37             : 
      38           0 : void ExchangePatterns::setFlag(const int flag) {
      39           0 :   PatternFlag=flag;
      40           0 : }
      41             : 
      42           0 : void ExchangePatterns::getFlag(int &flag) {
      43           0 :   flag=PatternFlag;
      44           0 : }
      45             : 
      46           0 : void ExchangePatterns::setSeed(const int seed)
      47             : {
      48           0 :   random.setSeed(seed);
      49           0 : }
      50             : 
      51           0 : void ExchangePatterns::getList(const TypesafePtr & ind)
      52             : {
      53           0 :   auto iind=ind.get<int*>({NumberOfReplicas});
      54           0 :   switch(PatternFlag)
      55             :   {
      56             :   case RANDOM:
      57           0 :     for(int i=0; i<NumberOfReplicas; i++) {
      58             :       int stat=1;
      59           0 :       while(stat) {
      60             :         stat=0;
      61           0 :         iind[i] = (int) (random.U01()*NumberOfReplicas);
      62           0 :         for(int j=0; j<i; j++) if(iind[i]==iind[j]) stat=1;
      63             :       }
      64             :     }
      65             :     break;
      66             :   case NEIGHBOR:
      67           0 :     for(int i=0; i<NumberOfReplicas; i++) iind[i]=i;
      68             :     break;
      69             :   }
      70           0 : }
      71             : 
      72             : }

Generated by: LCOV version 1.16