forked from lijiext/lammps
patch niche rcb issue
This commit is contained in:
parent
981b9a1f7a
commit
9239c9dedb
32
src/rcb.cpp
32
src/rcb.cpp
|
@ -467,6 +467,38 @@ void RCB::compute(int dimension, int n, double **x, double *wt,
|
|||
}
|
||||
}
|
||||
|
||||
//check if zero box width is the result due to dots being on box vertices
|
||||
//select half of the box in this case along the best dim
|
||||
//the best dim is chosen according to the optimum volume (to minimize surface area)
|
||||
|
||||
if(largest==0.0){
|
||||
double best_volume=0;
|
||||
double current_volume;
|
||||
int dim1o,dim2o;
|
||||
for (dim = 0; dim < dimension; dim++){
|
||||
if(dim==0){
|
||||
dim1o=1;
|
||||
dim2o=2;
|
||||
}
|
||||
if(dim==1){
|
||||
dim1o=0;
|
||||
dim2o=2;
|
||||
}
|
||||
if(dim==2){
|
||||
dim1o=0;
|
||||
dim2o=1;
|
||||
}
|
||||
valuehalf = 0.5*(lo[dim] + hi[dim]);
|
||||
current_volume = (hi[dim1o]-lo[dim1o])
|
||||
*(hi[dim2o]-lo[dim2o])*(valuehalf-lo[dim]);
|
||||
//chose cut that minimizes surface area by maximizing volume;
|
||||
if(current_volume>best_volume){ best_volume = current_volume;
|
||||
valuehalf_select = valuehalf;
|
||||
dim_select = dim;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copy results for best dim cut into dim,valuehalf,dotmark
|
||||
|
||||
dim = dim_select;
|
||||
|
|
Loading…
Reference in New Issue