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

« back to all changes in this revision

Viewing changes to src/MANYBODY/pair_comb.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 "neigh_request.h"
32
32
#include "group.h"
33
33
#include "update.h"
 
34
#include "my_page.h"
34
35
#include "math_const.h"
35
36
#include "memory.h"
36
37
#include "error.h"
50
51
  single_enable = 0;
51
52
  restartinfo = 0;
52
53
  one_coeff = 1;
 
54
  manybody_flag = 1;
53
55
 
54
56
  nmax = 0;
55
57
  NCo = NULL;
69
71
  phin = NULL;
70
72
  dphin = NULL;
71
73
  erpaw = NULL;
72
 
 
 
74
  
73
75
  sht_num = NULL;
74
76
  sht_first = NULL;
75
 
  maxpage = 0;
76
 
  pages = NULL;
 
77
 
 
78
  ipage = NULL;
 
79
  pgsize = oneatom = 0;
77
80
 
78
81
  // set comm size needed by this Pair
79
82
 
105
108
  memory->destroy(erpaw);
106
109
  memory->destroy(bbij);
107
110
  memory->destroy(sht_num);
108
 
  memory->destroy(sht_first);
 
111
  memory->sfree(sht_first);
 
112
 
 
113
  delete [] ipage;
109
114
 
110
115
  if (allocated) {
111
116
    memory->destroy(setflag);
540
545
  neighbor->requests[irequest]->half = 0;
541
546
  neighbor->requests[irequest]->full = 1;
542
547
 
543
 
  pgsize = neighbor->pgsize;
544
 
  oneatom = neighbor->oneatom;
545
 
  if (maxpage == 0) add_pages();
 
548
  // local Comb neighbor list
 
549
  // create pages if first time or if neighbor pgsize/oneatom has changed
 
550
 
 
551
  int create = 0;
 
552
  if (ipage == NULL) create = 1;
 
553
  if (pgsize != neighbor->pgsize) create = 1;
 
554
  if (oneatom != neighbor->oneatom) create = 1;
 
555
 
 
556
  if (create) {
 
557
    delete [] ipage;
 
558
    pgsize = neighbor->pgsize;
 
559
    oneatom = neighbor->oneatom;
 
560
 
 
561
    int nmypage = comm->nthreads;
 
562
    ipage = new MyPage<int>[nmypage];
 
563
    for (int i = 0; i < nmypage; i++)
 
564
      ipage[i].init(oneatom,pgsize);
 
565
  }
546
566
}
547
567
 
548
568
/* ----------------------------------------------------------------------
571
591
 
572
592
  FILE *fp;
573
593
  if (comm->me == 0) {
574
 
    fp = fopen(file,"r");
 
594
    fp = open_potential(file);
575
595
    if (fp == NULL) {
576
596
      char str[128];
577
597
      sprintf(str,"Cannot open COMB potential file %s",file);
1363
1383
  memory->create(NCo,nmax,"pair:NCo");
1364
1384
  memory->create(bbij,nmax,MAXNEIGH,"pair:bbij");
1365
1385
  memory->create(sht_num,nmax,"pair:sht_num");
1366
 
  sht_first = (int **) memory->smalloc(nmax*sizeof(int *),
1367
 
            "pair:sht_first");
 
1386
  sht_first = (int **) memory->smalloc(nmax*sizeof(int *),"pair:sht_first");
1368
1387
 
1369
1388
  // set interaction number: 0-0=0, 1-1=1, 0-1=1-0=2
1370
1389
 
2022
2041
  }
2023
2042
}
2024
2043
 
2025
 
/* ----------------------------------------------------------------------
2026
 
   memory usage of local atom-based arrays
2027
 
------------------------------------------------------------------------- */
2028
 
 
2029
 
double PairComb::memory_usage()
2030
 
{
2031
 
  double bytes = maxeatom * sizeof(double);
2032
 
  bytes += maxvatom*6 * sizeof(double);
2033
 
  bytes += nmax * sizeof(int);
2034
 
  bytes += MAXNEIGH * nmax * sizeof(int);
2035
 
  return bytes;
2036
 
}
2037
2044
/* ---------------------------------------------------------------------- */
2038
2045
 
2039
2046
void PairComb::Short_neigh()
2063
2070
  ilist = list->ilist;
2064
2071
  numneigh = list->numneigh;
2065
2072
  firstneigh = list->firstneigh;
2066
 
  int npntj = 0;
2067
 
  int npage = 0;
 
2073
 
 
2074
  // create Comb neighbor list
 
2075
 
 
2076
  ipage->reset();
2068
2077
 
2069
2078
  for (ii = 0; ii < inum; ii++) {
2070
2079
    i = ilist[ii];
2071
2080
    itype = type[i];
2072
2081
 
2073
 
    if (pgsize - npntj < oneatom) {
2074
 
      npntj = 0;
2075
 
      npage++;
2076
 
      if (npage == maxpage) add_pages();
2077
 
    }
2078
 
 
2079
2082
    nj = 0;
2080
 
    neighptrj = &pages[npage][npntj];
 
2083
    neighptrj = ipage->vget();
2081
2084
 
2082
2085
    xtmp = x[i][0];
2083
2086
    ytmp = x[i][1];
2102
2105
 
2103
2106
    sht_first[i] = neighptrj;
2104
2107
    sht_num[i] = nj;
2105
 
    npntj += nj;
 
2108
    ipage->vgot(nj);
 
2109
    if (ipage->status())
 
2110
      error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
2106
2111
  }
2107
2112
}
2108
2113
 
2109
 
/* ---------------------------------------------------------------------- */
 
2114
/* ----------------------------------------------------------------------
 
2115
   memory usage of local atom-based arrays
 
2116
------------------------------------------------------------------------- */
2110
2117
 
2111
 
void PairComb::add_pages(int howmany)
 
2118
double PairComb::memory_usage()
2112
2119
{
2113
 
  int toppage = maxpage;
2114
 
  maxpage += howmany*PGDELTA;
2115
 
 
2116
 
  pages = (int **)
2117
 
    memory->srealloc(pages,maxpage*sizeof(int *),"pair:pages");
2118
 
  for (int i = toppage; i < maxpage; i++)
2119
 
    memory->create(pages[i],pgsize,"pair:pages[i]");
 
2120
  double bytes = maxeatom * sizeof(double);
 
2121
  bytes += maxvatom*6 * sizeof(double);
 
2122
  bytes += nmax * sizeof(int);
 
2123
  bytes += nmax * sizeof(int *);
 
2124
 
 
2125
  for (int i = 0; i < comm->nthreads; i++)
 
2126
    bytes += ipage[i].size();
 
2127
 
 
2128
  bytes += nmax * sizeof(int);
 
2129
  bytes += MAXNEIGH*nmax * sizeof(double);
 
2130
  return bytes;
2120
2131
}