src/QMCDrivers/WalkerControlBase.cpp
/** copy good walkers to W
 *
 *  Good walkers are copied based on the registered number of copies
 *  Bad walkers are recycled to avoid memory allocation and deallocation.
 */
copy good walkers to W
Good walkers are copied based on the registered number of copies
Bad walkers are recycled to avoid memory allocation and deallocation.
copy good walkers to W Good walkers are copied based on the registered number of copies Bad walkers are recycled to avoid memory allocation and deallocation .
int WalkerControlBase::copyWalkers(MCWalkerConfiguration& W)
{
  const int size_good_w = good_w.size();
  std::vector<int> copy_list;
  for (int i = 0; i < size_good_w; i++)
  {
    for (int j = 0; j < ncopy_w[i]; j++)
    {
      if (bad_w.empty())
      {
        good_w.push_back(nullptr);
      }
      else
      {
        good_w.push_back(bad_w.back());
        bad_w.pop_back();
      }
      copy_list.push_back(i);
    }
  }
#pragma omp parallel for
  for (int i = size_good_w; i < good_w.size(); i++)
  {
    auto& wRef    = good_w[copy_list[i - size_good_w]];
    auto& awalker = good_w[i];
    if (awalker == nullptr)
      awalker = new Walker_t(*wRef);
    else
      *awalker = *wRef;
    awalker->ID       = (i - size_good_w) * num_contexts_ + MyContext;
    awalker->ParentID = wRef->ParentID;
  }
  W.clear();
  W.insert(W.begin(), good_w.begin(), good_w.end());
  for (int i = 0; i < bad_w.size(); i++)
    delete bad_w[i];
  good_w.clear();
  bad_w.clear();
  ncopy_w.clear();
  return W.getActiveWalkers();
}
int WalkerControlBase :: copyWalkers ( MCWalkerConfiguration & W ) { const int size_good_w = good_w . size ( ) ; std :: vector < int > copy_list ; for ( int i = 0 ; i < size_good_w ; i ++ ) { for ( int j = 0 ; j < ncopy_w [ i ] ; j ++ ) { if ( bad_w . empty ( ) ) { good_w . push_back ( nullptr ) ; } else { good_w . push_back ( bad_w . back ( ) ) ; bad_w . pop_back ( ) ; } copy_list . push_back ( i ) ; } } #pragma  omp parallel for for ( int i = size_good_w ; i < good_w . size ( ) ; i ++ ) { auto & wRef = good_w [ copy_list [ i - size_good_w ] ] ; auto & awalker = good_w [ i ] ; if ( awalker == nullptr ) awalker = new Walker_t ( * wRef ) ; else * awalker = * wRef ; awalker -> ID = ( i - size_good_w ) * num_contexts_ + MyContext ; awalker -> ParentID = wRef -> ParentID ; } W . clear ( ) ; W . insert ( W . begin ( ) , good_w . begin ( ) , good_w . end ( ) ) ; for ( int i = 0 ; i < bad_w . size ( ) ; i ++ ) delete bad_w [ i ] ; good_w . clear ( ) ; bad_w . clear ( ) ; ncopy_w . clear ( ) ; return W . getActiveWalkers ( ) ; }
copy good walkers to W
  Good walkers are copied based on the registered number of copies
  Bad walkers are recycled to avoid memory allocation and deallocation.
copy good walkers to W Good walkers are copied based on the registered number of copies Bad walkers are recycled to avoid memory allocation and deallocation .
// save current good walker size. // not fully sure this is correct or even used //clear the WalkerList to populate them with the good walkers //remove bad walkers if there are any left //clear good_w and ncopy_w for the next branch