1 /* ----------------------------------------------------------------------
2 LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3 https://www.lammps.org/, Sandia National Laboratories
4 Steve Plimpton, sjplimp@sandia.gov
5
6 Copyright (2003) Sandia Corporation. Under the terms of Contract
7 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8 certain rights in this software. This software is distributed under
9 the GNU General Public License.
10
11 See the README file in the top-level LAMMPS directory.
12 ------------------------------------------------------------------------- */
13
14 #include "atom_vec_oxdna.h"
15
16 #include "atom.h"
17 #include "error.h"
18 #include "force.h"
19
20 using namespace LAMMPS_NS;
21
22 /* ---------------------------------------------------------------------- */
AtomVecOxdna(LAMMPS * lmp)23 AtomVecOxdna::AtomVecOxdna(LAMMPS *lmp) : AtomVec(lmp)
24 {
25 molecular = Atom::MOLECULAR;
26 bonds_allow = 1;
27 mass_type = PER_TYPE;
28
29 atom->molecule_flag = 1;
30
31 // strings with peratom variables to include in each AtomVec method
32 // strings cannot contain fields in corresponding AtomVec default strings
33 // order of fields in a string does not matter
34 // except: fields_data_atom & fields_data_vel must match data file
35
36 fields_grow = (char *) "id5p";
37 fields_copy = (char *) "id5p";
38 fields_comm = (char *) "";
39 fields_comm_vel = (char *) "";
40 fields_reverse = (char *) "";
41 fields_border = (char *) "id5p";
42 fields_border_vel = (char *) "";
43 fields_exchange = (char *) "id5p";
44 fields_restart = (char *) "id5p";
45 fields_create = (char *) "";
46 fields_data_atom = (char *) "id type x";
47 fields_data_vel = (char *) "id v";
48
49 setup_fields();
50
51 if (!force->newton_bond)
52 error->warning(FLERR, "Write_data command requires newton on to preserve 3'->5' bond polarity");
53 }
54
55 /* ---------------------------------------------------------------------- */
~AtomVecOxdna()56 AtomVecOxdna::~AtomVecOxdna() {}
57
58 /* ----------------------------------------------------------------------
59 set local copies of all grow ptrs used by this class, except defaults
60 needed in replicate when 2 atom classes exist and it calls pack_restart()
61 ------------------------------------------------------------------------- */
62
grow_pointers()63 void AtomVecOxdna::grow_pointers()
64 {
65 id5p = atom->id5p;
66 }
67
68 /* ----------------------------------------------------------------------
69 initialize atom quantity 5' partner
70 ------------------------------------------------------------------------- */
71
data_atom_post(int ilocal)72 void AtomVecOxdna::data_atom_post(int ilocal)
73 {
74 tagint *id5p = atom->id5p;
75 id5p[ilocal] = -1;
76 }
77
78 /* ----------------------------------------------------------------------
79 process bond information as per data file
80 store 5' partner to inform 3'->5' bond directionality
81 ------------------------------------------------------------------------- */
82
data_bonds_post(int,int,tagint atom1,tagint atom2,tagint id_offset)83 void AtomVecOxdna::data_bonds_post(int /*m*/, int /*num_bond*/, tagint atom1, tagint atom2,
84 tagint id_offset)
85 {
86 int n;
87 tagint *id5p = atom->id5p;
88
89 if (id_offset) {
90 atom1 += id_offset;
91 atom2 += id_offset;
92 }
93
94 if ((n = atom->map(atom1)) >= 0) { id5p[n] = atom2; }
95 }
96