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: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory 8 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory 9 // 10 // File created by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory 11 ////////////////////////////////////////////////////////////////////////////////////// 12 13 14 #ifndef QMCPLUSPLUS_SPACEGRID_H 15 #define QMCPLUSPLUS_SPACEGRID_H 16 17 #include <Configuration.h> 18 #include "OhmmsPETE/Tensor.h" 19 #include "OhmmsPETE/OhmmsMatrix.h" 20 #include "Utilities/PooledData.h" 21 #include "QMCHamiltonians/observable_helper.h" 22 #include "Particle/DistanceTableData.h" 23 24 namespace qmcplusplus 25 { 26 class SpaceGrid : public QMCTraits, public PtclOnLatticeTraits 27 { 28 public: 29 typedef TinyVector<RealType, DIM> Point; 30 typedef PooledData<RealType> BufferType; 31 typedef Matrix<RealType> Matrix_t; 32 33 SpaceGrid(int& nvalues); 34 bool put(xmlNodePtr cur, 35 std::map<std::string, Point>& points, 36 ParticlePos_t& R, 37 std::vector<RealType>& Z, 38 int ndp, 39 bool is_periodic, 40 bool abort_on_fail = true) 41 { 42 Rptcl = &R; 43 Zptcl = &Z; 44 ndparticles = ndp; 45 return put(cur, points, is_periodic, abort_on_fail); 46 } 47 bool put(xmlNodePtr cur, std::map<std::string, Point>& points, bool is_periodic, bool abort_on_fail = true); 48 bool initialize_rectilinear(xmlNodePtr cur, std::string& coord, std::map<std::string, Point>& points); 49 bool initialize_voronoi(std::map<std::string, Point>& points); 50 void write_description(std::ostream& os, std::string& indent); 51 int allocate_buffer_space(BufferType& buf); 52 void registerCollectables(std::vector<observable_helper*>& h5desc, hid_t gid, int grid_index) const; 53 void evaluate(const ParticlePos_t& R, 54 const Matrix<RealType>& values, 55 BufferType& buf, 56 std::vector<bool>& particles_outside, 57 const DistanceTableData& dtab); 58 59 bool check_grid(void); nDomains(void)60 inline int nDomains(void) { return ndomains; } 61 62 void sum(const BufferType& buf, RealType* vals); 63 64 int buffer_start; 65 int buffer_end; 66 67 //private: 68 69 //same for all spacegrids 70 enum 71 { 72 cartesian = 0, 73 cylindrical, 74 spherical, 75 voronoi, 76 ncoordinates 77 } coordinate; 78 int buffer_offset; 79 int ndomains; 80 int nvalues_per_domain; 81 Matrix<RealType> domain_volumes; 82 Matrix<RealType> domain_centers; 83 84 //in use if sorting by particle count 85 bool chempot; 86 int npmin, npmax; 87 int npvalues; 88 Matrix<RealType> cellsamples; 89 enum 90 { 91 vacuum, 92 neutral, 93 noref 94 } reference; 95 std::vector<int> reference_count; 96 97 //really only used for cartesian-like grids 98 Point origin; 99 Tensor<RealType, DIM> axes; 100 Tensor<RealType, DIM> axinv; 101 RealType volume; 102 Matrix<RealType> domain_uwidths; 103 std::string axlabel[DIM]; 104 std::vector<int> gmap[DIM]; 105 RealType odu[DIM]; 106 RealType umin[DIM]; 107 RealType umax[DIM]; 108 int dimensions[DIM]; 109 int dm[DIM]; 110 bool periodic; 111 112 //voronoi grids 113 ParticlePos_t* Rptcl; 114 std::vector<RealType>* Zptcl; 115 struct irpair 116 { 117 RealType r; 118 int i; 119 }; 120 std::vector<irpair> nearcell; 121 int ndparticles; 122 123 //used only in evaluate 124 Point u, ub; 125 }; 126 127 128 } // namespace qmcplusplus 129 130 #endif 131