QMCPACK
ParticleUtility.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef OHMMS_PARTICLEUTILITY_H
15 #define OHMMS_PARTICLEUTILITY_H
16 
17 namespace qmcplusplus
18 {
19 
20 ////////////////////////////////////////////////////////////////
21 // Iterator is exposed. Parallel Implementation requires special care
22 ////////////////////////////////////////////////////////////////
23 template<class PL, class PV>
24 void convert(const PL& lat, const PV& pin, PV& pout)
25 {
26  if (pin.InUnit == pout.InUnit)
27  {
28  pout = pin;
29  return;
30  }
31  if (pin.InUnit)
32  {
33  for (int i = 0; i < pin.size(); i++)
34  pout[i] = lat.toCart(pin[i]);
35  return;
36  }
37  else
38  {
39  for (int i = 0; i < pin.size(); i++)
40  pout[i] = lat.toUnit(pin[i]);
41  return;
42  }
43 }
44 
45 ////////////////////////////////////////////////////////////////
46 // Iterator is exposed. Parallel Implementation requires special care
47 ////////////////////////////////////////////////////////////////
48 template<class PL, class PV>
49 void convert2Cart(const PL& lat, PV& pin)
50 {
51  if (pin.InUnit)
52  {
53  PV tmp(pin.size());
54  tmp = pin;
55  pin.InUnit = false;
56  for (int i = 0; i < pin.size(); i++)
57  pin[i] = lat.toCart(pin[i]);
58  }
59 }
60 
61 template<class PL, class PV>
62 void convert2Unit(const PL& lat, PV& pin)
63 {
64  if (!pin.InUnit)
65  {
66  PV tmp(pin.size());
67  tmp = pin;
68  pin.InUnit = true;
69  for (int i = 0; i < pin.size(); i++)
70  pin[i] = lat.toUnit(pin[i]);
71  }
72 }
73 
74 ////////////////////////////////////////////////////////////////
75 // Apply BC conditions to put the position type in lattice box [0,1)
76 ////////////////////////////////////////////////////////////////
77 template<class PL, class PV>
78 void wrapAroundBox(const PL& lat, const PV& pin, PV& pout)
79 {
80  if (pin.InUnit)
81  {
82  if (pout.InUnit)
83  {
84  for (int i = 0; i < pin.size(); i++)
85  {
86  pout[i] = lat.BConds.wrap(pin[i]); //unit -> unit
87  }
88  }
89  else
90  {
91  for (int i = 0; i < pin.size(); i++)
92  pout[i] = lat.toCart(lat.BConds.wrap(pin[i])); //unit -> cart
93  }
94  }
95  else
96  {
97  if (pout.InUnit)
98  {
99  for (int i = 0; i < pin.size(); i++)
100  pout[i] = lat.BConds.wrap(lat.toUnit(pin[i])); //cart -> unit
101  }
102  else
103  {
104  for (int i = 0; i < pin.size(); i++)
105  pout[i] = lat.toCart(lat.BConds.wrap(lat.toUnit(pin[i]))); //cart -> cart
106  }
107  }
108 }
109 
110 } // namespace qmcplusplus
111 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void convert(const PL &lat, const PV &pin, PV &pout)
void convert2Cart(const PL &lat, PV &pin)
void wrapAroundBox(const PL &lat, const PV &pin, PV &pout)
void convert2Unit(const PL &lat, PV &pin)