avoid segfault when trying to apply (strict) pbc or convert to/from fractional coordinates on an MPI rank without atoms

This commit is contained in:
Axel Kohlmeyer
2021-08-26 07:10:47 -04:00
parent 84896fc7d4
commit a7f4bbffcf
2 changed files with 9 additions and 4 deletions

View File

@ -37,6 +37,9 @@ typedef struct { double x,y,z; } dbl3_t;
void DomainOMP::pbc() void DomainOMP::pbc()
{ {
const int nlocal = atom->nlocal;
if (!nlocal) return;
dbl3_t * _noalias const x = (dbl3_t *)&atom->x[0][0]; dbl3_t * _noalias const x = (dbl3_t *)&atom->x[0][0];
dbl3_t * _noalias const v = (dbl3_t *)&atom->v[0][0]; dbl3_t * _noalias const v = (dbl3_t *)&atom->v[0][0];
const double * _noalias const lo = (triclinic == 0) ? boxlo : boxlo_lamda; const double * _noalias const lo = (triclinic == 0) ? boxlo : boxlo_lamda;
@ -44,7 +47,6 @@ void DomainOMP::pbc()
const double * _noalias const period = (triclinic == 0) ? prd : prd_lamda; const double * _noalias const period = (triclinic == 0) ? prd : prd_lamda;
const int * _noalias const mask = atom->mask; const int * _noalias const mask = atom->mask;
imageint * _noalias const image = atom->image; imageint * _noalias const image = atom->image;
const int nlocal = atom->nlocal;
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for LMP_DEFAULT_NONE schedule(static) #pragma omp parallel for LMP_DEFAULT_NONE schedule(static)
@ -141,8 +143,9 @@ void DomainOMP::pbc()
void DomainOMP::lamda2x(int n) void DomainOMP::lamda2x(int n)
{ {
dbl3_t * _noalias const x = (dbl3_t *)&atom->x[0][0];
const int num = n; const int num = n;
if (!n) return;
dbl3_t * _noalias const x = (dbl3_t *)&atom->x[0][0];
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for LMP_DEFAULT_NONE schedule(static) #pragma omp parallel for LMP_DEFAULT_NONE schedule(static)
@ -161,8 +164,9 @@ void DomainOMP::lamda2x(int n)
void DomainOMP::x2lamda(int n) void DomainOMP::x2lamda(int n)
{ {
dbl3_t * _noalias const x = (dbl3_t *)&atom->x[0][0];
const int num = n; const int num = n;
if (!n) return;
dbl3_t * _noalias const x = (dbl3_t *)&atom->x[0][0];
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for LMP_DEFAULT_NONE schedule(static) #pragma omp parallel for LMP_DEFAULT_NONE schedule(static)

View File

@ -528,10 +528,11 @@ void Domain::reset_box()
void Domain::pbc() void Domain::pbc()
{ {
int nlocal = atom->nlocal;
if (!nlocal) return;
int i; int i;
imageint idim,otherdims; imageint idim,otherdims;
double *lo,*hi,*period; double *lo,*hi,*period;
int nlocal = atom->nlocal;
double **x = atom->x; double **x = atom->x;
double **v = atom->v; double **v = atom->v;
int *mask = atom->mask; int *mask = atom->mask;