~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to src/atom.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-04-29 23:44:49 UTC
  • mfrom: (5.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20150429234449-mbhy9utku6hp6oq8
Tags: 0~20150313.gitfa668e1-1
Upload into unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#define CUDA_CHUNK 3000
48
48
#define MAXBODY 20       // max # of lines in one body, also in ReadData class
49
49
 
 
50
enum{LAYOUT_UNIFORM,LAYOUT_NONUNIFORM,LAYOUT_TILED};    // several files
 
51
 
50
52
/* ---------------------------------------------------------------------- */
51
53
 
52
54
Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
79
81
  mu = NULL;
80
82
  omega = angmom = torque = NULL;
81
83
  radius = rmass = NULL;
 
84
  ellipsoid = line = tri = body = NULL;
 
85
 
82
86
  vfrac = s0 = NULL;
83
87
  x0 = NULL;
84
 
  ellipsoid = line = tri = body = NULL;
 
88
 
85
89
  spin = NULL;
86
90
  eradius = ervel = erforce = NULL;
87
91
  cs = csforce = vforce = ervelforce = NULL;
88
92
  etag = NULL;
89
 
  rho = drho = NULL;
90
 
  e = de = NULL;
91
 
  cv = NULL;
 
93
 
 
94
  rho = drho = e = de = cv = NULL;
92
95
  vest = NULL;
93
96
 
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
132
135
 
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;
136
138
 
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;
 
139
  molecule_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;
 
144
 
 
145
  vfrac_flag = 0;
 
146
  spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
 
147
  cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
 
148
 
141
149
  rho_flag = e_flag = cv_flag = vest_flag = 0;
142
150
 
143
151
  // Peridynamic scale factor
200
208
  memory->destroy(v);
201
209
  memory->destroy(f);
202
210
 
 
211
  memory->destroy(molecule);
 
212
  memory->destroy(molindex);
 
213
  memory->destroy(molatom);
 
214
 
203
215
  memory->destroy(q);
204
216
  memory->destroy(mu);
205
217
  memory->destroy(omega);
207
219
  memory->destroy(torque);
208
220
  memory->destroy(radius);
209
221
  memory->destroy(rmass);
210
 
  memory->destroy(vfrac);
211
 
  memory->destroy(s0);
212
 
  memory->destroy(x0);
213
222
  memory->destroy(ellipsoid);
214
223
  memory->destroy(line);
215
224
  memory->destroy(tri);
216
225
  memory->destroy(body);
 
226
 
 
227
  memory->destroy(vfrac);
 
228
  memory->destroy(s0);
 
229
  memory->destroy(x0);
 
230
 
217
231
  memory->destroy(spin);
218
232
  memory->destroy(eradius);
219
233
  memory->destroy(ervel);
220
234
  memory->destroy(erforce);
 
235
  memory->destroy(ervelforce);
 
236
  memory->destroy(cs);
 
237
  memory->destroy(csforce);
 
238
  memory->destroy(vforce);
 
239
  memory->destroy(etag);
221
240
 
222
 
  memory->destroy(molecule);
223
 
  memory->destroy(molindex);
224
 
  memory->destroy(molatom);
 
241
  memory->destroy(rho);
 
242
  memory->destroy(drho);
 
243
  memory->destroy(e);
 
244
  memory->destroy(de);
 
245
  memory->destroy(cv);
 
246
  memory->destroy(vest);
225
247
 
226
248
  memory->destroy(nspecial);
227
249
  memory->destroy(special);
250
272
  memory->destroy(improper_atom3);
251
273
  memory->destroy(improper_atom4);
252
274
 
253
 
  // delete user-defined molecules
254
 
 
255
 
  for (int i = 0; i < nmolecule; i++) delete molecules[i];
256
 
  memory->sfree(molecules);
257
 
 
258
275
  // delete custom atom arrays
259
276
 
260
277
  for (int i = 0; i < nivector; i++) {
271
288
  memory->sfree(ivector);
272
289
  memory->sfree(dvector);
273
290
 
 
291
  // delete user-defined molecules
 
292
 
 
293
  for (int i = 0; i < nmolecule; i++) delete molecules[i];
 
294
  memory->sfree(molecules);
 
295
 
274
296
  // delete per-type arrays
275
297
 
276
298
  delete [] mass;
311
333
   called from lammps.cpp, input script, restart file, replicate
312
334
------------------------------------------------------------------------- */
313
335
 
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)
315
337
{
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
322
344
 
323
 
  sphere_flag = ellipsoid_flag = line_flag = tri_flag = 0;
324
 
  peri_flag = electron_flag = 0;
325
 
 
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;
 
347
 
 
348
  molecule_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;
 
353
 
 
354
  vfrac_flag = 0;
 
355
  spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
 
356
  cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
 
357
 
 
358
  rho_flag = e_flag = cv_flag = vest_flag = 0;
329
359
 
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
333
363
 
334
364
  int sflag;
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);
338
368
  avec->grow(1);
339
369
 
340
370
  if (sflag) {
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
------------------------------------------------------------------------- */
366
397
 
367
 
AtomVec *Atom::new_avec(const char *style, char *suffix, int &sflag)
 
398
AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag)
368
399
{
369
 
  if (suffix && lmp->suffix_enable) {
370
 
    sflag = 1;
371
 
    char estyle[256];
372
 
    sprintf(estyle,"%s/%s",style,suffix);
373
 
 
374
 
    if (0) return NULL;
375
 
 
376
 
#define ATOM_CLASS
377
 
#define AtomStyle(key,Class) \
378
 
    else if (strcmp(estyle,#key) == 0) return new Class(lmp);
379
 
#include "style_atom.h"
380
 
#undef AtomStyle
381
 
#undef ATOM_CLASS
382
 
 
 
400
  if (trysuffix && lmp->suffix_enable) {
 
401
    if (lmp->suffix) {
 
402
      sflag = 1;
 
403
      char estyle[256];
 
404
      sprintf(estyle,"%s/%s",style,lmp->suffix);
 
405
 
 
406
      if (0) return NULL;
 
407
 
 
408
#define ATOM_CLASS
 
409
#define AtomStyle(key,Class) \
 
410
      else if (strcmp(estyle,#key) == 0) return new Class(lmp);
 
411
#include "style_atom.h"
 
412
#undef AtomStyle
 
413
#undef ATOM_CLASS
 
414
    }
 
415
 
 
416
    if (lmp->suffix2) {
 
417
      sflag = 2;
 
418
      char estyle[256];
 
419
      sprintf(estyle,"%s/%s",style,lmp->suffix2);
 
420
 
 
421
      if (0) return NULL;
 
422
 
 
423
#define ATOM_CLASS
 
424
#define AtomStyle(key,Class) \
 
425
      else if (strcmp(estyle,#key) == 0) return new Class(lmp);
 
426
#include "style_atom.h"
 
427
#undef AtomStyle
 
428
#undef ATOM_CLASS
 
429
    }
383
430
  }
384
431
 
385
432
  sflag = 0;
386
 
 
387
433
  if (0) return NULL;
388
434
 
389
435
#define ATOM_CLASS
392
438
#include "style_atom.h"
393
439
#undef ATOM_CLASS
394
440
 
395
 
  else error->all(FLERR,"Invalid atom style");
396
 
 
 
441
  else error->all(FLERR,"Unknown atom style");
397
442
  return NULL;
398
443
}
399
444
 
474
519
      else if (strcmp(arg[iarg+1],"no") == 0) tag_enable = 2;
475
520
      else error->all(FLERR,"Illegal atom_modify command");
476
521
      iarg += 2;
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];
726
771
  }
727
772
 
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];
731
 
  }
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];
735
 
  }
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];
 
777
    }
 
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];
 
781
    }
 
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];
 
785
    }
 
786
 
 
787
  } else {
 
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];
 
791
    }
 
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];
 
795
    }
 
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];
 
799
    }
739
800
  }
740
801
 
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;
 
1938
 
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;
 
1942
 
 
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;
 
1952
 
 
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;
1876
1959
 
1877
1960
  return NULL;
1878
1961
}