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

multiple changes to integrate into LAMMPS more smoothly

- indentation at 2 blanks
- use BIGINT_FORMAT consistently
- use MathSpecial::square() instead of pow(x,2)
parent fddc164d
Loading
Loading
Loading
Loading
+416 −415
Original line number Diff line number Diff line
@@ -2,10 +2,10 @@
// Created by charlie sievers on 7/5/18.
//

#include "third_order.h"
#include <mpi.h>
#include <cmath>
#include <cstring>
#include "third_order.h"
#include "atom.h"
#include "domain.h"
#include "comm.h"
@@ -23,12 +23,12 @@
#include "pair.h"
#include "timer.h"
#include "finish.h"
#include "math_special.h"
#include <algorithm>
#include "complex"


#include <complex>

using namespace LAMMPS_NS;
using namespace MathSpecial;
enum{REGULAR,BALLISTICO};

/* ---------------------------------------------------------------------- */
@@ -179,13 +179,11 @@ void ThirdOrder::options(int narg, char **arg)
      filename = fss.str().c_str();
      file_flag = 1;
      iarg += 2;
        }
        else if (strcmp(arg[iarg],"binary") == 0) {
    } else if (strcmp(arg[iarg],"binary") == 0) {
      if (iarg + 2 > narg) error->all(FLERR, "Illegal third_order command");
      if (strcmp(arg[iarg+1],"gzip") == 0) {
        compressed = 1;
            }
            else if (strcmp(arg[iarg+1],"yes") == 0) {
      } else if (strcmp(arg[iarg+1],"yes") == 0) {
        binaryflag = 1;
      }
      iarg += 2;
@@ -253,7 +251,8 @@ void ThirdOrder::calculateMatrix()
    fprintf(screen,"Calculating Third Order ...\n");
    fprintf(screen,"  Total # of atoms = " BIGINT_FORMAT "\n", natoms);
    fprintf(screen,"  Atoms in group = " BIGINT_FORMAT "\n", gcount);
        fprintf(screen,"  Total third order elements = " BIGINT_FORMAT "\n", (dynlen*dynlen*dynlen) );
    fprintf(screen,"  Total third order elements = "
            BIGINT_FORMAT "\n", (dynlen*dynlen*dynlen) );
  }

  update->nsteps = 0;
@@ -339,8 +338,8 @@ void ThirdOrder::calculateMatrix()
  delete [] dynmat;
  delete [] fdynmat;

    if (screen && me ==0 ) fprintf(screen,"Finished Calculating Third Order Tensor\n");

  if (screen && me ==0 )
    fprintf(screen,"Finished Calculating Third Order Tensor\n");
}

/* ----------------------------------------------------------------------
@@ -356,19 +355,19 @@ void ThirdOrder::writeMatrix(double *dynmat, bigint i, int a, bigint j, int b)
  if (!binaryflag && fp) {
    clearerr(fp);
    for (int k = 0; k < gcount; k++){
            norm = pow(dynmat[k*3], 2)+
                pow(dynmat[k*3+1], 2)+
                pow(dynmat[k*3+2], 2);
      norm = square(dynmat[k*3])+
        square(dynmat[k*3+1])+
        square(dynmat[k*3+2]);
      if (norm > 1.0e-16)
        fprintf(fp,
                        "%llu %d %llu %d %llu %7.8f %7.8f %7.8f\n",
                BIGINT_FORMAT " %d " BIGINT_FORMAT " %d " BIGINT_FORMAT
                " %7.8f %7.8f %7.8f\n",
                i+1, a + 1, j+1, b + 1, groupmap[k]+1,
                dynmat[k*3] * conversion,
                dynmat[k*3+1] * conversion,
                dynmat[k*3+2] * conversion);
    }
    }
    else if (binaryflag && fp){
  } else if (binaryflag && fp){
    clearerr(fp);
    fwrite(&dynmat[0], sizeof(double), dynlen, fp);
  }
@@ -534,7 +533,8 @@ void ThirdOrder::create_groupmap()
  //create a map between global atom id and group atom id for each proc
  for (bigint i=1; i<=natoms; i++){
    local_idx = atom->map(i);
        if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit){
    if ((local_idx >= 0) && (local_idx < nlocal)
        && (mask[local_idx] & groupbit)){
      sub_groupmap[gid] = i;
      gid += 1;
    }
@@ -553,7 +553,8 @@ void ThirdOrder::create_groupmap()
  }

  //combine subgroup maps into total temporary groupmap
    MPI_Allgatherv(sub_groupmap,gid,MPI_LMP_BIGINT,temp_groupmap,recv,displs,MPI_LMP_BIGINT,world);
  MPI_Allgatherv(sub_groupmap,gid,MPI_LMP_BIGINT,
                 temp_groupmap,recv,displs,MPI_LMP_BIGINT,world);
  std::sort(temp_groupmap,temp_groupmap+gcount);

  //populate member groupmap based on temp groupmap
+52 −52

File changed.

Contains only whitespace changes.