14 template<ConfigType T>
19 if (numberOfGrids == 1)
MY_HEADING(
"Creating Grids");
21 std::cout <<
"Grid " << numberOfGrids <<
". Initializing a grid of size " <<
ngrid <<
" to the origin." << std::endl;
25 template<ConfigType T>
28 int ngridx,
int ngridy,
int ngridz):
ngrid(ngridx*ngridy*ngridz)
30 if ( !(lowerLimit.array() < upperLimit.array()).prod() )
31 MY_ERROR(
"ERROR: The coordinates of lowerLimit are not less than the upperLimit");
35 if (numberOfGrids == 1)
MY_HEADING(
"Creating Grids");
38 std::cout <<
"Grid " << numberOfGrids <<
". Creating a uniform grid of " <<
ngrid <<
" points between (" << lowerLimit
39 <<
") and (" << upperLimit <<
")"<< std::endl;
40 std::cout << std::endl;
45 coordinate= lowerLimit;
48 coordinate(0) = lowerLimit(0) + i*(upperLimit(0)-lowerLimit(0))/ngridx;
51 coordinate(1) = lowerLimit(1) + j*(upperLimit(1)-lowerLimit(1))/ngridy;
54 coordinate(2)= lowerLimit(2) + k*(upperLimit(2)-lowerLimit(2))/ngridz;
62 template<ConfigType T>
67 if (numberOfGrids == 1)
MY_HEADING(
"Creating Grids");
68 std::cout <<
"Grid " << numberOfGrids <<
". Reading grid from filename: " << filename << std::endl;
69 std::cout << std::endl;
71 std::ifstream file(filename);
76 for (
int i_dim=0; i_dim<
DIM; i_dim++)
77 if(!(file >> position(i_dim)))
MY_ERROR(
"ERROR: Reading grid coordinates");
82 template<ConfigType T>
85 std::vector<std::set<int>> gridNeighborLists;
89 origin.setConstant(0.0);
90 step.setConstant(padding);
99 std::set<int> gridContributingList;
100 Triplet bin= hashGrid.hashFunction(i_gridPoint);
105 std::vector<int>& particleList= hashParticles.hashTable[neighborBin];
107 for(
const auto& particle : particleList)
109 double distance= (subconfig.
coordinates.at(T).row(particle)-gridPoint).squaredNorm();
110 if (distance<=pow(padding,2))
111 gridContributingList.insert(particle);
114 gridNeighborLists.push_back(gridContributingList);
118 return gridNeighborLists;
122 template<ConfigType T>
125 std::ofstream file(filename+
".grid");
127 file <<
ngrid <<
"\n";
130 file << coordinate << std::endl;
133 template<ConfigType T>
136 std::cout <<
"Reading grid from file " << filename <<
"\n" << std::endl;
138 std::ifstream file(filename);
142 if (
ngrid!= ngridInFile)
143 MY_ERROR(
"Error: Number of grid points in file" <<
" = " << ngridInFile <<
144 ", does not equal to " <<
ngrid <<
" in grid.");
147 for (
int i_dim=0; i_dim<
DIM; i_dim++)
148 if(!(file >> position(i_dim)))
MY_ERROR(
"ERROR: Reading grid coordinates");
151 template<ConfigType T>
156 else MY_ERROR(
"Unrecognized grid type");
160 template<ConfigType T>
#define MY_HEADING(heading)
std::map< ConfigType, MatrixXd > coordinates
std::vector< std::set< int > > getGridNeighborLists(const SubConfiguration &, const double &) const
std::vector< Vector3d > coordinates
void write(std::string) const
#define MY_ERROR(message)
Eigen::Matrix< double, 1, DIM, Eigen::RowMajor > Vector3d
static int numberOfReferenceGrids
std::vector< Triplet > neighborList()
static int numberOfCurrentGrids