Skip to content

Commit

Permalink
Fixed Recalculation Cutoff Problem (#43)
Browse files Browse the repository at this point in the history
-Resolves #42

Simulation class:
-added new member variable Recalc_cutoff_sq_lat to be used by the findRecalcNeighbors function instead of const static local variable so that its value can be updated when calling the init function
  • Loading branch information
MikeHeiber authored Oct 26, 2018
1 parent 3b1c29a commit 2131f2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace KMC_Lattice {
Enable_selective_recalc = params.Enable_selective_recalc;
Recalc_cutoff = params.Recalc_cutoff;
Enable_full_recalc = params.Enable_full_recalc;
Recalc_cutoff_sq_lat = (int)((Recalc_cutoff / params.Unit_size)*(Recalc_cutoff / params.Unit_size));
// Lattice Parameters
Parameters_Lattice params_lattice;
params_lattice.Enable_periodic_x = params.Enable_periodic_x;
Expand Down Expand Up @@ -124,10 +125,9 @@ namespace KMC_Lattice {
}

vector<Object*> Simulation::findRecalcNeighbors(const Coords& coords) const {
const static int recalc_cutoff_sq_lat = (int)((Recalc_cutoff / lattice.getUnitSize())*(Recalc_cutoff / lattice.getUnitSize()));
vector<Object*> neighbor_ptrs(object_ptrs.size());
auto it = copy_if(object_ptrs.begin(), object_ptrs.end(), neighbor_ptrs.begin(), [this, &coords](Object* element) {
return lattice.calculateLatticeDistanceSquared(coords, element->getCoords()) <= recalc_cutoff_sq_lat;
return lattice.calculateLatticeDistanceSquared(coords, element->getCoords()) <= Recalc_cutoff_sq_lat;
});
neighbor_ptrs.resize(std::distance(neighbor_ptrs.begin(), it));
return neighbor_ptrs;
Expand Down
1 change: 1 addition & 0 deletions src/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ namespace KMC_Lattice {
bool Enable_selective_recalc;
int Recalc_cutoff;
bool Enable_full_recalc;
int Recalc_cutoff_sq_lat;
// Data Structures
std::list<Object*> object_ptrs;
std::list<Event*> event_ptrs;
Expand Down

0 comments on commit 2131f2d

Please sign in to comment.