Unverified Commit 0ab3ebba authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

improve readability

parent 822c7c5c
Loading
Loading
Loading
Loading
+22 −22
Original line number Original line Diff line number Diff line
@@ -192,7 +192,6 @@ void AtomVec::grow(int n)
{
{
  int datatype,cols,maxcols;
  int datatype,cols,maxcols;
  void *pdata;
  void *pdata;
  int nthreads = comm->nthreads;


  if (n == 0) grow_nmax();
  if (n == 0) grow_nmax();
  else nmax = n;
  else nmax = n;
@@ -206,38 +205,39 @@ void AtomVec::grow(int n)
  image = memory->grow(atom->image,nmax,"atom:image");
  image = memory->grow(atom->image,nmax,"atom:image");
  x = memory->grow(atom->x,nmax,3,"atom:x");
  x = memory->grow(atom->x,nmax,3,"atom:x");
  v = memory->grow(atom->v,nmax,3,"atom:v");
  v = memory->grow(atom->v,nmax,3,"atom:v");
  f = memory->grow(atom->f,nmax*nthreads,3,"atom:f");
  f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");


  for (int i = 0; i < ngrow; i++) {
  for (int i = 0; i < ngrow; i++) {
    pdata = mgrow.pdata[i];
    pdata = mgrow.pdata[i];
    datatype = mgrow.datatype[i];
    datatype = mgrow.datatype[i];
    cols = mgrow.cols[i];
    cols = mgrow.cols[i];
    const int nthreads = threads[i] ? comm->nthreads : 1;
    if (datatype == DOUBLE) {
    if (datatype == DOUBLE) {
      if (cols == 0)
      if (cols == 0)
        memory->grow(*((double **) pdata),nmax*(threads[i]?nthreads:1),"atom:dvec");
        memory->grow(*((double **) pdata),nmax*nthreads,"atom:dvec");
      else if (cols > 0)
      else if (cols > 0)
        memory->grow(*((double ***) pdata),nmax*(threads[i]?nthreads:1),cols,"atom:darray");
        memory->grow(*((double ***) pdata),nmax*nthreads,cols,"atom:darray");
      else {
      else {
        maxcols = *(mgrow.maxcols[i]);
        maxcols = *(mgrow.maxcols[i]);
        memory->grow(*((double ***) pdata),nmax*(threads[i]?nthreads:1),maxcols,"atom:darray");
        memory->grow(*((double ***) pdata),nmax*nthreads,maxcols,"atom:darray");
      }
      }
    } else if (datatype == INT) {
    } else if (datatype == INT) {
      if (cols == 0)
      if (cols == 0)
        memory->grow(*((int **) pdata),nmax*(threads[i]?nthreads:1),"atom:ivec");
        memory->grow(*((int **) pdata),nmax*nthreads,"atom:ivec");
      else if (cols > 0)
      else if (cols > 0)
        memory->grow(*((int ***) pdata),nmax*(threads[i]?nthreads:1),cols,"atom:iarray");
        memory->grow(*((int ***) pdata),nmax*nthreads,cols,"atom:iarray");
      else {
      else {
        maxcols = *(mgrow.maxcols[i]);
        maxcols = *(mgrow.maxcols[i]);
        memory->grow(*((int ***) pdata),nmax*(threads[i]?nthreads:1),maxcols,"atom:iarray");
        memory->grow(*((int ***) pdata),nmax*nthreads,maxcols,"atom:iarray");
      }
      }
    } else if (datatype == BIGINT) {
    } else if (datatype == BIGINT) {
      if (cols == 0)
      if (cols == 0)
        memory->grow(*((bigint **) pdata),nmax*(threads[i]?nthreads:1),"atom:bvec");
        memory->grow(*((bigint **) pdata),nmax*nthreads,"atom:bvec");
      else if (cols > 0)
      else if (cols > 0)
        memory->grow(*((bigint ***) pdata),nmax*(threads[i]?nthreads:1),cols,"atom:barray");
        memory->grow(*((bigint ***) pdata),nmax*nthreads,cols,"atom:barray");
      else {
      else {
        maxcols = *(mgrow.maxcols[i]);
        maxcols = *(mgrow.maxcols[i]);
        memory->grow(*((int ***) pdata),nmax*(threads[i]?nthreads:1),maxcols,"atom:barray");
        memory->grow(*((int ***) pdata),nmax*nthreads,maxcols,"atom:barray");
      }
      }
    }
    }
  }
  }
@@ -2281,7 +2281,6 @@ bigint AtomVec::memory_usage()
{
{
  int datatype,cols,index,maxcols;
  int datatype,cols,index,maxcols;
  void *pdata;
  void *pdata;
  int nthreads = comm->nthreads;


  bigint bytes = 0;
  bigint bytes = 0;


@@ -2291,39 +2290,40 @@ bigint AtomVec::memory_usage()
  bytes += memory->usage(image,nmax);
  bytes += memory->usage(image,nmax);
  bytes += memory->usage(x,nmax,3);
  bytes += memory->usage(x,nmax,3);
  bytes += memory->usage(v,nmax,3);
  bytes += memory->usage(v,nmax,3);
  bytes += memory->usage(f,nmax*nthreads,3);
  bytes += memory->usage(f,nmax*comm->nthreads,3);


  for (int i = 0; i < ngrow; i++) {
  for (int i = 0; i < ngrow; i++) {
    pdata = mgrow.pdata[i];
    pdata = mgrow.pdata[i];
    datatype = mgrow.datatype[i];
    datatype = mgrow.datatype[i];
    cols = mgrow.cols[i];
    cols = mgrow.cols[i];
    index = mgrow.index[i];
    index = mgrow.index[i];
    const int nthreads = threads[i] ? comm->nthreads : 1;
    if (datatype == DOUBLE) {
    if (datatype == DOUBLE) {
      if (cols == 0) {
      if (cols == 0) {
        bytes += memory->usage(*((double **) pdata),nmax*(threads[i]?nthreads:1));
        bytes += memory->usage(*((double **) pdata),nmax*nthreads);
      } else if (cols > 0) {
      } else if (cols > 0) {
        bytes += memory->usage(*((double ***) pdata),nmax*(threads[i]?nthreads:1),cols);
        bytes += memory->usage(*((double ***) pdata),nmax*nthreads,cols);
      } else {
      } else {
        maxcols = *(mgrow.maxcols[i]);
        maxcols = *(mgrow.maxcols[i]);
        bytes += memory->usage(*((double ***) pdata),nmax*(threads[i]?nthreads:1),maxcols);
        bytes += memory->usage(*((double ***) pdata),nmax*nthreads,maxcols);
      }
      }
    } else if (datatype == INT) {
    } else if (datatype == INT) {
      if (cols == 0) {
      if (cols == 0) {
        bytes += memory->usage(*((int **) pdata),nmax*(threads[i]?nthreads:1));
        bytes += memory->usage(*((int **) pdata),nmax*nthreads);
      } else if (cols > 0) {
      } else if (cols > 0) {
        bytes += memory->usage(*((int ***) pdata),nmax*(threads[i]?nthreads:1),cols);
        bytes += memory->usage(*((int ***) pdata),nmax*nthreads,cols);
      } else {
      } else {
        maxcols = *(mgrow.maxcols[i]);
        maxcols = *(mgrow.maxcols[i]);
        bytes += memory->usage(*((int ***) pdata),nmax*(threads[i]?nthreads:1),maxcols);
        bytes += memory->usage(*((int ***) pdata),nmax*nthreads,maxcols);
      }
      }
    } else if (datatype == BIGINT) {
    } else if (datatype == BIGINT) {
      if (cols == 0) {
      if (cols == 0) {
        bytes += memory->usage(*((bigint **) pdata),nmax*(threads[i]?nthreads:1));
        bytes += memory->usage(*((bigint **) pdata),nmax*nthreads);
      } else if (cols > 0) {
      } else if (cols > 0) {
        bytes += memory->usage(*((bigint ***) pdata),nmax*(threads[i]?nthreads:1),cols);
        bytes += memory->usage(*((bigint ***) pdata),nmax*nthreads,cols);
      } else {
      } else {
        maxcols = *(mgrow.maxcols[i]);
        maxcols = *(mgrow.maxcols[i]);
        bytes += memory->usage(*((bigint ***) pdata),nmax*(threads[i]?nthreads:1),maxcols);
        bytes += memory->usage(*((bigint ***) pdata),nmax*nthreads,maxcols);
      }
      }
    }
    }
  }
  }