1 // clang-format off
2 /* ----------------------------------------------------------------------
3 LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
4 https://www.lammps.org/, Sandia National Laboratories
5 Steve Plimpton, sjplimp@sandia.gov
6
7 Copyright (2003) Sandia Corporation. Under the terms of Contract
8 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
9 certain rights in this software. This software is distributed under
10 the GNU General Public License.
11
12 See the README file in the top-level LAMMPS directory.
13 ------------------------------------------------------------------------- */
14
15 #include "ntopo_angle_partial.h"
16
17 #include "atom.h"
18 #include "force.h"
19 #include "domain.h"
20 #include "update.h"
21 #include "output.h"
22 #include "thermo.h"
23 #include "memory.h"
24 #include "error.h"
25
26
27 using namespace LAMMPS_NS;
28
29 #define DELTA 10000
30
31 /* ---------------------------------------------------------------------- */
32
NTopoAnglePartial(LAMMPS * lmp)33 NTopoAnglePartial::NTopoAnglePartial(LAMMPS *lmp) : NTopo(lmp)
34 {
35 allocate_angle();
36 }
37
38 /* ---------------------------------------------------------------------- */
39
build()40 void NTopoAnglePartial::build()
41 {
42 int i,m,atom1,atom2,atom3;
43
44 int nlocal = atom->nlocal;
45 int *num_angle = atom->num_angle;
46 tagint **angle_atom1 = atom->angle_atom1;
47 tagint **angle_atom2 = atom->angle_atom2;
48 tagint **angle_atom3 = atom->angle_atom3;
49 int **angle_type = atom->angle_type;
50 int newton_bond = force->newton_bond;
51
52 int lostbond = output->thermo->lostbond;
53 int nmissing = 0;
54 nanglelist = 0;
55
56 for (i = 0; i < nlocal; i++)
57 for (m = 0; m < num_angle[i]; m++) {
58 if (angle_type[i][m] <= 0) continue;
59 atom1 = atom->map(angle_atom1[i][m]);
60 atom2 = atom->map(angle_atom2[i][m]);
61 atom3 = atom->map(angle_atom3[i][m]);
62 if (atom1 == -1 || atom2 == -1 || atom3 == -1) {
63 nmissing++;
64 if (lostbond == Thermo::ERROR)
65 error->one(FLERR,"Angle atoms {} {} {} missing on "
66 "proc {} at step {}",angle_atom1[i][m],
67 angle_atom2[i][m],angle_atom3[i][m],
68 me,update->ntimestep);
69 continue;
70 }
71 atom1 = domain->closest_image(i,atom1);
72 atom2 = domain->closest_image(i,atom2);
73 atom3 = domain->closest_image(i,atom3);
74 if (newton_bond || (i <= atom1 && i <= atom2 && i <= atom3)) {
75 if (nanglelist == maxangle) {
76 maxangle += DELTA;
77 memory->grow(anglelist,maxangle,4,"neigh_topo:anglelist");
78 }
79 anglelist[nanglelist][0] = atom1;
80 anglelist[nanglelist][1] = atom2;
81 anglelist[nanglelist][2] = atom3;
82 anglelist[nanglelist][3] = angle_type[i][m];
83 nanglelist++;
84 }
85 }
86
87 if (cluster_check) angle_check();
88 if (lostbond == Thermo::IGNORE) return;
89
90 int all;
91 MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
92 if (all && (me == 0))
93 error->warning(FLERR,"Angle atoms missing at step {}",update->ntimestep);
94 }
95