Skip to content

Commit

Permalink
bug fixing: pass idx bound warning and do correction
Browse files Browse the repository at this point in the history
  • Loading branch information
Han Wang committed Nov 9, 2019
1 parent d735223 commit 86a5163
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions source/lib/src/NeighborList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ build_clist (vector<vector<int > > & clist,
for (int dd = 0; dd < 3; ++dd){
idx[dd] = (inter[dd] - nat_orig[dd]) / cell_size[dd];
if (inter[dd] - nat_orig[dd] < 0.) idx[dd] --;
if (idx[dd] < nat_stt[dd] &&
count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_lower ++;
if (idx[dd] < nat_stt[dd]) {
if (count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_lower ++;
}
idx[dd] = nat_stt[dd];
}
else if (idx[dd] >= nat_end[dd] &&
count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_upper ++;
else if (idx[dd] >= nat_end[dd]) {
if (count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_upper ++;
}
idx[dd] = nat_end[dd] - 1;
}
idx[dd] += idx_orig_shift[dd];
Expand All @@ -102,20 +104,21 @@ build_clist (vector<vector<int > > & clist,
for (int dd = 0; dd < 3; ++dd){
idx[dd] = (inter[dd] - nat_orig[dd]) / cell_size[dd];
if (inter[dd] - nat_orig[dd] < 0.) idx[dd] --;
if (idx[dd] < ext_stt[dd] &&
count_warning_ghost_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
if (fabs((inter[dd] - nat_orig[dd]) - (ext_stt[dd] * cell_size[dd]))
if (idx[dd] < ext_stt[dd]) {
if (count_warning_ghost_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND &&
fabs((inter[dd] - nat_orig[dd]) - (ext_stt[dd] * cell_size[dd]))
> fabs(ext_stt[dd] * cell_size[dd]) * numeric_limits<double>::epsilon() * 5.
) {
cerr << "# warning: ghost idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_ghost_idx_lower ++;
}
idx[dd] = ext_stt[dd];
}
else if (idx[dd] >= ext_end[dd] &&
count_warning_ghost_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: ghost idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_ghost_idx_upper ++;
else if (idx[dd] >= ext_end[dd]) {
if (count_warning_ghost_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: ghost idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_ghost_idx_upper ++;
}
idx[dd] = ext_end[dd] - 1;
}
idx[dd] += idx_orig_shift[dd];
Expand Down Expand Up @@ -161,16 +164,18 @@ build_clist (vector<vector<int > > & clist,
for (int dd = 0; dd < 3; ++dd){
idx[dd] = (inter[dd] - nat_orig[dd]) / cell_size[dd];
if (inter[dd] - nat_orig[dd] < 0.) idx[dd] --;
if (idx[dd] < nat_stt[dd] &&
count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_lower ++;
if (idx[dd] < nat_stt[dd]) {
if (count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_lower ++;
}
idx[dd] = nat_stt[dd];
}
else if (idx[dd] >= nat_end[dd] &&
count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_upper ++;
else if (idx[dd] >= nat_end[dd]) {
if (count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
count_warning_loc_idx_upper ++;
}
idx[dd] = nat_end[dd] - 1;
}
}
Expand Down

0 comments on commit 86a5163

Please sign in to comment.