Commit afed8bb9 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

make changes to pass compilation test

- move MEAM class into LAMMPS_NS namespace
- move inclusion of meam.h header to pair_meamc.cpp to reduce namespace pollution
- use forward declaration for MEAM class reference
- make that class reference a pointer and add a destructor
- replace MAX/MIN macros with versions compatible with older compilers
parent 03c93b31
Loading
Loading
Loading
Loading
+46 −53
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ extern "C" {
    double fm_exp(double);
}

namespace LAMMPS_NS {

typedef enum { FCC, BCC, HCP, DIM, DIA, B1, C11, L12, B2 } lattice_t;

typedef struct
@@ -18,6 +20,11 @@ typedef struct
} allocatable_double_2d;

class MEAM {
 public:
  MEAM() {};
  ~MEAM() {
    meam_cleanup_();
  }
 private:
  // cutforce = force cutoff
  // cutforcesq = force cutoff squared
@@ -138,23 +145,8 @@ void meam_setup_global_(int*, int*, double*, int*, double*, double*, double*, do
};

// Functions we need for compat
#ifndef max
#define max(a, b)                                                              \
  ({                                                                           \
    __typeof__(a) _a = (a);                                                    \
    __typeof__(b) _b = (b);                                                    \
    _a > _b ? _a : _b;                                                         \
  })
#endif

#ifndef min
#define min(a, b)                                                              \
  ({                                                                           \
    __typeof__(a) _a = (a);                                                    \
    __typeof__(b) _b = (b);                                                    \
    _a < _b ? _a : _b;                                                         \
  })
#endif
#define MIN(A,B) ((A) < (B) ? (A) : (B))
#define MAX(A,B) ((A) > (B) ? (A) : (B))

#define iszero(f) (fabs(f) < 1e-20)

@@ -215,5 +207,6 @@ Fortran Array Semantics in C.
// access data with same index as used in fortran (1-based)
#define arr2(arr, i, j) arr.ptr[(arr.dim1) * (j - 1) + (i - 1)]

};

#endif
+2 −0
Original line number Diff line number Diff line
#include "meam.h"

using namespace LAMMPS_NS;

void
MEAM::meam_cleanup_(void)
{
+1 −0
Original line number Diff line number Diff line
#include "meam.h"
#include <math.h>

using namespace LAMMPS_NS;
// Extern "C" declaration has the form:
//
//  void meam_dens_final_(int *, int *, int *, int *, int *, double *, double *,
+1 −0
Original line number Diff line number Diff line
#include "meam.h"
#include <math.h>

using namespace LAMMPS_NS;
//     Extern "C" declaration has the form:
//
//  void meam_dens_init_(int *, int *, int *, double *, int *, int *, int *,
+3 −2
Original line number Diff line number Diff line
#include "meam.h"
#include <math.h>

using namespace LAMMPS_NS;
//     Extern "C" declaration has the form:
//
//  void meam_force_(int *, int *, int *, double *, int *, int *, int *, double
@@ -112,9 +113,9 @@ MEAM::meam_force_(int* iptr, int* nmax, int* eflag_either, int* eflag_global,
          ind = this->eltind[elti][eltj];
          pp = rij * this->rdrar + 1.0;
          kk = (int)pp;
          kk = min(kk, this->nrar - 1);
          kk = MIN(kk, this->nrar - 1);
          pp = pp - kk;
          pp = min(pp, 1.0);
          pp = MIN(pp, 1.0);
          phi = ((arr2(this->phirar3, kk, ind) * pp +
                  arr2(this->phirar2, kk, ind)) *
                   pp +
Loading