msm::PatchData Struct Reference

List of all members.

Public Member Functions

AtomCoordArraycoordArray ()
ForceArrayforceArray ()
 PatchData (ComputeMsmMgr *pmgr, int pid)
void init (int natoms)
void anterpolation ()
void sendCharge ()
void addPotential (const Grid< Float > &epart)
void interpolation ()
void anterpolationC1Hermite ()
void sendChargeC1Hermite ()
void addPotentialC1Hermite (const Grid< C1Vector > &epart)
void interpolationC1Hermite ()

Public Attributes

ComputeMsmMgrmgr
Mapmap
PatchDiagrampd
AtomCoordArray coord
ForceArray force
Grid< Floatqh
Grid< Floateh
Grid< Floatsubgrid
Grid< C1Vectorqh_c1hermite
Grid< C1Vectoreh_c1hermite
Grid< C1Vectorsubgrid_c1hermite
BigReal energy
int cntRecvs
int patchID
int sequence

Detailed Description

Definition at line 1738 of file ComputeMsm.C.


Constructor & Destructor Documentation

msm::PatchData::PatchData ( ComputeMsmMgr pmgr,
int  pid 
)

Definition at line 6227 of file ComputeMsm.C.

References ComputeMsmMgr::approx, msm::Map::bsx, msm::Map::bsy, msm::Map::bsz, ComputeMsmMgr::C1HERMITE, eh, eh_c1hermite, msm::Grid< T >::init(), map, ComputeMsmMgr::mapData(), mgr, msm::PatchDiagram::nrange, patchID, msm::Map::patchList, pd, qh, qh_c1hermite, msm::Grid< T >::resize(), subgrid, and subgrid_c1hermite.

06227                                                    {
06228     mgr = pmgr;
06229     map = &(mgr->mapData());
06230     patchID = pid;
06231     //PatchMap *pm = PatchMap::Object();
06232     pd = &(map->patchList[pid]);
06233     if (mgr->approx == ComputeMsmMgr::C1HERMITE) {
06234       qh_c1hermite.init(pd->nrange);
06235       eh_c1hermite.init(pd->nrange);
06236       subgrid_c1hermite.resize(map->bsx[0] * map->bsy[0] * map->bsz[0]);
06237     }
06238     else {
06239       qh.init(pd->nrange);
06240       eh.init(pd->nrange);
06241       subgrid.resize(map->bsx[0] * map->bsy[0] * map->bsz[0]);
06242     }
06243 #ifdef MSM_TIMING
06244     mgr->addTiming();
06245 #endif
06246   }


Member Function Documentation

void msm::PatchData::addPotential ( const Grid< Float > &  epart  ) 

Definition at line 6402 of file ComputeMsm.C.

References cntRecvs, MsmTimer::COMM, eh, interpolation(), mgr, msm::PatchDiagram::numRecvs, and pd.

06402                                                        {
06403 #ifdef MSM_TIMING
06404     double startTime, stopTime;
06405     startTime = CkWallTimer();
06406 #endif
06407     eh += epart;
06408 #ifdef MSM_TIMING
06409     stopTime = CkWallTimer();
06410     mgr->msmTiming[MsmTimer::COMM] += stopTime - startTime;
06411 #endif
06412     if (++cntRecvs == pd->numRecvs) {
06413       interpolation();
06414     }
06415   }

void msm::PatchData::addPotentialC1Hermite ( const Grid< C1Vector > &  epart  ) 

Definition at line 6678 of file ComputeMsm.C.

References cntRecvs, MsmTimer::COMM, eh_c1hermite, interpolationC1Hermite(), mgr, msm::PatchDiagram::numRecvs, and pd.

06678                                                                    {
06679 #ifdef MSM_TIMING
06680     double startTime, stopTime;
06681     startTime = CkWallTimer();
06682 #endif
06683     eh_c1hermite += epart;
06684 #ifdef MSM_TIMING
06685     stopTime = CkWallTimer();
06686     mgr->msmTiming[MsmTimer::COMM] += stopTime - startTime;
06687 #endif
06688     if (++cntRecvs == pd->numRecvs) {
06689       interpolationC1Hermite();
06690     }
06691   }

void msm::PatchData::anterpolation (  ) 

Definition at line 6265 of file ComputeMsm.C.

References MsmTimer::ANTERP, ComputeMsmMgr::approx, msm::Array< T >::buffer(), coord, msm::Grid< T >::data(), msm::IndexRange::ia(), msm::IndexRange::ib(), msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), ComputeMsmMgr::lattice, msm::Array< T >::len(), ComputeMsmMgr::MAX_POLY_DEGREE, mgr, NAMD_die(), msm::IndexRange::ni(), msm::IndexRange::nj(), patchID, ComputeMsmMgr::PolyDegree, qh, ComputeMsmMgr::s_edge, Lattice::scale(), sendCharge(), ComputeMsmMgr::sglower, ComputeMsmMgr::shx_1, ComputeMsmMgr::shy_1, ComputeMsmMgr::shz_1, ComputeMsmMgr::stencil_1d(), Vector::x, Vector::y, and Vector::z.

06265                                 {
06266 #ifdef DEBUG_MSM_GRID
06267     printf("patchID %d:  anterpolation\n", patchID);
06268 #endif
06269 
06270 #ifdef MSM_TIMING
06271     double startTime, stopTime;
06272     startTime = CkWallTimer();
06273 #endif
06274 #ifndef MSM_COMM_ONLY
06275     Float xphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06276     Float yphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06277     Float zphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06278 
06279     const Double rs_edge = Double( mgr->s_edge );
06280     const int s_size = ComputeMsmMgr::PolyDegree[mgr->approx] + 1;
06281 
06282     const int ia = qh.ia();
06283     const int ib = qh.ib();
06284     const int ja = qh.ja();
06285     const int jb = qh.jb();
06286     const int ka = qh.ka();
06287     const int kb = qh.kb();
06288     const int ni = qh.ni();
06289     const int nj = qh.nj();
06290     Float *qhbuffer = qh.data().buffer();
06291 
06292     // loop over atoms
06293     for (int n = 0;  n < coord.len();  n++) {
06294       Float q = coord[n].charge;
06295       if (0==q) continue;
06296 
06297       ScaledPosition s = mgr->lattice.scale(coord[n].position);
06298 
06299       BigReal sx_hx = (s.x - mgr->sglower.x) * mgr->shx_1;
06300       BigReal sy_hy = (s.y - mgr->sglower.y) * mgr->shy_1;
06301       BigReal sz_hz = (s.z - mgr->sglower.z) * mgr->shz_1;
06302 
06303       BigReal xlo = floor(sx_hx) - rs_edge;
06304       BigReal ylo = floor(sy_hy) - rs_edge;
06305       BigReal zlo = floor(sz_hz) - rs_edge;
06306 
06307       // calculate Phi stencils along each dimension
06308       Float xdelta = Float(sx_hx - xlo);
06309       mgr->stencil_1d(xphi, xdelta);
06310       Float ydelta = Float(sy_hy - ylo);
06311       mgr->stencil_1d(yphi, ydelta);
06312       Float zdelta = Float(sz_hz - zlo);
06313       mgr->stencil_1d(zphi, zdelta);
06314 
06315       int ilo = int(xlo);
06316       int jlo = int(ylo);
06317       int klo = int(zlo);
06318 
06319       // test to see if stencil is within edges of grid
06320       int iswithin = ( ia <= ilo && (ilo+(s_size-1)) <= ib &&
06321                        ja <= jlo && (jlo+(s_size-1)) <= jb &&
06322                        ka <= klo && (klo+(s_size-1)) <= kb );
06323 
06324       if ( ! iswithin ) {
06325 #if 0
06326         printf("PE %d:  atom %d:  pos= %g %g %g  patchID=%d\n",
06327             CkMyPe(), coord[n].id,
06328             coord[n].position.x, coord[n].position.y, coord[n].position.z,
06329             patchID);
06330         printf("PE %d:  atom subgrid [%d..%d] x [%d..%d] x [%d..%d]\n",
06331             CkMyPe(),
06332             ilo, ilo+s_size-1, jlo, jlo+s_size-1, klo, klo+s_size-1);
06333         printf("PE %d:  patch grid [%d..%d] x [%d..%d] x [%d..%d]\n",
06334             CkMyPe(),
06335             ia, ib, ja, jb, ka, kb);
06336 #endif
06337         char msg[100];
06338         snprintf(msg, sizeof(msg), "Atom %d is outside of the MSM grid.",
06339             coord[n].id);
06340         NAMD_die(msg);
06341       }
06342 
06343       // determine charge on cube of grid points around atom
06344       for (int k = 0;  k < s_size;  k++) {
06345         int koff = ((k+klo) - ka) * nj;
06346         Float ck = zphi[k] * q;
06347         for (int j = 0;  j < s_size;  j++) {
06348           int jkoff = (koff + (j+jlo) - ja) * ni;
06349           Float cjk = yphi[j] * ck;
06350           for (int i = 0;  i < s_size;  i++) {
06351             int ijkoff = jkoff + (i+ilo) - ia;
06352             qhbuffer[ijkoff] += xphi[i] * cjk;
06353           }
06354         }
06355       }
06356 
06357     } // end loop over atoms
06358 #endif // !MSM_COMM_ONLY
06359 #ifdef MSM_TIMING
06360     stopTime = CkWallTimer();
06361     mgr->msmTiming[MsmTimer::ANTERP] += stopTime - startTime;
06362 #endif
06363 
06364     sendCharge();
06365   }

void msm::PatchData::anterpolationC1Hermite (  ) 

Definition at line 6543 of file ComputeMsm.C.

References MsmTimer::ANTERP, msm::Array< T >::buffer(), coord, D000, D001, D010, D011, D100, D101, D110, D111, msm::Grid< T >::data(), ComputeMsmMgr::hxlen, ComputeMsmMgr::hylen, ComputeMsmMgr::hzlen, msm::IndexRange::ia(), msm::IndexRange::ib(), msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), ComputeMsmMgr::lattice, msm::Array< T >::len(), mgr, NAMD_die(), msm::IndexRange::ni(), msm::IndexRange::nj(), patchID, qh_c1hermite, Lattice::scale(), sendChargeC1Hermite(), ComputeMsmMgr::sglower, ComputeMsmMgr::shx_1, ComputeMsmMgr::shy_1, ComputeMsmMgr::shz_1, ComputeMsmMgr::stencil_1d_c1hermite(), C1Vector::velem, Vector::x, Vector::y, and Vector::z.

06543                                          {
06544 #ifdef DEBUG_MSM_GRID
06545     printf("patchID %d:  anterpolationC1Hermite\n", patchID);
06546 #endif
06547 
06548 #ifdef MSM_TIMING
06549     double startTime, stopTime;
06550     startTime = CkWallTimer();
06551 #endif
06552 #ifndef MSM_COMM_ONLY
06553     Float xphi[2], xpsi[2];
06554     Float yphi[2], ypsi[2];
06555     Float zphi[2], zpsi[2];
06556 
06557     const Float hx = Float(mgr->hxlen);  // real space grid spacing
06558     const Float hy = Float(mgr->hylen);
06559     const Float hz = Float(mgr->hzlen);
06560 
06561     const int ia = qh_c1hermite.ia();
06562     const int ib = qh_c1hermite.ib();
06563     const int ja = qh_c1hermite.ja();
06564     const int jb = qh_c1hermite.jb();
06565     const int ka = qh_c1hermite.ka();
06566     const int kb = qh_c1hermite.kb();
06567     const int ni = qh_c1hermite.ni();
06568     const int nj = qh_c1hermite.nj();
06569     C1Vector *qhbuffer = qh_c1hermite.data().buffer();
06570 
06571     // loop over atoms
06572     for (int n = 0;  n < coord.len();  n++) {
06573       Float q = coord[n].charge;
06574       if (0==q) continue;
06575 
06576       ScaledPosition s = mgr->lattice.scale(coord[n].position);
06577 
06578       BigReal sx_hx = (s.x - mgr->sglower.x) * mgr->shx_1;
06579       BigReal sy_hy = (s.y - mgr->sglower.y) * mgr->shy_1;
06580       BigReal sz_hz = (s.z - mgr->sglower.z) * mgr->shz_1;
06581 
06582       BigReal xlo = floor(sx_hx);
06583       BigReal ylo = floor(sy_hy);
06584       BigReal zlo = floor(sz_hz);
06585 
06586       // calculate Phi stencils along each dimension
06587       Float xdelta = Float(sx_hx - xlo);
06588       mgr->stencil_1d_c1hermite(xphi, xpsi, xdelta, hx);
06589       Float ydelta = Float(sy_hy - ylo);
06590       mgr->stencil_1d_c1hermite(yphi, ypsi, ydelta, hy);
06591       Float zdelta = Float(sz_hz - zlo);
06592       mgr->stencil_1d_c1hermite(zphi, zpsi, zdelta, hz);
06593 
06594       int ilo = int(xlo);
06595       int jlo = int(ylo);
06596       int klo = int(zlo);
06597 
06598       // test to see if stencil is within edges of grid
06599       int iswithin = ( ia <= ilo && ilo < ib &&
06600                        ja <= jlo && jlo < jb &&
06601                        ka <= klo && klo < kb );
06602 
06603       if ( ! iswithin ) {
06604         char msg[100];
06605         snprintf(msg, sizeof(msg), "Atom %d is outside of the MSM grid.",
06606             coord[n].id);
06607         NAMD_die(msg);
06608       }
06609 
06610       // determine charge on cube of grid points around atom
06611       for (int k = 0;  k < 2;  k++) {
06612         int koff = ((k+klo) - ka) * nj;
06613         Float c_zphi = zphi[k] * q;
06614         Float c_zpsi = zpsi[k] * q;
06615         for (int j = 0;  j < 2;  j++) {
06616           int jkoff = (koff + (j+jlo) - ja) * ni;
06617           Float c_yphi_zphi = yphi[j] * c_zphi;
06618           Float c_ypsi_zphi = ypsi[j] * c_zphi;
06619           Float c_yphi_zpsi = yphi[j] * c_zpsi;
06620           Float c_ypsi_zpsi = ypsi[j] * c_zpsi;
06621           for (int i = 0;  i < 2;  i++) {
06622             int ijkoff = jkoff + (i+ilo) - ia;
06623             qhbuffer[ijkoff].velem[D000] += xphi[i] * c_yphi_zphi;
06624             qhbuffer[ijkoff].velem[D100] += xpsi[i] * c_yphi_zphi;
06625             qhbuffer[ijkoff].velem[D010] += xphi[i] * c_ypsi_zphi;
06626             qhbuffer[ijkoff].velem[D001] += xphi[i] * c_yphi_zpsi;
06627             qhbuffer[ijkoff].velem[D110] += xpsi[i] * c_ypsi_zphi;
06628             qhbuffer[ijkoff].velem[D101] += xpsi[i] * c_yphi_zpsi;
06629             qhbuffer[ijkoff].velem[D011] += xphi[i] * c_ypsi_zpsi;
06630             qhbuffer[ijkoff].velem[D111] += xpsi[i] * c_ypsi_zpsi;
06631           }
06632         }
06633       }
06634 
06635     } // end loop over atoms
06636 
06637 #endif // !MSM_COMM_ONLY
06638 #ifdef MSM_TIMING
06639     stopTime = CkWallTimer();
06640     mgr->msmTiming[MsmTimer::ANTERP] += stopTime - startTime;
06641 #endif
06642 
06643     sendChargeC1Hermite();
06644   }

AtomCoordArray& msm::PatchData::coordArray (  )  [inline]

Definition at line 1756 of file ComputeMsm.C.

Referenced by ComputeMsm::doWork().

01756 { return coord; }

ForceArray& msm::PatchData::forceArray (  )  [inline]

Definition at line 1757 of file ComputeMsm.C.

01757 { return force; }

void msm::PatchData::init ( int  natoms  ) 

Definition at line 6248 of file ComputeMsm.C.

References ComputeMsmMgr::approx, ComputeMsmMgr::C1HERMITE, cntRecvs, coord, eh, eh_c1hermite, energy, force, mgr, qh, qh_c1hermite, msm::Grid< T >::reset(), and msm::Array< T >::resize().

Referenced by ComputeMsm::doWork().

06248                                  {
06249     coord.resize(natoms);
06250     force.resize(natoms);
06251     cntRecvs = 0;
06252     energy = 0;
06253     //memset(virial, 0, 3*3*sizeof(BigReal));
06254     for (int i = 0;  i < natoms;  i++)  force[i] = 0;
06255     if (mgr->approx == ComputeMsmMgr::C1HERMITE) {
06256       qh_c1hermite.reset(0);
06257       eh_c1hermite.reset(0);
06258     }
06259     else {
06260       qh.reset(0);
06261       eh.reset(0);
06262     }
06263   }

void msm::PatchData::interpolation (  ) 

Definition at line 6417 of file ComputeMsm.C.

References ComputeMsmMgr::approx, msm::Array< T >::buffer(), coord, ComputeMsmMgr::d_stencil_1d(), msm::Grid< T >::data(), ComputeMsmMgr::doneCompute(), eh, energy, force, ComputeMsmMgr::gzero, ComputeMsmMgr::hxlen_1, ComputeMsmMgr::hylen_1, ComputeMsmMgr::hzlen_1, msm::IndexRange::ia(), msm::IndexRange::ib(), MsmTimer::INTERP, msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), ComputeMsmMgr::lattice, msm::Array< T >::len(), ComputeMsmMgr::MAX_POLY_DEGREE, mgr, NAMD_die(), msm::IndexRange::ni(), msm::IndexRange::nj(), patchID, ComputeMsmMgr::PolyDegree, ComputeMsmMgr::s_edge, Lattice::scale(), ComputeMsmMgr::sglower, ComputeMsmMgr::shx_1, ComputeMsmMgr::shy_1, ComputeMsmMgr::shz_1, ComputeMsmMgr::srx_x, ComputeMsmMgr::srx_y, ComputeMsmMgr::srx_z, ComputeMsmMgr::sry_x, ComputeMsmMgr::sry_y, ComputeMsmMgr::sry_z, ComputeMsmMgr::srz_x, ComputeMsmMgr::srz_y, ComputeMsmMgr::srz_z, Vector::x, Vector::y, and Vector::z.

Referenced by addPotential().

06417                                 {
06418 #ifdef DEBUG_MSM_GRID
06419     printf("patchID %d:  interpolation\n", patchID);
06420 #endif
06421 
06422 #ifdef MSM_TIMING
06423     double startTime, stopTime;
06424     startTime = CkWallTimer();
06425 #endif
06426 #ifndef MSM_COMM_ONLY
06427     BigReal energy_self = 0;
06428 
06429     Float xphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06430     Float yphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06431     Float zphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06432     Float dxphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06433     Float dyphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06434     Float dzphi[ComputeMsmMgr::MAX_POLY_DEGREE+1];
06435 
06436     const Double rs_edge = Double( mgr->s_edge );
06437     const int s_size = ComputeMsmMgr::PolyDegree[mgr->approx] + 1;
06438 
06439     const Float hx_1 = Float(mgr->hxlen_1);  // real space inverse grid spacing
06440     const Float hy_1 = Float(mgr->hylen_1);
06441     const Float hz_1 = Float(mgr->hzlen_1);
06442 
06443     const int ia = eh.ia();
06444     const int ib = eh.ib();
06445     const int ja = eh.ja();
06446     const int jb = eh.jb();
06447     const int ka = eh.ka();
06448     const int kb = eh.kb();
06449     const int ni = eh.ni();
06450     const int nj = eh.nj();
06451     Float *ehbuffer = eh.data().buffer();
06452 
06453     // loop over atoms
06454     for (int n = 0;  n < coord.len();  n++) {
06455       Float q = coord[n].charge;
06456       if (0==q) continue;
06457 
06458       ScaledPosition s = mgr->lattice.scale(coord[n].position);
06459 
06460       BigReal sx_hx = (s.x - mgr->sglower.x) * mgr->shx_1;
06461       BigReal sy_hy = (s.y - mgr->sglower.y) * mgr->shy_1;
06462       BigReal sz_hz = (s.z - mgr->sglower.z) * mgr->shz_1;
06463 
06464       BigReal xlo = floor(sx_hx) - rs_edge;
06465       BigReal ylo = floor(sy_hy) - rs_edge;
06466       BigReal zlo = floor(sz_hz) - rs_edge;
06467 
06468       // calculate Phi stencils along each dimension
06469       Float xdelta = Float(sx_hx - xlo);
06470       mgr->d_stencil_1d(dxphi, xphi, xdelta, hx_1);
06471       Float ydelta = Float(sy_hy - ylo);
06472       mgr->d_stencil_1d(dyphi, yphi, ydelta, hy_1);
06473       Float zdelta = Float(sz_hz - zlo);
06474       mgr->d_stencil_1d(dzphi, zphi, zdelta, hz_1);
06475 
06476       int ilo = int(xlo);
06477       int jlo = int(ylo);
06478       int klo = int(zlo);
06479 
06480 #if 0
06481       // XXX don't need to test twice!
06482 
06483       // test to see if stencil is within edges of grid
06484       int iswithin = ( ia <= ilo && (ilo+(s_size-1)) <= ib &&
06485                        ja <= jlo && (jlo+(s_size-1)) <= jb &&
06486                        ka <= klo && (klo+(s_size-1)) <= kb );
06487 
06488       if ( ! iswithin ) {
06489         char msg[100];
06490         snprintf(msg, sizeof(msg), "Atom %d is outside of the MSM grid.",
06491             coord[n].id);
06492         NAMD_die(msg);
06493       }
06494 #endif
06495 
06496       // determine force on atom from surrounding potential grid points
06497       //Force f = 0;
06498       //BigReal e = 0;
06499       Float fx=0, fy=0, fz=0, e=0;
06500       for (int k = 0;  k < s_size;  k++) {
06501         int koff = ((k+klo) - ka) * nj;
06502         for (int j = 0;  j < s_size;  j++) {
06503           int jkoff = (koff + (j+jlo) - ja) * ni;
06504           Float cx = yphi[j] * zphi[k];
06505           Float cy = dyphi[j] * zphi[k];
06506           Float cz = yphi[j] * dzphi[k];
06507           for (int i = 0;  i < s_size;  i++) {
06508             int ijkoff = jkoff + (i+ilo) - ia;
06509             Float ec = ehbuffer[ijkoff];
06510             fx += ec * dxphi[i] * cx;
06511             fy += ec * xphi[i] * cy;
06512             fz += ec * xphi[i] * cz;
06513             e += ec * xphi[i] * cx;
06514           }
06515         }
06516       }
06517 
06518 #if 0
06519       force[n].x -= q * (mgr->srx_x * fx + mgr->srx_y * fy + mgr->srx_z * fz);
06520       force[n].y -= q * (mgr->sry_x * fx + mgr->sry_y * fy + mgr->sry_z * fz);
06521       force[n].z -= q * (mgr->srz_x * fx + mgr->srz_y * fy + mgr->srz_z * fz);
06522 #endif
06523       force[n].x -= q * fx;
06524       force[n].y -= q * fy;
06525       force[n].z -= q * fz;
06526       energy += q * e;
06527       energy_self += q * q;
06528 
06529     } // end loop over atoms
06530 
06531     energy_self *= mgr->gzero;
06532     energy -= energy_self;
06533     energy *= 0.5;
06534 #endif // !MSM_COMM_ONLY
06535 #ifdef MSM_TIMING
06536     stopTime = CkWallTimer();
06537     mgr->msmTiming[MsmTimer::INTERP] += stopTime - startTime;
06538     mgr->doneTiming();
06539 #endif
06540     mgr->doneCompute();
06541   }

void msm::PatchData::interpolationC1Hermite (  ) 

Definition at line 6693 of file ComputeMsm.C.

References msm::Array< T >::buffer(), coord, D000, D001, D010, D011, D100, D101, D110, D111, ComputeMsmMgr::d_stencil_1d_c1hermite(), msm::Grid< T >::data(), ComputeMsmMgr::doneCompute(), eh_c1hermite, energy, force, ComputeMsmMgr::gzero, ComputeMsmMgr::hxlen, ComputeMsmMgr::hxlen_1, ComputeMsmMgr::hylen, ComputeMsmMgr::hylen_1, ComputeMsmMgr::hzlen, ComputeMsmMgr::hzlen_1, msm::IndexRange::ia(), msm::IndexRange::ib(), MsmTimer::INTERP, msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), ComputeMsmMgr::lattice, msm::Array< T >::len(), mgr, NAMD_die(), msm::IndexRange::ni(), msm::IndexRange::nj(), patchID, Lattice::scale(), ComputeMsmMgr::sglower, ComputeMsmMgr::shx_1, ComputeMsmMgr::shy_1, ComputeMsmMgr::shz_1, ComputeMsmMgr::srx_x, ComputeMsmMgr::srx_y, ComputeMsmMgr::srx_z, ComputeMsmMgr::sry_x, ComputeMsmMgr::sry_y, ComputeMsmMgr::sry_z, ComputeMsmMgr::srz_x, ComputeMsmMgr::srz_y, ComputeMsmMgr::srz_z, C1Vector::velem, Vector::x, Vector::y, and Vector::z.

Referenced by addPotentialC1Hermite().

06693                                          {
06694 #ifdef DEBUG_MSM_GRID
06695     printf("patchID %d:  interpolation\n", patchID);
06696 #endif
06697 
06698 #ifdef MSM_TIMING
06699     double startTime, stopTime;
06700     startTime = CkWallTimer();
06701 #endif
06702 #ifndef MSM_COMM_ONLY
06703     BigReal energy_self = 0;
06704 
06705     Float xphi[2], dxphi[2], xpsi[2], dxpsi[2];
06706     Float yphi[2], dyphi[2], ypsi[2], dypsi[2];
06707     Float zphi[2], dzphi[2], zpsi[2], dzpsi[2];
06708 
06709     const Float hx = Float(mgr->hxlen);      // real space grid spacing
06710     const Float hy = Float(mgr->hylen);
06711     const Float hz = Float(mgr->hzlen);
06712 
06713     const Float hx_1 = Float(mgr->hxlen_1);  // real space inverse grid spacing
06714     const Float hy_1 = Float(mgr->hylen_1);
06715     const Float hz_1 = Float(mgr->hzlen_1);
06716 
06717     const int ia = eh_c1hermite.ia();
06718     const int ib = eh_c1hermite.ib();
06719     const int ja = eh_c1hermite.ja();
06720     const int jb = eh_c1hermite.jb();
06721     const int ka = eh_c1hermite.ka();
06722     const int kb = eh_c1hermite.kb();
06723     const int ni = eh_c1hermite.ni();
06724     const int nj = eh_c1hermite.nj();
06725     C1Vector *ehbuffer = eh_c1hermite.data().buffer();
06726 
06727     // loop over atoms
06728     for (int n = 0;  n < coord.len();  n++) {
06729       Float q = coord[n].charge;
06730       if (0==q) continue;
06731 
06732       ScaledPosition s = mgr->lattice.scale(coord[n].position);
06733 
06734       BigReal sx_hx = (s.x - mgr->sglower.x) * mgr->shx_1;
06735       BigReal sy_hy = (s.y - mgr->sglower.y) * mgr->shy_1;
06736       BigReal sz_hz = (s.z - mgr->sglower.z) * mgr->shz_1;
06737 
06738       BigReal xlo = floor(sx_hx);
06739       BigReal ylo = floor(sy_hy);
06740       BigReal zlo = floor(sz_hz);
06741 
06742       // calculate Phi stencils along each dimension
06743       Float xdelta = Float(sx_hx - xlo);
06744       mgr->d_stencil_1d_c1hermite(dxphi, xphi, dxpsi, xpsi,
06745           xdelta, hx, hx_1);
06746       Float ydelta = Float(sy_hy - ylo);
06747       mgr->d_stencil_1d_c1hermite(dyphi, yphi, dypsi, ypsi,
06748           ydelta, hy, hy_1);
06749       Float zdelta = Float(sz_hz - zlo);
06750       mgr->d_stencil_1d_c1hermite(dzphi, zphi, dzpsi, zpsi,
06751           zdelta, hz, hz_1);
06752 
06753       int ilo = int(xlo);
06754       int jlo = int(ylo);
06755       int klo = int(zlo);
06756 
06757 #if 0
06758       // XXX don't need to test twice!
06759 
06760       // test to see if stencil is within edges of grid
06761       int iswithin = ( ia <= ilo && ilo < ib &&
06762                        ja <= jlo && jlo < jb &&
06763                        ka <= klo && klo < kb );
06764 
06765       if ( ! iswithin ) {
06766         char msg[100];
06767         snprintf(msg, sizeof(msg), "Atom %d is outside of the MSM grid.",
06768             coord[n].id);
06769         NAMD_die(msg);
06770       }
06771 #endif
06772 
06773       // determine force on atom from surrounding potential grid points
06774       Float fx=0, fy=0, fz=0, e=0;
06775       for (int k = 0;  k < 2;  k++) {
06776         int koff = ((k+klo) - ka) * nj;
06777         for (int j = 0;  j < 2;  j++) {
06778           int jkoff = (koff + (j+jlo) - ja) * ni;
06779           Float c_yphi_zphi = yphi[j] * zphi[k];
06780           Float c_ypsi_zphi = ypsi[j] * zphi[k];
06781           Float c_yphi_zpsi = yphi[j] * zpsi[k];
06782           Float c_ypsi_zpsi = ypsi[j] * zpsi[k];
06783           Float c_yphi_dzphi = yphi[j] * dzphi[k];
06784           Float c_ypsi_dzphi = ypsi[j] * dzphi[k];
06785           Float c_yphi_dzpsi = yphi[j] * dzpsi[k];
06786           Float c_ypsi_dzpsi = ypsi[j] * dzpsi[k];
06787           Float c_dyphi_zphi = dyphi[j] * zphi[k];
06788           Float c_dypsi_zphi = dypsi[j] * zphi[k];
06789           Float c_dyphi_zpsi = dyphi[j] * zpsi[k];
06790           Float c_dypsi_zpsi = dypsi[j] * zpsi[k];
06791           for (int i = 0;  i < 2;  i++) {
06792             int ijkoff = jkoff + (i+ilo) - ia;
06793             fx += dxphi[i] * (c_yphi_zphi * ehbuffer[ijkoff].velem[D000]
06794                 + c_ypsi_zphi * ehbuffer[ijkoff].velem[D010]
06795                 + c_yphi_zpsi * ehbuffer[ijkoff].velem[D001]
06796                 + c_ypsi_zpsi * ehbuffer[ijkoff].velem[D011])
06797               + dxpsi[i] * (c_yphi_zphi * ehbuffer[ijkoff].velem[D100]
06798                   + c_ypsi_zphi * ehbuffer[ijkoff].velem[D110]
06799                   + c_yphi_zpsi * ehbuffer[ijkoff].velem[D101]
06800                   + c_ypsi_zpsi * ehbuffer[ijkoff].velem[D111]);
06801             fy += xphi[i] * (c_dyphi_zphi * ehbuffer[ijkoff].velem[D000]
06802                 + c_dypsi_zphi * ehbuffer[ijkoff].velem[D010]
06803                 + c_dyphi_zpsi * ehbuffer[ijkoff].velem[D001]
06804                 + c_dypsi_zpsi * ehbuffer[ijkoff].velem[D011])
06805               + xpsi[i] * (c_dyphi_zphi * ehbuffer[ijkoff].velem[D100]
06806                   + c_dypsi_zphi * ehbuffer[ijkoff].velem[D110]
06807                   + c_dyphi_zpsi * ehbuffer[ijkoff].velem[D101]
06808                   + c_dypsi_zpsi * ehbuffer[ijkoff].velem[D111]);
06809             fz += xphi[i] * (c_yphi_dzphi * ehbuffer[ijkoff].velem[D000]
06810                 + c_ypsi_dzphi * ehbuffer[ijkoff].velem[D010]
06811                 + c_yphi_dzpsi * ehbuffer[ijkoff].velem[D001]
06812                 + c_ypsi_dzpsi * ehbuffer[ijkoff].velem[D011])
06813               + xpsi[i] * (c_yphi_dzphi * ehbuffer[ijkoff].velem[D100]
06814                   + c_ypsi_dzphi * ehbuffer[ijkoff].velem[D110]
06815                   + c_yphi_dzpsi * ehbuffer[ijkoff].velem[D101]
06816                   + c_ypsi_dzpsi * ehbuffer[ijkoff].velem[D111]);
06817             e += xphi[i] * (c_yphi_zphi * ehbuffer[ijkoff].velem[D000]
06818                 + c_ypsi_zphi * ehbuffer[ijkoff].velem[D010]
06819                 + c_yphi_zpsi * ehbuffer[ijkoff].velem[D001]
06820                 + c_ypsi_zpsi * ehbuffer[ijkoff].velem[D011])
06821               + xpsi[i] * (c_yphi_zphi * ehbuffer[ijkoff].velem[D100]
06822                   + c_ypsi_zphi * ehbuffer[ijkoff].velem[D110]
06823                   + c_yphi_zpsi * ehbuffer[ijkoff].velem[D101]
06824                   + c_ypsi_zpsi * ehbuffer[ijkoff].velem[D111]);
06825           }
06826         }
06827       }
06828 
06829 #if 0
06830       force[n].x -= q * (mgr->srx_x * fx + mgr->srx_y * fy + mgr->srx_z * fz);
06831       force[n].y -= q * (mgr->sry_x * fx + mgr->sry_y * fy + mgr->sry_z * fz);
06832       force[n].z -= q * (mgr->srz_x * fx + mgr->srz_y * fy + mgr->srz_z * fz);
06833 #endif
06834       force[n].x -= q * fx;
06835       force[n].y -= q * fy;
06836       force[n].z -= q * fz;
06837       energy += q * e;
06838       energy_self += q * q;
06839 
06840     } // end loop over atoms
06841 
06842     energy_self *= mgr->gzero;
06843     energy -= energy_self;
06844     energy *= 0.5;
06845 #endif // !MSM_COMM_ONLY
06846 #ifdef MSM_TIMING
06847     stopTime = CkWallTimer();
06848     mgr->msmTiming[MsmTimer::INTERP] += stopTime - startTime;
06849     mgr->doneTiming();
06850 #endif
06851     mgr->doneCompute();
06852   }

void msm::PatchData::sendCharge (  ) 

Definition at line 6367 of file ComputeMsm.C.

References MsmTimer::COMM, msm::Grid< T >::data(), msm::Grid< T >::extract(), msm::Ivec::i, msm::Grid< T >::init(), msm::Ivec::j, msm::Ivec::k, msm::Array< T >::len(), msm::BlockIndex::level, mgr, MSM_PRIORITY, ComputeMsmMgr::msmBlock, msm::BlockIndex::n, pd, GridMsg::put(), qh, msm::PatchDiagram::send, sequence, SET_PRIORITY, subgrid, and msm::Grid< T >::updateLower().

Referenced by anterpolation().

06367                              {
06368 #ifdef MSM_TIMING
06369     double startTime, stopTime;
06370 #endif
06371     int priority = 1;
06372     // buffer portions of grid to send to Blocks on level 0
06373     // allocate the largest buffer space we'll need
06374     //Grid<BigReal> subgrid;
06375     //subgrid.resize(map->bsx[0] * map->bsy[0] * map->bsz[0]);
06376     for (int n = 0;  n < pd->send.len();  n++) {
06377 #ifdef MSM_TIMING
06378       startTime = CkWallTimer();
06379 #endif
06380       // initialize the proper subgrid indexing range
06381       subgrid.init( pd->send[n].nrange );
06382       // extract the values from the larger grid into the subgrid
06383       qh.extract(subgrid);
06384       // translate the subgrid indexing range to match the MSM block
06385       subgrid.updateLower( pd->send[n].nrange_wrap.lower() );
06386       // add the subgrid charges into the block
06387       BlockIndex& bindex = pd->send[n].nblock_wrap;
06388       // place subgrid into message
06389       int msgsz = subgrid.data().len() * sizeof(Float);
06390       GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
06391       SET_PRIORITY(gm, sequence, MSM_PRIORITY + priority);
06392       gm->put(subgrid, bindex.level, sequence);
06393 #ifdef MSM_TIMING
06394       stopTime = CkWallTimer();
06395       mgr->msmTiming[MsmTimer::COMM] += stopTime - startTime;
06396 #endif
06397       mgr->msmBlock[bindex.level](
06398           bindex.n.i, bindex.n.j, bindex.n.k).addCharge(gm);
06399     }
06400   }

void msm::PatchData::sendChargeC1Hermite (  ) 

Definition at line 6646 of file ComputeMsm.C.

References MsmTimer::COMM, msm::Grid< T >::data(), msm::Grid< T >::extract(), msm::Ivec::i, msm::Grid< T >::init(), msm::Ivec::j, msm::Ivec::k, msm::Array< T >::len(), msm::BlockIndex::level, mgr, MSM_PRIORITY, ComputeMsmMgr::msmC1HermiteBlock, msm::BlockIndex::n, pd, GridMsg::put(), qh_c1hermite, msm::PatchDiagram::send, sequence, SET_PRIORITY, subgrid_c1hermite, and msm::Grid< T >::updateLower().

Referenced by anterpolationC1Hermite().

06646                                       {
06647 #ifdef MSM_TIMING
06648     double startTime, stopTime;
06649 #endif
06650     int priority = 1;
06651     // buffer portions of grid to send to Blocks on level 0
06652     for (int n = 0;  n < pd->send.len();  n++) {
06653 #ifdef MSM_TIMING
06654       startTime = CkWallTimer();
06655 #endif
06656       // initialize the proper subgrid indexing range
06657       subgrid_c1hermite.init( pd->send[n].nrange );
06658       // extract the values from the larger grid into the subgrid
06659       qh_c1hermite.extract(subgrid_c1hermite);
06660       // translate the subgrid indexing range to match the MSM block
06661       subgrid_c1hermite.updateLower( pd->send[n].nrange_wrap.lower() );
06662       // add the subgrid charges into the block
06663       BlockIndex& bindex = pd->send[n].nblock_wrap;
06664       // place subgrid into message
06665       int msgsz = subgrid_c1hermite.data().len() * sizeof(C1Vector);
06666       GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
06667       SET_PRIORITY(gm, sequence, MSM_PRIORITY + priority);
06668       gm->put(subgrid_c1hermite, bindex.level, sequence);
06669 #ifdef MSM_TIMING
06670       stopTime = CkWallTimer();
06671       mgr->msmTiming[MsmTimer::COMM] += stopTime - startTime;
06672 #endif
06673       mgr->msmC1HermiteBlock[bindex.level](
06674           bindex.n.i, bindex.n.j, bindex.n.k).addCharge(gm);
06675     }
06676   }


Member Data Documentation

Definition at line 1752 of file ComputeMsm.C.

Referenced by addPotential(), addPotentialC1Hermite(), and init().

Definition at line 1745 of file ComputeMsm.C.

Referenced by addPotential(), init(), interpolation(), and PatchData().

Definition at line 1748 of file ComputeMsm.C.

Referenced by addPotentialC1Hermite(), init(), interpolationC1Hermite(), and PatchData().

Definition at line 1740 of file ComputeMsm.C.

Referenced by PatchData().

Definition at line 1744 of file ComputeMsm.C.

Referenced by anterpolation(), init(), PatchData(), and sendCharge().

Definition at line 1747 of file ComputeMsm.C.

Referenced by anterpolationC1Hermite(), init(), PatchData(), and sendChargeC1Hermite().

Definition at line 1754 of file ComputeMsm.C.

Referenced by ComputeMsm::doWork(), sendCharge(), and sendChargeC1Hermite().

Definition at line 1746 of file ComputeMsm.C.

Referenced by PatchData(), and sendCharge().

Definition at line 1749 of file ComputeMsm.C.

Referenced by PatchData(), and sendChargeC1Hermite().


The documentation for this struct was generated from the following file:

Generated on 8 Dec 2019 for NAMD by  doxygen 1.6.1