From 65e93cbaab76aec1165096ee302bdd973f1230ef Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 26 Oct 2020 17:06:27 -0400 Subject: [PATCH] decrement/increment molindex and atomindex to have 1-based indices in files and 0-based internally --- src/MOLECULE/atom_vec_template.cpp | 25 +++++++++++++++++++++++-- src/MOLECULE/atom_vec_template.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index 3b05a9a139..d21bd39cf9 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -112,6 +112,27 @@ void AtomVecTemplate::create_atom_post(int ilocal) molatom[ilocal] = -1; } +/* ---------------------------------------------------------------------- + modify values for AtomVec::pack_data() to pack +------------------------------------------------------------------------- */ + +void AtomVecTemplate::pack_data_pre(int ilocal) +{ + molindex[ilocal]++; + molatom[ilocal]++; +} + +/* ---------------------------------------------------------------------- + unmodify values packed by AtomVec::pack_data() +------------------------------------------------------------------------- */ + +void AtomVecTemplate::pack_data_post(int ilocal) +{ + molindex[ilocal]--; + molatom[ilocal]--; +} + + /* ---------------------------------------------------------------------- modify what AtomVec::data_atom() just unpacked or initialize other atom quantities @@ -119,8 +140,8 @@ void AtomVecTemplate::create_atom_post(int ilocal) void AtomVecTemplate::data_atom_post(int ilocal) { - int molindex_one = molindex[ilocal]; - int molatom_one = molatom[ilocal]; + int molindex_one = --molindex[ilocal]; + int molatom_one = --molatom[ilocal]; if (molindex_one < 0 || molindex_one >= nset) error->one(FLERR,"Invalid template index in Atoms section of data file"); diff --git a/src/MOLECULE/atom_vec_template.h b/src/MOLECULE/atom_vec_template.h index 3bf2ec6273..99acf5d855 100644 --- a/src/MOLECULE/atom_vec_template.h +++ b/src/MOLECULE/atom_vec_template.h @@ -31,6 +31,8 @@ class AtomVecTemplate : public AtomVec { void grow_pointers(); void process_args(int, char **); void create_atom_post(int); + void pack_data_pre(int); + void pack_data_post(int); void data_atom_post(int); private: