NAMD
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
ComputeMsmMgr Class Reference
Inheritance diagram for ComputeMsmMgr:

Public Types

enum  {
  VXX =0, VXY, VXZ, VYY,
  VYZ, VZZ, VMAX
}
 
enum  Approx {
  CUBIC =0, QUINTIC, QUINTIC2, SEPTIC,
  SEPTIC3, NONIC, NONIC4, C1HERMITE,
  NUM_APPROX
}
 
enum  Split {
  TAYLOR2 =0, TAYLOR3, TAYLOR4, TAYLOR5,
  TAYLOR6, TAYLOR7, TAYLOR8, TAYLOR2_DISP,
  TAYLOR3_DISP, TAYLOR4_DISP, TAYLOR5_DISP, TAYLOR6_DISP,
  TAYLOR7_DISP, TAYLOR8_DISP, NUM_SPLIT
}
 
enum  { MAX_POLY_DEGREE = 9, MAX_NSTENCIL_SIZE = (2*MAX_POLY_DEGREE + 1), MAX_NSTENCIL_SKIP_ZERO = (MAX_POLY_DEGREE + 2), NUM_APPROX_FORMS = (NONIC4 - CUBIC) + 1 }
 

Public Member Functions

 ComputeMsmMgr ()
 
 ~ComputeMsmMgr ()
 
void initialize (MsmInitMsg *)
 
void initialize_create ()
 
void recvMsmBlockProxy (MsmBlockProxyMsg *)
 
void recvMsmGridCutoffProxy (MsmGridCutoffProxyMsg *)
 
void recvMsmC1HermiteBlockProxy (MsmC1HermiteBlockProxyMsg *)
 
void recvMsmC1HermiteGridCutoffProxy (MsmC1HermiteGridCutoffProxyMsg *)
 
void update (CkQdMsg *)
 
void compute (msm::Array< int > &patchIDList)
 
void addPotential (GridMsg *)
 
void doneCompute ()
 
void setCompute (ComputeMsm *c)
 
msm::PatchPtrArraypatchPtrArray ()
 
msm::MapmapData ()
 
int numLevels () const
 
void setup_hgrid_1d (BigReal len, BigReal &hh, int &nn, int &ia, int &ib, int isperiodic)
 
void setup_periodic_blocksize (int &bsize, int n)
 
int blockFlatIndex (int level, int i, int j, int k)
 
float calcBlockWork (const msm::BlockDiagram &b)
 
float calcGcutWork (const msm::BlockSend &bs)
 
void initVirialContrib ()
 
void addVirialContrib ()
 
void subtractVirialContrib ()
 
void doneVirialContrib ()
 
void stencil_1d (Float phi[], Float t)
 
void d_stencil_1d (Float dphi[], Float phi[], Float t, Float h_1)
 
void stencil_1d_c1hermite (Float phi[], Float psi[], Float t, Float h)
 
void d_stencil_1d_c1hermite (Float dphi[], Float phi[], Float dpsi[], Float psi[], Float t, Float h, Float h_1)
 

Static Public Member Functions

static int sign (int n)
 
static void splitting (BigReal &g, BigReal &dg, BigReal r_a, int _split)
 
static void ndsplitting (BigReal pg[], BigReal s, int n, int _split)
 
static void gc_c1hermite_elem_accum (C1Matrix &matrix, BigReal _c, Vector rv, BigReal _a, int _split)
 

Public Attributes

CProxy_ComputeMsmMgr msmProxy
 
ComputeMsmmsmCompute
 
msm::Array< CProxy_MsmBlock > msmBlock
 
msm::Array
< CProxy_MsmC1HermiteBlock > 
msmC1HermiteBlock
 
CProxy_MsmGridCutoff msmGridCutoff
 
CProxy_MsmC1HermiteGridCutoff msmC1HermiteGridCutoff
 
int numGridCutoff
 
msm::Map map
 
msm::PatchPtrArray patchPtr
 
msm::Grid< Floatsubgrid
 
msm::Grid< C1Vectorsubgrid_c1hermite
 
msm::Array< int > blockAssign
 
msm::Array< int > gcutAssign
 
msm::Grid< Floatgvsum
 
int numVirialContrib
 
int cntVirialContrib
 
Float virial [VMAX]
 
Vector c
 
Vector u
 
Vector v
 
Vector w
 
Vector ru
 
Vector rv
 
Vector rw
 
int ispu
 
int ispv
 
int ispw
 
Lattice lattice
 
ScaledPosition smin
 
ScaledPosition smax
 
BigReal gridspacing
 
BigReal padding
 
BigReal gridScalingFactor
 
BigReal a
 
BigReal hxlen
 
BigReal hylen
 
BigReal hzlen
 
BigReal hxlen_1
 
BigReal hylen_1
 
BigReal hzlen_1
 
Vector hu
 
Vector hv
 
Vector hw
 
Float hufx
 
Float hufy
 
Float hufz
 
Float hvfx
 
Float hvfy
 
Float hvfz
 
Float hwfx
 
Float hwfy
 
Float hwfz
 
int nhx
 
int nhy
 
int nhz
 
int approx
 
int split
 
int nlevels
 
int dispersion
 
BigReal gzero
 
Vector sglower
 
BigReal shx
 
BigReal shy
 
BigReal shz
 
BigReal shx_1
 
BigReal shy_1
 
BigReal shz_1
 
Vector sx_shx
 
Vector sy_shy
 
Vector sz_shz
 
Float srx_x
 
Float srx_y
 
Float srx_z
 
Float sry_x
 
Float sry_y
 
Float sry_z
 
Float srz_x
 
Float srz_y
 
Float srz_z
 
int s_edge
 
int omega
 

Static Public Attributes

static const int PolyDegree [NUM_APPROX]
 
static const int Nstencil [NUM_APPROX]
 
static const int IndexOffset [NUM_APPROX][MAX_NSTENCIL_SKIP_ZERO]
 
static const Float PhiStencil [NUM_APPROX_FORMS][MAX_NSTENCIL_SKIP_ZERO]
 

Friends

struct msm::PatchData
 
class MsmBlock
 
class MsmBlockMap
 
class MsmGridCutoffMap
 

Detailed Description

Definition at line 364 of file ComputeMsm.C.

Member Enumeration Documentation

anonymous enum
Enumerator
VXX 
VXY 
VXZ 
VYY 
VYZ 
VZZ 
VMAX 

Definition at line 526 of file ComputeMsm.C.

anonymous enum
Enumerator
MAX_POLY_DEGREE 
MAX_NSTENCIL_SIZE 
MAX_NSTENCIL_SKIP_ZERO 
NUM_APPROX_FORMS 

Definition at line 633 of file ComputeMsm.C.

633  {
634  // Approximation formulas with up to degree 9 polynomials.
635  MAX_POLY_DEGREE = 9,
636 
637  // Max stencil length for polynomial approximation.
639 
640  // Max stencil length when skipping zeros
641  // (almost half entries are zero for interpolating polynomials).
643 
644  // Number of scalar approximation formulaes
645  NUM_APPROX_FORMS = (NONIC4 - CUBIC) + 1
646  };
Enumerator
CUBIC 
QUINTIC 
QUINTIC2 
SEPTIC 
SEPTIC3 
NONIC 
NONIC4 
C1HERMITE 
NUM_APPROX 

Definition at line 625 of file ComputeMsm.C.

Constructor & Destructor Documentation

ComputeMsmMgr::ComputeMsmMgr ( )

Definition at line 3854 of file ComputeMsm.C.

3854  :
3855  msmProxy(thisgroup), msmCompute(0)
3856 {
3857 #ifdef DEBUG_MSM_VERBOSE
3858  printf("ComputeMsmMgr: (constructor) PE %d\n", CkMyPe());
3859 #endif
3860  CkpvAccess(BOCclass_group).computeMsmMgr = thisgroup;
3861 
3862 #ifdef MSM_TIMING
3863  if (CkMyPe() == 0) {
3864  msmTimer = CProxy_MsmTimer::ckNew();
3865  }
3866  initTiming();
3867 #endif
3868 #ifdef MSM_PROFILING
3869  if (CkMyPe() == 0) {
3870  msmProfiler = CProxy_MsmProfiler::ckNew();
3871  }
3872  initProfiling();
3873 #endif
3874 }
ComputeMsm * msmCompute
Definition: ComputeMsm.C:462
CProxy_ComputeMsmMgr msmProxy
Definition: ComputeMsm.C:461
ComputeMsmMgr::~ComputeMsmMgr ( )

Definition at line 3876 of file ComputeMsm.C.

3877 {
3878 #ifdef DEBUG_MSM_VERBOSE
3879  printf("ComputeMsmMgr: (destructor) PE %d\n", CkMyPe());
3880 #endif
3881  // free memory?
3882 }

Member Function Documentation

void ComputeMsmMgr::addPotential ( GridMsg gm)

Definition at line 6018 of file ComputeMsm.C.

References approx, C1HERMITE, GridMsg::get(), NAMD_die(), patchPtr, subgrid, and subgrid_c1hermite.

Referenced by MsmBlock::sendDownPotential(), MsmC1HermiteBlock::sendDownPotential(), MsmBlock::sumReducedPotential(), and MsmC1HermiteBlock::sumReducedPotential().

6019 {
6020  int pid; // receive patch ID
6021  int pseq;
6022  if (approx == C1HERMITE) {
6023  gm->get(subgrid_c1hermite, pid, pseq);
6024  }
6025  else {
6026  gm->get(subgrid, pid, pseq);
6027  }
6028  delete gm;
6029  if (patchPtr[pid] == NULL) {
6030  char msg[100];
6031  snprintf(msg, sizeof(msg), "Expecting patch %d to exist on PE %d",
6032  pid, CkMyPe());
6033  NAMD_die(msg);
6034  }
6035  if (approx == C1HERMITE) {
6036  patchPtr[pid]->addPotentialC1Hermite(subgrid_c1hermite);
6037  }
6038  else {
6039  patchPtr[pid]->addPotential(subgrid);
6040  }
6041 }
msm::PatchPtrArray patchPtr
Definition: ComputeMsm.C:476
msm::Grid< Float > subgrid
Definition: ComputeMsm.C:480
void NAMD_die(const char *err_msg)
Definition: common.C:83
msm::Grid< C1Vector > subgrid_c1hermite
Definition: ComputeMsm.C:481
void get(msm::Grid< T > &g, int &id, int &seq)
Definition: ComputeMsm.C:141
void ComputeMsmMgr::addVirialContrib ( )
inline

Definition at line 533 of file ComputeMsm.C.

References numVirialContrib.

533  {
535  }
int numVirialContrib
Definition: ComputeMsm.C:524
int ComputeMsmMgr::blockFlatIndex ( int  level,
int  i,
int  j,
int  k 
)
inline

Definition at line 487 of file ComputeMsm.C.

References msm::Map::blockLevel, and map.

487  {
488  int n = 0;
489  for (int l = 0; l < level; l++) {
490  n += map.blockLevel[l].nn();
491  }
492  return (n + map.blockLevel[level].flatindex(i,j,k));
493  }
Array< Grid< BlockDiagram > > blockLevel
Definition: MsmMap.h:956
msm::Map map
Definition: ComputeMsm.C:471
float ComputeMsmMgr::calcBlockWork ( const msm::BlockDiagram b)
inline

Definition at line 494 of file ComputeMsm.C.

References approx, msm::Map::bsx, msm::Map::bsy, msm::Map::bsz, C1HERMITE, msm::IndexRange::extent(), msm::Map::gc, msm::Map::gc_c1hermite, msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, map, msm::BlockDiagram::nrange, and msm::BlockDiagram::nrangeCutoff.

494  {
495  // XXX ratio of work for MsmBlock to MsmGridCutoff?
496  const float scalingFactor = 3;
497  const int volumeFullBlock = map.bsx[0] * map.bsy[0] * map.bsz[0];
498  msm::Ivec gn;
499  if (approx == C1HERMITE) {
500  gn = map.gc_c1hermite[0].extent();
501  }
502  else {
503  gn = map.gc[0].extent();
504  }
505  const int volumeFullCutoff = (map.bsx[0] + gn.i - 1) *
506  (map.bsy[0] + gn.j - 1) * (map.bsz[0] + gn.k - 1);
507  msm::Ivec n = b.nrange.extent();
508  int volumeBlock = n.i * n.j * n.k;
509  msm::Ivec nc = b.nrangeCutoff.extent();
510  int volumeCutoff = nc.i * nc.j * nc.k;
511  return( scalingFactor * (float(volumeBlock) / volumeFullBlock) *
512  (float(volumeCutoff) / volumeFullCutoff) );
513  }
Array< int > bsz
Definition: MsmMap.h:960
int k
Definition: MsmMap.h:411
Array< int > bsy
Definition: MsmMap.h:960
int i
Definition: MsmMap.h:411
Ivec extent() const
Definition: MsmMap.h:445
int j
Definition: MsmMap.h:411
IndexRange nrange
Definition: MsmMap.h:911
Array< int > bsx
Definition: MsmMap.h:960
IndexRange nrangeCutoff
Definition: MsmMap.h:912
Array< Grid< Float > > gc
Definition: MsmMap.h:944
msm::Map map
Definition: ComputeMsm.C:471
Array< Grid< C1Matrix > > gc_c1hermite
Definition: MsmMap.h:949
float ComputeMsmMgr::calcGcutWork ( const msm::BlockSend bs)
inline

Definition at line 514 of file ComputeMsm.C.

References msm::Map::bsx, msm::Map::bsy, msm::Map::bsz, msm::IndexRange::extent(), msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, map, and msm::BlockSend::nrange_wrap.

514  {
515  const int volumeFullBlock = map.bsx[0] * map.bsy[0] * map.bsz[0];
516  msm::Ivec n = bs.nrange_wrap.extent();;
517  int volumeBlock = n.i * n.j * n.k;
518  return( float(volumeBlock) / volumeFullBlock );
519  }
Array< int > bsz
Definition: MsmMap.h:960
int k
Definition: MsmMap.h:411
Array< int > bsy
Definition: MsmMap.h:960
int i
Definition: MsmMap.h:411
Ivec extent() const
Definition: MsmMap.h:445
int j
Definition: MsmMap.h:411
Array< int > bsx
Definition: MsmMap.h:960
IndexRange nrange_wrap
Definition: MsmMap.h:870
msm::Map map
Definition: ComputeMsm.C:471
void ComputeMsmMgr::compute ( msm::Array< int > &  patchIDList)

Definition at line 5990 of file ComputeMsm.C.

References approx, C1HERMITE, msm::Array< T >::len(), NAMD_die(), and patchPtr.

Referenced by ComputeMsm::doWork().

5991 {
5992 #ifdef DEBUG_MSM_VERBOSE
5993  printf("ComputeMsmMgr: compute() PE=%d\n", CkMyPe());
5994 #endif
5995 
5996  int n;
5997  for (n = 0; n < patchIDList.len(); n++) {
5998  int patchID = patchIDList[n];
5999  if (patchPtr[patchID] == NULL) {
6000  char msg[100];
6001  snprintf(msg, sizeof(msg),
6002  "Expected MSM data for patch %d does not exist on PE %d",
6003  patchID, CkMyPe());
6004  NAMD_die(msg);
6005  }
6006  if (approx == C1HERMITE) {
6007  patchPtr[patchID]->anterpolationC1Hermite();
6008  }
6009  else {
6010  patchPtr[patchID]->anterpolation();
6011  }
6012  // all else should follow from here
6013  }
6014  return;
6015 }
int len() const
Definition: MsmMap.h:218
msm::PatchPtrArray patchPtr
Definition: ComputeMsm.C:476
void NAMD_die(const char *err_msg)
Definition: common.C:83
void ComputeMsmMgr::d_stencil_1d ( Float  dphi[],
Float  phi[],
Float  t,
Float  h_1 
)
inline

Definition at line 937 of file ComputeMsm.C.

References approx, CUBIC, NAMD_die(), NONIC, NONIC4, QUINTIC, QUINTIC2, SEPTIC, and SEPTIC3.

Referenced by msm::PatchData::interpolation().

937  {
938  switch (approx) {
939  case CUBIC:
940  phi[0] = 0.5f * (1 - t) * (2 - t) * (2 - t);
941  dphi[0] = (1.5f * t - 2) * (2 - t) * h_1;
942  t--;
943  phi[1] = (1 - t) * (1 + t - 1.5f * t * t);
944  dphi[1] = (-5 + 4.5f * t) * t * h_1;
945  t--;
946  phi[2] = (1 + t) * (1 - t - 1.5f * t * t);
947  dphi[2] = (-5 - 4.5f * t) * t * h_1;
948  t--;
949  phi[3] = 0.5f * (1 + t) * (2 + t) * (2 + t);
950  dphi[3] = (1.5f * t + 2) * (2 + t) * h_1;
951  break;
952  case QUINTIC:
953  phi[0] = (1.f/24) * (1-t) * (2-t) * (3-t) * (3-t) * (4-t);
954  dphi[0] = ((-1.f/24) * ((3-t) * (3-t) * (14 + t * (-14 + 3*t))
955  + 2 * (1-t) * (2-t) * (3-t) * (4-t))) * h_1;
956  t--;
957  phi[1] = (1-t) * (2-t) * (3-t) * ((1.f/6)
958  + t * (0.375f - (5.f/24)*t));
959  dphi[1] = (-((1.f/6) + t * (0.375f - (5.f/24)*t)) *
960  (11 + t * (-12 + 3*t)) + (1-t) * (2-t) * (3-t) *
961  (0.375f - (5.f/12)*t)) * h_1;
962  t--;
963  phi[2] = (1-t*t) * (2-t) * (0.5f + t * (0.25f - (5.f/12)*t));
964  dphi[2] = (-(0.5f + t * (0.25f - (5.f/12)*t)) * (1 + t * (4 - 3*t))
965  + (1-t*t) * (2-t) * (0.25f - (5.f/6)*t)) * h_1;
966  t--;
967  phi[3] = (1-t*t) * (2+t) * (0.5f - t * (0.25f + (5.f/12)*t));
968  dphi[3] = ((0.5f + t * (-0.25f - (5.f/12)*t)) * (1 + t * (-4 - 3*t))
969  - (1-t*t) * (2+t) * (0.25f + (5.f/6)*t)) * h_1;
970  t--;
971  phi[4] = (1+t) * (2+t) * (3+t) * ((1.f/6)
972  - t * (0.375f + (5.f/24)*t));
973  dphi[4] = (((1.f/6) + t * (-0.375f - (5.f/24)*t)) *
974  (11 + t * (12 + 3*t)) - (1+t) * (2+t) * (3+t) *
975  (0.375f + (5.f/12)*t)) * h_1;
976  t--;
977  phi[5] = (1.f/24) * (1+t) * (2+t) * (3+t) * (3+t) * (4+t);
978  dphi[5] = ((1.f/24) * ((3+t) * (3+t) * (14 + t * (14 + 3*t))
979  + 2 * (1+t) * (2+t) * (3+t) * (4+t))) * h_1;
980  break;
981  case QUINTIC2:
982  phi[0] = (1.f/24) * (3-t) * (3-t) * (3-t) * (t-2) * (5*t-8);
983  dphi[0] = ((1.f/24) * (3-t) * (3-t) * ((3-t)*(5*t-8)
984  - 3*(t-2)*(5*t-8) + 5*(t-2)*(3-t))) * h_1;
985  t--;
986  phi[1] = (-1.f/24) * (2-t) * (t-1) * (-48+t*(153+t*(-114+t*25)));
987  dphi[1] = ((-1.f/24) * ((2-t)*(-48+t*(153+t*(-114+t*25)))
988  - (t-1)* (-48+t*(153+t*(-114+t*25)))
989  + (2-t)*(t-1)*(153+t*(-228+t*75)))) * h_1;
990  t--;
991  phi[2] = (1.f/12) * (1-t) * (12+t*(12+t*(-3+t*(-38+t*25))));
992  dphi[2] = ((1.f/12) * (-(12+t*(12+t*(-3+t*(-38+t*25))))
993  + (1-t)*(12+t*(-6+t*(-114+t*100))))) * h_1;
994  t--;
995  phi[3] = (1.f/12) * (1+t) * (12+t*(-12+t*(-3+t*(38+t*25))));
996  dphi[3] = ((1.f/12) * ((12+t*(-12+t*(-3+t*(38+t*25))))
997  + (1+t)*(-12+t*(-6+t*(114+t*100))))) * h_1;
998  t--;
999  phi[4] = (-1.f/24) * (2+t) * (t+1) * (48+t*(153+t*(114+t*25)));
1000  dphi[4] = ((-1.f/24) * ((2+t)*(48+t*(153+t*(114+t*25)))
1001  + (t+1)* (48+t*(153+t*(114+t*25)))
1002  + (2+t)*(t+1)*(153+t*(228+t*75)))) * h_1;
1003  t--;
1004  phi[5] = (1.f/24) * (3+t) * (3+t) * (3+t) * (t+2) * (5*t+8);
1005  dphi[5] = ((1.f/24) * (3+t) * (3+t) * ((3+t)*(5*t+8)
1006  + 3*(t+2)*(5*t+8) + 5*(t+2)*(3+t))) * h_1;
1007  break;
1008  case SEPTIC:
1009  phi[0] = (-1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-4)*(t-5)*(t-6);
1010  dphi[0] = (-1.f/720)*(t-4)*(-1944+t*(3644+t*(-2512+t*(807
1011  +t*(-122+t*7))))) * h_1;
1012  t--;
1013  phi[1] = (1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-5)*(-6+t*(-20+7*t));
1014  dphi[1] = (1.f/720)*(756+t*(-9940+t*(17724+t*(-12740+t*(4445
1015  +t*(-750+t*49)))))) * h_1;
1016  t--;
1017  phi[2] = (-1.f/240)*(t*t-1)*(t-2)*(t-3)*(t-4)*(-10+t*(-12+7*t));
1018  dphi[2] = (-1.f/240)*(-28+t*(1260+t*(-756+t*(-1260+t*(1365
1019  +t*(-450+t*49)))))) * h_1;
1020  t--;
1021  phi[3] = (1.f/144)*(t*t-1)*(t*t-4)*(t-3)*(-12+t*(-4+7*t));
1022  dphi[3] = (1.f/144)*t*(-560+t*(84+t*(644+t*(-175
1023  +t*(-150+t*49))))) * h_1;
1024  t--;
1025  phi[4] = (-1.f/144)*(t*t-1)*(t*t-4)*(t+3)*(-12+t*(4+7*t));
1026  dphi[4] = (-1.f/144)*t*(560+t*(84+t*(-644+t*(-175
1027  +t*(150+t*49))))) * h_1;
1028  t--;
1029  phi[5] = (1.f/240)*(t*t-1)*(t+2)*(t+3)*(t+4)*(-10+t*(12+7*t));
1030  dphi[5] = (1.f/240)*(-28+t*(-1260+t*(-756+t*(1260+t*(1365
1031  +t*(450+t*49)))))) * h_1;
1032  t--;
1033  phi[6] = (-1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(-6+t*(20+7*t));
1034  dphi[6] = (-1.f/720)*(756+t*(9940+t*(17724+t*(12740+t*(4445
1035  +t*(750+t*49)))))) * h_1;
1036  t--;
1037  phi[7] = (1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+4)*(t+5)*(t+6);
1038  dphi[7] = (1.f/720)*(t+4)*(1944+t*(3644+t*(2512+t*(807
1039  +t*(122+t*7))))) * h_1;
1040  break;
1041  case SEPTIC3:
1042  phi[0] = (3632.f/5) + t*((-7456.f/5) + t*((58786.f/45) + t*(-633
1043  + t*((26383.f/144) + t*((-22807.f/720) + t*((727.f/240)
1044  + t*(-89.f/720)))))));
1045  dphi[0] = ((-7456.f/5) + t*((117572.f/45) + t*(-1899
1046  + t*((26383.f/36) + t*((-22807.f/144) + t*((727.f/40)
1047  + t*(-623.f/720))))))) * h_1;
1048  t--;
1049  phi[1] = -440 + t*((25949.f/20) + t*((-117131.f/72) + t*((2247.f/2)
1050  + t*((-66437.f/144) + t*((81109.f/720) + t*((-727.f/48)
1051  + t*(623.f/720)))))));
1052  dphi[1] = ((25949.f/20) + t*((-117131.f/36) + t*((6741.f/2)
1053  + t*((-66437.f/36) + t*((81109.f/144) + t*((-727.f/8)
1054  + t*(4361.f/720))))))) * h_1;
1055  t--;
1056  phi[2] = (138.f/5) + t*((-8617.f/60) + t*((12873.f/40) + t*((-791.f/2)
1057  + t*((4557.f/16) + t*((-9583.f/80) + t*((2181.f/80)
1058  + t*(-623.f/240)))))));
1059  dphi[2] = ((-8617.f/60) + t*((12873.f/20) + t*((-2373.f/2)
1060  + t*((4557.f/4) + t*((-9583.f/16) + t*((6543.f/40)
1061  + t*(-4361.f/240))))))) * h_1;
1062  t--;
1063  phi[3] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((2569.f/144)
1064  + t*((-727.f/48) + t*(623.f/144)))));
1065  dphi[3] = (t*((-49.f/18) + t*t*((-959.f/36) + t*((12845.f/144)
1066  + t*((-727.f/8) + t*(4361.f/144)))))) * h_1;
1067  t--;
1068  phi[4] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((-2569.f/144)
1069  + t*((-727.f/48) + t*(-623.f/144)))));
1070  dphi[4] = (t*((-49.f/18) + t*t*((-959.f/36) + t*((-12845.f/144)
1071  + t*((-727.f/8) + t*(-4361.f/144)))))) * h_1;
1072  t--;
1073  phi[5] = (138.f/5) + t*((8617.f/60) + t*((12873.f/40) + t*((791.f/2)
1074  + t*((4557.f/16) + t*((9583.f/80) + t*((2181.f/80)
1075  + t*(623.f/240)))))));
1076  dphi[5] = ((8617.f/60) + t*((12873.f/20) + t*((2373.f/2)
1077  + t*((4557.f/4) + t*((9583.f/16) + t*((6543.f/40)
1078  + t*(4361.f/240))))))) * h_1;
1079  t--;
1080  phi[6] = -440 + t*((-25949.f/20) + t*((-117131.f/72) + t*((-2247.f/2)
1081  + t*((-66437.f/144) + t*((-81109.f/720) + t*((-727.f/48)
1082  + t*(-623.f/720)))))));
1083  dphi[6] = ((-25949.f/20) + t*((-117131.f/36) + t*((-6741.f/2)
1084  + t*((-66437.f/36) + t*((-81109.f/144) + t*((-727.f/8)
1085  + t*(-4361.f/720))))))) * h_1;
1086  t--;
1087  phi[7] = (3632.f/5) + t*((7456.f/5) + t*((58786.f/45) + t*(633
1088  + t*((26383.f/144) + t*((22807.f/720) + t*((727.f/240)
1089  + t*(89.f/720)))))));
1090  dphi[7] = ((7456.f/5) + t*((117572.f/45) + t*(1899
1091  + t*((26383.f/36) + t*((22807.f/144) + t*((727.f/40)
1092  + t*(623.f/720))))))) * h_1;
1093  break;
1094  case NONIC:
1095  phi[0] = (-1.f/40320)*(t-8)*(t-7)*(t-6)*(t-5)*(t-5)*(t-4)*(t-3)*
1096  (t-2)*(t-1);
1097  dphi[0] = (-1.f/40320)*(t-5)*(-117648+t*(256552+t*(-221416
1098  +t*(99340+t*(-25261+t*(3667+t*(-283+t*9)))))))*h_1;
1099  t--;
1100  phi[1] = (1.f/40320)*(t-7)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*
1101  (-8+t*(-35+9*t));
1102  dphi[1] = (1.f/40320)*(71856+t*(-795368+t*(1569240+t*(-1357692
1103  +t*(634725+t*(-172116+t*(27090+t*(-2296+t*81))))))))*h_1;
1104  t--;
1105  phi[2] = (-1.f/10080)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*
1106  (-14+t*(-25+9*t));
1107  dphi[2] = (1.f/10080)*(3384+t*(-69080+t*(55026
1108  +t*(62580+t*(-99225+t*(51660+t*(-13104+t*(1640
1109  +t*(-81)))))))))*h_1;
1110  t--;
1111  phi[3] = (1.f/1440)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*
1112  (-6+t*(-5+3*t));
1113  dphi[3] = (1.f/1440)*(72+t*(-6344+t*(2070
1114  +t*(7644+t*(-4725+t*(-828+t*(1260+t*(-328+t*27))))))))*h_1;
1115  t--;
1116  phi[4] = (-1.f/2880)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*
1117  (-20+t*(-5+9*t));
1118  dphi[4] = (-1.f/2880)*t*(10792+t*(-972+t*(-12516
1119  +t*(2205+t*(3924+t*(-882+t*(-328+t*81)))))))*h_1;
1120  t--;
1121  phi[5] = (1.f/2880)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*
1122  (-20+t*(5+9*t));
1123  dphi[5] = (1.f/2880)*t*(-10792+t*(-972+t*(12516
1124  +t*(2205+t*(-3924+t*(-882+t*(328+t*81)))))))*h_1;
1125  t--;
1126  phi[6] = (-1.f/1440)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*
1127  (-6+t*(5+3*t));
1128  dphi[6] = (1.f/1440)*(-72+t*(-6344+t*(-2070
1129  +t*(7644+t*(4725+t*(-828+t*(-1260+t*(-328+t*(-27)))))))))*h_1;
1130  t--;
1131  phi[7] = (1.f/10080)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)*
1132  (-14+t*(25+9*t));
1133  dphi[7] = (1.f/10080)*(-3384+t*(-69080+t*(-55026
1134  +t*(62580+t*(99225+t*(51660+t*(13104+t*(1640+t*81))))))))*h_1;
1135  t--;
1136  phi[8] = (-1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)*(t+7)*
1137  (-8+t*(35+9*t));
1138  dphi[8] = (-1.f/40320)*(71856+t*(795368+t*(1569240
1139  +t*(1357692+t*(634725+t*(172116+t*(27090+t*(2296
1140  +t*81))))))))*h_1;
1141  t--;
1142  phi[9] = (1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+5)*(t+6)*
1143  (t+7)*(t+8);
1144  dphi[9] = (1.f/40320)*(t+5)*(117648+t*(256552+t*(221416
1145  +t*(99340+t*(25261+t*(3667+t*(283+t*9)))))))*h_1;
1146  break;
1147  case NONIC4:
1148  { // begin grouping to define local variables
1149  double Tphi[10], Tdphi[10];
1150  double T=t;
1151  Tphi[0] = 439375./7+T*(-64188125./504+T*(231125375./2016
1152  +T*(-17306975./288+T*(7761805./384+T*(-2895587./640
1153  +T*(129391./192+T*(-259715./4032+T*(28909./8064
1154  +T*(-3569./40320)))))))));
1155  Tdphi[0] = (-64188125./504+T*(231125375./1008
1156  +T*(-17306975./96+T*(7761805./96+T*(-2895587./128
1157  +T*(129391./32+T*(-259715./576+T*(28909./1008
1158  +T*(-3569./4480))))))))) * h_1;
1159  T--;
1160  Tphi[1] = -56375+T*(8314091./56+T*(-49901303./288+T*(3763529./32
1161  +T*(-19648027./384+T*(9469163./640+T*(-545977./192
1162  +T*(156927./448+T*(-28909./1152
1163  +T*(3569./4480)))))))));
1164  Tdphi[1] = (8314091./56+T*(-49901303./144+T*(11290587./32
1165  +T*(-19648027./96+T*(9469163./128+T*(-545977./32
1166  +T*(156927./64+T*(-28909./144
1167  +T*(32121./4480))))))))) * h_1;
1168  T--;
1169  Tphi[2] = 68776./7+T*(-1038011./28+T*(31157515./504+T*(-956669./16
1170  +T*(3548009./96+T*(-2422263./160+T*(197255./48
1171  +T*(-19959./28+T*(144545./2016
1172  +T*(-3569./1120)))))))));
1173  Tdphi[2] = (-1038011./28+T*(31157515./252+T*(-2870007./16
1174  +T*(3548009./24+T*(-2422263./32+T*(197255./8
1175  +T*(-19959./4+T*(144545./252
1176  +T*(-32121./1120))))))))) * h_1;
1177  T--;
1178  Tphi[3] = -154+T*(12757./12+T*(-230123./72+T*(264481./48
1179  +T*(-576499./96+T*(686147./160+T*(-96277./48
1180  +T*(14221./24+T*(-28909./288+T*(3569./480)))))))));
1181  Tdphi[3] = (12757./12+T*(-230123./36+T*(264481./16
1182  +T*(-576499./24+T*(686147./32+T*(-96277./8
1183  +T*(99547./24+T*(-28909./36
1184  +T*(10707./160))))))))) * h_1;
1185  T--;
1186  Tphi[4] = 1+T*T*(-205./144+T*T*(91./192+T*(-6181./320
1187  +T*(6337./96+T*(-2745./32+T*(28909./576
1188  +T*(-3569./320)))))));
1189  Tdphi[4] = T*(-205./72+T*T*(91./48+T*(-6181./64
1190  +T*(6337./16+T*(-19215./32+T*(28909./72
1191  +T*(-32121./320))))))) * h_1;
1192  T--;
1193  Tphi[5] = 1+T*T*(-205./144+T*T*(91./192+T*(6181./320
1194  +T*(6337./96+T*(2745./32+T*(28909./576
1195  +T*(3569./320)))))));
1196  Tdphi[5] = T*(-205./72+T*T*(91./48+T*(6181./64
1197  +T*(6337./16+T*(19215./32+T*(28909./72
1198  +T*(32121./320))))))) * h_1;
1199  T--;
1200  Tphi[6] = -154+T*(-12757./12+T*(-230123./72+T*(-264481./48
1201  +T*(-576499./96+T*(-686147./160+T*(-96277./48
1202  +T*(-14221./24+T*(-28909./288+T*(-3569./480)))))))));
1203  Tdphi[6] = (-12757./12+T*(-230123./36+T*(-264481./16
1204  +T*(-576499./24+T*(-686147./32+T*(-96277./8
1205  +T*(-99547./24+T*(-28909./36
1206  +T*(-10707./160))))))))) * h_1;
1207  T--;
1208  Tphi[7] = 68776./7+T*(1038011./28+T*(31157515./504+T*(956669./16
1209  +T*(3548009./96+T*(2422263./160+T*(197255./48
1210  +T*(19959./28+T*(144545./2016+T*(3569./1120)))))))));
1211  Tdphi[7] = (1038011./28+T*(31157515./252+T*(2870007./16
1212  +T*(3548009./24+T*(2422263./32+T*(197255./8
1213  +T*(19959./4+T*(144545./252
1214  +T*(32121./1120))))))))) * h_1;
1215  T--;
1216  Tphi[8] = -56375+T*(-8314091./56+T*(-49901303./288+T*(-3763529./32
1217  +T*(-19648027./384+T*(-9469163./640+T*(-545977./192
1218  +T*(-156927./448+T*(-28909./1152
1219  +T*(-3569./4480)))))))));
1220  Tdphi[8] = (-8314091./56+T*(-49901303./144+T*(-11290587./32
1221  +T*(-19648027./96+T*(-9469163./128+T*(-545977./32
1222  +T*(-156927./64+T*(-28909./144
1223  +T*(-32121./4480))))))))) * h_1;
1224  T--;
1225  Tphi[9] = 439375./7+T*(64188125./504+T*(231125375./2016
1226  +T*(17306975./288+T*(7761805./384+T*(2895587./640
1227  +T*(129391./192+T*(259715./4032+T*(28909./8064
1228  +T*(3569./40320)))))))));
1229  Tdphi[9] = (64188125./504+T*(231125375./1008
1230  +T*(17306975./96+T*(7761805./96+T*(2895587./128
1231  +T*(129391./32+T*(259715./576+T*(28909./1008
1232  +T*(3569./4480))))))))) * h_1;
1233  for (int i=0; i < 10; i++) {
1234  phi[i] = Float(Tphi[i]);
1235  dphi[i] = Float(Tdphi[i]);
1236  }
1237  } // end grouping to define local variables
1238  break;
1239  default:
1240  NAMD_die("Unknown MSM approximation.");
1241  } // switch
1242  } // d_stencil_1d()
void NAMD_die(const char *err_msg)
Definition: common.C:83
float Float
Definition: MsmMap.h:74
void ComputeMsmMgr::d_stencil_1d_c1hermite ( Float  dphi[],
Float  phi[],
Float  dpsi[],
Float  psi[],
Float  t,
Float  h,
Float  h_1 
)
inline

Definition at line 1252 of file ComputeMsm.C.

Referenced by msm::PatchData::interpolationC1Hermite().

1254  {
1255  phi[0] = (1 - t) * (1 - t) * (1 + 2*t);
1256  dphi[0] = -6 * t * (1 - t) * h_1;
1257  psi[0] = h * t * (1 - t) * (1 - t);
1258  dpsi[0] = (1 - t) * (1 - 3*t);
1259  t--;
1260  phi[1] = (1 + t) * (1 + t) * (1 - 2*t);
1261  dphi[1] = -6 * t * (1 + t) * h_1;
1262  psi[1] = h * t * (1 + t) * (1 + t);
1263  dpsi[1] = (1 + t) * (1 + 3*t);
1264  }
void ComputeMsmMgr::doneCompute ( )

Definition at line 6044 of file ComputeMsm.C.

References msmCompute, and ComputeMsm::saveResults().

Referenced by msm::PatchData::interpolation(), and msm::PatchData::interpolationC1Hermite().

6045 {
6047 }
ComputeMsm * msmCompute
Definition: ComputeMsm.C:462
void saveResults()
Definition: ComputeMsm.C:6161
void ComputeMsmMgr::doneVirialContrib ( )
inline

Definition at line 539 of file ComputeMsm.C.

References c, cntVirialContrib, gvsum, hufx, hufy, hufz, hvfx, hvfy, hvfz, hwfx, hwfy, hwfz, msm::IndexRange::ia(), msm::IndexRange::ib(), initVirialContrib(), msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), numVirialContrib, virial, VMAX, VXX, VXY, VXZ, VYY, VYZ, and VZZ.

539  {
541  // reduce all gvsum contributions into virial tensor
542  for (int n = 0; n < VMAX; n++) { virial[n] = 0; }
543  int ia = gvsum.ia();
544  int ib = gvsum.ib();
545  int ja = gvsum.ja();
546  int jb = gvsum.jb();
547  int ka = gvsum.ka();
548  int kb = gvsum.kb();
549  for (int k = ka; k <= kb; k++) {
550  for (int j = ja; j <= jb; j++) {
551  for (int i = ia; i <= ib; i++) {
552  Float cu = Float(i);
553  Float cv = Float(j);
554  Float cw = Float(k);
555  Float c = gvsum(i,j,k);
556  Float vx = cu*hufx + cv*hvfx + cw*hwfx;
557  Float vy = cu*hufy + cv*hvfy + cw*hwfy;
558  Float vz = cu*hufz + cv*hvfz + cw*hwfz;
559  virial[VXX] -= c * vx * vx;
560  virial[VXY] -= c * vx * vy;
561  virial[VXZ] -= c * vx * vz;
562  virial[VYY] -= c * vy * vy;
563  virial[VYZ] -= c * vy * vz;
564  virial[VZZ] -= c * vz * vz;
565  }
566  }
567  }
569  }
570  }
int ka() const
Definition: MsmMap.h:438
int numVirialContrib
Definition: ComputeMsm.C:524
int ia() const
Definition: MsmMap.h:434
void initVirialContrib()
Definition: ComputeMsm.C:529
int cntVirialContrib
Definition: ComputeMsm.C:525
msm::Grid< Float > gvsum
Definition: ComputeMsm.C:523
int kb() const
Definition: MsmMap.h:439
Float virial[VMAX]
Definition: ComputeMsm.C:527
int jb() const
Definition: MsmMap.h:437
float Float
Definition: MsmMap.h:74
int ib() const
Definition: MsmMap.h:435
int ja() const
Definition: MsmMap.h:436
static void ComputeMsmMgr::gc_c1hermite_elem_accum ( C1Matrix matrix,
BigReal  _c,
Vector  rv,
BigReal  _a,
int  _split 
)
inlinestatic

Definition at line 1410 of file ComputeMsm.C.

References C1_VECTOR_SIZE, C1INDEX, D000, D001, D010, D011, D100, D101, D110, D111, C1Matrix::melem, ndsplitting(), rv, TAYLOR2, TAYLOR3, TAYLOR4, TAYLOR5, Vector::x, Vector::y, and Vector::z.

Referenced by initialize().

1411  {
1412  const BigReal a_1 = 1./_a;
1413  const BigReal a_2 = a_1 * a_1;
1414  const BigReal s = (rv * rv) * a_2;
1415  const BigReal dx = -2 * rv.x * a_2; // ds/dx
1416  const BigReal dy = -2 * rv.y * a_2; // ds/dy
1417  const BigReal dz = -2 * rv.z * a_2; // ds/dz
1418  const BigReal dd = 2 * a_2; // d^2s/dx^2 = d^2s/dy^2 = d^2s/dz^2
1419  BigReal tmp;
1420  enum { nderiv = C1_VECTOR_SIZE-1 };
1421  BigReal p[nderiv];
1422  Float *g = matrix.melem;
1423 
1424  // multiply entire matrix by this coefficient
1425  _c = _c * a_1;
1426 
1427  // compute derivatives (d/ds)^k of splitting g(s), s=r^2
1428  ndsplitting(p, s, nderiv, _split);
1429 
1430  // weight 0
1431  tmp = _c * p[0];
1432  g[C1INDEX(D000,D000)] += tmp;
1433 
1434  // weight 1
1435  tmp = _c * p[1] * dx;
1436  g[C1INDEX(D100,D000)] += tmp;
1437  g[C1INDEX(D000,D100)] -= tmp;
1438 
1439  tmp = _c * p[1] * dy;
1440  g[C1INDEX(D010,D000)] += tmp;
1441  g[C1INDEX(D000,D010)] -= tmp;
1442 
1443  tmp = _c * p[1] * dz;
1444  g[C1INDEX(D001,D000)] += tmp;
1445  g[C1INDEX(D000,D001)] -= tmp;
1446 
1447  // C1 splitting returns here
1448 
1449  // weight 2
1450  tmp = _c * p[2] * dx * dy;
1451  g[C1INDEX(D110,D000)] += tmp;
1452  g[C1INDEX(D000,D110)] += tmp;
1453  g[C1INDEX(D100,D010)] -= tmp;
1454  g[C1INDEX(D010,D100)] -= tmp;
1455 
1456  tmp = _c * p[2] * dx * dz;
1457  g[C1INDEX(D101,D000)] += tmp;
1458  g[C1INDEX(D000,D101)] += tmp;
1459  g[C1INDEX(D100,D001)] -= tmp;
1460  g[C1INDEX(D001,D100)] -= tmp;
1461 
1462  tmp = _c * p[2] * dy * dz;
1463  g[C1INDEX(D011,D000)] += tmp;
1464  g[C1INDEX(D000,D011)] += tmp;
1465  g[C1INDEX(D010,D001)] -= tmp;
1466  g[C1INDEX(D001,D010)] -= tmp;
1467 
1468  tmp = _c * (p[2] * dx*dx + p[1] * dd);
1469  g[C1INDEX(D100,D100)] -= tmp;
1470  tmp = _c * (p[2] * dy*dy + p[1] * dd);
1471  g[C1INDEX(D010,D010)] -= tmp;
1472  tmp = _c * (p[2] * dz*dz + p[1] * dd);
1473  g[C1INDEX(D001,D001)] -= tmp;
1474 
1475  // C2 splitting returns here
1476  if (_split == TAYLOR2) return;
1477 
1478  // weight 3
1479  tmp = _c * p[3] * dx * dy * dz;
1480  g[C1INDEX(D111,D000)] += tmp;
1481  g[C1INDEX(D110,D001)] -= tmp;
1482  g[C1INDEX(D101,D010)] -= tmp;
1483  g[C1INDEX(D011,D100)] -= tmp;
1484  g[C1INDEX(D100,D011)] += tmp;
1485  g[C1INDEX(D010,D101)] += tmp;
1486  g[C1INDEX(D001,D110)] += tmp;
1487  g[C1INDEX(D000,D111)] -= tmp;
1488 
1489  tmp = _c * (p[3] * dx*dx * dy + p[2] * dd * dy);
1490  g[C1INDEX(D110,D100)] -= tmp;
1491  g[C1INDEX(D100,D110)] += tmp;
1492 
1493  tmp = _c * (p[3] * dx*dx * dz + p[2] * dd * dz);
1494  g[C1INDEX(D101,D100)] -= tmp;
1495  g[C1INDEX(D100,D101)] += tmp;
1496 
1497  tmp = _c * (p[3] * dy*dy * dx + p[2] * dd * dx);
1498  g[C1INDEX(D110,D010)] -= tmp;
1499  g[C1INDEX(D010,D110)] += tmp;
1500 
1501  tmp = _c * (p[3] * dy*dy * dz + p[2] * dd * dz);
1502  g[C1INDEX(D011,D010)] -= tmp;
1503  g[C1INDEX(D010,D011)] += tmp;
1504 
1505  tmp = _c * (p[3] * dz*dz * dx + p[2] * dd * dx);
1506  g[C1INDEX(D101,D001)] -= tmp;
1507  g[C1INDEX(D001,D101)] += tmp;
1508 
1509  tmp = _c * (p[3] * dz*dz * dy + p[2] * dd * dy);
1510  g[C1INDEX(D011,D001)] -= tmp;
1511  g[C1INDEX(D001,D011)] += tmp;
1512 
1513  // C3 splitting returns here
1514  if (_split == TAYLOR3) return;
1515 
1516  // weight 4
1517  tmp = _c * (p[4] * dx*dx * dy * dz + p[3] * dd * dy * dz);
1518  g[C1INDEX(D111,D100)] -= tmp;
1519  g[C1INDEX(D100,D111)] -= tmp;
1520  g[C1INDEX(D110,D101)] += tmp;
1521  g[C1INDEX(D101,D110)] += tmp;
1522 
1523  tmp = _c * (p[4] * dy*dy * dx * dz + p[3] * dd * dx * dz);
1524  g[C1INDEX(D111,D010)] -= tmp;
1525  g[C1INDEX(D010,D111)] -= tmp;
1526  g[C1INDEX(D110,D011)] += tmp;
1527  g[C1INDEX(D011,D110)] += tmp;
1528 
1529  tmp = _c * (p[4] * dz*dz * dx * dy + p[3] * dd * dx * dy);
1530  g[C1INDEX(D111,D001)] -= tmp;
1531  g[C1INDEX(D001,D111)] -= tmp;
1532  g[C1INDEX(D101,D011)] += tmp;
1533  g[C1INDEX(D011,D101)] += tmp;
1534 
1535  tmp = _c * (p[4] * dx*dx * dy*dy + p[3] * dx*dx * dd
1536  + p[3] * dd * dy*dy + p[2] * dd * dd);
1537  g[C1INDEX(D110,D110)] += tmp;
1538  tmp = _c * (p[4] * dx*dx * dz*dz + p[3] * dx*dx * dd
1539  + p[3] * dd * dz*dz + p[2] * dd * dd);
1540  g[C1INDEX(D101,D101)] += tmp;
1541  tmp = _c * (p[4] * dy*dy * dz*dz + p[3] * dy*dy * dd
1542  + p[3] * dd * dz*dz + p[2] * dd * dd);
1543  g[C1INDEX(D011,D011)] += tmp;
1544 
1545  // C4 splitting returns here
1546  if (_split == TAYLOR4) return;
1547 
1548  // weight 5
1549  tmp = _c * (p[5] * dx*dx * dy*dy * dz + p[4] * dx*dx * dd * dz
1550  + p[4] * dd * dy*dy * dz + p[3] * dd * dd * dz);
1551  g[C1INDEX(D111,D110)] += tmp;
1552  g[C1INDEX(D110,D111)] -= tmp;
1553 
1554  tmp = _c * (p[5] * dx*dx * dz*dz * dy + p[4] * dx*dx * dd * dy
1555  + p[4] * dd * dz*dz * dy + p[3] * dd * dd * dy);
1556  g[C1INDEX(D111,D101)] += tmp;
1557  g[C1INDEX(D101,D111)] -= tmp;
1558 
1559  tmp = _c * (p[5] * dy*dy * dz*dz * dx + p[4] * dy*dy * dd * dx
1560  + p[4] * dd * dz*dz * dx + p[3] * dd * dd * dx);
1561  g[C1INDEX(D111,D011)] += tmp;
1562  g[C1INDEX(D011,D111)] -= tmp;
1563 
1564  // C5 splitting returns here
1565  if (_split == TAYLOR5) return;
1566 
1567  // weight 6
1568  tmp = _c * (p[6] * dx*dx * dy*dy * dz*dz + p[5] * dx*dx * dy*dy * dd
1569  + p[5] * dx*dx * dd * dz*dz + p[5] * dd * dy*dy * dz*dz
1570  + p[4] * dx*dx * dd * dd + p[4] * dd * dy*dy * dd
1571  + p[4] * dd * dd * dz*dz + p[3] * dd * dd * dd);
1572  g[C1INDEX(D111,D111)] -= tmp;
1573 
1574  // calculate full matrix for C6 or higher splitting
1575 
1576  } // gc_c1hermite_elem_accum()
Definition: MsmMap.h:187
Definition: MsmMap.h:187
BigReal z
Definition: Vector.h:66
Definition: MsmMap.h:187
#define C1INDEX(drj, dri)
Definition: MsmMap.h:191
Definition: MsmMap.h:187
BigReal x
Definition: Vector.h:66
Definition: MsmMap.h:187
float Float
Definition: MsmMap.h:74
static void ndsplitting(BigReal pg[], BigReal s, int n, int _split)
Definition: ComputeMsm.C:1266
Float melem[C1_MATRIX_SIZE]
Definition: MsmMap.h:111
Definition: MsmMap.h:187
BigReal y
Definition: Vector.h:66
Definition: MsmMap.h:187
Definition: MsmMap.h:187
double BigReal
Definition: common.h:114
void ComputeMsmMgr::initialize ( MsmInitMsg msg)

Definition at line 3969 of file ComputeMsm.C.

References Lattice::a(), a, Lattice::a_p(), Lattice::a_r(), approx, ASSERT, Lattice::b(), Lattice::b_p(), Lattice::b_r(), msm::Map::blockLevel, msm::Map::bsx, msm::Map::bsy, msm::Map::bsz, Lattice::c(), c, C1HERMITE, C1INDEX, Lattice::c_p(), Lattice::c_r(), cross(), CUBIC, SimParameters::cutoff, D000, D001, D010, D011, D100, D101, D110, D111, dispersion, endi(), msm::Map::foldfactor, msm::Map::gc, msm::Map::gc_c1hermite, gc_c1hermite_elem_accum(), msm::Map::gpro_c1hermite, msm::Map::gres_c1hermite, msm::Map::grespro, msm::Map::gridrange, gridScalingFactor, gridspacing, msm::Map::gvc, gvsum, gzero, hu, hufx, hufy, hufz, hv, hvfx, hvfy, hvfz, hw, hwfx, hwfy, hwfz, hxlen, hxlen_1, hylen, hylen_1, hzlen, hzlen_1, msm::IndexRange::ia(), msm::IndexRange::ib(), iINFO(), iout, msm::Map::ispx, msm::Map::ispy, msm::Map::ispz, msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), SimParameters::lattice, lattice, Vector::length(), map, MSM_MAX_BLOCK_VOLUME, SimParameters::MSMApprox, SimParameters::MSMBlockSizeX, SimParameters::MSMBlockSizeY, SimParameters::MSMBlockSizeZ, SimParameters::MSMGridSpacing, SimParameters::MSMLevels, SimParameters::MSMPadding, SimParameters::MSMSplit, SimParameters::MSMxmax, SimParameters::MSMxmin, SimParameters::MSMymax, SimParameters::MSMymin, SimParameters::MSMzmax, SimParameters::MSMzmin, NAMD_die(), nhx, nhy, nhz, msm::IndexRange::ni(), msm::IndexRange::nj(), msm::IndexRange::nk(), nlevels, msm::IndexRange::nn(), NONIC, NONIC4, Nstencil, NUM_APPROX, NUM_SPLIT, PatchMap::numPatches(), PatchMap::Object(), Node::Object(), omega, padding, msm::Map::patchList, PhiStencil, PolyDegree, QUINTIC, QUINTIC2, msm::Grid< T >::reset(), msm::Array< T >::resize(), ru, rv, rw, s_edge, Lattice::scale(), SEPTIC, SEPTIC3, C1Matrix::set(), msm::Grid< T >::set(), msm::Grid< T >::setbounds(), setup_hgrid_1d(), setup_periodic_blocksize(), sglower, shx, shx_1, shy, shy_1, shz, shz_1, Node::simParameters, simParams, MsmInitMsg::smax, smax, MsmInitMsg::smin, smin, split, splitting(), srx_x, srx_y, srx_z, sry_x, sry_y, sry_z, srz_x, srz_y, srz_z, sx_shx, sy_shy, sz_shz, TAYLOR2, TAYLOR2_DISP, TAYLOR3, TAYLOR4, TAYLOR5, TAYLOR6, TAYLOR7, TAYLOR8, Vector::unit(), virial, VMAX, Vector::x, Vector::y, and Vector::z.

3970 {
3971 #ifdef DEBUG_MSM_VERBOSE
3972  printf("ComputeMsmMgr: initialize() PE %d\n", CkMyPe());
3973 #endif
3974 
3975  smin = msg->smin;
3976  smax = msg->smax;
3977  delete msg;
3978 
3979 #if 0
3980  printf("PE%d: initializing MSM\n", CkMyPe());
3981 #endif
3982 
3984 
3985  // get required sim params, check validity
3986  lattice = simParams->lattice;
3987 
3988  // set user-defined extent of system
3989  Vector rmin(simParams->MSMxmin, simParams->MSMymin, simParams->MSMzmin);
3990  Vector rmax(simParams->MSMxmax, simParams->MSMymax, simParams->MSMzmax);
3991  Vector sdmin = lattice.scale(rmin);
3992  Vector sdmax = lattice.scale(rmax);
3993  // swap coordinates between min and max to correct for possible rotation
3994  if (sdmin.x > sdmax.x) { double t=sdmin.x; sdmin.x=sdmax.x; sdmax.x=t; }
3995  if (sdmin.y > sdmax.y) { double t=sdmin.y; sdmin.y=sdmax.y; sdmax.y=t; }
3996  if (sdmin.z > sdmax.z) { double t=sdmin.z; sdmin.z=sdmax.z; sdmax.z=t; }
3997  // extend smin, smax by user-defined extent, where appropriate
3998  if ( ! lattice.a_p() && (sdmin.x != 0 || sdmax.x != 0)) {
3999  if (sdmin.x < smin.x) {
4000  smin.x = sdmin.x;
4001  if (CkMyPe() == 0) {
4002  iout << iINFO << "MSM extending minimum X to "
4003  << simParams->MSMxmin << " A\n" << endi;
4004  }
4005  }
4006  if (sdmax.x > smax.x) {
4007  smax.x = sdmax.x;
4008  if (CkMyPe() == 0) {
4009  iout << iINFO << "MSM extending maximum X to "
4010  << simParams->MSMxmax << " A\n" << endi;
4011  }
4012  }
4013  }
4014  if ( ! lattice.b_p() && (sdmin.y != 0 || sdmax.y != 0)) {
4015  if (sdmin.y < smin.y) {
4016  smin.y = sdmin.y;
4017  if (CkMyPe() == 0) {
4018  iout << iINFO << "MSM extending minimum Y to "
4019  << simParams->MSMymin << " A\n" << endi;
4020  }
4021  }
4022  if (sdmax.y > smax.y) {
4023  smax.y = sdmax.y;
4024  if (CkMyPe() == 0) {
4025  iout << iINFO << "MSM extending maximum Y to "
4026  << simParams->MSMymax << " A\n" << endi;
4027  }
4028  }
4029  }
4030  if ( ! lattice.c_p() && (sdmin.z != 0 || sdmax.z != 0)) {
4031  if (sdmin.z < smin.z) {
4032  smin.z = sdmin.z;
4033  if (CkMyPe() == 0) {
4034  iout << iINFO << "MSM extending minimum Z to "
4035  << simParams->MSMzmin << " A\n" << endi;
4036  }
4037  }
4038  if (sdmax.z > smax.z) {
4039  smax.z = sdmax.z;
4040  if (CkMyPe() == 0) {
4041  iout << iINFO << "MSM extending maximum Z to "
4042  << simParams->MSMzmax << " A\n" << endi;
4043  }
4044  }
4045  }
4046 
4047 #ifdef DEBUG_MSM_VERBOSE
4048  printf("smin = %g %g %g smax = %g %g %g\n",
4049  smin.x, smin.y, smin.z, smax.x, smax.y, smax.z);
4050 #endif
4051 
4052  approx = simParams->MSMApprox;
4053  if (approx < 0 || approx >= NUM_APPROX) {
4054  NAMD_die("MSM: unknown approximation requested (MSMApprox)");
4055  }
4056 
4057  split = simParams->MSMSplit;
4058  if (split < 0 || split >= NUM_SPLIT) {
4059  NAMD_die("MSM: unknown splitting requested (MSMSplit)");
4060  }
4061 
4062  if (CkMyPe() == 0) {
4063  const char *approx_str, *split_str;
4064  switch (approx) {
4065  case CUBIC: approx_str = "C1 cubic"; break;
4066  case QUINTIC: approx_str = "C1 quintic"; break;
4067  case QUINTIC2: approx_str = "C2 quintic"; break;
4068  case SEPTIC: approx_str = "C1 septic"; break;
4069  case SEPTIC3: approx_str = "C3 septic"; break;
4070  case NONIC: approx_str = "C1 nonic"; break;
4071  case NONIC4: approx_str = "C4 nonic"; break;
4072  case C1HERMITE: approx_str = "C1 Hermite"; break;
4073  default: approx_str = "unknown"; break;
4074  }
4075  switch (split) {
4076  case TAYLOR2: split_str = "C2 Taylor"; break;
4077  case TAYLOR3: split_str = "C3 Taylor"; break;
4078  case TAYLOR4: split_str = "C4 Taylor"; break;
4079  case TAYLOR5: split_str = "C5 Taylor"; break;
4080  case TAYLOR6: split_str = "C6 Taylor"; break;
4081  case TAYLOR7: split_str = "C7 Taylor"; break;
4082  case TAYLOR8: split_str = "C8 Taylor"; break;
4083  default: split_str = "unknown"; break;
4084  }
4085  iout << iINFO << "MSM using "
4086  << approx_str << " interpolation\n";
4087  iout << iINFO << "MSM using "
4088  << split_str << " splitting function\n";
4089  }
4090 
4091  a = simParams->cutoff;
4092 
4093  if (approx == C1HERMITE) {
4094  gridScalingFactor = 2;
4095  }
4096  else {
4097  gridScalingFactor = 1;
4098  }
4099 
4101  if (gridspacing <= 0) {
4102  NAMD_die("MSM: grid spacing must be greater than 0 (MSMGridSpacing)");
4103  }
4104  else if (gridspacing >= a) {
4105  NAMD_die("MSM: grid spacing must be less than cutoff (MSMGridSpacing)");
4106  }
4107 
4108  padding = gridScalingFactor * simParams->MSMPadding;
4109  if (padding < 0) {
4110  NAMD_die("MSM: padding must be non-negative (MSMPadding)");
4111  }
4112 
4113  // set maximum number of levels (default 0 adapts levels to system)
4114  nlevels = simParams->MSMLevels;
4115 
4116  // XXX dispersion unused for now
4117  dispersion = 0;
4118  if ( ! dispersion && split >= TAYLOR2_DISP) {
4119  NAMD_die("MSM: requested splitting for long-range dispersion "
4120  "(not implemented)");
4121  }
4122 
4123  // set block sizes for grid decomposition
4124  int bsx = simParams->MSMBlockSizeX / int(gridScalingFactor);
4125  int bsy = simParams->MSMBlockSizeY / int(gridScalingFactor);
4126  int bsz = simParams->MSMBlockSizeZ / int(gridScalingFactor);
4127  if (bsx <= 0 || bsy <= 0 || bsz <= 0) {
4128  NAMD_die("MSM: invalid block size requested (MSMBlockSize[XYZ])");
4129  }
4130 #ifdef MSM_FIXED_SIZE_GRID_MSG
4131  else if (bsx * bsy * bsz > MSM_MAX_BLOCK_VOLUME) {
4132  NAMD_die("MSM: requested block size (MSMBlockSize[XYZ]) too big");
4133  }
4134 #endif
4135  if (CkMyPe() == 0) {
4136  iout << iINFO << "MSM block size decomposition along X is "
4137  << bsx << " grid points\n";
4138  iout << iINFO << "MSM block size decomposition along Y is "
4139  << bsy << " grid points\n";
4140  iout << iINFO << "MSM block size decomposition along Z is "
4141  << bsz << " grid points\n";
4142  }
4143 
4144  s_edge = (PolyDegree[approx] - 1) / 2; // stencil edge size
4145  omega = 2 * PolyDegree[approx]; // smallest non-periodic grid length
4146 
4147  BigReal xlen, ylen, zlen;
4148  Vector sgmin, sgmax; // grid min and max, in scaled coordinates
4149  int ispx = lattice.a_p();
4150  int ispy = lattice.b_p();
4151  int ispz = lattice.c_p();
4152  int ispany = (ispx || ispy || ispz); // is there any periodicity?
4153 
4154  if (ispx) { // periodic along basis vector
4155  xlen = lattice.a().length();
4156  sgmax.x = 0.5;
4157  sgmin.x = -0.5;
4158  }
4159  else { // non-periodic
4160  sgmax.x = smax.x + padding; // pad the edges
4161  sgmin.x = smin.x - padding;
4162  ASSERT(gridspacing > 0);
4163  // restrict center to be on a grid point
4164  BigReal mupper = ceil(sgmax.x / (2*gridspacing));
4165  BigReal mlower = floor(sgmin.x / (2*gridspacing));
4166  sgmax.x = 2*gridspacing*mupper;
4167  sgmin.x = 2*gridspacing*mlower;
4168  xlen = sgmax.x - sgmin.x;
4169  }
4170 #ifdef DEBUG_MSM_VERBOSE
4171  printf("xlen = %g sgmin.x = %g sgmax.x = %g\n", xlen, sgmin.x, sgmax.x);
4172 #endif
4173 
4174  if (ispy) { // periodic along basis vector
4175  ylen = lattice.b().length();
4176  sgmax.y = 0.5;
4177  sgmin.y = -0.5;
4178  }
4179  else { // non-periodic
4180  sgmax.y = smax.y + padding; // pad the edges
4181  sgmin.y = smin.y - padding;
4182  ASSERT(gridspacing > 0);
4183  // restrict center to be on a grid point
4184  BigReal mupper = ceil(sgmax.y / (2*gridspacing));
4185  BigReal mlower = floor(sgmin.y / (2*gridspacing));
4186  sgmax.y = 2*gridspacing*mupper;
4187  sgmin.y = 2*gridspacing*mlower;
4188  ylen = sgmax.y - sgmin.y;
4189  }
4190 #ifdef DEBUG_MSM_VERBOSE
4191  printf("ylen = %g sgmin.y = %g sgmax.y = %g\n", ylen, sgmin.y, sgmax.y);
4192 #endif
4193 
4194  if (ispz) { // periodic along basis vector
4195  zlen = lattice.c().length();
4196  sgmax.z = 0.5;
4197  sgmin.z = -0.5;
4198  }
4199  else { // non-periodic
4200  sgmax.z = smax.z + padding; // pad the edges
4201  sgmin.z = smin.z - padding;
4202  ASSERT(gridspacing > 0);
4203  // restrict center to be on a grid point
4204  BigReal mupper = ceil(sgmax.z / (2*gridspacing));
4205  BigReal mlower = floor(sgmin.z / (2*gridspacing));
4206  sgmax.z = 2*gridspacing*mupper;
4207  sgmin.z = 2*gridspacing*mlower;
4208  zlen = sgmax.z - sgmin.z;
4209  }
4210 #ifdef DEBUG_MSM_VERBOSE
4211  printf("zlen = %g sgmin.z = %g sgmax.z = %g\n", zlen, sgmin.z, sgmax.z);
4212 #endif
4213  sglower = sgmin;
4214 
4215  int ia, ib, ja, jb, ka, kb;
4216  setup_hgrid_1d(xlen, hxlen, nhx, ia, ib, ispx);
4217  setup_hgrid_1d(ylen, hylen, nhy, ja, jb, ispy);
4218  setup_hgrid_1d(zlen, hzlen, nhz, ka, kb, ispz);
4219  hxlen_1 = 1 / hxlen;
4220  hylen_1 = 1 / hylen;
4221  hzlen_1 = 1 / hzlen;
4222  if (CkMyPe() == 0) {
4223  if (ispx || ispy || ispz) {
4224  iout << iINFO << "MSM grid spacing along X is "<< hxlen << " A\n";
4225  iout << iINFO << "MSM grid spacing along Y is "<< hylen << " A\n";
4226  iout << iINFO << "MSM grid spacing along Z is "<< hzlen << " A\n";
4227  }
4228  else {
4229  iout << iINFO << "MSM grid spacing is " << gridspacing << " A\n";
4230  }
4231  if ( ! ispx || ! ispy || ! ispz ) {
4232  iout << iINFO<<"MSM non-periodic padding is "<< padding << " A\n";
4233  }
4234  }
4235 
4236  int ni = ib - ia + 1;
4237  int nj = jb - ja + 1;
4238  int nk = kb - ka + 1;
4239  int n;
4240 
4241 #if 0
4242  // reserve temp space for factored grid transfer operation
4243  n = (nk > omega ? nk : omega); // row along z-dimension
4244  lzd.resize(n);
4245  n *= (nj > omega ? nj : omega); // plane along yz-dimensions
4246  lyzd.resize(n);
4247 #endif
4248 
4249  int lastnelems = 1;
4250  int smallestnbox = 1;
4251  int isclamped = 0;
4252  int maxlevels = nlevels; // user-defined number of levels
4253 
4254 #ifdef DEBUG_MSM_VERBOSE
4255  printf("maxlevels = %d\n", maxlevels);
4256 #endif
4257  if (nlevels <= 0) { // instead we set number of levels
4258  n = ni;
4259  if (n < nj) n = nj;
4260  if (n < nk) n = nk;
4261  for (maxlevels = 1; n > 0; n >>= 1) maxlevels++;
4262  if (ispany == 0) { // no periodicity
4263  // use rule of thumb 3/4 diameter of grid cutoff sphere
4264  int ngci = (int) ceil(3*a / hxlen) - 1;
4265  int ngcj = (int) ceil(3*a / hylen) - 1;
4266  int ngck = (int) ceil(3*a / hzlen) - 1;
4267  int omega3 = omega * omega * omega;
4268  int nhalf = (int) sqrt((double)ni * nj * nk);
4269  lastnelems = (nhalf > omega3 ? nhalf : omega3);
4270  smallestnbox = ngci * ngcj * ngck; // smaller grids don't reduce work
4271  isclamped = 1;
4272  }
4273  }
4274 #ifdef DEBUG_MSM_VERBOSE
4275  printf("maxlevels = %d\n", maxlevels);
4276 #endif
4277 
4278  // allocate space for storing grid dimensions for each level
4279  map.gridrange.resize(maxlevels);
4280 
4281  // set periodicity flags
4282  map.ispx = ispx;
4283  map.ispy = ispy;
4284  map.ispz = ispz;
4285 
4286  int level = 0;
4287  int done = 0;
4288  int alldone = 0;
4289  do {
4290  map.gridrange[level].setbounds(ia, ib, ja, jb, ka, kb);
4291 
4292  // Msm index?
4293 
4294  if (++level == nlevels) done |= 0x07; // user limit on levels
4295 
4296  if (isclamped) {
4297  int nelems = ni * nj * nk;
4298  if (nelems <= lastnelems) done |= 0x07;
4299  if (nelems <= smallestnbox) done |= 0x07;
4300  }
4301 
4302  alldone = (done == 0x07); // make sure all dimensions are done
4303 
4304  if (ispx) {
4305  ni >>= 1;
4306  ib = ni-1;
4307  if (ni & 1) done |= 0x07; // == 3 or 1
4308  else if (ni == 2) done |= 0x01; // can do one more
4309  }
4310  else {
4311  ia = -((-ia+1)/2) - s_edge;
4312  ib = (ib+1)/2 + s_edge;
4313  ni = ib - ia + 1;
4314  if (ni <= omega) done |= 0x01; // can do more restrictions
4315  }
4316 
4317  if (ispy) {
4318  nj >>= 1;
4319  jb = nj-1;
4320  if (nj & 1) done |= 0x07; // == 3 or 1
4321  else if (nj == 2) done |= 0x02; // can do one more
4322  }
4323  else {
4324  ja = -((-ja+1)/2) - s_edge;
4325  jb = (jb+1)/2 + s_edge;
4326  nj = jb - ja + 1;
4327  if (nj <= omega) done |= 0x02; // can do more restrictions
4328  }
4329 
4330  if (ispz) {
4331  nk >>= 1;
4332  kb = nk-1;
4333  if (nk & 1) done |= 0x07; // == 3 or 1
4334  else if (nk == 2) done |= 0x04; // can do one more
4335  }
4336  else {
4337  ka = -((-ka+1)/2) - s_edge;
4338  kb = (kb+1)/2 + s_edge;
4339  nk = kb - ka + 1;
4340  if (nk <= omega) done |= 0x04; // can do more restrictions
4341  }
4342  } while ( ! alldone );
4343  nlevels = level;
4344 
4345  // for periodic boundaries, don't visit top level (all 0)
4346  // toplevel visited only for all nonperiodic boundaries
4347  int toplevel = (ispany ? nlevels : nlevels - 1);
4348 
4349  // resize down to the actual number of levels (does not change alloc)
4350  map.gridrange.resize(nlevels);
4351 
4352  // print out some information about MSM
4353  if (CkMyPe() == 0) {
4354  iout << iINFO << "MSM using " << nlevels << " levels\n";
4355  for (n = 0; n < nlevels; n++) {
4356  char s[100];
4357  snprintf(s, sizeof(s), " level %d: "
4358  "[%d..%d] x [%d..%d] x [%d..%d]\n", n,
4359  map.gridrange[n].ia(), map.gridrange[n].ib(),
4360  map.gridrange[n].ja(), map.gridrange[n].jb(),
4361  map.gridrange[n].ka(), map.gridrange[n].kb());
4362  iout << iINFO << s;
4363  }
4364  iout << endi;
4365  }
4366 
4367  // find grid spacing basis vectors
4368  hu = hxlen * lattice.a().unit();
4369  hv = hylen * lattice.b().unit();
4370  hw = hzlen * lattice.c().unit();
4371  hufx = Float(hu.x);
4372  hufy = Float(hu.y);
4373  hufz = Float(hu.z);
4374  hvfx = Float(hv.x);
4375  hvfy = Float(hv.y);
4376  hvfz = Float(hv.z);
4377  hwfx = Float(hw.x);
4378  hwfy = Float(hw.y);
4379  hwfz = Float(hw.z);
4380 
4381  ru = lattice.a_r();
4382  rv = lattice.b_r();
4383  rw = lattice.c_r();
4384 
4385  // determine grid spacings in scaled space
4386  shx = ru * hu;
4387  shy = rv * hv;
4388  shz = rw * hw;
4389  shx_1 = 1 / shx;
4390  shy_1 = 1 / shy;
4391  shz_1 = 1 / shz;
4392 
4393  // row vectors to transform interpolated force back to real space
4394  // XXX Is not needed.
4395  sx_shx = shx_1 * Vector(ru.x, rv.x, rw.x);
4396  sy_shy = shy_1 * Vector(ru.y, rv.y, rw.y);
4397  sz_shz = shz_1 * Vector(ru.z, rv.z, rw.z);
4398  srx_x = Float(sx_shx.x);
4399  srx_y = Float(sx_shx.y);
4400  srx_z = Float(sx_shx.z);
4401  sry_x = Float(sy_shy.x);
4402  sry_y = Float(sy_shy.y);
4403  sry_z = Float(sy_shy.z);
4404  srz_x = Float(sz_shz.x);
4405  srz_y = Float(sz_shz.y);
4406  srz_z = Float(sz_shz.z);
4407 
4408  Vector pu = cross(hv, hw);
4409  BigReal s = (hu * pu) / (pu * pu);
4410  pu *= s; // pu is orthogonal projection of hu onto hv CROSS hw
4411 
4412  Vector pv = cross(hw, hu);
4413  s = (hv * pv) / (pv * pv);
4414  pv *= s; // pv is orthogonal projection of hv onto hw CROSS hu
4415 
4416  Vector pw = cross(hu, hv);
4417  s = (hw * pw) / (pw * pw);
4418  pw *= s; // pw is orthogonal projection of hw onto hu CROSS hv
4419 
4420  // radii for parallelepiped of weights enclosing grid cutoff sphere
4421  ni = (int) ceil(2*a / pu.length() ) - 1;
4422  nj = (int) ceil(2*a / pv.length() ) - 1;
4423  nk = (int) ceil(2*a / pw.length() ) - 1;
4424 
4425  Float scaling = 1;
4426  Float scaling_factor = 0.5f;
4427  BigReal a_1 = 1/a;
4428  BigReal a_p = a_1;
4429  if (dispersion) {
4430  a_p = a_p * a_p * a_p; // = 1/a^3
4431  a_p = a_p * a_p; // = 1/a^6
4432  scaling_factor = 1.f/64; // = 1/2^6
4433  }
4434  int i, j, k;
4435  if (approx < C1HERMITE) {
4436  // resize gc and gvc constants for number of levels
4437  map.gc.resize(nlevels);
4438  map.gvc.resize(nlevels);
4439 
4440  for (level = 0; level < toplevel; level++) {
4441  map.gc[level].setbounds(-ni, ni, -nj, nj, -nk, nk);
4442  map.gvc[level].setbounds(-ni, ni, -nj, nj, -nk, nk);
4443 
4444  for (k = -nk; k <= nk; k++) {
4445  for (j = -nj; j <= nj; j++) {
4446  for (i = -ni; i <= ni; i++) {
4447  if (level == 0) {
4448  BigReal s, t, gs=0, gt=0, g=0, dgs=0, dgt=0, dg=0;
4449  BigReal vlen = (i*hu + j*hv + k*hw).length();
4450  s = vlen * a_1;
4451  t = 0.5 * s;
4452  if (t >= 1) {
4453  g = 0;
4454  dg = 0;
4455  }
4456  else {
4457  splitting(gt, dgt, t, split);
4458  if (s >= 1) {
4459  BigReal s_1 = 1/s;
4460  if (dispersion) {
4461  gs = s_1 * s_1 * s_1; // = 1/s^3
4462  gs = gs * gs; // = 1/s^6
4463  dgs = -6 * gs * s_1;
4464  }
4465  else {
4466  gs = s_1;
4467  dgs = -gs * s_1;
4468  }
4469  }
4470  else {
4471  splitting(gs, dgs, s, split);
4472  }
4473  g = (gs - scaling_factor * gt) * a_p;
4474  BigReal c=0;
4475  if (i || j || k) {
4476  c = a_p * a_1 / vlen;
4477  }
4478  dg = 0.5 * (dgs - 0.5*scaling_factor * dgt) * c;
4479 
4480  // Msm index?
4481 
4482  }
4483  map.gc[0](i,j,k) = Float(g);
4484  map.gvc[0](i,j,k) = Float(dg);
4485  } // if level 0
4486  else {
4487  map.gc[level](i,j,k) = scaling * map.gc[0](i,j,k);
4488  map.gvc[level](i,j,k) = scaling * map.gvc[0](i,j,k);
4489  }
4490 
4491  } // for i
4492  } // for j
4493  } // for k
4494  scaling *= scaling_factor;
4495 
4496  } // for level
4497 
4498  // for summed virial factors
4499  gvsum.setbounds(-ni, ni, -nj, nj, -nk, nk);
4500  // make sure final virial sum is initialized to 0
4501  for (i = 0; i < VMAX; i++) { virial[i] = 0; }
4502 
4503  if (toplevel < nlevels) {
4504  // nonperiodic along all basis vector directions
4505  // calculate top level weights where all grid points
4506  // interact with each other
4507  ni = map.gridrange[toplevel].ni();
4508  nj = map.gridrange[toplevel].nj();
4509  nk = map.gridrange[toplevel].nk();
4510  map.gc[toplevel].setbounds(-ni, ni, -nj, nj, -nk, nk);
4511 
4512  // Msm index?
4513 
4514  for (k = -nk; k <= nk; k++) {
4515  for (j = -nj; j <= nj; j++) {
4516  for (i = -ni; i <= ni; i++) {
4517  BigReal s, gs, d;
4518  BigReal vlen = (i*hu + j*hv + k*hw).length();
4519  s = vlen * a_1;
4520  if (s >= 1) {
4521  BigReal s_1 = 1/s;
4522  if (dispersion) {
4523  gs = s_1 * s_1 * s_1; // = 1/s^3
4524  gs = gs * gs; // = 1/s^6
4525  }
4526  else {
4527  gs = s_1;
4528  }
4529  }
4530  else {
4531  splitting(gs, d, s, split);
4532  }
4533  map.gc[toplevel](i,j,k) = scaling * Float(gs * a_p);
4534  } // for i
4535  } // for j
4536  } // for k
4537  } // if toplevel
4538 
4539  // generate grespro stencil
4540  const int nstencil = Nstencil[approx];
4541  const Float *phi = PhiStencil[approx];
4542  map.grespro.set(0, nstencil, 0, nstencil, 0, nstencil);
4543  for (k = 0; k < nstencil; k++) {
4544  for (j = 0; j < nstencil; j++) {
4545  for (i = 0; i < nstencil; i++) {
4546  map.grespro(i,j,k) = phi[i] * phi[j] * phi[k];
4547  }
4548  }
4549  }
4550 
4551  } // end if approx < C1HERMITE
4552  else {
4553  // C1HERMITE
4554  // resize gc_c1hermite constants for number of levels
4555  map.gc_c1hermite.resize(nlevels);
4556  scaling = 1;
4557 
4558  for (level = 0; level < toplevel; level++) {
4559 
4560  Vector hmu = scaling * hu;
4561  Vector hmv = scaling * hv;
4562  Vector hmw = scaling * hw;
4563  BigReal am = scaling * a;
4564 
4565  map.gc_c1hermite[level].setbounds(-ni, ni, -nj, nj, -nk, nk);
4566 
4567  for (k = -nk; k <= nk; k++) {
4568  for (j = -nj; j <= nj; j++) {
4569  for (i = -ni; i <= ni; i++) {
4570  C1Matrix& m = map.gc_c1hermite[level](i,j,k);
4571  Vector rv = i*hmu + j*hmv + k*hmw;
4572  BigReal r2 = rv * rv;
4573  m.set(0);
4574  if (r2 < 4*am*am) {
4575  // accumulate D( g_{a}(0,r) ) term for this level
4576  gc_c1hermite_elem_accum(m, 1, rv, am, split);
4577  // accumulate D( -g_{2a}(0,r) ) term for this level
4578  gc_c1hermite_elem_accum(m, -1, rv, 2*am, split);
4579  } // if within cutoff
4580  }
4581  }
4582  } // end loop over gc_c1hermite elements for this level
4583  scaling *= 2; // double grid spacing and cutoff at each iteration
4584 
4585  } // end loop over levels
4586 
4587  if (toplevel < nlevels) {
4588  Vector hmu = scaling * hu;
4589  Vector hmv = scaling * hv;
4590  Vector hmw = scaling * hw;
4591  BigReal am = scaling * a;
4592 
4593  // nonperiodic along all basis vector directions
4594  // calculate top level weights where all grid points
4595  // interact with each other
4596  ni = map.gridrange[toplevel].ni();
4597  nj = map.gridrange[toplevel].nj();
4598  nk = map.gridrange[toplevel].nk();
4599  map.gc_c1hermite[toplevel].setbounds(-ni, ni, -nj, nj, -nk, nk);
4600 
4601  for (k = -nk; k <= nk; k++) {
4602  for (j = -nj; j <= nj; j++) {
4603  for (i = -ni; i <= ni; i++) {
4604  C1Matrix& m = map.gc_c1hermite[level](i,j,k);
4605  Vector rv = i*hmu + j*hmv + k*hmw;
4606  m.set(0);
4607  // accumulate D( g_{a}(0,r) ) term for this level
4608  gc_c1hermite_elem_accum(m, 1, rv, am, split);
4609  }
4610  }
4611  } // end loop over gc_c1hermite elements for top level
4612 
4613  } // end if top level
4614 
4615  // C1 Hermite restriction and prolongation stencils
4616  map.gres_c1hermite.resize(nlevels-1);
4617  map.gpro_c1hermite.resize(nlevels-1);
4618 
4619  enum {
4620  ND = 3, // stencil diameter
4621  NR = ND/2 // stencil radius
4622  };
4623 
4624  // the master basis functions PHI0 and PHI1 for the 3-point stencil
4625  // and their derivatives DPHI0 and DPHI1
4626  const double PHI0[ND] = { 0.5, 1, 0.5 };
4627  const double DPHI0[ND] = { 1.5, 0, -1.5 };
4628  const double PHI1[ND] = { -0.125, 0, 0.125 };
4629  const double DPHI1[ND] = { -0.25, 1, -0.25 };
4630 
4631  // for intermediate calculations
4632  double xphi0_base_array[ND];
4633  double dxphi0_base_array[ND];
4634  double yphi0_base_array[ND];
4635  double dyphi0_base_array[ND];
4636  double zphi0_base_array[ND];
4637  double dzphi0_base_array[ND];
4638  double xphi1_base_array[ND];
4639  double dxphi1_base_array[ND];
4640  double yphi1_base_array[ND];
4641  double dyphi1_base_array[ND];
4642  double zphi1_base_array[ND];
4643  double dzphi1_base_array[ND];
4644  // will point to center of stencil arrays
4645  double *xphi0, *dxphi0, *xphi1, *dxphi1;
4646  double *yphi0, *dyphi0, *yphi1, *dyphi1;
4647  double *zphi0, *dzphi0, *zphi1, *dzphi1;
4648 
4649  for (n = 0; n < ND; n++) {
4650  xphi0_base_array[n] = PHI0[n];
4651  dxphi0_base_array[n] = hxlen_1 * DPHI0[n]; // scale by grid spacing
4652  xphi1_base_array[n] = hxlen * PHI1[n]; // scale by grid spacing
4653  dxphi1_base_array[n] = DPHI1[n];
4654  yphi0_base_array[n] = PHI0[n];
4655  dyphi0_base_array[n] = hylen_1 * DPHI0[n]; // scale by grid spacing
4656  yphi1_base_array[n] = hylen * PHI1[n]; // scale by grid spacing
4657  dyphi1_base_array[n] = DPHI1[n];
4658  zphi0_base_array[n] = PHI0[n];
4659  dzphi0_base_array[n] = hzlen_1 * DPHI0[n]; // scale by grid spacing
4660  zphi1_base_array[n] = hzlen * PHI1[n]; // scale by grid spacing
4661  dzphi1_base_array[n] = DPHI1[n];
4662  }
4663  xphi0 = xphi0_base_array + NR; // point into center of arrays
4664  dxphi0 = dxphi0_base_array + NR;
4665  xphi1 = xphi1_base_array + NR;
4666  dxphi1 = dxphi1_base_array + NR;
4667  yphi0 = yphi0_base_array + NR;
4668  dyphi0 = dyphi0_base_array + NR;
4669  yphi1 = yphi1_base_array + NR;
4670  dyphi1 = dyphi1_base_array + NR;
4671  zphi0 = zphi0_base_array + NR;
4672  dzphi0 = dzphi0_base_array + NR;
4673  zphi1 = zphi1_base_array + NR;
4674  dzphi1 = dzphi1_base_array + NR;
4675 
4676  for (level = 0; level < nlevels-1; level++) {
4677  // allocate space for restriction and prolongation stencils
4678  map.gres_c1hermite[level].set(0, ND, 0, ND, 0, ND);
4679  map.gpro_c1hermite[level].set(0, ND, 0, ND, 0, ND);
4680 
4681  // scale up to next level grid spacing
4682  //
4683  // have to determine for each dimension whether or not
4684  // a periodic grid spacing has increased
4685  // (equivalent to if there are fewer grid points)
4686  for (n = -NR; n <= NR; n++) {
4687  if ( ! ispx ||
4688  map.gridrange[level+1].ni() < map.gridrange[level].ni() ) {
4689  dxphi0[n] *= 0.5;
4690  xphi1[n] *= 2;
4691  }
4692  if ( ! ispy ||
4693  map.gridrange[level+1].nj() < map.gridrange[level].nj() ) {
4694  dyphi0[n] *= 0.5;
4695  yphi1[n] *= 2;
4696  }
4697  if ( ! ispz ||
4698  map.gridrange[level+1].nk() < map.gridrange[level].nk() ) {
4699  dzphi0[n] *= 0.5;
4700  zphi1[n] *= 2;
4701  }
4702  }
4703 
4704  // loop over restriction stencil matrices
4705  // calculate from partial derivatives
4706  for (k = -NR; k <= NR; k++) {
4707  for (j = -NR; j <= NR; j++) {
4708  for (i = -NR; i <= NR; i++) {
4709  Float *t = map.gres_c1hermite[level](i+NR,j+NR,k+NR).melem;
4710 
4711  t[C1INDEX(D000,D000)] = xphi0[i] * yphi0[j] * zphi0[k];
4712  t[C1INDEX(D000,D100)] = dxphi0[i] * yphi0[j] * zphi0[k];
4713  t[C1INDEX(D000,D010)] = xphi0[i] * dyphi0[j] * zphi0[k];
4714  t[C1INDEX(D000,D001)] = xphi0[i] * yphi0[j] * dzphi0[k];
4715  t[C1INDEX(D000,D110)] = dxphi0[i] * dyphi0[j] * zphi0[k];
4716  t[C1INDEX(D000,D101)] = dxphi0[i] * yphi0[j] * dzphi0[k];
4717  t[C1INDEX(D000,D011)] = xphi0[i] * dyphi0[j] * dzphi0[k];
4718  t[C1INDEX(D000,D111)] = dxphi0[i] * dyphi0[j] * dzphi0[k];
4719 
4720  t[C1INDEX(D100,D000)] = xphi1[i] * yphi0[j] * zphi0[k];
4721  t[C1INDEX(D100,D100)] = dxphi1[i] * yphi0[j] * zphi0[k];
4722  t[C1INDEX(D100,D010)] = xphi1[i] * dyphi0[j] * zphi0[k];
4723  t[C1INDEX(D100,D001)] = xphi1[i] * yphi0[j] * dzphi0[k];
4724  t[C1INDEX(D100,D110)] = dxphi1[i] * dyphi0[j] * zphi0[k];
4725  t[C1INDEX(D100,D101)] = dxphi1[i] * yphi0[j] * dzphi0[k];
4726  t[C1INDEX(D100,D011)] = xphi1[i] * dyphi0[j] * dzphi0[k];
4727  t[C1INDEX(D100,D111)] = dxphi1[i] * dyphi0[j] * dzphi0[k];
4728 
4729  t[C1INDEX(D010,D000)] = xphi0[i] * yphi1[j] * zphi0[k];
4730  t[C1INDEX(D010,D100)] = dxphi0[i] * yphi1[j] * zphi0[k];
4731  t[C1INDEX(D010,D010)] = xphi0[i] * dyphi1[j] * zphi0[k];
4732  t[C1INDEX(D010,D001)] = xphi0[i] * yphi1[j] * dzphi0[k];
4733  t[C1INDEX(D010,D110)] = dxphi0[i] * dyphi1[j] * zphi0[k];
4734  t[C1INDEX(D010,D101)] = dxphi0[i] * yphi1[j] * dzphi0[k];
4735  t[C1INDEX(D010,D011)] = xphi0[i] * dyphi1[j] * dzphi0[k];
4736  t[C1INDEX(D010,D111)] = dxphi0[i] * dyphi1[j] * dzphi0[k];
4737 
4738  t[C1INDEX(D001,D000)] = xphi0[i] * yphi0[j] * zphi1[k];
4739  t[C1INDEX(D001,D100)] = dxphi0[i] * yphi0[j] * zphi1[k];
4740  t[C1INDEX(D001,D010)] = xphi0[i] * dyphi0[j] * zphi1[k];
4741  t[C1INDEX(D001,D001)] = xphi0[i] * yphi0[j] * dzphi1[k];
4742  t[C1INDEX(D001,D110)] = dxphi0[i] * dyphi0[j] * zphi1[k];
4743  t[C1INDEX(D001,D101)] = dxphi0[i] * yphi0[j] * dzphi1[k];
4744  t[C1INDEX(D001,D011)] = xphi0[i] * dyphi0[j] * dzphi1[k];
4745  t[C1INDEX(D001,D111)] = dxphi0[i] * dyphi0[j] * dzphi1[k];
4746 
4747  t[C1INDEX(D110,D000)] = xphi1[i] * yphi1[j] * zphi0[k];
4748  t[C1INDEX(D110,D100)] = dxphi1[i] * yphi1[j] * zphi0[k];
4749  t[C1INDEX(D110,D010)] = xphi1[i] * dyphi1[j] * zphi0[k];
4750  t[C1INDEX(D110,D001)] = xphi1[i] * yphi1[j] * dzphi0[k];
4751  t[C1INDEX(D110,D110)] = dxphi1[i] * dyphi1[j] * zphi0[k];
4752  t[C1INDEX(D110,D101)] = dxphi1[i] * yphi1[j] * dzphi0[k];
4753  t[C1INDEX(D110,D011)] = xphi1[i] * dyphi1[j] * dzphi0[k];
4754  t[C1INDEX(D110,D111)] = dxphi1[i] * dyphi1[j] * dzphi0[k];
4755 
4756  t[C1INDEX(D101,D000)] = xphi1[i] * yphi0[j] * zphi1[k];
4757  t[C1INDEX(D101,D100)] = dxphi1[i] * yphi0[j] * zphi1[k];
4758  t[C1INDEX(D101,D010)] = xphi1[i] * dyphi0[j] * zphi1[k];
4759  t[C1INDEX(D101,D001)] = xphi1[i] * yphi0[j] * dzphi1[k];
4760  t[C1INDEX(D101,D110)] = dxphi1[i] * dyphi0[j] * zphi1[k];
4761  t[C1INDEX(D101,D101)] = dxphi1[i] * yphi0[j] * dzphi1[k];
4762  t[C1INDEX(D101,D011)] = xphi1[i] * dyphi0[j] * dzphi1[k];
4763  t[C1INDEX(D101,D111)] = dxphi1[i] * dyphi0[j] * dzphi1[k];
4764 
4765  t[C1INDEX(D011,D000)] = xphi0[i] * yphi1[j] * zphi1[k];
4766  t[C1INDEX(D011,D100)] = dxphi0[i] * yphi1[j] * zphi1[k];
4767  t[C1INDEX(D011,D010)] = xphi0[i] * dyphi1[j] * zphi1[k];
4768  t[C1INDEX(D011,D001)] = xphi0[i] * yphi1[j] * dzphi1[k];
4769  t[C1INDEX(D011,D110)] = dxphi0[i] * dyphi1[j] * zphi1[k];
4770  t[C1INDEX(D011,D101)] = dxphi0[i] * yphi1[j] * dzphi1[k];
4771  t[C1INDEX(D011,D011)] = xphi0[i] * dyphi1[j] * dzphi1[k];
4772  t[C1INDEX(D011,D111)] = dxphi0[i] * dyphi1[j] * dzphi1[k];
4773 
4774  t[C1INDEX(D111,D000)] = xphi1[i] * yphi1[j] * zphi1[k];
4775  t[C1INDEX(D111,D100)] = dxphi1[i] * yphi1[j] * zphi1[k];
4776  t[C1INDEX(D111,D010)] = xphi1[i] * dyphi1[j] * zphi1[k];
4777  t[C1INDEX(D111,D001)] = xphi1[i] * yphi1[j] * dzphi1[k];
4778  t[C1INDEX(D111,D110)] = dxphi1[i] * dyphi1[j] * zphi1[k];
4779  t[C1INDEX(D111,D101)] = dxphi1[i] * yphi1[j] * dzphi1[k];
4780  t[C1INDEX(D111,D011)] = xphi1[i] * dyphi1[j] * dzphi1[k];
4781  t[C1INDEX(D111,D111)] = dxphi1[i] * dyphi1[j] * dzphi1[k];
4782  }
4783  }
4784  } // end loops over restriction stencil matrices
4785 
4786  // loop over prolongation stencil matrices
4787  // prolongation stencil matrices are the transpose of restriction
4788  for (k = -NR; k <= NR; k++) {
4789  for (j = -NR; j <= NR; j++) {
4790  for (i = -NR; i <= NR; i++) {
4791  Float *t = map.gres_c1hermite[level](i+NR,j+NR,k+NR).melem;
4792  Float *tt = map.gpro_c1hermite[level](i+NR,j+NR,k+NR).melem;
4793 
4794  tt[C1INDEX(D000,D000)] = t[C1INDEX(D000,D000)];
4795  tt[C1INDEX(D000,D100)] = t[C1INDEX(D100,D000)];
4796  tt[C1INDEX(D000,D010)] = t[C1INDEX(D010,D000)];
4797  tt[C1INDEX(D000,D001)] = t[C1INDEX(D001,D000)];
4798  tt[C1INDEX(D000,D110)] = t[C1INDEX(D110,D000)];
4799  tt[C1INDEX(D000,D101)] = t[C1INDEX(D101,D000)];
4800  tt[C1INDEX(D000,D011)] = t[C1INDEX(D011,D000)];
4801  tt[C1INDEX(D000,D111)] = t[C1INDEX(D111,D000)];
4802 
4803  tt[C1INDEX(D100,D000)] = t[C1INDEX(D000,D100)];
4804  tt[C1INDEX(D100,D100)] = t[C1INDEX(D100,D100)];
4805  tt[C1INDEX(D100,D010)] = t[C1INDEX(D010,D100)];
4806  tt[C1INDEX(D100,D001)] = t[C1INDEX(D001,D100)];
4807  tt[C1INDEX(D100,D110)] = t[C1INDEX(D110,D100)];
4808  tt[C1INDEX(D100,D101)] = t[C1INDEX(D101,D100)];
4809  tt[C1INDEX(D100,D011)] = t[C1INDEX(D011,D100)];
4810  tt[C1INDEX(D100,D111)] = t[C1INDEX(D111,D100)];
4811 
4812  tt[C1INDEX(D010,D000)] = t[C1INDEX(D000,D010)];
4813  tt[C1INDEX(D010,D100)] = t[C1INDEX(D100,D010)];
4814  tt[C1INDEX(D010,D010)] = t[C1INDEX(D010,D010)];
4815  tt[C1INDEX(D010,D001)] = t[C1INDEX(D001,D010)];
4816  tt[C1INDEX(D010,D110)] = t[C1INDEX(D110,D010)];
4817  tt[C1INDEX(D010,D101)] = t[C1INDEX(D101,D010)];
4818  tt[C1INDEX(D010,D011)] = t[C1INDEX(D011,D010)];
4819  tt[C1INDEX(D010,D111)] = t[C1INDEX(D111,D010)];
4820 
4821  tt[C1INDEX(D001,D000)] = t[C1INDEX(D000,D001)];
4822  tt[C1INDEX(D001,D100)] = t[C1INDEX(D100,D001)];
4823  tt[C1INDEX(D001,D010)] = t[C1INDEX(D010,D001)];
4824  tt[C1INDEX(D001,D001)] = t[C1INDEX(D001,D001)];
4825  tt[C1INDEX(D001,D110)] = t[C1INDEX(D110,D001)];
4826  tt[C1INDEX(D001,D101)] = t[C1INDEX(D101,D001)];
4827  tt[C1INDEX(D001,D011)] = t[C1INDEX(D011,D001)];
4828  tt[C1INDEX(D001,D111)] = t[C1INDEX(D111,D001)];
4829 
4830  tt[C1INDEX(D110,D000)] = t[C1INDEX(D000,D110)];
4831  tt[C1INDEX(D110,D100)] = t[C1INDEX(D100,D110)];
4832  tt[C1INDEX(D110,D010)] = t[C1INDEX(D010,D110)];
4833  tt[C1INDEX(D110,D001)] = t[C1INDEX(D001,D110)];
4834  tt[C1INDEX(D110,D110)] = t[C1INDEX(D110,D110)];
4835  tt[C1INDEX(D110,D101)] = t[C1INDEX(D101,D110)];
4836  tt[C1INDEX(D110,D011)] = t[C1INDEX(D011,D110)];
4837  tt[C1INDEX(D110,D111)] = t[C1INDEX(D111,D110)];
4838 
4839  tt[C1INDEX(D101,D000)] = t[C1INDEX(D000,D101)];
4840  tt[C1INDEX(D101,D100)] = t[C1INDEX(D100,D101)];
4841  tt[C1INDEX(D101,D010)] = t[C1INDEX(D010,D101)];
4842  tt[C1INDEX(D101,D001)] = t[C1INDEX(D001,D101)];
4843  tt[C1INDEX(D101,D110)] = t[C1INDEX(D110,D101)];
4844  tt[C1INDEX(D101,D101)] = t[C1INDEX(D101,D101)];
4845  tt[C1INDEX(D101,D011)] = t[C1INDEX(D011,D101)];
4846  tt[C1INDEX(D101,D111)] = t[C1INDEX(D111,D101)];
4847 
4848  tt[C1INDEX(D011,D000)] = t[C1INDEX(D000,D011)];
4849  tt[C1INDEX(D011,D100)] = t[C1INDEX(D100,D011)];
4850  tt[C1INDEX(D011,D010)] = t[C1INDEX(D010,D011)];
4851  tt[C1INDEX(D011,D001)] = t[C1INDEX(D001,D011)];
4852  tt[C1INDEX(D011,D110)] = t[C1INDEX(D110,D011)];
4853  tt[C1INDEX(D011,D101)] = t[C1INDEX(D101,D011)];
4854  tt[C1INDEX(D011,D011)] = t[C1INDEX(D011,D011)];
4855  tt[C1INDEX(D011,D111)] = t[C1INDEX(D111,D011)];
4856 
4857  tt[C1INDEX(D111,D000)] = t[C1INDEX(D000,D111)];
4858  tt[C1INDEX(D111,D100)] = t[C1INDEX(D100,D111)];
4859  tt[C1INDEX(D111,D010)] = t[C1INDEX(D010,D111)];
4860  tt[C1INDEX(D111,D001)] = t[C1INDEX(D001,D111)];
4861  tt[C1INDEX(D111,D110)] = t[C1INDEX(D110,D111)];
4862  tt[C1INDEX(D111,D101)] = t[C1INDEX(D101,D111)];
4863  tt[C1INDEX(D111,D011)] = t[C1INDEX(D011,D111)];
4864  tt[C1INDEX(D111,D111)] = t[C1INDEX(D111,D111)];
4865  }
4866  }
4867  } // end loops over prolongation stencil matrices
4868 
4869  } // end loop over levels
4870 
4871  } // end if C1HERMITE
4872 
4873  // calculate self energy factor for splitting
4874  BigReal gs=0, d=0;
4875  splitting(gs, d, 0, split);
4876  gzero = gs * a_p;
4877 
4878  if (CkMyPe() == 0) {
4879  iout << iINFO << "MSM finished calculating stencils\n" << endi;
4880  }
4881 
4882  // allocate map for patches
4883  PatchMap *pm = PatchMap::Object();
4884  int numpatches = pm->numPatches();
4885  map.patchList.resize(numpatches);
4886 #ifdef DEBUG_MSM_VERBOSE
4887  printf("numPatches = %d\n", numpatches);
4888 #endif
4889 
4890  // allocate map for blocks for each grid level
4891  map.blockLevel.resize(nlevels);
4892  map.bsx.resize(nlevels);
4893  map.bsy.resize(nlevels);
4894  map.bsz.resize(nlevels);
4895 #ifdef MSM_FOLD_FACTOR
4896  map.foldfactor.resize(nlevels);
4897 #endif
4898  for (level = 0; level < nlevels; level++) {
4899  msm::IndexRange& g = map.gridrange[level];
4901  int gia = g.ia();
4902  int gni = g.ni();
4903  int gja = g.ja();
4904  int gnj = g.nj();
4905  int gka = g.ka();
4906  int gnk = g.nk();
4907  map.bsx[level] = bsx;
4908  map.bsy[level] = bsy;
4909  map.bsz[level] = bsz;
4910  if (/* map.bsx[level] < gni ||
4911  map.bsy[level] < gnj ||
4912  map.bsz[level] < gnk */ 1) {
4913  // make sure that block sizes divide evenly into periodic dimensions
4914  if (ispx) setup_periodic_blocksize(map.bsx[level], gni);
4915  if (ispy) setup_periodic_blocksize(map.bsy[level], gnj);
4916  if (ispz) setup_periodic_blocksize(map.bsz[level], gnk);
4917 #ifdef MSM_DEBUG_VERBOSE
4918  if (CkMyPe() == 0) {
4919  printf("level = %d\n map.bs* = %d %d %d gn* = %d %d %d\n",
4920  level, map.bsx[level], map.bsy[level], map.bsz[level],gni,gnj,gnk);
4921  }
4922 #endif
4923  // subdivide grid into multiple blocks
4924  // == ceil(gni / bsx), etc.
4925  int bni = (gni / map.bsx[level]) + (gni % map.bsx[level] != 0);
4926  int bnj = (gnj / map.bsy[level]) + (gnj % map.bsy[level] != 0);
4927  int bnk = (gnk / map.bsz[level]) + (gnk % map.bsz[level] != 0);
4928 #ifdef MSM_FOLD_FACTOR
4929  if (/* level > 2 && */ (bni == 1 || bnj == 1 || bnk == 1)) {
4930  map.foldfactor[level].set(bsx / gni, bsy / gnj, bsz / gnk);
4931 #if 0
4932  if (CkMyPe() == 0) {
4933  printf("Setting MSM FoldFactor level %d: %d %d %d\n",
4934  level, bsx / gni, bsy / gnj, bsz / gnk);
4935  }
4936 #endif
4937  }
4938 #endif
4939  b.set(0, bni, 0, bnj, 0, bnk);
4940  for (k = 0; k < bnk; k++) {
4941  for (j = 0; j < bnj; j++) {
4942  for (i = 0; i < bni; i++) {
4943  b(i,j,k).reset();
4944  int ia = gia + i*map.bsx[level];
4945  int ib = ia + map.bsx[level] - 1;
4946  int ja = gja + j*map.bsy[level];
4947  int jb = ja + map.bsy[level] - 1;
4948  int ka = gka + k*map.bsz[level];
4949  int kb = ka + map.bsz[level] - 1;
4950  if (ib >= gia + gni) ib = gia + gni - 1;
4951  if (jb >= gja + gnj) jb = gja + gnj - 1;
4952  if (kb >= gka + gnk) kb = gka + gnk - 1;
4953  b(i,j,k).nrange.setbounds(ia, ib, ja, jb, ka, kb);
4954  }
4955  }
4956  }
4957  }
4958  /*
4959  else {
4960  // make entire grid into single block
4961  b.set(0, 1, 0, 1, 0, 1);
4962  b(0,0,0).reset();
4963  b(0,0,0).nrange.set(gia, gni, gja, gnj, gka, gnk);
4964  // set correct block dimensions
4965  map.bsx[level] = gni;
4966  map.bsy[level] = gnj;
4967  map.bsz[level] = gnk;
4968  }
4969  */
4970  }
4971  //CkExit();
4972 #ifdef DEBUG_MSM_VERBOSE
4973  printf("Done allocating map for grid levels\n");
4974  printf("Grid level decomposition:\n");
4975  for (level = 0; level < nlevels; level++) {
4977  int bia = b.ia();
4978  int bib = b.ib();
4979  int bja = b.ja();
4980  int bjb = b.jb();
4981  int bka = b.ka();
4982  int bkb = b.kb();
4983  for (k = bka; k <= bkb; k++) {
4984  for (j = bja; j <= bjb; j++) {
4985  for (i = bia; i <= bib; i++) {
4986  int ia = b(i,j,k).nrange.ia();
4987  int ib = b(i,j,k).nrange.ib();
4988  int ja = b(i,j,k).nrange.ja();
4989  int jb = b(i,j,k).nrange.jb();
4990  int ka = b(i,j,k).nrange.ka();
4991  int kb = b(i,j,k).nrange.kb();
4992  printf("level=%d id=%d %d %d [%d..%d] x [%d..%d] x [%d..%d]"
4993  " --> %d\n",
4994  level, i, j, k, ia, ib, ja, jb, ka, kb,
4995  b(i,j,k).nrange.nn());
4996  }
4997  }
4998  }
4999  }
5000 #endif
5001  if (CkMyPe() == 0) {
5002  iout << iINFO << "MSM finished creating map for grid levels\n" << endi;
5003  }
5004 
5005  initialize2();
5006 } // ComputeMsmMgr::initialize()
static Node * Object()
Definition: Node.h:86
Array< int > bsz
Definition: MsmMap.h:960
Array< Grid< C1Matrix > > gpro_c1hermite
Definition: MsmMap.h:952
Array< PatchDiagram > patchList
Definition: MsmMap.h:955
void reset(const T &t)
Definition: MsmMap.h:670
void resize(int n)
Definition: MsmMap.h:254
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:107
Definition: MsmMap.h:187
Vector a_r() const
Definition: Lattice.h:268
Definition: MsmMap.h:187
BigReal shz
Definition: ComputeMsm.C:613
#define MSM_MAX_BLOCK_VOLUME
Definition: MsmMap.h:37
Array< int > bsy
Definition: MsmMap.h:960
int ispx
Definition: MsmMap.h:958
int ka() const
Definition: MsmMap.h:438
static PatchMap * Object()
Definition: PatchMap.h:27
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
Vector c_r() const
Definition: Lattice.h:270
int ispy
Definition: MsmMap.h:958
__device__ __forceinline__ float3 cross(const float3 v1, const float3 v2)
BigReal z
Definition: Vector.h:66
int ia() const
Definition: MsmMap.h:434
Vector sx_shx
Definition: ComputeMsm.C:615
BigReal shy_1
Definition: ComputeMsm.C:614
ScaledPosition smin
Definition: ComputeMsm.C:593
Definition: MsmMap.h:187
Vector sy_shy
Definition: ComputeMsm.C:616
BigReal gridspacing
Definition: ComputeMsm.C:595
#define iout
Definition: InfoStream.h:87
int ispz
Definition: MsmMap.h:958
void setup_periodic_blocksize(int &bsize, int n)
Definition: ComputeMsm.C:3932
BigReal length(void) const
Definition: Vector.h:169
#define C1INDEX(drj, dri)
Definition: MsmMap.h:191
BigReal shz_1
Definition: ComputeMsm.C:614
BigReal shx
Definition: ComputeMsm.C:613
BigReal hylen_1
Definition: ComputeMsm.C:600
BigReal gridScalingFactor
Definition: ComputeMsm.C:597
Vector b_r() const
Definition: Lattice.h:269
void set(int pia, int pni, int pja, int pnj, int pka, int pnk)
Definition: MsmMap.h:608
Vector sglower
Definition: ComputeMsm.C:610
void setbounds(int pia, int pib, int pja, int pjb, int pka, int pkb)
Definition: MsmMap.h:612
Array< Grid< BlockDiagram > > blockLevel
Definition: MsmMap.h:956
BigReal hzlen_1
Definition: ComputeMsm.C:600
BigReal hxlen
Definition: ComputeMsm.C:599
Definition: MsmMap.h:187
static const Float PhiStencil[NUM_APPROX_FORMS][MAX_NSTENCIL_SKIP_ZERO]
Definition: ComputeMsm.C:660
ScaledPosition smax
Definition: ComputeMsm.C:594
Array< Grid< C1Matrix > > gres_c1hermite
Definition: MsmMap.h:951
static const int Nstencil[NUM_APPROX]
Definition: ComputeMsm.C:652
msm::Grid< Float > gvsum
Definition: ComputeMsm.C:523
#define ASSERT(E)
int kb() const
Definition: MsmMap.h:439
ScaledPosition smax
Definition: ComputeMsm.h:21
void setup_hgrid_1d(BigReal len, BigReal &hh, int &nn, int &ia, int &ib, int isperiodic)
Definition: ComputeMsm.C:3893
int nn() const
Definition: MsmMap.h:443
Float virial[VMAX]
Definition: ComputeMsm.C:527
BigReal hzlen
Definition: ComputeMsm.C:599
int jb() const
Definition: MsmMap.h:437
BigReal shy
Definition: ComputeMsm.C:613
int nj() const
Definition: MsmMap.h:441
BigReal x
Definition: Vector.h:66
Array< int > bsx
Definition: MsmMap.h:960
Array< IndexRange > gridrange
Definition: MsmMap.h:942
BigReal MSMGridSpacing
void NAMD_die(const char *err_msg)
Definition: common.C:83
Definition: MsmMap.h:187
float Float
Definition: MsmMap.h:74
Definition: MsmMap.h:187
#define simParams
Definition: Output.C:127
int numPatches(void) const
Definition: PatchMap.h:59
int nk() const
Definition: MsmMap.h:442
ScaledPosition smin
Definition: ComputeMsm.h:21
Array< FoldFactor > foldfactor
Definition: MsmMap.h:962
BigReal y
Definition: Vector.h:66
Vector b() const
Definition: Lattice.h:253
static const int PolyDegree[NUM_APPROX]
Definition: ComputeMsm.C:649
Definition: MsmMap.h:187
static void splitting(BigReal &g, BigReal &dg, BigReal r_a, int _split)
Definition: ComputeMsm.C:667
static void gc_c1hermite_elem_accum(C1Matrix &matrix, BigReal _c, Vector rv, BigReal _a, int _split)
Definition: ComputeMsm.C:1410
Array< Grid< Float > > gc
Definition: MsmMap.h:944
ScaledPosition scale(Position p) const
Definition: Lattice.h:83
int ib() const
Definition: MsmMap.h:435
Array< Grid< Float > > gvc
Definition: MsmMap.h:945
Vector sz_shz
Definition: ComputeMsm.C:617
Definition: MsmMap.h:187
msm::Map map
Definition: ComputeMsm.C:471
void set(Float r)
Definition: MsmMap.h:113
infostream & endi(infostream &s)
Definition: InfoStream.C:38
int ja() const
Definition: MsmMap.h:436
Grid< Float > grespro
Definition: MsmMap.h:946
int ni() const
Definition: MsmMap.h:440
int b_p() const
Definition: Lattice.h:274
BigReal MSMPadding
Array< Grid< C1Matrix > > gc_c1hermite
Definition: MsmMap.h:949
BigReal shx_1
Definition: ComputeMsm.C:614
int a_p() const
Definition: Lattice.h:273
BigReal padding
Definition: ComputeMsm.C:596
BigReal gzero
Definition: ComputeMsm.C:608
BigReal hylen
Definition: ComputeMsm.C:599
Vector a() const
Definition: Lattice.h:252
Vector unit(void) const
Definition: Vector.h:182
Vector c() const
Definition: Lattice.h:254
double BigReal
Definition: common.h:114
int c_p() const
Definition: Lattice.h:275
BigReal hxlen_1
Definition: ComputeMsm.C:600
Lattice lattice
Definition: ComputeMsm.C:592
void ComputeMsmMgr::initialize_create ( )

Definition at line 5798 of file ComputeMsm.C.

References approx, ASSERT, msm::Map::blockLevel, C1HERMITE, endi(), iINFO(), iout, map, msmBlock, msmC1HermiteBlock, msmC1HermiteGridCutoff, msmGridCutoff, msmProxy, msm::IndexRange::ni(), msm::IndexRange::nj(), msm::IndexRange::nk(), nlevels, MsmBlockProxyMsg::put(), MsmC1HermiteBlockProxyMsg::put(), MsmGridCutoffProxyMsg::put(), MsmC1HermiteGridCutoffProxyMsg::put(), and msm::Array< T >::resize().

5798  {
5799  int i, j, k, n, level;
5800 
5801  if (CkMyPe() == 0) {
5802 
5803  // on PE 0, create 3D chare array of MsmBlock for each level;
5804  // broadcast this array of proxies to the rest of the group
5805  if (approx == C1HERMITE) {
5807  }
5808  else {
5810  }
5811  for (level = 0; level < nlevels; level++) {
5812  int ni = map.blockLevel[level].ni();
5813  int nj = map.blockLevel[level].nj();
5814  int nk = map.blockLevel[level].nk();
5815 #ifdef MSM_NODE_MAPPING
5816  CkPrintf("Using MsmBlockMap for level %d\n", level);
5817  CProxy_MsmBlockMap blockMap = CProxy_MsmBlockMap::ckNew(level);
5818  CkArrayOptions opts(ni, nj, nk);
5819  opts.setMap(blockMap);
5820  if (approx == C1HERMITE) {
5821  msmC1HermiteBlock[level] =
5822  CProxy_MsmC1HermiteBlock::ckNew(level, opts);
5823  }
5824  else {
5825  msmBlock[level] = CProxy_MsmBlock::ckNew(level, opts);
5826  }
5827 #else
5828  if (approx == C1HERMITE) {
5829  msmC1HermiteBlock[level] =
5830  CProxy_MsmC1HermiteBlock::ckNew(level, ni, nj, nk);
5831  }
5832  else {
5833  msmBlock[level] = CProxy_MsmBlock::ckNew(level, ni, nj, nk);
5834  }
5835 #endif
5836 #ifdef DEBUG_MSM_VERBOSE
5837  printf("Create MsmBlock[%d] 3D chare array ( %d x %d x %d )\n",
5838  level, ni, nj, nk);
5839 #endif
5840  char msg[128];
5841  int nijk = ni * nj * nk;
5842  sprintf(msg, "MSM grid level %d decomposed into %d block%s"
5843  " ( %d x %d x %d )\n",
5844  level, nijk, (nijk==1 ? "" : "s"), ni, nj, nk);
5845  iout << iINFO << msg;
5846  }
5847  if (approx == C1HERMITE) {
5849  msg->put(msmC1HermiteBlock);
5850  msmProxy.recvMsmC1HermiteBlockProxy(msg); // broadcast
5851  }
5852  else {
5854  msg->put(msmBlock);
5855  msmProxy.recvMsmBlockProxy(msg); // broadcast
5856  }
5857 
5858 #ifdef MSM_GRID_CUTOFF_DECOMP
5859  // on PE 0, create 1D chare array of MsmGridCutoff
5860  // broadcast this array proxy to the rest of the group
5861 #ifdef MSM_NODE_MAPPING
5862  CkPrintf("Using MsmGridCutoffMap\n");
5863  CProxy_MsmGridCutoffMap gcutMap = CProxy_MsmGridCutoffMap::ckNew();
5864  CkArrayOptions optsgcut(numGridCutoff);
5865  optsgcut.setMap(gcutMap);
5866  if (approx == C1HERMITE) {
5867  msmC1HermiteGridCutoff = CProxy_MsmC1HermiteGridCutoff::ckNew(optsgcut);
5868  }
5869  else {
5870  msmGridCutoff = CProxy_MsmGridCutoff::ckNew(optsgcut);
5871  }
5872 #else
5873  if (approx == C1HERMITE) {
5875  CProxy_MsmC1HermiteGridCutoff::ckNew(numGridCutoff);
5876  }
5877  else {
5878  msmGridCutoff = CProxy_MsmGridCutoff::ckNew(numGridCutoff);
5879  }
5880 #endif
5881  if (approx == C1HERMITE) {
5884  gcmsg->put(&msmC1HermiteGridCutoff);
5885  msmProxy.recvMsmC1HermiteGridCutoffProxy(gcmsg);
5886  }
5887  else {
5889  gcmsg->put(&msmGridCutoff);
5890  msmProxy.recvMsmGridCutoffProxy(gcmsg);
5891  }
5892 
5893  // XXX PE 0 initializes each MsmGridCutoff
5894  // one-to-many
5895  // for M length chare array, better for each PE to initialize M/P?
5896  for (level = 0; level < nlevels; level++) { // for all levels
5898  int bni = b.ni();
5899  int bnj = b.nj();
5900  int bnk = b.nk();
5901  for (k = 0; k < bnk; k++) { // for all blocks
5902  for (j = 0; j < bnj; j++) {
5903  for (i = 0; i < bni; i++) {
5904  // source for charges
5905  msm::BlockIndex bi = msm::BlockIndex(level, msm::Ivec(i,j,k));
5906  int numSendAcross = b(i,j,k).sendAcross.len();
5907  ASSERT( numSendAcross == b(i,j,k).indexGridCutoff.len() );
5908  // for this source, loop over destinations for potentials
5909  for (n = 0; n < numSendAcross; n++) {
5910  msm::BlockSend &bs = b(i,j,k).sendAcross[n];
5911  int index = b(i,j,k).indexGridCutoff[n];
5912  MsmGridCutoffInitMsg *bsmsg = new MsmGridCutoffInitMsg(bi, bs);
5913  if (approx == C1HERMITE) {
5914  msmC1HermiteGridCutoff[index].setup(bsmsg);
5915  }
5916  else {
5917  msmGridCutoff[index].setup(bsmsg);
5918  }
5919  } // traverse sendAcross, indexGridCutoff arrays
5920 
5921  }
5922  }
5923  } // end for all blocks
5924 
5925  } // end for all levels
5926 
5927  iout << iINFO << "MSM grid cutoff calculation decomposed into "
5928  << numGridCutoff << " work objects\n";
5929 #endif
5930  iout << endi;
5931  }
5932 
5933 #ifdef DEBUG_MSM_VERBOSE
5934  printf("end of initialization\n");
5935 #endif
5936 } // ComputeMsmMgr::initialize_create()
void resize(int n)
Definition: MsmMap.h:254
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:107
void put(const msm::Array< CProxy_MsmC1HermiteBlock > &a)
Definition: ComputeMsm.C:182
#define iout
Definition: InfoStream.h:87
Array< Grid< BlockDiagram > > blockLevel
Definition: MsmMap.h:956
void put(const msm::Array< CProxy_MsmBlock > &a)
Definition: ComputeMsm.C:159
CProxy_ComputeMsmMgr msmProxy
Definition: ComputeMsm.C:461
#define ASSERT(E)
int nj() const
Definition: MsmMap.h:441
CProxy_MsmGridCutoff msmGridCutoff
Definition: ComputeMsm.C:467
CProxy_MsmC1HermiteGridCutoff msmC1HermiteGridCutoff
Definition: ComputeMsm.C:468
int nk() const
Definition: MsmMap.h:442
msm::Array< CProxy_MsmBlock > msmBlock
Definition: ComputeMsm.C:464
msm::Array< CProxy_MsmC1HermiteBlock > msmC1HermiteBlock
Definition: ComputeMsm.C:465
msm::Map map
Definition: ComputeMsm.C:471
void put(const CProxy_MsmC1HermiteGridCutoff *p)
Definition: ComputeMsm.C:223
infostream & endi(infostream &s)
Definition: InfoStream.C:38
int ni() const
Definition: MsmMap.h:440
void put(const CProxy_MsmGridCutoff *p)
Definition: ComputeMsm.C:205
void ComputeMsmMgr::initVirialContrib ( )
inline

Definition at line 529 of file ComputeMsm.C.

References cntVirialContrib, gvsum, and msm::Grid< T >::reset().

Referenced by doneVirialContrib().

529  {
530  gvsum.reset(0);
531  cntVirialContrib = 0;
532  }
void reset(const T &t)
Definition: MsmMap.h:670
int cntVirialContrib
Definition: ComputeMsm.C:525
msm::Grid< Float > gvsum
Definition: ComputeMsm.C:523
msm::Map& ComputeMsmMgr::mapData ( )
inline

Definition at line 447 of file ComputeMsm.C.

References map.

Referenced by ComputeMsm::doWork(), msm::PatchData::PatchData(), and ComputeMsm::saveResults().

447 { return map; }
msm::Map map
Definition: ComputeMsm.C:471
static void ComputeMsmMgr::ndsplitting ( BigReal  pg[],
BigReal  s,
int  n,
int  _split 
)
inlinestatic

Definition at line 1266 of file ComputeMsm.C.

References NAMD_die(), TAYLOR2, TAYLOR3, TAYLOR4, TAYLOR5, TAYLOR6, TAYLOR7, and TAYLOR8.

Referenced by gc_c1hermite_elem_accum().

1266  {
1267  int k = 0;
1268  if (k == n) return;
1269  if (s <= 1) {
1270  // compute derivatives of smoothed part
1271  switch (_split) {
1272  case TAYLOR2:
1273  pg[k++] = 1 + (s-1)*(-1./2 + (s-1)*(3./8));
1274  if (k == n) break;
1275  pg[k++] = -1./2 + (s-1)*(3./4);
1276  if (k == n) break;
1277  pg[k++] = 3./4;
1278  break;
1279  case TAYLOR3:
1280  pg[k++] = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16)));
1281  if (k == n) break;
1282  pg[k++] = -1./2 + (s-1)*(3./4 + (s-1)*(-15./16));
1283  if (k == n) break;
1284  pg[k++] = 3./4 + (s-1)*(-15./8);
1285  if (k == n) break;
1286  pg[k++] = -15./8;
1287  break;
1288  case TAYLOR4:
1289  pg[k++] = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
1290  + (s-1)*(35./128))));
1291  if (k == n) break;
1292  pg[k++] = -1./2 + (s-1)*(3./4 + (s-1)*(-15./16 + (s-1)*(35./32)));
1293  if (k == n) break;
1294  pg[k++] = 3./4 + (s-1)*(-15./8 + (s-1)*(105./32));
1295  if (k == n) break;
1296  pg[k++] = -15./8 + (s-1)*(105./16);
1297  if (k == n) break;
1298  pg[k++] = 105./16;
1299  break;
1300  case TAYLOR5:
1301  pg[k++] = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
1302  + (s-1)*(35./128 + (s-1)*(-63./256)))));
1303  if (k == n) break;
1304  pg[k++] = -1./2 + (s-1)*(3./4 + (s-1)*(-15./16 + (s-1)*(35./32
1305  + (s-1)*(-315./256))));
1306  if (k == n) break;
1307  pg[k++] = 3./4 + (s-1)*(-15./8 + (s-1)*(105./32 + (s-1)*(-315./64)));
1308  if (k == n) break;
1309  pg[k++] = -15./8 + (s-1)*(105./16 + (s-1)*(-945./64));
1310  if (k == n) break;
1311  pg[k++] = 105./16 + (s-1)*(-945./32);
1312  if (k == n) break;
1313  pg[k++] = -945./32;
1314  break;
1315  case TAYLOR6:
1316  pg[k++] = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
1317  + (s-1)*(35./128 + (s-1)*(-63./256 + (s-1)*(231./1024))))));
1318  if (k == n) break;
1319  pg[k++] = -1./2 + (s-1)*(3./4 + (s-1)*(-15./16 + (s-1)*(35./32
1320  + (s-1)*(-315./256 + (s-1)*(693./512)))));
1321  if (k == n) break;
1322  pg[k++] = 3./4 + (s-1)*(-15./8 + (s-1)*(105./32 + (s-1)*(-315./64
1323  + (s-1)*(3465./512))));
1324  if (k == n) break;
1325  pg[k++] = -15./8 + (s-1)*(105./16 + (s-1)*(-945./64
1326  + (s-1)*(3465./128)));
1327  if (k == n) break;
1328  pg[k++] = 105./16 + (s-1)*(-945./32 + (s-1)*(10395./128));
1329  if (k == n) break;
1330  pg[k++] = -945./32 + (s-1)*(10395./64);
1331  if (k == n) break;
1332  pg[k++] = 10395./64;
1333  break;
1334  case TAYLOR7:
1335  pg[k++] = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
1336  + (s-1)*(35./128 + (s-1)*(-63./256
1337  + (s-1)*(231./1024 + (s-1)*(-429./2048)))))));
1338  if (k == n) break;
1339  pg[k++] = -1./2 + (s-1)*(3./4 + (s-1)*(-15./16 + (s-1)*(35./32
1340  + (s-1)*(-315./256 + (s-1)*(693./512
1341  + (s-1)*(-3003./2048))))));
1342  if (k == n) break;
1343  pg[k++] = 3./4 + (s-1)*(-15./8 + (s-1)*(105./32 + (s-1)*(-315./64
1344  + (s-1)*(3465./512 + (s-1)*(-9009./1024)))));
1345  if (k == n) break;
1346  pg[k++] = -15./8 + (s-1)*(105./16 + (s-1)*(-945./64 + (s-1)*(3465./128
1347  + (s-1)*(-45045./1024))));
1348  if (k == n) break;
1349  pg[k++] = 105./16 + (s-1)*(-945./32 + (s-1)*(10395./128
1350  + (s-1)*(-45045./256)));
1351  if (k == n) break;
1352  pg[k++] = -945./32 + (s-1)*(10395./64 + (s-1)*(-135135./256));
1353  if (k == n) break;
1354  pg[k++] = 10395./64 + (s-1)*(-135135./128);
1355  if (k == n) break;
1356  pg[k++] = -135135./128;
1357  break;
1358  case TAYLOR8:
1359  pg[k++] = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
1360  + (s-1)*(35./128 + (s-1)*(-63./256
1361  + (s-1)*(231./1024 + (s-1)*(-429./2048
1362  + (s-1)*(6435./32768))))))));
1363  if (k == n) break;
1364  pg[k++] = -1./2 + (s-1)*(3./4 + (s-1)*(-15./16 + (s-1)*(35./32
1365  + (s-1)*(-315./256 + (s-1)*(693./512
1366  + (s-1)*(-3003./2048 + (s-1)*(6435./4096)))))));
1367  if (k == n) break;
1368  pg[k++] = 3./4 + (s-1)*(-15./8 + (s-1)*(105./32 + (s-1)*(-315./64
1369  + (s-1)*(3465./512 + (s-1)*(-9009./1024
1370  + (s-1)*(45045./4096))))));
1371  if (k == n) break;
1372  pg[k++] = -15./8 + (s-1)*(105./16 + (s-1)*(-945./64 + (s-1)*(3465./128
1373  + (s-1)*(-45045./1024 + (s-1)*(135135./2048)))));
1374  if (k == n) break;
1375  pg[k++] = 105./16 + (s-1)*(-945./32 + (s-1)*(10395./128
1376  + (s-1)*(-45045./256 + (s-1)*(675675./2048))));
1377  if (k == n) break;
1378  pg[k++] = -945./32 + (s-1)*(10395./64 + (s-1)*(-135135./256
1379  + (s-1)*(675675./512)));
1380  if (k == n) break;
1381  pg[k++] = 10395./64 + (s-1)*(-135135./128 + (s-1)*(2027025./512));
1382  if (k == n) break;
1383  pg[k++] = -135135./128 + (s-1)*(2027025./256);
1384  if (k == n) break;
1385  pg[k++] = 2027025./256;
1386  break;
1387  default:
1388  NAMD_die("Unknown MSM splitting.");
1389  }
1390  } // if (s <= 1)
1391  else { // (s > 1)
1392  // compute derivatives of s^(-1/2)
1393  const BigReal s_1 = 1./s;
1394  BigReal s_p = sqrt(s_1);
1395  BigReal p = -0.5;
1396  BigReal _c = 1;
1397  pg[k++] = _c * s_p;
1398  while (k < n) {
1399  s_p *= s_1;
1400  _c *= p;
1401  p -= 1;
1402  pg[k++] = _c * s_p;
1403  }
1404  } // else (s > 1)
1405  // higher derivatives are zero
1406  while (k < n) pg[k++] = 0;
1407  } // ndsplitting()
void NAMD_die(const char *err_msg)
Definition: common.C:83
double BigReal
Definition: common.h:114
int ComputeMsmMgr::numLevels ( ) const
inline

Definition at line 449 of file ComputeMsm.C.

References nlevels.

449 { return nlevels; }
msm::PatchPtrArray& ComputeMsmMgr::patchPtrArray ( )
inline

Definition at line 445 of file ComputeMsm.C.

References patchPtr.

Referenced by ComputeMsm::doWork(), and ComputeMsm::saveResults().

445 { return patchPtr; }
msm::PatchPtrArray patchPtr
Definition: ComputeMsm.C:476
void ComputeMsmMgr::recvMsmBlockProxy ( MsmBlockProxyMsg msg)

Definition at line 5939 of file ComputeMsm.C.

References MsmBlockProxyMsg::get(), and msmBlock.

5940 {
5941  msg->get(msmBlock);
5942  delete(msg);
5943 }
void get(msm::Array< CProxy_MsmBlock > &a)
Definition: ComputeMsm.C:168
msm::Array< CProxy_MsmBlock > msmBlock
Definition: ComputeMsm.C:464
void ComputeMsmMgr::recvMsmC1HermiteBlockProxy ( MsmC1HermiteBlockProxyMsg msg)

Definition at line 5951 of file ComputeMsm.C.

References MsmC1HermiteBlockProxyMsg::get(), and msmC1HermiteBlock.

5954 {
5955  msg->get(msmC1HermiteBlock);
5956  delete(msg);
5957 }
void get(msm::Array< CProxy_MsmC1HermiteBlock > &a)
Definition: ComputeMsm.C:192
msm::Array< CProxy_MsmC1HermiteBlock > msmC1HermiteBlock
Definition: ComputeMsm.C:465
void ComputeMsmMgr::recvMsmC1HermiteGridCutoffProxy ( MsmC1HermiteGridCutoffProxyMsg msg)

Definition at line 5959 of file ComputeMsm.C.

References MsmC1HermiteGridCutoffProxyMsg::get(), and msmC1HermiteGridCutoff.

5962 {
5963  msg->get(&msmC1HermiteGridCutoff);
5964  delete(msg);
5965 }
void get(CProxy_MsmC1HermiteGridCutoff *p)
Definition: ComputeMsm.C:229
CProxy_MsmC1HermiteGridCutoff msmC1HermiteGridCutoff
Definition: ComputeMsm.C:468
void ComputeMsmMgr::recvMsmGridCutoffProxy ( MsmGridCutoffProxyMsg msg)

Definition at line 5945 of file ComputeMsm.C.

References MsmGridCutoffProxyMsg::get(), and msmGridCutoff.

5946 {
5947  msg->get(&msmGridCutoff);
5948  delete(msg);
5949 }
CProxy_MsmGridCutoff msmGridCutoff
Definition: ComputeMsm.C:467
void get(CProxy_MsmGridCutoff *p)
Definition: ComputeMsm.C:210
void ComputeMsmMgr::setCompute ( ComputeMsm c)
inline

Definition at line 443 of file ComputeMsm.C.

References c, msmCompute, and ComputeMsm::setMgr().

443 { msmCompute = c; c->setMgr(this); } // local
ComputeMsm * msmCompute
Definition: ComputeMsm.C:462
void setMgr(ComputeMsmMgr *mgr)
Definition: ComputeMsm.h:32
void ComputeMsmMgr::setup_hgrid_1d ( BigReal  len,
BigReal hh,
int &  nn,
int &  ia,
int &  ib,
int  isperiodic 
)

Definition at line 3893 of file ComputeMsm.C.

References ASSERT, gridspacing, NAMD_die(), and s_edge.

Referenced by initialize().

3895 {
3896  ASSERT(gridspacing > 0);
3897  if (isperiodic) {
3898  const BigReal hmin = (4./5) * gridspacing;
3899  const BigReal hmax = 1.5 * hmin;
3900  hh = len;
3901  nn = 1; // start with one grid point across length
3902  while (hh >= hmax) {
3903  hh *= 0.5; // halve spacing and double grid points
3904  nn <<= 1;
3905  }
3906  if (hh < hmin) {
3907  if (nn < 4) {
3908  NAMD_die("Basis vector is too short or MSM grid spacing is too large");
3909  }
3910  hh *= (4./3); // scale hh by 4/3 and nn by 3/4
3911  nn >>= 2;
3912  nn *= 3;
3913  }
3914  // now we have: hmin <= h < hmax,
3915  // where nn is a power of 2 times no more than one power of 3
3916  ia = 0;
3917  ib = nn-1;
3918  }
3919  else {
3920  hh = gridspacing;
3921  // Instead of "nn = (int) ceil(len / hh);"
3922  // len is divisible by hh, up to roundoff error, so round to closest nn
3923  nn = (int) floor(len/hh + 0.5);
3924  ia = -s_edge;
3925  ib = nn + s_edge;
3926  }
3927 } // ComputeMsmMgr::setup_hgrid_1d()
BigReal gridspacing
Definition: ComputeMsm.C:595
#define ASSERT(E)
void NAMD_die(const char *err_msg)
Definition: common.C:83
double BigReal
Definition: common.h:114
void ComputeMsmMgr::setup_periodic_blocksize ( int &  bsize,
int  n 
)

Definition at line 3932 of file ComputeMsm.C.

References NAMD_die().

Referenced by initialize().

3933 {
3934  if (n % bsize != 0) {
3935  // n is either 2^k or 3*2^k
3936  int newbsize = 1;
3937  if (n % 3 == 0) newbsize = 3;
3938  while (newbsize < bsize && newbsize < n) newbsize *= 2;
3939  if (bsize < newbsize) newbsize /= 2;
3940  if (n % newbsize != 0) {
3941  NAMD_die("MSM grid size for periodic dimensions must be "
3942  "a power of 2 times at most one power of 3");
3943  }
3944  bsize = newbsize;
3945  }
3946  return;
3947 }
void NAMD_die(const char *err_msg)
Definition: common.C:83
static int ComputeMsmMgr::sign ( int  n)
inlinestatic

Definition at line 452 of file ComputeMsm.C.

452  {
453  return (n < 0 ? -1 : (n > 0 ? 1 : 0));
454  }
static void ComputeMsmMgr::splitting ( BigReal g,
BigReal dg,
BigReal  r_a,
int  _split 
)
inlinestatic

Definition at line 667 of file ComputeMsm.C.

References NAMD_die(), TAYLOR2, TAYLOR2_DISP, TAYLOR3, TAYLOR3_DISP, TAYLOR4, TAYLOR4_DISP, TAYLOR5, TAYLOR5_DISP, TAYLOR6, TAYLOR6_DISP, TAYLOR7, TAYLOR7_DISP, TAYLOR8, and TAYLOR8_DISP.

Referenced by initialize().

667  {
668  BigReal s = r_a * r_a; // s = (r/a)^2, assuming 0 <= s <= 1
669  switch (_split) {
670  case TAYLOR2:
671  g = 1 + (s-1)*(-1./2 + (s-1)*(3./8));
672  dg = (2*r_a)*(-1./2 + (s-1)*(3./4));
673  break;
674  case TAYLOR3:
675  g = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16)));
676  dg = (2*r_a)*(-1./2 + (s-1)*(3./4 + (s-1)*(-15./16)));
677  break;
678  case TAYLOR4:
679  g = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
680  + (s-1)*(35./128))));
681  dg = (2*r_a)*(-1./2 + (s-1)*(3./4 + (s-1)*(-15./16
682  + (s-1)*(35./32))));
683  break;
684  case TAYLOR5:
685  g = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
686  + (s-1)*(35./128 + (s-1)*(-63./256)))));
687  dg = (2*r_a)*(-1./2 + (s-1)*(3./4 + (s-1)*(-15./16
688  + (s-1)*(35./32 + (s-1)*(-315./256)))));
689  break;
690  case TAYLOR6:
691  g = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
692  + (s-1)*(35./128 + (s-1)*(-63./256
693  + (s-1)*(231./1024))))));
694  dg = (2*r_a)*(-1./2 + (s-1)*(3./4 + (s-1)*(-15./16
695  + (s-1)*(35./32 + (s-1)*(-315./256
696  + (s-1)*(693./512))))));
697  break;
698  case TAYLOR7:
699  g = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
700  + (s-1)*(35./128 + (s-1)*(-63./256
701  + (s-1)*(231./1024 + (s-1)*(-429./2048)))))));
702  dg = (2*r_a)*(-1./2 + (s-1)*(3./4 + (s-1)*(-15./16
703  + (s-1)*(35./32 + (s-1)*(-315./256
704  + (s-1)*(693./512 + (s-1)*(-3003./2048)))))));
705  break;
706  case TAYLOR8:
707  g = 1 + (s-1)*(-1./2 + (s-1)*(3./8 + (s-1)*(-5./16
708  + (s-1)*(35./128 + (s-1)*(-63./256
709  + (s-1)*(231./1024 + (s-1)*(-429./2048
710  + (s-1)*(6435./32768))))))));
711  dg = (2*r_a)*(-1./2 + (s-1)*(3./4 + (s-1)*(-15./16
712  + (s-1)*(35./32 + (s-1)*(-315./256
713  + (s-1)*(693./512 + (s-1)*(-3003./2048
714  + (s-1)*(6435./4096))))))));
715  break;
716  case TAYLOR2_DISP:
717  g = 1 + (s-1)*(-3 + (s-1)*(6));
718  dg = (2*r_a)*(-3 + (s-1)*(12));
719  break;
720  case TAYLOR3_DISP:
721  g = 1 + (s-1)*(-3 + (s-1)*(6 + (s-1)*(-10)));
722  dg = (2*r_a)*(-3 + (s-1)*(12 + (s-1)*(-30)));
723  break;
724  case TAYLOR4_DISP:
725  g = 1 + (s-1)*(-3 + (s-1)*(6 + (s-1)*(-10 + (s-1)*(15))));
726  dg = (2*r_a)*(-3 + (s-1)*(12 + (s-1)*(-30 + (s-1)*(60))));
727  break;
728  case TAYLOR5_DISP:
729  g = 1 + (s-1)*(-3 + (s-1)*(6 + (s-1)*(-10
730  + (s-1)*(15 + (s-1)*(-21)))));
731  dg = (2*r_a)*(-3 + (s-1)*(12 + (s-1)*(-30
732  + (s-1)*(60 + (s-1)*(-105)))));
733  break;
734  case TAYLOR6_DISP:
735  g = 1 + (s-1)*(-3 + (s-1)*(6 + (s-1)*(-10
736  + (s-1)*(15 + (s-1)*(-21 + (s-1)*(28))))));
737  dg = (2*r_a)*(-3 + (s-1)*(12 + (s-1)*(-30
738  + (s-1)*(60 + (s-1)*(-105 + (s-1)*(168))))));
739  break;
740  case TAYLOR7_DISP:
741  g = 1 + (s-1)*(-3 + (s-1)*(6 + (s-1)*(-10
742  + (s-1)*(15 + (s-1)*(-21 + (s-1)*(28
743  + (s-1)*(-36)))))));
744  dg = (2*r_a)*(-3 + (s-1)*(12 + (s-1)*(-30
745  + (s-1)*(60 + (s-1)*(-105 + (s-1)*(168
746  + (s-1)*(-252)))))));
747  break;
748  case TAYLOR8_DISP:
749  g = 1 + (s-1)*(-3 + (s-1)*(6 + (s-1)*(-10
750  + (s-1)*(15 + (s-1)*(-21 + (s-1)*(28
751  + (s-1)*(-36 + (s-1)*(45))))))));
752  dg = (2*r_a)*(-3 + (s-1)*(12 + (s-1)*(-30
753  + (s-1)*(60 + (s-1)*(-105 + (s-1)*(168
754  + (s-1)*(-252 + (s-1)*(360))))))));
755  break;
756  default:
757  NAMD_die("Unknown MSM splitting.");
758  } // switch
759  } // splitting()
void NAMD_die(const char *err_msg)
Definition: common.C:83
double BigReal
Definition: common.h:114
void ComputeMsmMgr::stencil_1d ( Float  phi[],
Float  t 
)
inline

Definition at line 761 of file ComputeMsm.C.

References approx, CUBIC, NAMD_die(), NONIC, NONIC4, QUINTIC, QUINTIC2, SEPTIC, and SEPTIC3.

Referenced by msm::PatchData::anterpolation().

761  {
762  switch (approx) {
763  case CUBIC:
764  phi[0] = 0.5f * (1 - t) * (2 - t) * (2 - t);
765  t--;
766  phi[1] = (1 - t) * (1 + t - 1.5f * t * t);
767  t--;
768  phi[2] = (1 + t) * (1 - t - 1.5f * t * t);
769  t--;
770  phi[3] = 0.5f * (1 + t) * (2 + t) * (2 + t);
771  break;
772  case QUINTIC:
773  phi[0] = (1.f/24) * (1-t) * (2-t) * (3-t) * (3-t) * (4-t);
774  t--;
775  phi[1] = (1-t) * (2-t) * (3-t) * ((1.f/6)
776  + t * (0.375f - (5.f/24)*t));
777  t--;
778  phi[2] = (1-t*t) * (2-t) * (0.5f + t * (0.25f - (5.f/12)*t));
779  t--;
780  phi[3] = (1-t*t) * (2+t) * (0.5f - t * (0.25f + (5.f/12)*t));
781  t--;
782  phi[4] = (1+t) * (2+t) * (3+t) * ((1.f/6)
783  - t * (0.375f + (5.f/24)*t));
784  t--;
785  phi[5] = (1.f/24) * (1+t) * (2+t) * (3+t) * (3+t) * (4+t);
786  break;
787  case QUINTIC2:
788  phi[0] = (1.f/24) * (3-t) * (3-t) * (3-t) * (t-2) * (5*t-8);
789  t--;
790  phi[1] = (-1.f/24) * (2-t) * (t-1) * (-48+t*(153+t*(-114+t*25)));
791  t--;
792  phi[2] = (1.f/12) * (1-t) * (12+t*(12+t*(-3+t*(-38+t*25))));
793  t--;
794  phi[3] = (1.f/12) * (1+t) * (12+t*(-12+t*(-3+t*(38+t*25))));
795  t--;
796  phi[4] = (-1.f/24) * (2+t) * (t+1) * (48+t*(153+t*(114+t*25)));
797  t--;
798  phi[5] = (1.f/24) * (3+t) * (3+t) * (3+t) * (t+2) * (5*t+8);
799  break;
800  case SEPTIC:
801  phi[0] = (-1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-4)*(t-5)*(t-6);
802  t--;
803  phi[1] = (1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-5)*(-6+t*(-20+7*t));
804  t--;
805  phi[2] = (-1.f/240)*(t*t-1)*(t-2)*(t-3)*(t-4)*(-10+t*(-12+7*t));
806  t--;
807  phi[3] = (1.f/144)*(t*t-1)*(t*t-4)*(t-3)*(-12+t*(-4+7*t));
808  t--;
809  phi[4] = (-1.f/144)*(t*t-1)*(t*t-4)*(t+3)*(-12+t*(4+7*t));
810  t--;
811  phi[5] = (1.f/240)*(t*t-1)*(t+2)*(t+3)*(t+4)*(-10+t*(12+7*t));
812  t--;
813  phi[6] = (-1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(-6+t*(20+7*t));
814  t--;
815  phi[7] = (1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+4)*(t+5)*(t+6);
816  break;
817  case SEPTIC3:
818  phi[0] = (3632.f/5) + t*((-7456.f/5) + t*((58786.f/45) + t*(-633
819  + t*((26383.f/144) + t*((-22807.f/720) + t*((727.f/240)
820  + t*(-89.f/720)))))));
821  t--;
822  phi[1] = -440 + t*((25949.f/20) + t*((-117131.f/72) + t*((2247.f/2)
823  + t*((-66437.f/144) + t*((81109.f/720) + t*((-727.f/48)
824  + t*(623.f/720)))))));
825  t--;
826  phi[2] = (138.f/5) + t*((-8617.f/60) + t*((12873.f/40) + t*((-791.f/2)
827  + t*((4557.f/16) + t*((-9583.f/80) + t*((2181.f/80)
828  + t*(-623.f/240)))))));
829  t--;
830  phi[3] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((2569.f/144)
831  + t*((-727.f/48) + t*(623.f/144)))));
832  t--;
833  phi[4] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((-2569.f/144)
834  + t*((-727.f/48) + t*(-623.f/144)))));
835  t--;
836  phi[5] = (138.f/5) + t*((8617.f/60) + t*((12873.f/40) + t*((791.f/2)
837  + t*((4557.f/16) + t*((9583.f/80) + t*((2181.f/80)
838  + t*(623.f/240)))))));
839  t--;
840  phi[6] = -440 + t*((-25949.f/20) + t*((-117131.f/72) + t*((-2247.f/2)
841  + t*((-66437.f/144) + t*((-81109.f/720) + t*((-727.f/48)
842  + t*(-623.f/720)))))));
843  t--;
844  phi[7] = (3632.f/5) + t*((7456.f/5) + t*((58786.f/45) + t*(633
845  + t*((26383.f/144) + t*((22807.f/720) + t*((727.f/240)
846  + t*(89.f/720)))))));
847  break;
848  case NONIC:
849  phi[0] = (-1.f/40320)*(t-8)*(t-7)*(t-6)*(t-5)*(t-5)*(t-4)*(t-3)*
850  (t-2)*(t-1);
851  t--;
852  phi[1] = (1.f/40320)*(t-7)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*
853  (-8+t*(-35+9*t));
854  t--;
855  phi[2] = (-1.f/10080)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*
856  (-14+t*(-25+9*t));
857  t--;
858  phi[3] = (1.f/1440)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*
859  (-6+t*(-5+3*t));
860  t--;
861  phi[4] = (-1.f/2880)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*
862  (-20+t*(-5+9*t));
863  t--;
864  phi[5] = (1.f/2880)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*
865  (-20+t*(5+9*t));
866  t--;
867  phi[6] = (-1.f/1440)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*
868  (-6+t*(5+3*t));
869  t--;
870  phi[7] = (1.f/10080)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)*
871  (-14+t*(25+9*t));
872  t--;
873  phi[8] = (-1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)*(t+7)*
874  (-8+t*(35+9*t));
875  t--;
876  phi[9] = (1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+5)*(t+6)*
877  (t+7)*(t+8);
878  break;
879  case NONIC4:
880  { // begin grouping to define local variables
881  double Tphi[10];
882  double T=t;
883  Tphi[0] = 439375./7+T*(-64188125./504+T*(231125375./2016
884  +T*(-17306975./288+T*(7761805./384+T*(-2895587./640
885  +T*(129391./192+T*(-259715./4032+T*(28909./8064
886  +T*(-3569./40320)))))))));
887  T--;
888  Tphi[1] = -56375+T*(8314091./56+T*(-49901303./288+T*(3763529./32
889  +T*(-19648027./384+T*(9469163./640+T*(-545977./192
890  +T*(156927./448+T*(-28909./1152
891  +T*(3569./4480)))))))));
892  T--;
893  Tphi[2] = 68776./7+T*(-1038011./28+T*(31157515./504+T*(-956669./16
894  +T*(3548009./96+T*(-2422263./160+T*(197255./48
895  +T*(-19959./28+T*(144545./2016
896  +T*(-3569./1120)))))))));
897  T--;
898  Tphi[3] = -154+T*(12757./12+T*(-230123./72+T*(264481./48
899  +T*(-576499./96+T*(686147./160+T*(-96277./48
900  +T*(14221./24+T*(-28909./288+T*(3569./480)))))))));
901  T--;
902  Tphi[4] = 1+T*T*(-205./144+T*T*(91./192+T*(-6181./320
903  +T*(6337./96+T*(-2745./32+T*(28909./576
904  +T*(-3569./320)))))));
905  T--;
906  Tphi[5] = 1+T*T*(-205./144+T*T*(91./192+T*(6181./320
907  +T*(6337./96+T*(2745./32+T*(28909./576
908  +T*(3569./320)))))));
909  T--;
910  Tphi[6] = -154+T*(-12757./12+T*(-230123./72+T*(-264481./48
911  +T*(-576499./96+T*(-686147./160+T*(-96277./48
912  +T*(-14221./24+T*(-28909./288+T*(-3569./480)))))))));
913  T--;
914  Tphi[7] = 68776./7+T*(1038011./28+T*(31157515./504+T*(956669./16
915  +T*(3548009./96+T*(2422263./160+T*(197255./48
916  +T*(19959./28+T*(144545./2016+T*(3569./1120)))))))));
917  T--;
918  Tphi[8] = -56375+T*(-8314091./56+T*(-49901303./288+T*(-3763529./32
919  +T*(-19648027./384+T*(-9469163./640+T*(-545977./192
920  +T*(-156927./448+T*(-28909./1152
921  +T*(-3569./4480)))))))));
922  T--;
923  Tphi[9] = 439375./7+T*(64188125./504+T*(231125375./2016
924  +T*(17306975./288+T*(7761805./384+T*(2895587./640
925  +T*(129391./192+T*(259715./4032+T*(28909./8064
926  +T*(3569./40320)))))))));
927  for (int i=0; i < 10; i++) {
928  phi[i] = Float(Tphi[i]);
929  }
930  } // end grouping to define local variables
931  break;
932  default:
933  NAMD_die("Unknown MSM approximation.");
934  } // switch
935  } // stencil_1d()
void NAMD_die(const char *err_msg)
Definition: common.C:83
float Float
Definition: MsmMap.h:74
void ComputeMsmMgr::stencil_1d_c1hermite ( Float  phi[],
Float  psi[],
Float  t,
Float  h 
)
inline

Definition at line 1244 of file ComputeMsm.C.

Referenced by msm::PatchData::anterpolationC1Hermite().

1244  {
1245  phi[0] = (1 - t) * (1 - t) * (1 + 2*t);
1246  psi[0] = h * t * (1 - t) * (1 - t);
1247  t--;
1248  phi[1] = (1 + t) * (1 + t) * (1 - 2*t);
1249  psi[1] = h * t * (1 + t) * (1 + t);
1250  }
void ComputeMsmMgr::subtractVirialContrib ( )
inline

Definition at line 536 of file ComputeMsm.C.

References numVirialContrib.

536  {
538  }
int numVirialContrib
Definition: ComputeMsm.C:524
void ComputeMsmMgr::update ( CkQdMsg *  msg)

Definition at line 5967 of file ComputeMsm.C.

References approx, C1HERMITE, msmBlock, msmC1HermiteBlock, and nlevels.

5968 {
5969 #ifdef DEBUG_MSM_VERBOSE
5970  printf("ComputeMsmMgr: update() PE %d\n", CkMyPe());
5971 #endif
5972  delete msg;
5973 
5974  // have to setup sections AFTER initialization is finished
5975  if (CkMyPe() == 0) {
5976  for (int level = 0; level < nlevels; level++) {
5977  if (approx == C1HERMITE) {
5978  msmC1HermiteBlock[level].setupSections();
5979  }
5980  else {
5981  msmBlock[level].setupSections();
5982  }
5983  }
5984  }
5985 
5986  // XXX how do update for constant pressure simulation?
5987 }
msm::Array< CProxy_MsmBlock > msmBlock
Definition: ComputeMsm.C:464
msm::Array< CProxy_MsmC1HermiteBlock > msmC1HermiteBlock
Definition: ComputeMsm.C:465

Friends And Related Function Documentation

friend struct msm::PatchData
friend

Definition at line 365 of file ComputeMsm.C.

friend class MsmBlock
friend

Definition at line 366 of file ComputeMsm.C.

friend class MsmBlockMap
friend

Definition at line 368 of file ComputeMsm.C.

friend class MsmGridCutoffMap
friend

Definition at line 369 of file ComputeMsm.C.

Member Data Documentation

BigReal ComputeMsmMgr::a

Definition at line 598 of file ComputeMsm.C.

Referenced by initialize().

int ComputeMsmMgr::approx
msm::Array<int> ComputeMsmMgr::blockAssign

Definition at line 484 of file ComputeMsm.C.

Vector ComputeMsmMgr::c

Definition at line 588 of file ComputeMsm.C.

Referenced by doneVirialContrib(), initialize(), and setCompute().

int ComputeMsmMgr::cntVirialContrib

Definition at line 525 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initVirialContrib().

int ComputeMsmMgr::dispersion

Definition at line 607 of file ComputeMsm.C.

Referenced by initialize().

msm::Array<int> ComputeMsmMgr::gcutAssign

Definition at line 485 of file ComputeMsm.C.

Referenced by MsmGridCutoffMap::MsmGridCutoffMap().

BigReal ComputeMsmMgr::gridScalingFactor

Definition at line 597 of file ComputeMsm.C.

Referenced by initialize().

BigReal ComputeMsmMgr::gridspacing

Definition at line 595 of file ComputeMsm.C.

Referenced by initialize(), and setup_hgrid_1d().

msm::Grid<Float> ComputeMsmMgr::gvsum

Definition at line 523 of file ComputeMsm.C.

Referenced by doneVirialContrib(), initialize(), and initVirialContrib().

BigReal ComputeMsmMgr::gzero
Vector ComputeMsmMgr::hu

Definition at line 601 of file ComputeMsm.C.

Referenced by initialize().

Float ComputeMsmMgr::hufx

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Float ComputeMsmMgr::hufy

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Float ComputeMsmMgr::hufz

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Vector ComputeMsmMgr::hv

Definition at line 601 of file ComputeMsm.C.

Referenced by initialize().

Float ComputeMsmMgr::hvfx

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Float ComputeMsmMgr::hvfy

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Float ComputeMsmMgr::hvfz

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Vector ComputeMsmMgr::hw

Definition at line 601 of file ComputeMsm.C.

Referenced by initialize().

Float ComputeMsmMgr::hwfx

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Float ComputeMsmMgr::hwfy

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

Float ComputeMsmMgr::hwfz

Definition at line 602 of file ComputeMsm.C.

Referenced by doneVirialContrib(), and initialize().

BigReal ComputeMsmMgr::hxlen
BigReal ComputeMsmMgr::hxlen_1
BigReal ComputeMsmMgr::hylen
BigReal ComputeMsmMgr::hylen_1
BigReal ComputeMsmMgr::hzlen
BigReal ComputeMsmMgr::hzlen_1
const int ComputeMsmMgr::IndexOffset
static
Initial value:
= {
{-3, -1, 0, 1, 3},
{-5, -3, -1, 0, 1, 3, 5},
{-5, -3, -1, 0, 1, 3, 5},
{-7, -5, -3, -1, 0, 1, 3, 5, 7},
{-7, -5, -3, -1, 0, 1, 3, 5, 7},
{-9, -7, -5, -3, -1, 0, 1, 3, 5, 7, 9},
{-9, -7, -5, -3, -1, 0, 1, 3, 5, 7, 9},
{-1, 0, 1},
}

Definition at line 656 of file ComputeMsm.C.

Referenced by MsmBlockKernel< Vtype, Mtype >::prolongationKernel(), and MsmBlockKernel< Vtype, Mtype >::restrictionKernel().

int ComputeMsmMgr::ispu

Definition at line 590 of file ComputeMsm.C.

int ComputeMsmMgr::ispv

Definition at line 590 of file ComputeMsm.C.

int ComputeMsmMgr::ispw

Definition at line 590 of file ComputeMsm.C.

Lattice ComputeMsmMgr::lattice
msm::Map ComputeMsmMgr::map
msm::Array<CProxy_MsmBlock> ComputeMsmMgr::msmBlock
msm::Array<CProxy_MsmC1HermiteBlock> ComputeMsmMgr::msmC1HermiteBlock
CProxy_MsmC1HermiteGridCutoff ComputeMsmMgr::msmC1HermiteGridCutoff

Definition at line 468 of file ComputeMsm.C.

Referenced by initialize_create(), and recvMsmC1HermiteGridCutoffProxy().

ComputeMsm* ComputeMsmMgr::msmCompute

Definition at line 462 of file ComputeMsm.C.

Referenced by doneCompute(), and setCompute().

CProxy_MsmGridCutoff ComputeMsmMgr::msmGridCutoff

Definition at line 467 of file ComputeMsm.C.

Referenced by initialize_create(), and recvMsmGridCutoffProxy().

CProxy_ComputeMsmMgr ComputeMsmMgr::msmProxy

Definition at line 461 of file ComputeMsm.C.

Referenced by initialize_create().

int ComputeMsmMgr::nhx

Definition at line 603 of file ComputeMsm.C.

Referenced by initialize().

int ComputeMsmMgr::nhy

Definition at line 603 of file ComputeMsm.C.

Referenced by initialize().

int ComputeMsmMgr::nhz

Definition at line 603 of file ComputeMsm.C.

Referenced by initialize().

int ComputeMsmMgr::nlevels
const int ComputeMsmMgr::Nstencil
static
Initial value:
= {
5, 7, 7, 9, 9, 11, 11, 3,
}

Definition at line 652 of file ComputeMsm.C.

Referenced by initialize(), MsmBlockKernel< Vtype, Mtype >::prolongationKernel(), and MsmBlockKernel< Vtype, Mtype >::restrictionKernel().

int ComputeMsmMgr::numGridCutoff

Definition at line 469 of file ComputeMsm.C.

int ComputeMsmMgr::numVirialContrib

Definition at line 524 of file ComputeMsm.C.

Referenced by addVirialContrib(), doneVirialContrib(), and subtractVirialContrib().

int ComputeMsmMgr::omega

Definition at line 623 of file ComputeMsm.C.

Referenced by initialize().

BigReal ComputeMsmMgr::padding

Definition at line 596 of file ComputeMsm.C.

Referenced by initialize().

msm::PatchPtrArray ComputeMsmMgr::patchPtr

Definition at line 476 of file ComputeMsm.C.

Referenced by addPotential(), compute(), and patchPtrArray().

const Float ComputeMsmMgr::PhiStencil
static
Initial value:
= {
{-1.f/16, 9.f/16, 1, 9.f/16, -1.f/16},
{3.f/256, -25.f/256, 75.f/128, 1, 75.f/128, -25.f/256, 3.f/256},
{3.f/256, -25.f/256, 75.f/128, 1, 75.f/128, -25.f/256, 3.f/256},
{ -5.f/2048, 49.f/2048, -245.f/2048, 1225.f/2048, 1, 1225.f/2048,
-245.f/2048, 49.f/2048, -5.f/2048 },
{ -5.f/2048, 49.f/2048, -245.f/2048, 1225.f/2048, 1, 1225.f/2048,
-245.f/2048, 49.f/2048, -5.f/2048 },
{ 35.f/65536, -405.f/65536, 567.f/16384, -2205.f/16384,
19845.f/32768, 1, 19845.f/32768, -2205.f/16384, 567.f/16384,
-405.f/65536, 35.f/65536 },
{ 35.f/65536, -405.f/65536, 567.f/16384, -2205.f/16384,
19845.f/32768, 1, 19845.f/32768, -2205.f/16384, 567.f/16384,
-405.f/65536, 35.f/65536 },
}

Definition at line 660 of file ComputeMsm.C.

Referenced by initialize().

const int ComputeMsmMgr::PolyDegree
static
Initial value:
= {
3, 5, 5, 7, 7, 9, 9, 1,
}

Definition at line 649 of file ComputeMsm.C.

Referenced by msm::PatchData::anterpolation(), initialize(), and msm::PatchData::interpolation().

Vector ComputeMsmMgr::ru

Definition at line 589 of file ComputeMsm.C.

Referenced by initialize().

Vector ComputeMsmMgr::rv

Definition at line 589 of file ComputeMsm.C.

Referenced by gc_c1hermite_elem_accum(), and initialize().

Vector ComputeMsmMgr::rw

Definition at line 589 of file ComputeMsm.C.

Referenced by initialize().

int ComputeMsmMgr::s_edge
Vector ComputeMsmMgr::sglower
BigReal ComputeMsmMgr::shx

Definition at line 613 of file ComputeMsm.C.

Referenced by initialize().

BigReal ComputeMsmMgr::shx_1
BigReal ComputeMsmMgr::shy

Definition at line 613 of file ComputeMsm.C.

Referenced by initialize().

BigReal ComputeMsmMgr::shy_1
BigReal ComputeMsmMgr::shz

Definition at line 613 of file ComputeMsm.C.

Referenced by initialize().

BigReal ComputeMsmMgr::shz_1
ScaledPosition ComputeMsmMgr::smax

Definition at line 594 of file ComputeMsm.C.

Referenced by initialize().

ScaledPosition ComputeMsmMgr::smin

Definition at line 593 of file ComputeMsm.C.

Referenced by initialize().

int ComputeMsmMgr::split

Definition at line 605 of file ComputeMsm.C.

Referenced by initialize().

Float ComputeMsmMgr::srx_x
Float ComputeMsmMgr::srx_y
Float ComputeMsmMgr::srx_z
Float ComputeMsmMgr::sry_x
Float ComputeMsmMgr::sry_y
Float ComputeMsmMgr::sry_z
Float ComputeMsmMgr::srz_x
Float ComputeMsmMgr::srz_y
Float ComputeMsmMgr::srz_z
msm::Grid<Float> ComputeMsmMgr::subgrid
msm::Grid<C1Vector> ComputeMsmMgr::subgrid_c1hermite

Definition at line 481 of file ComputeMsm.C.

Referenced by addPotential().

Vector ComputeMsmMgr::sx_shx

Definition at line 615 of file ComputeMsm.C.

Referenced by initialize().

Vector ComputeMsmMgr::sy_shy

Definition at line 616 of file ComputeMsm.C.

Referenced by initialize().

Vector ComputeMsmMgr::sz_shz

Definition at line 617 of file ComputeMsm.C.

Referenced by initialize().

Vector ComputeMsmMgr::u

Definition at line 588 of file ComputeMsm.C.

Vector ComputeMsmMgr::v

Definition at line 588 of file ComputeMsm.C.

Float ComputeMsmMgr::virial[VMAX]

Definition at line 527 of file ComputeMsm.C.

Referenced by doneVirialContrib(), initialize(), and ComputeMsm::saveResults().

Vector ComputeMsmMgr::w

Definition at line 588 of file ComputeMsm.C.


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