7 #ifndef COMPUTESELFTUPLES_H     8 #define COMPUTESELFTUPLES_H    14 template <
class T, 
class S, 
class P> 
class SelfTuples : 
public HomeTuples<T, S, P> {
    17     SelfTuples(
int type=-1) : HomeTuples<T,S,P>(type) {}
    22       const std::vector<int>& pids = std::vector<int>()) {
    23       if (isBasePatch != NULL) {
    24         iout << 
iWARN << 
"Non-NULL isBasePatch detected in SelfTuples::loadTuples()" << 
endi;
    29       #ifdef MEM_OPT_VERSION    30       typename ElemTraits<T>::signature *allSigs;
    41       #ifdef MEM_OPT_VERSION    42       allSigs = ElemTraits<T>::get_sig_pointer(node->
molecule);
    44       T::getMoleculePointers(node->
molecule,
    45         &numTuples, &tuplesByAtom, &tupleStructs);
    48       T::getParameterPointers(node->
parameters, &tupleValues);
    50       this->tupleList.clear();
    59       Real invLesFactor = lesOn ?
    76       if (pids.size() == 0) ai = ai.begin();
    78       int numPid = (pids.size() == 0) ? tuplePatchList.
size() : pids.size();
    80       for (
int ipid=0;ipid < numPid;ipid++) {
    85         if (pids.size() == 0) {
    98         for (
int j=0; j < numAtoms; j++)
   100 #ifdef MEM_OPT_VERSION   101           typename ElemTraits<T>::signature *thisAtomSig =
   102                    &allSigs[ElemTraits<T>::get_sig_id(atomExt[j])];
   104           T::getTupleInfo(thisAtomSig, &numTuples, &allTuples);
   105           for(
int k=0; k<numTuples; k++) {
   106             T t(atomExt[j].
id, &allTuples[k], tupleValues);
   109           int32 *curTuple = tuplesByAtom[atomExt[j].
id];
   110           for( ; *curTuple != -1; ++curTuple) {
   111             T t(&tupleStructs[*curTuple],tupleValues);
   114             aid[0] = atomMap->
localID(t.atomID[0]);
   115             int homepatch = aid[0].
pid;
   122             int fep_tuple_type = 0;
   123             for (i=1; i < T::size; i++) {
   124               aid[i] = atomMap->
localID(t.atomID[i]);
   125               samepatch = samepatch && ( homepatch == aid[i].
pid );
   134             if (sdScaling && is_fep_sd) {   
   135               for (i=0; i < num_unpert_bonds; i++) {
   137                     && t.atomID[0]==unpert_bonds[i].atom1
   138                     && t.atomID[1]==unpert_bonds[i].atom2) is_fep_sd = 0;
   140               for (i=0; i < num_unpert_angles; i++) {
   142                     && t.atomID[0]==unpert_angles[i].atom1
   143                     && t.atomID[1]==unpert_angles[i].atom2
   144                     && t.atomID[2]==unpert_angles[i].atom3) is_fep_sd = 0;
   146               for (i=0; i < num_unpert_dihedrals; i++) {
   148                     && t.atomID[0]==unpert_dihedrals[i].atom1
   149                     && t.atomID[1]==unpert_dihedrals[i].atom2
   150                     && t.atomID[2]==unpert_dihedrals[i].atom3
   151                     && t.atomID[3]==unpert_dihedrals[i].atom4) is_fep_sd = 0;
   154             if (T::size < 4 && !soluteScalingAll) has_ss = 
false;
   156               t.scale = (!has_les && !has_ss) ? 1.0 : ( has_les ? invLesFactor : soluteScalingFactor );
   157               if (is_fep_ss) t.scale = (fep_tuple_type == 4) ? OneMinusLambda : Lambda;
   158               if (is_fep_sd && sdScaling) t.scale = (fep_tuple_type == 4 || fep_tuple_type == 2) ? OneMinusLambda : Lambda;
   161               for(i=0; i < T::size; i++) {
   163                 t.localIndex[i] = aid[i].
index;
   165 #ifdef MEM_OPT_VERSION   170                 for(i=0; i<T::size; i++){
   174                 if(!allfixed) this->tupleList.push_back(t);
   176                 this->tupleList.push_back(t);
   180               this->tupleList.push_back(t);
   194 #ifndef USE_HOMETUPLES   197     virtual void loadTuples(
void) {
   200       #ifdef MEM_OPT_VERSION   201       typename ElemTraits<T>::signature *allSigs;
   203       int32 **tuplesByAtom;
   207       const P *tupleValues;
   210       #ifdef MEM_OPT_VERSION   211       allSigs = ElemTraits<T>::get_sig_pointer(node->
molecule);
   213       T::getMoleculePointers(node->
molecule,
   214                     &numTuples, &tuplesByAtom, &tupleStructs);
   217       T::getParameterPointers(node->
parameters, &tupleValues);
   219       this->tupleList.resize(0);
   228       Real invLesFactor = lesOn ?
   246       for ( ai = ai.
begin(); ai != ai.
end(); ai++ )
   255         for (
int j=0; j < numAtoms; j++)
   257            #ifdef MEM_OPT_VERSION   258            typename ElemTraits<T>::signature *thisAtomSig =
   259                    &allSigs[ElemTraits<T>::get_sig_id(atomExt[j])];
   261            T::getTupleInfo(thisAtomSig, &numTuples, &allTuples);
   262            for(
int k=0; k<numTuples; k++) {
   263                T t(atomExt[j].
id, &allTuples[k], tupleValues);
   266            int32 *curTuple = tuplesByAtom[atomExt[j].
id];    
   268            for( ; *curTuple != -1; ++curTuple) {
   269              T t(&tupleStructs[*curTuple],tupleValues);
   272              aid[0] = this->atomMap->
localID(t.atomID[0]);
   273              int homepatch = aid[0].
pid;
   280              int fep_tuple_type = 0;
   281              for (i=1; i < T::size; i++) {
   282                  aid[i] = this->atomMap->
localID(t.atomID[i]);
   283                  samepatch = samepatch && ( homepatch == aid[i].
pid );
   292              if (T::size < 4 && !soluteScalingAll) has_ss = 
false;
   293              if (sdScaling && is_fep_sd) {
   294                for (i=0; i < num_unpert_bonds; i++) {
   296                      && t.atomID[0]==unpert_bonds[i].
atom1   297                      && t.atomID[1]==unpert_bonds[i].
atom2) is_fep_sd = 0;
   299                for (i=0; i < num_unpert_angles; i++) {
   301                      && t.atomID[0]==unpert_angles[i].
atom1   302                      && t.atomID[1]==unpert_angles[i].
atom2   303                      && t.atomID[2]==unpert_angles[i].
atom3) is_fep_sd = 0;
   305                for (i=0; i < num_unpert_dihedrals; i++) {
   307                      && t.atomID[0]==unpert_dihedrals[i].
atom1   308                      && t.atomID[1]==unpert_dihedrals[i].
atom2   309                      && t.atomID[2]==unpert_dihedrals[i].
atom3   310                      && t.atomID[3]==unpert_dihedrals[i].
atom4) is_fep_sd = 0;
   314                t.scale = (!has_les && !has_ss) ? 1.0 : ( has_les ? invLesFactor : soluteScalingFactor );
   315                if (is_fep_ss) t.scale = (fep_tuple_type == 4) ? OneMinusLambda : Lambda;
   316                if (is_fep_sd && sdScaling) t.scale = (fep_tuple_type == 4 || fep_tuple_type == 2) ? OneMinusLambda : Lambda;
   319                for(i=0; i < T::size; i++) {
   321                    t.localIndex[i] = aid[i].
index;
   323              #ifdef MEM_OPT_VERSION   328                  for(i=0; i<T::size; i++){
   332                  if(!allfixed) this->tupleList.add(t);
   334                  this->tupleList.add(t);
   337                this->tupleList.add(t);
   356       for (ap = ap.
begin(); ap != ap.
end(); ap++) {
   369 #ifdef USE_HOMETUPLES   370       this->tuples = 
new SelfTuples<T, S, P>();
   373       this->tuplePatchList.
clear();
   377       this->setNumPatches(this->tuplePatchList.
size());
   379       this->doLoadTuples = 
true;
   381       int myNode = CkMyPe();
   395 #ifdef TRACE_COMPUTE_OBJECTS   396     double traceObjStartTime = CmiWallTimer();
   401 #ifdef TRACE_COMPUTE_OBJECTS 
Elem * find(const Elem &elem)
 
#define COMPUTE_PROXY_PRIORITY
 
int num_alch_unpert_Dihedrals
 
void unregisterAvgPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
 
#define TRACE_COMPOBJ_IDOFFSET
 
static void partition(int *order, const FullAtom *atoms, int begin, int end)
 
static PatchMap * Object()
 
Angle * alch_unpert_angles
 
SimParameters * simParameters
 
int num_alch_unpert_Bonds
 
void unregisterForceDeposit(Compute *cid, Box< Patch, Results > **const box)
 
std::ostream & endi(std::ostream &s)
 
std::ostream & iWARN(std::ostream &s)
 
int num_alch_unpert_Angles
 
unsigned char get_ss_type(int anum) const
 
int add(const Elem &elem)
 
Dihedral * alch_unpert_dihedrals
 
virtual ~ComputeSelfTuples()
 
UniqueSetIter< T > begin(void) const
 
#define COMPUTE_HOME_PRIORITY
 
BigReal soluteScalingFactor
 
ComputeSelfTuples(ComputeID c, PatchID p)
 
LocalID localID(AtomID id)
 
Box< Patch, CompAtom > * positionBox
 
UniqueSetIter< T > end(void) const
 
virtual void doWork(void)
 
unsigned char get_fep_type(int anum) const
 
void unregisterPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
 
Box< Patch, CompAtom > * avgPositionBox
 
virtual void initialize(void)
 
Box< Patch, Results > * forceBox
 
#define PATCH_PRIORITY(PID)