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

« back to all changes in this revision

Viewing changes to src/MANYBODY/pair_airebo.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2013-11-20 22:41:36 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20131120224136-tzx7leh606fqnckm
Tags: 0~20131119.git7162cf0-1
* [e65b919] Imported Upstream version 0~20131119.git7162cf0
* [f7bddd4] Fix some problems, introduced by upstream recently.
* [3616dfc] Use wrap-and-sort script.
* [7e92030] Ignore quilt dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "neighbor.h"
32
32
#include "neigh_list.h"
33
33
#include "neigh_request.h"
 
34
#include "my_page.h"
34
35
#include "math_const.h"
35
36
#include "math_special.h"
36
37
#include "memory.h"
55
56
  maxlocal = 0;
56
57
  REBO_numneigh = NULL;
57
58
  REBO_firstneigh = NULL;
58
 
  maxpage = 0;
59
 
  pages = NULL;
 
59
  ipage = NULL;
 
60
  pgsize = oneatom = 0;
 
61
 
60
62
  nC = nH = NULL;
 
63
  manybody_flag = 1;
61
64
}
62
65
 
63
66
/* ----------------------------------------------------------------------
68
71
{
69
72
  memory->destroy(REBO_numneigh);
70
73
  memory->sfree(REBO_firstneigh);
71
 
  for (int i = 0; i < maxpage; i++) memory->destroy(pages[i]);
72
 
  memory->sfree(pages);
 
74
  delete [] ipage;
73
75
  memory->destroy(nC);
74
76
  memory->destroy(nH);
75
77
 
138
140
{
139
141
  if (narg != 1 && narg != 3) error->all(FLERR,"Illegal pair_style command");
140
142
 
141
 
  cutlj = force->numeric(arg[0]);
 
143
  cutlj = force->numeric(FLERR,arg[0]);
142
144
 
143
145
  ljflag = torflag = 1;
144
146
  if (narg == 3) {
145
 
    ljflag = force->inumeric(arg[1]);
146
 
    torflag = force->inumeric(arg[2]);
 
147
    ljflag = force->inumeric(FLERR,arg[1]);
 
148
    torflag = force->inumeric(FLERR,arg[2]);
147
149
  }
148
150
}
149
151
 
220
222
  neighbor->requests[irequest]->full = 1;
221
223
  neighbor->requests[irequest]->ghost = 1;
222
224
 
223
 
  // local REBO neighbor list memory
224
 
 
225
 
  pgsize = neighbor->pgsize;
226
 
  oneatom = neighbor->oneatom;
227
 
  if (maxpage == 0) add_pages();
 
225
  // local REBO neighbor list
 
226
  // create pages if first time or if neighbor pgsize/oneatom has changed
 
227
 
 
228
  int create = 0;
 
229
  if (ipage == NULL) create = 1;
 
230
  if (pgsize != neighbor->pgsize) create = 1;
 
231
  if (oneatom != neighbor->oneatom) create = 1;
 
232
 
 
233
  if (create) {
 
234
    delete [] ipage;
 
235
    pgsize = neighbor->pgsize;
 
236
    oneatom = neighbor->oneatom;
 
237
 
 
238
    int nmypage= comm->nthreads;
 
239
    ipage = new MyPage<int>[nmypage];
 
240
    for (int i = 0; i < nmypage; i++)
 
241
      ipage[i].init(oneatom,pgsize,PGDELTA);
 
242
  }
228
243
}
229
244
 
230
245
/* ----------------------------------------------------------------------
328
343
  // store all REBO neighs of owned and ghost atoms
329
344
  // scan full neighbor list of I
330
345
 
331
 
  int npage = 0;
332
 
  int npnt = 0;
 
346
  ipage->reset();
333
347
 
334
348
  for (ii = 0; ii < allnum; ii++) {
335
349
    i = ilist[ii];
336
350
 
337
 
    if (pgsize - npnt < oneatom) {
338
 
      npnt = 0;
339
 
      npage++;
340
 
      if (npage == maxpage) add_pages();
341
 
    }
342
 
    neighptr = &pages[npage][npnt];
343
351
    n = 0;
 
352
    neighptr = ipage->vget();
344
353
 
345
354
    xtmp = x[i][0];
346
355
    ytmp = x[i][1];
370
379
 
371
380
    REBO_firstneigh[i] = neighptr;
372
381
    REBO_numneigh[i] = n;
373
 
    npnt += n;
374
 
    if (npnt >= pgsize)
375
 
      error->one(FLERR,
376
 
                 "Neighbor list overflow, boost neigh_modify one or page");
 
382
    ipage->vgot(n);
 
383
    if (ipage->status())
 
384
      error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
377
385
  }
378
386
}
379
387
 
3285
3293
}
3286
3294
 
3287
3295
/* ----------------------------------------------------------------------
3288
 
   add pages to REBO neighbor list
3289
 
------------------------------------------------------------------------- */
3290
 
 
3291
 
void PairAIREBO::add_pages(int howmany)
3292
 
{
3293
 
  int toppage = maxpage;
3294
 
  maxpage += howmany*PGDELTA;
3295
 
 
3296
 
  pages = (int **)
3297
 
    memory->srealloc(pages,maxpage*sizeof(int *),"AIREBO:pages");
3298
 
  for (int i = toppage; i < maxpage; i++)
3299
 
    memory->create(pages[i],pgsize,"AIREBO:pages[i]");
3300
 
}
3301
 
 
3302
 
/* ----------------------------------------------------------------------
3303
3296
   read AIREBO potential file
3304
3297
------------------------------------------------------------------------- */
3305
3298
 
3332
3325
  // read file on proc 0
3333
3326
 
3334
3327
  if (me == 0) {
3335
 
    FILE *fp = fopen(filename,"r");
 
3328
    FILE *fp = open_potential(filename);
3336
3329
    if (fp == NULL) {
3337
3330
      char str[128];
3338
3331
      sprintf(str,"Cannot open AIREBO potential file %s",filename);
4198
4191
  double bytes = 0.0;
4199
4192
  bytes += maxlocal * sizeof(int);
4200
4193
  bytes += maxlocal * sizeof(int *);
4201
 
  bytes += maxpage * neighbor->pgsize * sizeof(int);
4202
 
  bytes += 3 * maxlocal * sizeof(double);
 
4194
 
 
4195
  for (int i = 0; i < comm->nthreads; i++)
 
4196
    bytes += ipage[i].size();
 
4197
  
 
4198
  bytes += 2*maxlocal * sizeof(double);
4203
4199
  return bytes;
4204
4200
}