47
47
#define CUDA_CHUNK 3000
48
48
#define MAXBODY 20 // max # of lines in one body, also in ReadData class
50
enum{LAYOUT_UNIFORM,LAYOUT_NONUNIFORM,LAYOUT_TILED}; // several files
50
52
/* ---------------------------------------------------------------------- */
52
54
Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
80
82
omega = angmom = torque = NULL;
81
83
radius = rmass = NULL;
84
ellipsoid = line = tri = body = NULL;
84
ellipsoid = line = tri = body = NULL;
86
90
eradius = ervel = erforce = NULL;
87
91
cs = csforce = vforce = ervelforce = NULL;
94
rho = drho = e = de = cv = NULL;
94
97
bond_per_atom = extra_bond_per_atom = 0;
130
133
// initialize atom style and array existence flags
131
134
// customize by adding new flag
133
sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
134
peri_flag = electron_flag = 0;
136
sphere_flag = peri_flag = electron_flag = 0;
135
137
wavepacket_flag = sph_flag = 0;
137
molecule_flag = q_flag = mu_flag = 0;
138
rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0;
139
vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0;
140
cs_flag = csforce_flag = vforce_flag = ervelforce_flag= etag_flag = 0;
140
q_flag = mu_flag = 0;
141
omega_flag = torque_flag = angmom_flag = 0;
142
radius_flag = rmass_flag = 0;
143
ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
146
spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
147
cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
141
149
rho_flag = e_flag = cv_flag = vest_flag = 0;
143
151
// Peridynamic scale factor
207
219
memory->destroy(torque);
208
220
memory->destroy(radius);
209
221
memory->destroy(rmass);
210
memory->destroy(vfrac);
213
222
memory->destroy(ellipsoid);
214
223
memory->destroy(line);
215
224
memory->destroy(tri);
216
225
memory->destroy(body);
227
memory->destroy(vfrac);
217
231
memory->destroy(spin);
218
232
memory->destroy(eradius);
219
233
memory->destroy(ervel);
220
234
memory->destroy(erforce);
235
memory->destroy(ervelforce);
237
memory->destroy(csforce);
238
memory->destroy(vforce);
239
memory->destroy(etag);
222
memory->destroy(molecule);
223
memory->destroy(molindex);
224
memory->destroy(molatom);
241
memory->destroy(rho);
242
memory->destroy(drho);
246
memory->destroy(vest);
226
248
memory->destroy(nspecial);
227
249
memory->destroy(special);
250
272
memory->destroy(improper_atom3);
251
273
memory->destroy(improper_atom4);
253
// delete user-defined molecules
255
for (int i = 0; i < nmolecule; i++) delete molecules[i];
256
memory->sfree(molecules);
258
275
// delete custom atom arrays
260
277
for (int i = 0; i < nivector; i++) {
311
333
called from lammps.cpp, input script, restart file, replicate
312
334
------------------------------------------------------------------------- */
314
void Atom::create_avec(const char *style, int narg, char **arg, char *suffix)
336
void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix)
316
338
delete [] atom_style;
317
339
if (avec) delete avec;
320
342
// may have been set by old avec
321
343
// customize by adding new flag
323
sphere_flag = ellipsoid_flag = line_flag = tri_flag = 0;
324
peri_flag = electron_flag = 0;
326
molecule_flag = q_flag = mu_flag = 0;
327
rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0;
328
vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0;
345
sphere_flag = peri_flag = electron_flag = 0;
346
wavepacket_flag = sph_flag = 0;
349
q_flag = mu_flag = 0;
350
omega_flag = torque_flag = angmom_flag = 0;
351
radius_flag = rmass_flag = 0;
352
ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
355
spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
356
cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
358
rho_flag = e_flag = cv_flag = vest_flag = 0;
330
360
// create instance of AtomVec
331
361
// use grow() to initialize atom-based arrays to length 1
332
362
// so that x[0][0] can always be referenced even if proc has no atoms
335
avec = new_avec(style,suffix,sflag);
365
avec = new_avec(style,trysuffix,sflag);
336
366
avec->store_args(narg,arg);
337
367
avec->process_args(narg,arg);
341
371
char estyle[256];
342
sprintf(estyle,"%s/%s",style,suffix);
372
if (sflag == 1) sprintf(estyle,"%s/%s",style,lmp->suffix);
373
else sprintf(estyle,"%s/%s",style,lmp->suffix2);
343
374
int n = strlen(estyle) + 1;
344
375
atom_style = new char[n];
345
376
strcpy(atom_style,estyle);
364
395
generate an AtomVec class, first with suffix appended
365
396
------------------------------------------------------------------------- */
367
AtomVec *Atom::new_avec(const char *style, char *suffix, int &sflag)
398
AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag)
369
if (suffix && lmp->suffix_enable) {
372
sprintf(estyle,"%s/%s",style,suffix);
377
#define AtomStyle(key,Class) \
378
else if (strcmp(estyle,#key) == 0) return new Class(lmp);
379
#include "style_atom.h"
400
if (trysuffix && lmp->suffix_enable) {
404
sprintf(estyle,"%s/%s",style,lmp->suffix);
409
#define AtomStyle(key,Class) \
410
else if (strcmp(estyle,#key) == 0) return new Class(lmp);
411
#include "style_atom.h"
419
sprintf(estyle,"%s/%s",style,lmp->suffix2);
424
#define AtomStyle(key,Class) \
425
else if (strcmp(estyle,#key) == 0) return new Class(lmp);
426
#include "style_atom.h"
387
433
if (0) return NULL;
389
435
#define ATOM_CLASS
474
519
else if (strcmp(arg[iarg+1],"no") == 0) tag_enable = 2;
475
520
else error->all(FLERR,"Illegal atom_modify command");
477
} if (strcmp(arg[iarg],"map") == 0) {
522
} else if (strcmp(arg[iarg],"map") == 0) {
478
523
if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command");
479
524
if (domain->box_exist)
480
525
error->all(FLERR,
725
770
sublo[2] = domain->sublo_lamda[2]; subhi[2] = domain->subhi_lamda[2];
728
if (domain->xperiodic) {
729
if (comm->myloc[0] == 0) sublo[0] -= epsilon[0];
730
if (comm->myloc[0] == comm->procgrid[0]-1) subhi[0] += epsilon[0];
732
if (domain->yperiodic) {
733
if (comm->myloc[1] == 0) sublo[1] -= epsilon[1];
734
if (comm->myloc[1] == comm->procgrid[1]-1) subhi[1] += epsilon[1];
736
if (domain->zperiodic) {
737
if (comm->myloc[2] == 0) sublo[2] -= epsilon[2];
738
if (comm->myloc[2] == comm->procgrid[2]-1) subhi[2] += epsilon[2];
773
if (comm->layout != LAYOUT_TILED) {
774
if (domain->xperiodic) {
775
if (comm->myloc[0] == 0) sublo[0] -= epsilon[0];
776
if (comm->myloc[0] == comm->procgrid[0]-1) subhi[0] += epsilon[0];
778
if (domain->yperiodic) {
779
if (comm->myloc[1] == 0) sublo[1] -= epsilon[1];
780
if (comm->myloc[1] == comm->procgrid[1]-1) subhi[1] += epsilon[1];
782
if (domain->zperiodic) {
783
if (comm->myloc[2] == 0) sublo[2] -= epsilon[2];
784
if (comm->myloc[2] == comm->procgrid[2]-1) subhi[2] += epsilon[2];
788
if (domain->xperiodic) {
789
if (comm->mysplit[0][0] == 0.0) sublo[0] -= epsilon[0];
790
if (comm->mysplit[0][1] == 1.0) subhi[0] += epsilon[0];
792
if (domain->yperiodic) {
793
if (comm->mysplit[1][0] == 0.0) sublo[1] -= epsilon[1];
794
if (comm->mysplit[1][1] == 1.0) subhi[1] += epsilon[1];
796
if (domain->zperiodic) {
797
if (comm->mysplit[2][0] == 0.0) sublo[2] -= epsilon[2];
798
if (comm->mysplit[2][1] == 1.0) subhi[2] += epsilon[2];
741
802
// xptr = which word in line starts xyz coords
1867
1928
if (strcmp(name,"q") == 0) return (void *) q;
1868
1929
if (strcmp(name,"mu") == 0) return (void *) mu;
1869
1930
if (strcmp(name,"omega") == 0) return (void *) omega;
1870
if (strcmp(name,"amgmom") == 0) return (void *) angmom;
1931
if (strcmp(name,"angmom") == 0) return (void *) angmom;
1871
1932
if (strcmp(name,"torque") == 0) return (void *) torque;
1872
1933
if (strcmp(name,"radius") == 0) return (void *) radius;
1873
1934
if (strcmp(name,"rmass") == 0) return (void *) rmass;
1935
if (strcmp(name,"ellipsoid") == 0) return (void *) ellipsoid;
1936
if (strcmp(name,"line") == 0) return (void *) line;
1937
if (strcmp(name,"tri") == 0) return (void *) tri;
1874
1939
if (strcmp(name,"vfrac") == 0) return (void *) vfrac;
1875
1940
if (strcmp(name,"s0") == 0) return (void *) s0;
1941
if (strcmp(name,"x0") == 0) return (void *) x0;
1943
if (strcmp(name,"spin") == 0) return (void *) spin;
1944
if (strcmp(name,"eradius") == 0) return (void *) eradius;
1945
if (strcmp(name,"ervel") == 0) return (void *) ervel;
1946
if (strcmp(name,"erforce") == 0) return (void *) erforce;
1947
if (strcmp(name,"ervelforce") == 0) return (void *) ervelforce;
1948
if (strcmp(name,"cs") == 0) return (void *) cs;
1949
if (strcmp(name,"csforce") == 0) return (void *) csforce;
1950
if (strcmp(name,"vforce") == 0) return (void *) vforce;
1951
if (strcmp(name,"etag") == 0) return (void *) etag;
1953
if (strcmp(name,"rho") == 0) return (void *) rho;
1954
if (strcmp(name,"drho") == 0) return (void *) drho;
1955
if (strcmp(name,"e") == 0) return (void *) e;
1956
if (strcmp(name,"de") == 0) return (void *) de;
1957
if (strcmp(name,"cv") == 0) return (void *) cv;
1958
if (strcmp(name,"vest") == 0) return (void *) vest;