19 if (numberOfGrids == 1)
MY_HEADING(
"Creating Grids");
21 std::cout <<
"Grid " << numberOfGrids <<
". Initializing a grid of size " <<
ngrid <<
" to the origin." << std::endl;
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;
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);
74 coordinates.resize(ngrid);
75 for(
auto& position : coordinates)
76 for (
int i_dim=0; i_dim<
DIM; i_dim++)
77 if(!(file >> position(i_dim)))
MY_ERROR(
"ERROR: Reading grid coordinates");
85 std::vector<std::set<int>> gridNeighborLists;
89 origin.setConstant(0.0);
90 step.setConstant(padding);
97 for(
const auto& gridPoint : coordinates)
99 std::set<int> gridContributingList;
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;
121template<ConfigType T>
124 std::ofstream file(filename+
".grid");
126 file << ngrid <<
"\n";
128 for (
const auto& coordinate : coordinates)
129 file << coordinate << std::endl;
132template<ConfigType T>
135 std::cout <<
"Reading grid from file " << filename <<
"\n" << std::endl;
137 std::ifstream file(filename);
141 if (ngrid!= ngridInFile)
142 MY_ERROR(
"Error: Number of grid points in file" <<
" = " << ngridInFile <<
143 ", does not equal to " << ngrid <<
" in grid.");
145 for(
auto& position : coordinates)
146 for (
int i_dim=0; i_dim<
DIM; i_dim++)
147 if(!(file >> position(i_dim)))
MY_ERROR(
"ERROR: Reading grid coordinates");
150template<ConfigType T>
155 else MY_ERROR(
"Unrecognized grid type");
159template<ConfigType T>
164template<ConfigType T>
173template<ConfigType T>
179 std::set<int> gridContributingList;
186 const std::vector<int>& particleList=
188 hashParticles.
hashTable.at(neighborBin) : std::vector<int>();
191 for(
const auto& particle : particleList)
193 double distance= (subconfig.coordinates.at(T).row(particle)-grid.coordinates[i_gridPoint]).squaredNorm();
194 if (distance<=pow(padding,2))
195 gridContributingList.insert(particle);
198 return gridContributingList;
std::map< ConfigType, MatrixXd > coordinates
Map from configuration type (Reference or Current) to coordinate matrices.
static int numberOfReferenceGrids
static int numberOfCurrentGrids
std::vector< Vector3d > coordinates
std::set< int > getGridPointNeighbors(const int &) const
GridSubConfiguration(const Grid< T > &, const SubConfiguration &, const double &)
std::vector< std::set< int > > getGridNeighborLists(const SubConfiguration &, const double &) const
void write(std::string) const
Triplet hashFunction(const int &i) const
std::map< Triplet, std::vector< int > > hashTable
std::vector< Triplet > neighborList()
#define MY_ERROR(message)
Eigen::Matrix< double, 1, DIM, Eigen::RowMajor > Vector3d
#define MY_HEADING(heading)