NAMD
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PmePencilZ Class Reference

#include <PmeSolver.h>

Inheritance diagram for PmePencilZ:

Public Member Functions

PmePencilZ_SDAG_CODE PmePencilZ ()
 
 PmePencilZ (CkMigrateMessage *m)
 
virtual ~PmePencilZ ()
 
void skip ()
 

Protected Member Functions

void initBlockSizes ()
 
void submitReductions (unsigned int iGrid)
 

Protected Attributes

PmeGrid pmeGrid
 
bool doEnergy
 
bool doVirial
 
int simulationStep
 
std::array< FFTCompute *, NUM_GRID_MAXfftComputes
 
std::array< PmeTranspose *, NUM_GRID_MAXpmeTransposes
 
std::array< PmeKSpaceCompute *, NUM_GRID_MAXpmeKSpaceComputes
 
std::array< int, NUM_GRID_MAXenergyReady
 
std::vector< int > blockSizes
 
Lattice lattice
 
int numStrayAtoms
 
int imsg
 

Detailed Description

Definition at line 257 of file PmeSolver.h.

Constructor & Destructor Documentation

◆ PmePencilZ() [1/2]

PmePencilZ::PmePencilZ ( )

Definition at line 594 of file PmeSolver.C.

References doEnergy, doVirial, fftComputes, NUM_GRID_MAX, numStrayAtoms, ReductionMgr::Object(), pmeKSpaceComputes, pmeTransposes, PatchData::reduction, REDUCTIONS_BASIC, and ReductionMgr::willSubmit().

594  {
595  __sdag_init();
596  setMigratable(false);
597  for (unsigned int iGrid = 0; iGrid < NUM_GRID_MAX; ++iGrid) {
598  pmeTransposes[iGrid] = NULL;
599  fftComputes[iGrid] = NULL;
600  pmeKSpaceComputes[iGrid] = NULL;
601  }
603 #ifdef NODEGROUP_FORCE_REGISTER
604 // #if false
605  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
606  PatchData *patchData = cpdata.ckLocalBranch();
607  nodeReduction = patchData->reduction;
608 #endif
609  doEnergy = false;
610  doVirial = false;
611  numStrayAtoms = 0;
612 }
std::array< PmeKSpaceCompute *, NUM_GRID_MAX > pmeKSpaceComputes
Definition: PmeSolver.h:270
bool doEnergy
Definition: PmeSolver.h:266
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:366
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:279
NodeReduction * reduction
Definition: PatchData.h:133
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
bool doVirial
Definition: PmeSolver.h:266
int numStrayAtoms
Definition: PmeSolver.h:274
std::array< PmeTranspose *, NUM_GRID_MAX > pmeTransposes
Definition: PmeSolver.h:269
std::array< FFTCompute *, NUM_GRID_MAX > fftComputes
Definition: PmeSolver.h:268

◆ PmePencilZ() [2/2]

PmePencilZ::PmePencilZ ( CkMigrateMessage *  m)

Definition at line 614 of file PmeSolver.C.

References NAMD_bug().

614  {
615  NAMD_bug("PmePencilZ cannot be migrated");
616  //__sdag_init();
617  // setMigratable(false);
618  // fftCompute = NULL;
619  // pmeTranspose = NULL;
620 }
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ ~PmePencilZ()

PmePencilZ::~PmePencilZ ( )
virtual

Definition at line 622 of file PmeSolver.C.

References fftComputes, NUM_GRID_MAX, pmeKSpaceComputes, and pmeTransposes.

622  {
623 // if (fftCompute != NULL) delete fftCompute;
624 // if (pmeTranspose != NULL) delete pmeTranspose;
625 // if (pmeKSpaceCompute != NULL) delete pmeKSpaceCompute;
626 // if (fftCompute2 != NULL) delete fftCompute2;
627 // if (pmeTranspose2 != NULL) delete pmeTranspose2;
628 // if (pmeKSpaceCompute2 != NULL) delete pmeKSpaceCompute2;
629  for (unsigned int iGrid = 0; iGrid < NUM_GRID_MAX; ++iGrid) {
630  if (pmeTransposes[iGrid] != NULL) delete pmeTransposes[iGrid];
631  if (fftComputes[iGrid] != NULL) delete fftComputes[iGrid];
632  if (pmeKSpaceComputes[iGrid] != NULL) delete pmeKSpaceComputes[iGrid];
633  }
634  delete reduction;
635 }
std::array< PmeKSpaceCompute *, NUM_GRID_MAX > pmeKSpaceComputes
Definition: PmeSolver.h:270
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
std::array< PmeTranspose *, NUM_GRID_MAX > pmeTransposes
Definition: PmeSolver.h:269
std::array< FFTCompute *, NUM_GRID_MAX > fftComputes
Definition: PmeSolver.h:268

Member Function Documentation

◆ initBlockSizes()

void PmePencilZ::initBlockSizes ( )
protected

Definition at line 665 of file PmeSolver.C.

References blockSizes, getBlockDim(), Perm_Z_cX_Y, pmeGrid, and PmeGrid::zBlocks.

665  {
666  blockSizes.resize(pmeGrid.zBlocks);
667  for (int z=0;z < pmeGrid.zBlocks;z++) {
668  int i0, i1, j0, j1, k0, k1;
669  getBlockDim(pmeGrid, Perm_Z_cX_Y, z, thisIndex.x, thisIndex.y,
670  i0, i1, j0, j1, k0, k1);
671  int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
672  blockSizes[z] = size;
673  }
674 }
int zBlocks
Definition: PmeBase.h:25
std::vector< int > blockSizes
Definition: PmeSolver.h:272
PmeGrid pmeGrid
Definition: PmeSolver.h:265
static void getBlockDim(const PmeGrid &pmeGrid, const int permutation, const int iblock, const int jblock, const int kblock, int &i0, int &i1, int &j0, int &j1, int &k0, int &k1)
Definition: PmeSolverUtil.h:89

◆ skip()

void PmePencilZ::skip ( void  )

Definition at line 865 of file PmeSolver.C.

References SubmitReduction::submit().

865  {
866  reduction->submit();
867 }
void submit(void)
Definition: ReductionMgr.h:324

◆ submitReductions()

void PmePencilZ::submitReductions ( unsigned int  iGrid)
protected

Definition at line 688 of file PmeSolver.C.

References energyReady, SubmitReduction::item(), NAMD_bug(), NUM_GRID_MAX, numStrayAtoms, Node::Object(), pmeKSpaceComputes, REDUCTION_ELECT_ENERGY_SLOW, REDUCTION_ELECT_ENERGY_SLOW_F, REDUCTION_ELECT_ENERGY_SLOW_TI_1, REDUCTION_ELECT_ENERGY_SLOW_TI_2, REDUCTION_STRAY_CHARGE_ERRORS, Node::simParameters, simParams, simulationStep, and SubmitReduction::submit().

688  {
689  if (pmeKSpaceComputes[iGrid] == NULL)
690  NAMD_bug("PmePencilZ::submitReductions, pmeKSpaceCompute not initialized");
691 // fprintf(stderr, "PmePencilZ::submitReductions\n");
693  double virial[9];
694  double energy = pmeKSpaceComputes[iGrid]->getEnergy();
695  pmeKSpaceComputes[iGrid]->getVirial(virial);
696  if (simParams->alchOn) {
697  double energy_F = energy;
698  double scale1 = 1.0;
699  double scale2 = 1.0;
700  if (simParams->alchFepOn) {
701  switch (iGrid) {
702  case 0: {
703  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
704  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
705  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
706  const BigReal elecLambda2Up = simParams->getElecLambda(alchLambda2);
707  scale1 = elecLambdaUp;
708  scale2 = elecLambda2Up;
709  break;
710  }
711  case 1: {
712  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
713  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
714  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
715  const BigReal elecLambda2Down = simParams->getElecLambda(1 - alchLambda2);
716  scale1 = elecLambdaDown;
717  scale2 = elecLambda2Down;
718  break;
719  }
720  case 2: {
721  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
722  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
723  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
724  const BigReal elecLambda2Up = simParams->getElecLambda(alchLambda2);
725  scale1 = 1.0 - elecLambdaUp;
726  scale2 = 1.0 - elecLambda2Up;
727  break;
728  }
729  case 3: {
730  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
731  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
732  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
733  const BigReal elecLambda2Down = simParams->getElecLambda(1 - alchLambda2);
734  scale1 = 1.0 - elecLambdaDown;
735  scale2 = 1.0 - elecLambda2Down;
736  break;
737  }
738  case 4: {
739  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
740  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
741  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
742  const BigReal elecLambda2Up = simParams->getElecLambda(alchLambda2);
743  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
744  const BigReal elecLambda2Down = simParams->getElecLambda(1 - alchLambda2);
745  scale1 = -1.0 * (elecLambdaUp + elecLambdaDown - 1.0);
746  scale2 = -1.0 * (elecLambda2Up + elecLambda2Down - 1.0);
747  break;
748  }
749  }
750  energy *= scale1;
751  energy_F *= scale2;
752  for (size_t i = 0; i < 9; ++i) {
753  virial[i] *= scale1;
754  }
755 #if NODEGROUP_FORCE_REGISTER
756  nodeReduction->item(REDUCTION_ELECT_ENERGY_SLOW_F) += energy_F;
757 #endif
758  reduction->item(REDUCTION_ELECT_ENERGY_SLOW_F) += energy_F;
759  }
760  if (simParams->alchThermIntOn) {
761  double energy_TI_1 = 0.0;
762  double energy_TI_2 = 0.0;
763  double scale1 = 1.0;
764  switch (iGrid) {
765  case 0: {
766  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
767  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
768  scale1 = elecLambdaUp;
769  energy_TI_1 = energy;
770  break;
771  }
772  case 1: {
773  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
774  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
775  scale1 = elecLambdaDown;
776  energy_TI_2 = energy;
777  break;
778  }
779  case 2: {
780  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
781  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
782  scale1 = 1.0 - elecLambdaUp;
783  energy_TI_1 = -1.0 * energy;
784  break;
785  }
786  case 3: {
787  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
788  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
789  scale1 = 1.0 - elecLambdaDown;
790  energy_TI_2 = -1.0 * energy;
791  break;
792  }
793  case 4: {
794  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
795  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
796  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
797  scale1 = -1.0 * (elecLambdaUp + elecLambdaDown - 1.0);
798  energy_TI_1 = -1.0 * energy;
799  energy_TI_2 = -1.0 * energy;
800  break;
801  }
802  }
803 // fprintf(stdout, "Grid %u : energy_TI_1 = %lf ; energy_TI_2 = %lf\n", iGrid, energy_TI_1, energy_TI_2);
804 #if NODEGROUP_FORCE_REGISTER
805  nodeReduction->item(REDUCTION_ELECT_ENERGY_SLOW_TI_1) += energy_TI_1;
806  nodeReduction->item(REDUCTION_ELECT_ENERGY_SLOW_TI_2) += energy_TI_2;
807 #endif
808  reduction->item(REDUCTION_ELECT_ENERGY_SLOW_TI_1) += energy_TI_1;
809  reduction->item(REDUCTION_ELECT_ENERGY_SLOW_TI_2) += energy_TI_2;
810  }
811  }
812 #ifdef NODEGROUP_FORCE_REGISTER
813 // #if false
814  // XXX Expect a race condition, need atomic access to nodeReduction
815  nodeReduction->item(REDUCTION_ELECT_ENERGY_SLOW) += energy;
816  nodeReduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[0];
817  nodeReduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[1];
818  nodeReduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[2];
819  nodeReduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[3];
820  nodeReduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[4];
821  nodeReduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[5];
822  nodeReduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[6];
823  nodeReduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[7];
824  nodeReduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[8];
825 #endif
826  reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += energy;
827  reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[0];
828  reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[1];
829  reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[2];
830  reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[3];
831  reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[4];
832  reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[5];
833  reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[6];
834  reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[7];
835  reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[8];
837  numStrayAtoms = 0;
838  energyReady[iGrid] = 1;
839  bool ready_to_submit = true;
840  for (size_t i = 0; i < NUM_GRID_MAX; ++i) {
841  if (energyReady[i] == -1) continue;
842  if (energyReady[i] == 0) ready_to_submit = false;
843  }
844  if (ready_to_submit) {
845  reduction->submit();
846  for (size_t i = 0; i < NUM_GRID_MAX; ++i) {
847  if (energyReady[i] == -1) continue;
848  if (energyReady[i] == 1) energyReady[i] = 0;
849  }
850  }
851 }
static Node * Object()
Definition: Node.h:86
std::array< PmeKSpaceCompute *, NUM_GRID_MAX > pmeKSpaceComputes
Definition: PmeSolver.h:270
SimParameters * simParameters
Definition: Node.h:181
BigReal & item(int i)
Definition: ReductionMgr.h:313
int simulationStep
Definition: PmeSolver.h:267
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
void NAMD_bug(const char *err_msg)
Definition: common.C:195
std::array< int, NUM_GRID_MAX > energyReady
Definition: PmeSolver.h:271
int numStrayAtoms
Definition: PmeSolver.h:274
#define simParams
Definition: Output.C:129
void submit(void)
Definition: ReductionMgr.h:324
double BigReal
Definition: common.h:123

Member Data Documentation

◆ blockSizes

std::vector<int> PmePencilZ::blockSizes
protected

Definition at line 272 of file PmeSolver.h.

Referenced by initBlockSizes().

◆ doEnergy

bool PmePencilZ::doEnergy
protected

Definition at line 266 of file PmeSolver.h.

Referenced by PmePencilZ().

◆ doVirial

bool PmePencilZ::doVirial
protected

Definition at line 266 of file PmeSolver.h.

Referenced by PmePencilZ().

◆ energyReady

std::array<int, NUM_GRID_MAX> PmePencilZ::energyReady
protected

Definition at line 271 of file PmeSolver.h.

Referenced by submitReductions().

◆ fftComputes

std::array<FFTCompute*, NUM_GRID_MAX> PmePencilZ::fftComputes
protected

Definition at line 268 of file PmeSolver.h.

Referenced by PmePencilZ(), and ~PmePencilZ().

◆ imsg

int PmePencilZ::imsg
protected

Definition at line 277 of file PmeSolver.h.

◆ lattice

Lattice PmePencilZ::lattice
protected

Definition at line 273 of file PmeSolver.h.

◆ numStrayAtoms

int PmePencilZ::numStrayAtoms
protected

Definition at line 274 of file PmeSolver.h.

Referenced by PmePencilZ(), and submitReductions().

◆ pmeGrid

PmeGrid PmePencilZ::pmeGrid
protected

Definition at line 265 of file PmeSolver.h.

Referenced by initBlockSizes().

◆ pmeKSpaceComputes

std::array<PmeKSpaceCompute*, NUM_GRID_MAX> PmePencilZ::pmeKSpaceComputes
protected

Definition at line 270 of file PmeSolver.h.

Referenced by PmePencilZ(), submitReductions(), and ~PmePencilZ().

◆ pmeTransposes

std::array<PmeTranspose*, NUM_GRID_MAX> PmePencilZ::pmeTransposes
protected

Definition at line 269 of file PmeSolver.h.

Referenced by PmePencilZ(), and ~PmePencilZ().

◆ simulationStep

int PmePencilZ::simulationStep
protected

Definition at line 267 of file PmeSolver.h.

Referenced by submitReductions().


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