LCOV - code coverage report
Current view: top level - core - ExchangePatterns.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 6 30 20.0 %
Date: 2018-12-19 07:49:13 Functions: 2 7 28.6 %

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

Generated by: LCOV version 1.13