Skip to content

Commit 9b6e58d

Browse files
authored
Merge pull request #119 from amcadmus/devel
bug fixing: pass idx bound warning and do correction
2 parents 65e14dc + 29d457c commit 9b6e58d

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

source/lib/src/NeighborList.cpp

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,18 @@ build_clist (vector<vector<int > > & clist,
7979
for (int dd = 0; dd < 3; ++dd){
8080
idx[dd] = (inter[dd] - nat_orig[dd]) / cell_size[dd];
8181
if (inter[dd] - nat_orig[dd] < 0.) idx[dd] --;
82-
if (idx[dd] < nat_stt[dd] &&
83-
count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
84-
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
85-
count_warning_loc_idx_lower ++;
82+
if (idx[dd] < nat_stt[dd]) {
83+
if (count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
84+
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
85+
count_warning_loc_idx_lower ++;
86+
}
8687
idx[dd] = nat_stt[dd];
8788
}
88-
else if (idx[dd] >= nat_end[dd] &&
89-
count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
90-
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
91-
count_warning_loc_idx_upper ++;
89+
else if (idx[dd] >= nat_end[dd]) {
90+
if (count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
91+
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
92+
count_warning_loc_idx_upper ++;
93+
}
9294
idx[dd] = nat_end[dd] - 1;
9395
}
9496
idx[dd] += idx_orig_shift[dd];
@@ -102,20 +104,21 @@ build_clist (vector<vector<int > > & clist,
102104
for (int dd = 0; dd < 3; ++dd){
103105
idx[dd] = (inter[dd] - nat_orig[dd]) / cell_size[dd];
104106
if (inter[dd] - nat_orig[dd] < 0.) idx[dd] --;
105-
if (idx[dd] < ext_stt[dd] &&
106-
count_warning_ghost_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
107-
if (fabs((inter[dd] - nat_orig[dd]) - (ext_stt[dd] * cell_size[dd]))
107+
if (idx[dd] < ext_stt[dd]) {
108+
if (count_warning_ghost_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND &&
109+
fabs((inter[dd] - nat_orig[dd]) - (ext_stt[dd] * cell_size[dd]))
108110
> fabs(ext_stt[dd] * cell_size[dd]) * numeric_limits<double>::epsilon() * 5.
109111
) {
110112
cerr << "# warning: ghost idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
111113
count_warning_ghost_idx_lower ++;
112114
}
113115
idx[dd] = ext_stt[dd];
114116
}
115-
else if (idx[dd] >= ext_end[dd] &&
116-
count_warning_ghost_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
117-
cerr << "# warning: ghost idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
118-
count_warning_ghost_idx_upper ++;
117+
else if (idx[dd] >= ext_end[dd]) {
118+
if (count_warning_ghost_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
119+
cerr << "# warning: ghost idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
120+
count_warning_ghost_idx_upper ++;
121+
}
119122
idx[dd] = ext_end[dd] - 1;
120123
}
121124
idx[dd] += idx_orig_shift[dd];
@@ -161,16 +164,18 @@ build_clist (vector<vector<int > > & clist,
161164
for (int dd = 0; dd < 3; ++dd){
162165
idx[dd] = (inter[dd] - nat_orig[dd]) / cell_size[dd];
163166
if (inter[dd] - nat_orig[dd] < 0.) idx[dd] --;
164-
if (idx[dd] < nat_stt[dd] &&
165-
count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
166-
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
167-
count_warning_loc_idx_lower ++;
167+
if (idx[dd] < nat_stt[dd]) {
168+
if (count_warning_loc_idx_lower < MAX_WARN_IDX_OUT_OF_BOUND) {
169+
cerr << "# warning: loc idx out of lower bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
170+
count_warning_loc_idx_lower ++;
171+
}
168172
idx[dd] = nat_stt[dd];
169173
}
170-
else if (idx[dd] >= nat_end[dd] &&
171-
count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
172-
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
173-
count_warning_loc_idx_upper ++;
174+
else if (idx[dd] >= nat_end[dd]) {
175+
if (count_warning_loc_idx_upper < MAX_WARN_IDX_OUT_OF_BOUND) {
176+
cerr << "# warning: loc idx out of upper bound (ignored if warned for more than " << MAX_WARN_IDX_OUT_OF_BOUND << " times) " << endl;
177+
count_warning_loc_idx_upper ++;
178+
}
174179
idx[dd] = nat_end[dd] - 1;
175180
}
176181
}

0 commit comments

Comments
 (0)