NAMD
Macros | Typedefs | Functions
HomePatch.C File Reference
#include "NamdTypes.h"
#include "common.h"
#include "time.h"
#include <math.h>
#include "charm++.h"
#include "qd.h"
#include "SimParameters.h"
#include "HomePatch.h"
#include "AtomMap.h"
#include "Node.h"
#include "PatchMap.inl"
#include "main.h"
#include "ProxyMgr.decl.h"
#include "ProxyMgr.h"
#include "Migration.h"
#include "Molecule.h"
#include "PatchMgr.h"
#include "Sequencer.h"
#include "Broadcasts.h"
#include "LdbCoordinator.h"
#include "ReductionMgr.h"
#include "Sync.h"
#include "Random.h"
#include "Priorities.h"
#include "ComputeNonbondedUtil.h"
#include "ComputeGBIS.inl"
#include "SortAtoms.h"
#include "MigrationCUDAKernel.h"
#include "ComputeQM.h"
#include "ComputeQMMgr.decl.h"
#include "NamdEventsProfiling.h"
#include "Debug.h"
#include <vector>
#include <algorithm>

Go to the source code of this file.

Macros

#define TINY   1.0e-20;
 
#define MAXHGS   10
 
#define MIN_DEBUG_LEVEL   2
 
#define MASS_EPSILON   (1.0e-35)
 
#define FIX_FOR_WATER
 

Typedefs

typedef int HGArrayInt[MAXHGS]
 
typedef BigReal HGArrayBigReal[MAXHGS]
 
typedef zVector HGArrayVector[MAXHGS]
 
typedef BigReal HGMatrixBigReal[MAXHGS][MAXHGS]
 
typedef zVector HGMatrixVector[MAXHGS][MAXHGS]
 

Functions

int average (CompAtom *qtilde, const HGArrayVector &q, BigReal *lambda, const int n, const int m, const HGArrayBigReal &imass, const HGArrayBigReal &length2, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab, const BigReal tolf, const int ntrial)
 
void mollify (CompAtom *qtilde, const HGArrayVector &q0, const BigReal *lambda, HGArrayVector &force, const int n, const int m, const HGArrayBigReal &imass, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab)
 
void MSHAKE_CUDA (int *, const int size, const RattleParam *rattleParam, BigReal *refx, BigReal *refy, BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, const BigReal tol2, const int maxiter, bool &done, bool &consFailure)
 
static int compDistance (const void *a, const void *b)
 
void PatchDataSOA_initialize (PatchDataSOA *p)
 
size_t PatchDataSOA_set_size (PatchDataSOA *p, int natoms, int padding)
 
void PatchDataSOA_set_buffer (PatchDataSOA *p, void *mybuffer)
 
void lubksb (HGMatrixBigReal &a, int n, HGArrayInt &indx, HGArrayBigReal &b)
 
void ludcmp (HGMatrixBigReal &a, int n, HGArrayInt &indx, BigReal *d)
 
void G_q (const HGArrayVector &refab, HGMatrixVector &gqij, const int n, const int m, const HGArrayInt &ial, const HGArrayInt &ibl)
 

Macro Definition Documentation

◆ FIX_FOR_WATER

#define FIX_FOR_WATER

Redistribute forces from lone pair site onto its host atoms.

Atoms are "labeled" i, j, k, l, where atom i is the lone pair. Positions of atoms are ri, rj, rk, rl. Forces of atoms are fi, fj, fk, fl; updated forces are returned. Accumulate updates to the virial.

The forces on the atoms are updated so that:

  • the force fi on the lone pair site is 0
  • the net force fi+fj+fk+fl is conserved
  • the net torque cross(ri,fi)+cross(rj,fj)+cross(rk,fk)+cross(rl,fl) is conserved

If "midpt" is true (nonzero), then use the midpoint of rk and rl (e.g. rk and rl are the hydrogen atoms for water). Otherwise use planes defined by ri,rj,rk and rj,rk,rl.

Having "midpt" set true corresponds in CHARMM to having a negative distance parameter in Lphost.

Use FIX_FOR_WATER below to fix the case that occurs when the lone pair site for water lies on the perpendicular bisector of rk and rl, making the cross(r,s) zero.

Definition at line 2787 of file HomePatch.C.

◆ MASS_EPSILON

#define MASS_EPSILON   (1.0e-35)

Definition at line 80 of file HomePatch.C.

◆ MAXHGS

#define MAXHGS   10

Definition at line 55 of file HomePatch.C.

◆ MIN_DEBUG_LEVEL

#define MIN_DEBUG_LEVEL   2

Definition at line 56 of file HomePatch.C.

◆ TINY

#define TINY   1.0e-20;

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 54 of file HomePatch.C.

Referenced by ludcmp().

Typedef Documentation

◆ HGArrayBigReal

typedef BigReal HGArrayBigReal[MAXHGS]

Definition at line 66 of file HomePatch.C.

◆ HGArrayInt

typedef int HGArrayInt[MAXHGS]

Definition at line 65 of file HomePatch.C.

◆ HGArrayVector

typedef zVector HGArrayVector[MAXHGS]

Definition at line 67 of file HomePatch.C.

◆ HGMatrixBigReal

typedef BigReal HGMatrixBigReal[MAXHGS][MAXHGS]

Definition at line 68 of file HomePatch.C.

◆ HGMatrixVector

typedef zVector HGMatrixVector[MAXHGS][MAXHGS]

Definition at line 69 of file HomePatch.C.

Function Documentation

◆ average()

int average ( CompAtom qtilde,
const HGArrayVector q,
BigReal lambda,
const int  n,
const int  m,
const HGArrayBigReal imass,
const HGArrayBigReal length2,
const HGArrayInt ial,
const HGArrayInt ibl,
const HGArrayVector refab,
const BigReal  tolf,
const int  ntrial 
)

Definition at line 6464 of file HomePatch.C.

References endi(), G_q(), iINFO(), iout, lubksb(), ludcmp(), and CompAtom::position.

Referenced by PressureProfileReduction::getData(), HomePatch::mollyAverage(), PressureProfileReduction::PressureProfileReduction(), and PressureProfileReduction::~PressureProfileReduction().

6464  {
6465  // input: n = length of hydrogen group to be averaged (shaked)
6466  // q[n] = vector array of original positions
6467  // m = number of constraints
6468  // imass[n] = inverse mass for each atom
6469  // length2[m] = square of reference bond length for each constraint
6470  // ial[m] = atom a in each constraint
6471  // ibl[m] = atom b in each constraint
6472  // refab[m] = vector of q_ial(i) - q_ibl(i) for each constraint
6473  // tolf = function error tolerance for Newton's iteration
6474  // ntrial = max number of Newton's iterations
6475  // output: lambda[m] = double array of lagrange multipliers (used by mollify)
6476  // qtilde[n] = vector array of averaged (shaked) positions
6477 
6478  int k,k1,i,j;
6479  BigReal errx,errf,d,tolx;
6480 
6481  HGArrayInt indx;
6482  HGArrayBigReal p;
6483  HGArrayBigReal fvec;
6484  HGMatrixBigReal fjac;
6485  HGArrayVector avgab;
6486  HGMatrixVector grhs;
6487  HGMatrixVector auxrhs;
6488  HGMatrixVector glhs;
6489 
6490  // iout <<iINFO << "average: n="<<n<<" m="<<m<<std::endl<<endi;
6491  tolx=tolf;
6492 
6493  // initialize lambda, globalGrhs
6494 
6495  for (i=0;i<m;i++) {
6496  lambda[i]=0.0;
6497  }
6498 
6499  // define grhs, auxrhs for all iterations
6500  // grhs= g_x(q)
6501  //
6502  G_q(refab,grhs,n,m,ial,ibl);
6503  for (k=1;k<=ntrial;k++) {
6504  // usrfun(qtilde,q0,lambda,fvec,fjac,n,water);
6505  HGArrayBigReal gij;
6506  // this used to be main loop of usrfun
6507  // compute qtilde given q0, lambda, IMASSes
6508  {
6509  BigReal multiplier;
6510  HGArrayVector tmp;
6511  for (i=0;i<m;i++) {
6512  multiplier = lambda[i];
6513  // auxrhs = M^{-1}grhs^{T}
6514  for (j=0;j<n;j++) {
6515  auxrhs[i][j]=multiplier*imass[j]*grhs[i][j];
6516  }
6517  }
6518  for (j=0;j<n;j++) {
6519  // tmp[j]=0.0;
6520  for (i=0;i<m;i++) {
6521  tmp[j]+=auxrhs[i][j];
6522  }
6523  }
6524 
6525  for (j=0;j<n;j++) {
6526  qtilde[j].position=q[j]+tmp[j];
6527  }
6528  // delete [] tmp;
6529  }
6530 
6531  for ( i = 0; i < m; i++ ) {
6532  avgab[i] = qtilde[ial[i]].position - qtilde[ibl[i]].position;
6533  }
6534 
6535  // iout<<iINFO << "Calling Jac" << std::endl<<endi;
6536  // Jac(qtilde, q0, fjac,n,water);
6537  {
6538  // Vector glhs[3*n+3];
6539 
6540  HGMatrixVector grhs2;
6541 
6542  G_q(avgab,glhs,n,m,ial,ibl);
6543 #ifdef DEBUG0
6544  iout<<iINFO << "G_q:" << std::endl<<endi;
6545  for (i=0;i<m;i++) {
6546  iout<<iINFO << glhs[i*n+0] << " " << glhs[i*n+1] << " " << glhs[i*n+2] << std::endl<<endi;
6547  }
6548 #endif
6549  // G_q(refab,grhs2,m,ial,ibl);
6550  // update with the masses
6551  for (j=0; j<n; j++) { // number of atoms
6552  for (i=0; i<m;i++) { // number of constraints
6553  grhs2[i][j] = grhs[i][j]*imass[j];
6554  }
6555  }
6556 
6557  // G_q(qtilde) * M^-1 G_q'(q0) =
6558  // G_q(qtilde) * grhs'
6559  for (i=0;i<m;i++) { // number of constraints
6560  for (j=0;j<m;j++) { // number of constraints
6561  fjac[i][j] = 0;
6562  for (k1=0;k1<n;k1++) {
6563  fjac[i][j] += glhs[i][k1]*grhs2[j][k1];
6564  }
6565  }
6566  }
6567 #ifdef DEBUG0
6568  iout<<iINFO << "glhs" <<endi;
6569  for(i=0;i<9;i++) {
6570  iout<<iINFO << glhs[i] << ","<<endi;
6571  }
6572  iout<<iINFO << std::endl<<endi;
6573  for(i=0;i<9;i++) {
6574  iout<<iINFO << grhs2[i] << ","<<endi;
6575  }
6576  iout<<iINFO << std::endl<<endi;
6577 #endif
6578  // delete[] grhs2;
6579  }
6580  // end of Jac calculation
6581 #ifdef DEBUG0
6582  iout<<iINFO << "Jac" << std::endl<<endi;
6583  for (i=0;i<m;i++)
6584  for (j=0;j<m;j++)
6585  iout<<iINFO << fjac[i][j] << " "<<endi;
6586  iout<< std::endl<<endi;
6587 #endif
6588  // calculate constraints in gij for n constraints this being a water
6589  // G(qtilde, gij, n, water);
6590  for (i=0;i<m;i++) {
6591  gij[i]=avgab[i]*avgab[i]-length2[i];
6592  }
6593 #ifdef DEBUG0
6594  iout<<iINFO << "G" << std::endl<<endi;
6595  iout<<iINFO << "( "<<endi;
6596  for(i=0;i<m-1;i++) {
6597  iout<<iINFO << gij[i] << ", "<<endi;
6598  }
6599  iout<<iINFO << gij[m-1] << ")" << std::endl<<endi;
6600 #endif
6601  // fill the return vector
6602  for(i=0;i<m;i++) {
6603  fvec[i] = gij[i];
6604  }
6605  // free up the constraints
6606  // delete[] gij;
6607  // continue Newton's iteration
6608  errf=0.0;
6609  for (i=0;i<m;i++) errf += fabs(fvec[i]);
6610 #ifdef DEBUG0
6611  iout<<iINFO << "errf: " << errf << std::endl<<endi;
6612 #endif
6613  if (errf <= tolf) {
6614  break;
6615  }
6616  for (i=0;i<m;i++) p[i] = -fvec[i];
6617  // iout<<iINFO << "Doing dcmp in average " << std::endl<<endi;
6618  ludcmp(fjac,m,indx,&d);
6619  lubksb(fjac,m,indx,p);
6620 
6621  errx=0.0;
6622  for (i=0;i<m;i++) {
6623  errx += fabs(p[i]);
6624  }
6625  for (i=0;i<m;i++)
6626  lambda[i] += p[i];
6627 
6628 #ifdef DEBUG0
6629  iout<<iINFO << "lambda:" << lambda[0]
6630  << " " << lambda[1] << " " << lambda[2] << std::endl<<endi;
6631  iout<<iINFO << "errx: " << errx << std::endl<<endi;
6632 #endif
6633  if (errx <= tolx) break;
6634 #ifdef DEBUG0
6635  iout<<iINFO << "Qtilde:" << std::endl<<endi;
6636  iout<<iINFO << qtilde[0].position << " " << qtilde[1].position << " " << qtilde[2].position << std::endl<<endi;
6637 #endif
6638  }
6639 #ifdef DEBUG
6640  iout<<iINFO << "LAMBDA:" << lambda[0] << " " << lambda[1] << " " << lambda[2] << std::endl<<endi;
6641 #endif
6642 
6643  return k; //
6644 }
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
Position position
Definition: NamdTypes.h:77
BigReal HGMatrixBigReal[MAXHGS][MAXHGS]
Definition: HomePatch.C:68
#define iout
Definition: InfoStream.h:51
BigReal HGArrayBigReal[MAXHGS]
Definition: HomePatch.C:66
zVector HGMatrixVector[MAXHGS][MAXHGS]
Definition: HomePatch.C:69
void lubksb(HGMatrixBigReal &a, int n, HGArrayInt &indx, HGArrayBigReal &b)
Definition: HomePatch.C:6379
int HGArrayInt[MAXHGS]
Definition: HomePatch.C:65
void ludcmp(HGMatrixBigReal &a, int n, HGArrayInt &indx, BigReal *d)
Definition: HomePatch.C:6402
void G_q(const HGArrayVector &refab, HGMatrixVector &gqij, const int n, const int m, const HGArrayInt &ial, const HGArrayInt &ibl)
Definition: HomePatch.C:6452
zVector HGArrayVector[MAXHGS]
Definition: HomePatch.C:67
double BigReal
Definition: common.h:123

◆ compDistance()

static int compDistance ( const void *  a,
const void *  b 
)
static

Definition at line 497 of file HomePatch.C.

Referenced by HomePatch::buildSpanningTree().

498 {
499  int d1 = abs(*(int *)a - CkMyPe());
500  int d2 = abs(*(int *)b - CkMyPe());
501  if (d1 < d2)
502  return -1;
503  else if (d1 == d2)
504  return 0;
505  else
506  return 1;
507 }

◆ G_q()

void G_q ( const HGArrayVector refab,
HGMatrixVector gqij,
const int  n,
const int  m,
const HGArrayInt ial,
const HGArrayInt ibl 
)
inline

Definition at line 6452 of file HomePatch.C.

Referenced by average(), and mollify().

6453  {
6454  int i;
6455  // step through the rows of the matrix
6456  for(i=0;i<m;i++) {
6457  gqij[i][ial[i]]=2.0*refab[i];
6458  gqij[i][ibl[i]]=-gqij[i][ial[i]];
6459  }
6460 };

◆ lubksb()

void lubksb ( HGMatrixBigReal a,
int  n,
HGArrayInt indx,
HGArrayBigReal b 
)
inline

Definition at line 6379 of file HomePatch.C.

Referenced by average(), and mollify().

6381 {
6382  int i,ii=-1,ip,j;
6383  double sum;
6384 
6385  for (i=0;i<n;i++) {
6386  ip=indx[i];
6387  sum=b[ip];
6388  b[ip]=b[i];
6389  if (ii >= 0)
6390  for (j=ii;j<i;j++) sum -= a[i][j]*b[j];
6391  else if (sum) ii=i;
6392  b[i]=sum;
6393  }
6394  for (i=n-1;i>=0;i--) {
6395  sum=b[i];
6396  for (j=i+1;j<n;j++) sum -= a[i][j]*b[j];
6397  b[i]=sum/a[i][i];
6398  }
6399 }

◆ ludcmp()

void ludcmp ( HGMatrixBigReal a,
int  n,
HGArrayInt indx,
BigReal d 
)
inline

Definition at line 6402 of file HomePatch.C.

References NAMD_die(), and TINY.

Referenced by average(), and mollify().

6403 {
6404 
6405  int i,imax,j,k;
6406  double big,dum,sum,temp;
6407  HGArrayBigReal vv;
6408  *d=1.0;
6409  for (i=0;i<n;i++) {
6410  big=0.0;
6411  for (j=0;j<n;j++)
6412  if ((temp=fabs(a[i][j])) > big) big=temp;
6413  if (big == 0.0) NAMD_die("Singular matrix in routine ludcmp\n");
6414  vv[i]=1.0/big;
6415  }
6416  for (j=0;j<n;j++) {
6417  for (i=0;i<j;i++) {
6418  sum=a[i][j];
6419  for (k=0;k<i;k++) sum -= a[i][k]*a[k][j];
6420  a[i][j]=sum;
6421  }
6422  big=0.0;
6423  for (i=j;i<n;i++) {
6424  sum=a[i][j];
6425  for (k=0;k<j;k++)
6426  sum -= a[i][k]*a[k][j];
6427  a[i][j]=sum;
6428  if ( (dum=vv[i]*fabs(sum)) >= big) {
6429  big=dum;
6430  imax=i;
6431  }
6432  }
6433  if (j != imax) {
6434  for (k=0;k<n;k++) {
6435  dum=a[imax][k];
6436  a[imax][k]=a[j][k];
6437  a[j][k]=dum;
6438  }
6439  *d = -(*d);
6440  vv[imax]=vv[j];
6441  }
6442  indx[j]=imax;
6443  if (a[j][j] == 0.0) a[j][j]=TINY;
6444  if (j != n-1) {
6445  dum=1.0/(a[j][j]);
6446  for (i=j+1;i<n;i++) a[i][j] *= dum;
6447  }
6448  }
6449 }
#define TINY
Definition: HomePatch.C:54
BigReal HGArrayBigReal[MAXHGS]
Definition: HomePatch.C:66
void NAMD_die(const char *err_msg)
Definition: common.C:147

◆ mollify()

void mollify ( CompAtom qtilde,
const HGArrayVector q0,
const BigReal lambda,
HGArrayVector force,
const int  n,
const int  m,
const HGArrayBigReal imass,
const HGArrayInt ial,
const HGArrayInt ibl,
const HGArrayVector refab 
)

Definition at line 6646 of file HomePatch.C.

References G_q(), lubksb(), ludcmp(), and CompAtom::position.

Referenced by HomePatch::mollyMollify().

6646  {
6647  int i,j,k;
6648  BigReal d;
6649  HGMatrixBigReal fjac;
6650  Vector zero(0.0,0.0,0.0);
6651 
6652  HGArrayVector tmpforce;
6653  HGArrayVector tmpforce2;
6654  HGArrayVector y;
6655  HGMatrixVector grhs;
6656  HGMatrixVector glhs;
6657  HGArrayBigReal aux;
6658  HGArrayInt indx;
6659 
6660  for(i=0;i<n;i++) {
6661  tmpforce[i]=imass[i]*force[i];
6662  }
6663 
6664  HGMatrixVector grhs2;
6665  HGArrayVector avgab;
6666 
6667  for ( i = 0; i < m; i++ ) {
6668  avgab[i] = qtilde[ial[i]].position - qtilde[ibl[i]].position;
6669  }
6670 
6671  G_q(avgab,glhs,n,m,ial,ibl);
6672  G_q(refab,grhs,n,m,ial,ibl);
6673  // update with the masses
6674  for (j=0; j<n; j++) { // number of atoms
6675  for (i=0; i<m;i++) { // number of constraints
6676  grhs2[i][j] = grhs[i][j]*imass[j];
6677  }
6678  }
6679 
6680  // G_q(qtilde) * M^-1 G_q'(q0) =
6681  // G_q(qtilde) * grhs'
6682  for (i=0;i<m;i++) { // number of constraints
6683  for (j=0;j<m;j++) { // number of constraints
6684  fjac[j][i] = 0;
6685  for (k=0;k<n;k++) {
6686  fjac[j][i] += glhs[i][k]*grhs2[j][k];
6687  }
6688  }
6689  }
6690 
6691  // aux=gqij*tmpforce
6692  // globalGrhs::computeGlobalGrhs(q0,n,water);
6693  // G_q(refab,grhs,m,ial,ibl);
6694  for(i=0;i<m;i++) {
6695  aux[i]=0.0;
6696  for(j=0;j<n;j++) {
6697  aux[i]+=grhs[i][j]*tmpforce[j];
6698  }
6699  }
6700 
6701  ludcmp(fjac,m,indx,&d);
6702  lubksb(fjac,m,indx,aux);
6703 
6704  for(j=0;j<n;j++) {
6705  y[j] = zero;
6706  for(i=0;i<m;i++) {
6707  y[j] += aux[i]*glhs[i][j];
6708  }
6709  }
6710  for(i=0;i<n;i++) {
6711  y[i]=force[i]-y[i];
6712  }
6713 
6714  // gqq12*y
6715  for(i=0;i<n;i++) {
6716  tmpforce2[i]=imass[i]*y[i];
6717  }
6718 
6719  // here we assume that tmpforce is initialized to zero.
6720  for (i=0;i<n;i++) {
6721  tmpforce[i]=zero;
6722  }
6723 
6724  for (j=0;j<m;j++) {
6725  Vector tmpf = 2.0*lambda[j]*(tmpforce2[ial[j]]-tmpforce2[ibl[j]]);
6726  tmpforce[ial[j]] += tmpf;
6727  tmpforce[ibl[j]] -= tmpf;
6728  }
6729  // c-ji the other bug for 2 constraint water was this line (2-4-99)
6730  // for(i=0;i<m;i++) {
6731  for(i=0;i<n;i++) {
6732  force[i]=tmpforce[i]+y[i];
6733  }
6734 
6735 }
Definition: Vector.h:72
Position position
Definition: NamdTypes.h:77
BigReal HGMatrixBigReal[MAXHGS][MAXHGS]
Definition: HomePatch.C:68
BigReal HGArrayBigReal[MAXHGS]
Definition: HomePatch.C:66
zVector HGMatrixVector[MAXHGS][MAXHGS]
Definition: HomePatch.C:69
void lubksb(HGMatrixBigReal &a, int n, HGArrayInt &indx, HGArrayBigReal &b)
Definition: HomePatch.C:6379
int HGArrayInt[MAXHGS]
Definition: HomePatch.C:65
void ludcmp(HGMatrixBigReal &a, int n, HGArrayInt &indx, BigReal *d)
Definition: HomePatch.C:6402
void G_q(const HGArrayVector &refab, HGMatrixVector &gqij, const int n, const int m, const HGArrayInt &ial, const HGArrayInt &ibl)
Definition: HomePatch.C:6452
zVector HGArrayVector[MAXHGS]
Definition: HomePatch.C:67
double BigReal
Definition: common.h:123

◆ MSHAKE_CUDA()

void MSHAKE_CUDA ( int *  ,
const int  size,
const RattleParam rattleParam,
BigReal refx,
BigReal refy,
BigReal refz,
BigReal posx,
BigReal posy,
BigReal posz,
const BigReal  tol2,
const int  maxiter,
bool &  done,
bool &  consFailure 
)

◆ PatchDataSOA_initialize()

void PatchDataSOA_initialize ( PatchDataSOA p)

Initialize fundamental parts of PatchDataSOA.

Definition at line 2366 of file HomePatch.C.

References PatchDataSOA::buffer, PatchDataSOA::maxAtoms, PatchDataSOA::numAtoms, and PatchDataSOA::numBytes.

2366  {
2367  p->buffer = NULL;
2368  p->numBytes = 0;
2369  p->numAtoms = 0;
2370  p->maxAtoms = 0;
2371 }
int32 maxAtoms
max number of atoms available, multiple of MAXFACTOR
Definition: NamdTypes.h:447
size_t numBytes
number of bytes allocated for soa_buffer
Definition: NamdTypes.h:445
unsigned char * buffer
Definition: NamdTypes.h:365
int32 numAtoms
number of atoms
Definition: NamdTypes.h:446

◆ PatchDataSOA_set_buffer()

void PatchDataSOA_set_buffer ( PatchDataSOA p,
void *  mybuffer 
)

Caller provides the buffer space to be used. Set all pointers relative to this provided address, pointing into the buffer space.

Definition at line 2393 of file HomePatch.C.

References PatchDataSOA::atomFixed, PatchDataSOA::buffer, PatchDataSOA::charge, PatchDataSOA::exclId, PatchDataSOA::f_global_x, PatchDataSOA::f_global_y, PatchDataSOA::f_global_z, PatchDataSOA::f_nbond_x, PatchDataSOA::f_nbond_y, PatchDataSOA::f_nbond_z, PatchDataSOA::f_normal_x, PatchDataSOA::f_normal_y, PatchDataSOA::f_normal_z, PatchDataSOA::f_saved_nbond_x, PatchDataSOA::f_saved_nbond_y, PatchDataSOA::f_saved_nbond_z, PatchDataSOA::f_saved_slow_x, PatchDataSOA::f_saved_slow_y, PatchDataSOA::f_saved_slow_z, PatchDataSOA::f_slow_x, PatchDataSOA::f_slow_y, PatchDataSOA::f_slow_z, PatchDataSOA::fixedPosition_x, PatchDataSOA::fixedPosition_y, PatchDataSOA::fixedPosition_z, PatchDataSOA::gaussrand_x, PatchDataSOA::gaussrand_y, PatchDataSOA::gaussrand_z, PatchDataSOA::groupFixed, PatchDataSOA::hydrogenGroupSize, PatchDataSOA::id, PatchDataSOA::isWater, PatchDataSOA::langevinParam, PatchDataSOA::langScalRandBBK2, PatchDataSOA::langScalVelBBK2, PatchDataSOA::mass, PatchDataSOA::maxAtoms, PatchDataSOA::migrationGroupSize, PatchDataSOA::nonbondedGroupSize, Node::Object(), PatchDataSOA::partition, PatchDataSOA::pos_x, PatchDataSOA::pos_y, PatchDataSOA::pos_z, PatchDataSOA::posNew_x, PatchDataSOA::posNew_y, PatchDataSOA::posNew_z, PatchDataSOA::recipMass, PatchDataSOA::rigidBondLength, PatchDataSOA::sigId, Node::simParameters, simParams, PatchDataSOA::sortOrder, PatchDataSOA::status, PatchDataSOA::transform_i, PatchDataSOA::transform_j, PatchDataSOA::transform_k, PatchDataSOA::unsortOrder, PatchDataSOA::vdwType, PatchDataSOA::vel_x, PatchDataSOA::vel_y, PatchDataSOA::vel_z, PatchDataSOA::velNew_x, PatchDataSOA::velNew_y, and PatchDataSOA::velNew_z.

2396  {
2398  p->buffer = (unsigned char *) mybuffer;
2399  unsigned char *t = p->buffer;
2400  p->pos_x = (double *) t;
2401  t += p->maxAtoms * sizeof(double);
2402  p->pos_y = (double *) t;
2403  t += p->maxAtoms * sizeof(double);
2404  p->pos_z = (double *) t;
2405  t += p->maxAtoms * sizeof(double);
2406  p->charge = (float *) t;
2407  t += p->maxAtoms * sizeof(float);
2408  p->vdwType = (int *) t;
2409  t += p->maxAtoms * sizeof(int);
2410  p->partition = (int *) t;
2411  t += p->maxAtoms * sizeof(int);
2412  p->nonbondedGroupSize = (int *) t;
2413  t += p->maxAtoms * sizeof(int);
2414  p->hydrogenGroupSize = (int *) t;
2415  t += p->maxAtoms * sizeof(int);
2416  p->isWater = (int *) t;
2417  t += p->maxAtoms * sizeof(int);
2418  p->sortOrder = (int *) t;
2419  t += p->maxAtoms * sizeof(int);
2420  p->unsortOrder = (int *) t;
2421  t += p->maxAtoms * sizeof(int);
2422  p->id = (int *) t;
2423  t += p->maxAtoms * sizeof(int);
2424  p->exclId = (int *) t;
2425  t += p->maxAtoms * sizeof(int);
2426  p->sigId = (int *) t;
2427  t += p->maxAtoms * sizeof(int);
2428  p->atomFixed = (int *) t;
2429  t += p->maxAtoms * sizeof(int);
2430  p->groupFixed = (int *) t;
2431  t += p->maxAtoms * sizeof(int);
2432  p->vel_x = (double *) t;
2433  t += p->maxAtoms * sizeof(double);
2434  p->vel_y = (double *) t;
2435  t += p->maxAtoms * sizeof(double);
2436  p->vel_z = (double *) t;
2437  t += p->maxAtoms * sizeof(double);
2438  p->fixedPosition_x = (double *) t;
2439  t += p->maxAtoms * sizeof(double);
2440  p->fixedPosition_y = (double *) t;
2441  t += p->maxAtoms * sizeof(double);
2442  p->fixedPosition_z = (double *) t;
2443  t += p->maxAtoms * sizeof(double);
2444  p->recipMass = (double *) t;
2445  t += p->maxAtoms * sizeof(double);
2446  p->mass = (float *) t;
2447  t += p->maxAtoms * sizeof(float);
2448  p->langevinParam = (float *) t;
2449  t += p->maxAtoms * sizeof(float);
2450  p->status = (int *) t;
2451  t += p->maxAtoms * sizeof(int);
2452  p->transform_i = (int *) t;
2453  t += p->maxAtoms * sizeof(int);
2454  p->transform_j = (int *) t;
2455  t += p->maxAtoms * sizeof(int);
2456  p->transform_k = (int *) t;
2457  t += p->maxAtoms * sizeof(int);
2458  p->migrationGroupSize = (int *) t;
2459  t += p->maxAtoms * sizeof(int);
2460  p->rigidBondLength = (float *) t;
2461  t += p->maxAtoms * sizeof(float);
2462  p->langScalVelBBK2 = (float *) t;
2463  t += p->maxAtoms * sizeof(float);
2464  p->langScalRandBBK2 = (float *) t;
2465  t += p->maxAtoms * sizeof(float);
2466  p->gaussrand_x = (float *) t;
2467  t += p->maxAtoms * sizeof(float);
2468  p->gaussrand_y = (float *) t;
2469  t += p->maxAtoms * sizeof(float);
2470  p->gaussrand_z = (float *) t;
2471  t += p->maxAtoms * sizeof(float);
2472  p->f_normal_x = (double *) t;
2473  t += p->maxAtoms * sizeof(double);
2474  p->f_normal_y = (double *) t;
2475  t += p->maxAtoms * sizeof(double);
2476  p->f_normal_z = (double *) t;
2477  t += p->maxAtoms * sizeof(double);
2478  p->f_nbond_x = (double *) t;
2479  t += p->maxAtoms * sizeof(double);
2480  p->f_nbond_y = (double *) t;
2481  t += p->maxAtoms * sizeof(double);
2482  p->f_nbond_z = (double *) t;
2483  t += p->maxAtoms * sizeof(double);
2484  p->f_slow_x = (double *) t;
2485  t += p->maxAtoms * sizeof(double);
2486  p->f_slow_y = (double *) t;
2487  t += p->maxAtoms * sizeof(double);
2488  p->f_slow_z = (double *) t;
2489  t += p->maxAtoms * sizeof(float);
2490  if (simParams->colvarsOn || simParams->tclForcesOn){
2491  p->f_global_x = (double *) t;
2492  t += p->maxAtoms * sizeof(double);
2493  p->f_global_y = (double *) t;
2494  t += p->maxAtoms * sizeof(double);
2495  p->f_global_z = (double *) t;
2496  t += p->maxAtoms * sizeof(double);
2497  }
2498  p->f_saved_nbond_x = (double *) t;
2499  t += p->maxAtoms * sizeof(double);
2500  p->f_saved_nbond_y = (double *) t;
2501  t += p->maxAtoms * sizeof(double);
2502  p->f_saved_nbond_z = (double *) t;
2503  t += p->maxAtoms * sizeof(double);
2504  p->f_saved_slow_x = (double *) t;
2505  t += p->maxAtoms * sizeof(double);
2506  p->f_saved_slow_y = (double *) t;
2507  t += p->maxAtoms * sizeof(double);
2508  p->f_saved_slow_z = (double *) t;
2509  t += p->maxAtoms * sizeof(double);
2510  p->velNew_x = (double *) t;
2511  t += p->maxAtoms * sizeof(double);
2512  p->velNew_y = (double *) t;
2513  t += p->maxAtoms * sizeof(double);
2514  p->velNew_z = (double *) t;
2515  t += p->maxAtoms * sizeof(double);
2516  p->posNew_x = (double *) t;
2517  t += p->maxAtoms * sizeof(double);
2518  p->posNew_y = (double *) t;
2519  t += p->maxAtoms * sizeof(double);
2520  p->posNew_z = (double *) t;
2521 }
static Node * Object()
Definition: Node.h:86
double * vel_y
Definition: NamdTypes.h:387
int32 * isWater
Definition: NamdTypes.h:376
double * f_normal_z
Definition: NamdTypes.h:420
int32 * groupFixed
Definition: NamdTypes.h:384
double * f_normal_y
Definition: NamdTypes.h:419
double * posNew_z
Definition: NamdTypes.h:443
int32 * exclId
Definition: NamdTypes.h:381
int32 * unsortOrder
Definition: NamdTypes.h:379
double * f_saved_slow_z
Definition: NamdTypes.h:435
double * f_slow_y
Definition: NamdTypes.h:425
SimParameters * simParameters
Definition: Node.h:181
double * f_global_z
Definition: NamdTypes.h:429
int32 maxAtoms
max number of atoms available, multiple of MAXFACTOR
Definition: NamdTypes.h:447
double * f_saved_slow_y
Definition: NamdTypes.h:434
float * langScalVelBBK2
derived from langevinParam
Definition: NamdTypes.h:409
double * f_saved_slow_x
Definition: NamdTypes.h:433
float * gaussrand_y
Definition: NamdTypes.h:414
double * pos_y
Definition: NamdTypes.h:368
double * velNew_z
Definition: NamdTypes.h:440
double * fixedPosition_y
Definition: NamdTypes.h:391
int32 * migrationGroupSize
Definition: NamdTypes.h:404
float * mass
Definition: NamdTypes.h:395
double * f_global_y
Definition: NamdTypes.h:428
double * f_nbond_y
Definition: NamdTypes.h:422
double * f_nbond_z
Definition: NamdTypes.h:423
int32 * hydrogenGroupSize
Definition: NamdTypes.h:375
double * f_normal_x
Definition: NamdTypes.h:418
float * langevinParam
Definition: NamdTypes.h:396
float * gaussrand_x
fill with Gaussian distributed random numbers
Definition: NamdTypes.h:413
int32 * vdwType
Definition: NamdTypes.h:372
int32 * sortOrder
Definition: NamdTypes.h:378
float * gaussrand_z
Definition: NamdTypes.h:415
double * vel_x
Jim recommends double precision velocity.
Definition: NamdTypes.h:386
int32 * id
Definition: NamdTypes.h:380
float * charge
Definition: NamdTypes.h:371
int32 * transform_i
Definition: NamdTypes.h:400
double * f_saved_nbond_x
Definition: NamdTypes.h:430
int32 * partition
Definition: NamdTypes.h:373
double * f_saved_nbond_z
Definition: NamdTypes.h:432
double * posNew_y
Definition: NamdTypes.h:442
float * rigidBondLength
Definition: NamdTypes.h:406
int32 * transform_k
Definition: NamdTypes.h:402
double * recipMass
derived from mass
Definition: NamdTypes.h:394
#define simParams
Definition: Output.C:129
double * velNew_y
Definition: NamdTypes.h:439
double * fixedPosition_x
Definition: NamdTypes.h:390
double * pos_z
Definition: NamdTypes.h:369
double * f_slow_x
Definition: NamdTypes.h:424
double * pos_x
Definition: NamdTypes.h:367
int32 * transform_j
Definition: NamdTypes.h:401
double * vel_z
Definition: NamdTypes.h:388
int32 * sigId
Definition: NamdTypes.h:382
double * f_saved_nbond_y
Definition: NamdTypes.h:431
double * f_nbond_x
Definition: NamdTypes.h:421
unsigned char * buffer
Definition: NamdTypes.h:365
double * f_global_x
Definition: NamdTypes.h:427
double * fixedPosition_z
Definition: NamdTypes.h:392
int32 * status
Definition: NamdTypes.h:398
float * langScalRandBBK2
from langevinParam and recipMass
Definition: NamdTypes.h:410
double * posNew_x
Definition: NamdTypes.h:441
int32 * atomFixed
Definition: NamdTypes.h:383
int32 * nonbondedGroupSize
Definition: NamdTypes.h:374
double * f_slow_z
Definition: NamdTypes.h:426
double * velNew_x
temp storage for rigid bond constraints
Definition: NamdTypes.h:438

◆ PatchDataSOA_set_size()

size_t PatchDataSOA_set_size ( PatchDataSOA p,
int  natoms,
int  pad = MAXFACTOR 
)

Set sizes based on number of atoms and padding factor. Sets internally numAtoms, maxAtoms, and numBytes. Returns numBytes.

Definition at line 2373 of file HomePatch.C.

References PatchDataSOA::maxAtoms, PatchDataSOA::numAtoms, PatchDataSOA::numBytes, Node::Object(), Node::simParameters, and simParams.

2377  {
2378  if (natoms > p->maxAtoms) {
2379  // maxAtoms extends numAtoms to next multiple of padding
2380  p->maxAtoms = ((natoms + padding - 1) / padding) * padding;
2381  // set numBytes to allow each array to have maxAtoms space
2382  // count up total number of double, float, and int arrays
2383  // XXX TODO : these magic numbers are bad for maintability
2385  int numdoubles = (simParams->colvarsOn || simParams->tclForcesOn) ? 34: 31;
2386  p->numBytes = p->maxAtoms *
2387  (numdoubles * sizeof(double) + 9*sizeof(float) + 17*sizeof(int));
2388  }
2389  p->numAtoms = natoms;
2390  return p->numBytes;
2391 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:181
int32 maxAtoms
max number of atoms available, multiple of MAXFACTOR
Definition: NamdTypes.h:447
size_t numBytes
number of bytes allocated for soa_buffer
Definition: NamdTypes.h:445
#define simParams
Definition: Output.C:129
int32 numAtoms
number of atoms
Definition: NamdTypes.h:446