1 /* ----------------------------------------------------------------------
2 This is the
3
4 ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗████████╗███████╗
5 ██║ ██║██╔════╝ ██╔════╝ ██╔════╝ ██║ ██║╚══██╔══╝██╔════╝
6 ██║ ██║██║ ███╗██║ ███╗██║ ███╗███████║ ██║ ███████╗
7 ██║ ██║██║ ██║██║ ██║██║ ██║██╔══██║ ██║ ╚════██║
8 ███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║ ██║ ██║ ███████║
9 ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝®
10
11 DEM simulation engine, released by
12 DCS Computing Gmbh, Linz, Austria
13 http://www.dcs-computing.com, office@dcs-computing.com
14
15 LIGGGHTS® is part of CFDEM®project:
16 http://www.liggghts.com | http://www.cfdem.com
17
18 Core developer and main author:
19 Christoph Kloss, christoph.kloss@dcs-computing.com
20
21 LIGGGHTS® is open-source, distributed under the terms of the GNU Public
22 License, version 2 or later. It is distributed in the hope that it will
23 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
24 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have
25 received a copy of the GNU General Public License along with LIGGGHTS®.
26 If not, see http://www.gnu.org/licenses . See also top-level README
27 and LICENSE files.
28
29 LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH,
30 the producer of the LIGGGHTS® software and the CFDEM®coupling software
31 See http://www.cfdem.com/terms-trademark-policy for details.
32
33 -------------------------------------------------------------------------
34 Contributing author and copyright for this file:
35 This file is from LAMMPS
36 LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
37 http://lammps.sandia.gov, Sandia National Laboratories
38 Steve Plimpton, sjplimp@sandia.gov
39
40 Copyright (2003) Sandia Corporation. Under the terms of Contract
41 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
42 certain rights in this software. This software is distributed under
43 the GNU General Public License.
44 ------------------------------------------------------------------------- */
45
46 #include <stdlib.h>
47 #include <string.h>
48 #include "ctype.h"
49 #include "pair_hybrid_overlay.h"
50 #include "atom.h"
51 #include "force.h"
52 #include "neighbor.h"
53 #include "neigh_request.h"
54 #include "error.h"
55
56 using namespace LAMMPS_NS;
57
58 /* ---------------------------------------------------------------------- */
59
PairHybridOverlay(LAMMPS * lmp)60 PairHybridOverlay::PairHybridOverlay(LAMMPS *lmp) : PairHybrid(lmp) {}
61
62 /* ----------------------------------------------------------------------
63 set coeffs for one or more type pairs
64 ------------------------------------------------------------------------- */
65
coeff(int narg,char ** arg)66 void PairHybridOverlay::coeff(int narg, char **arg)
67 {
68 if (narg < 3) error->all(FLERR,"Incorrect args for pair coefficients");
69 if (!allocated) allocate();
70
71 int ilo,ihi,jlo,jhi;
72 force->bounds(arg[0],atom->ntypes,ilo,ihi);
73 force->bounds(arg[1],atom->ntypes,jlo,jhi);
74
75 // 3rd arg = pair sub-style name
76 // 4th arg = pair sub-style index if name used multiple times
77 // allow for "none" as valid sub-style name
78
79 int multflag = 0;
80 int m;
81
82 for (m = 0; m < nstyles; m++) {
83 multflag = 0;
84 if (strcmp(arg[2],keywords[m]) == 0) {
85 if (multiple[m]) {
86 multflag = 1;
87 if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients");
88 if (!isdigit(arg[3][0]))
89 error->all(FLERR,"Incorrect args for pair coefficients");
90 int index = force->inumeric(FLERR,arg[3]);
91 if (index == multiple[m]) break;
92 else continue;
93 } else break;
94 }
95 }
96
97 int none = 0;
98 if (m == nstyles) {
99 if (strcmp(arg[2],"none") == 0) none = 1;
100 else error->all(FLERR,"Pair coeff for hybrid has invalid style");
101 }
102
103 // move 1st/2nd args to 2nd/3rd args
104 // if multflag: move 1st/2nd args to 3rd/4th args
105 // just copy ptrs, since arg[] points into original input line
106
107 arg[2+multflag] = arg[1];
108 arg[1+multflag] = arg[0];
109
110 // invoke sub-style coeff() starting with 1st remaining arg
111
112 if (!none) styles[m]->coeff(narg-1-multflag,&arg[1+multflag]);
113
114 // set setflag and which type pairs map to which sub-style
115 // if sub-style is none: set hybrid subflag, wipe out map
116 // else: set hybrid setflag & map only if substyle setflag is set
117 // if sub-style is new for type pair, add as multiple mapping
118 // if sub-style exists for type pair, don't add, just update coeffs
119
120 int count = 0;
121 for (int i = ilo; i <= ihi; i++) {
122 for (int j = MAX(jlo,i); j <= jhi; j++) {
123 if (none) {
124 setflag[i][j] = 1;
125 nmap[i][j] = 0;
126 count++;
127 } else if (styles[m]->setflag[i][j]) {
128 int k;
129 for (k = 0; k < nmap[i][j]; k++)
130 if (map[i][j][k] == m) break;
131 if (k == nmap[i][j]) map[i][j][nmap[i][j]++] = m;
132 setflag[i][j] = 1;
133 count++;
134 }
135 }
136 }
137
138 if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
139 }
140
141 /* ----------------------------------------------------------------------
142 combine sub-style neigh list requests and create new ones if needed
143 ------------------------------------------------------------------------- */
144
modify_requests()145 void PairHybridOverlay::modify_requests()
146 {
147 int i,j;
148 NeighRequest *irq,*jrq;
149
150 // loop over pair requests only
151 // if a previous list is same kind with same skip attributes
152 // then make this one a copy list of that one
153 // works whether both lists are no-skip or yes-skip
154 // will not point a list at a copy list, but at copy list's parent
155
156 for (i = 0; i < neighbor->nrequest; i++) {
157 if (!neighbor->requests[i]->pair) continue;
158
159 irq = neighbor->requests[i];
160 for (j = 0; j < i; j++) {
161 if (!neighbor->requests[j]->pair) continue;
162 jrq = neighbor->requests[j];
163 if (irq->same_kind(jrq) && irq->same_skip(jrq)) {
164 irq->copy = 1;
165 irq->otherlist = j;
166 break;
167 }
168 }
169 }
170
171 // perform same operations on skip lists as pair style = hybrid
172
173 PairHybrid::modify_requests();
174 }
175