62 |
|
useReactionField = 0; |
63 |
|
useGB = 0; |
64 |
|
useEAM = 0; |
65 |
+ |
|
66 |
+ |
haveCutoffGroups = false; |
67 |
|
|
68 |
|
excludes = Exclude::Instance(); |
69 |
|
|
452 |
|
isError = 0; |
453 |
|
|
454 |
|
getFortranGroupArray(this, mfact, ngroup, groupList, groupStart); |
455 |
< |
|
455 |
> |
//it may not be a good idea to pass the address of first element in vector |
456 |
> |
//since c++ standard does not require vector to be stored continously in meomory |
457 |
> |
//Most of the compilers will organize the memory of vector continously |
458 |
|
setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl, |
459 |
|
&nGlobalExcludes, globalExcludes, molMembershipArray, |
460 |
|
&mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError); |
567 |
|
|
568 |
|
void getFortranGroupArray(SimInfo* info, vector<double>& mfact, int& ngroup, |
569 |
|
vector<int>& groupList, vector<int>& groupStart){ |
570 |
< |
Molecule* mol; |
570 |
> |
Molecule* myMols; |
571 |
|
Atom** myAtoms; |
572 |
|
int numAtom; |
573 |
|
int curIndex; |
574 |
|
double mtot; |
575 |
< |
|
575 |
> |
int numMol; |
576 |
> |
int numCutoffGroups; |
577 |
> |
CutoffGroup* myCutoffGroup; |
578 |
> |
vector<CutoffGroup*>::iterator iterCutoff; |
579 |
> |
Atom* cutoffAtom; |
580 |
> |
vector<Atom*>::iterator iterAtom; |
581 |
> |
int atomIndex; |
582 |
> |
double totalMass; |
583 |
> |
|
584 |
|
mfact.clear(); |
585 |
|
groupList.clear(); |
586 |
|
groupStart.clear(); |
587 |
|
|
588 |
|
//Be careful, fortran array begin at 1 |
589 |
|
curIndex = 1; |
590 |
< |
|
591 |
< |
if(info->useMolecularCutoffs){ |
592 |
< |
|
593 |
< |
#ifdef IS_MPI |
594 |
< |
ngroup = mpiSim->getMyNMol(); |
590 |
> |
|
591 |
> |
myMols = info->molecules; |
592 |
> |
numMol = info->n_mol; |
593 |
> |
for(int i = 0; i < numMol; i++){ |
594 |
> |
numAtom = myMols[i].getNAtoms(); |
595 |
> |
myAtoms = myMols[i].getMyAtoms(); |
596 |
> |
|
597 |
> |
|
598 |
> |
for(int j = 0; j < numAtom; j++){ |
599 |
> |
|
600 |
> |
|
601 |
> |
#ifdef IS_MPI |
602 |
> |
atomIndex = myAtoms[j]->getGlobalIndex(); |
603 |
|
#else |
604 |
< |
ngroup = info->n_mol; |
604 |
> |
atomIndex = myAtoms[j]->getIndex(); |
605 |
|
#endif |
586 |
– |
|
587 |
– |
for(int i = 0; i < ngroup; i ++){ |
588 |
– |
mol = &(info->molecules[i]); |
589 |
– |
numAtom = mol->getNAtoms(); |
590 |
– |
myAtoms = mol->getMyAtoms(); |
591 |
– |
mtot = 0.0; |
606 |
|
|
607 |
< |
for(int j=0; j < numAtom; j++) |
608 |
< |
mtot += myAtoms[j]->getMass(); |
609 |
< |
|
610 |
< |
for(int j=0; j < numAtom; j++){ |
611 |
< |
|
612 |
< |
// We want the local Index: |
613 |
< |
groupList.push_back(myAtoms[j]->getIndex() + 1); |
600 |
< |
mfact.push_back(myAtoms[j]->getMass() / mtot); |
601 |
< |
|
607 |
> |
if(myMols[i].belongToCutoffGroup(atomIndex)) |
608 |
> |
continue; |
609 |
> |
else{ |
610 |
> |
// this is a fraction of the cutoff group's mass, not the mass itself! |
611 |
> |
mfact.push_back(1.0); |
612 |
> |
groupList.push_back(myAtoms[j]->getIndex() + 1); |
613 |
> |
groupStart.push_back(curIndex++); |
614 |
|
} |
615 |
+ |
} |
616 |
|
|
617 |
< |
groupStart.push_back(curIndex); |
618 |
< |
curIndex += numAtom; |
617 |
> |
numCutoffGroups = myMols[i].getNCutoffGroups(); |
618 |
> |
for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff); myCutoffGroup != NULL; |
619 |
> |
myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){ |
620 |
> |
|
621 |
> |
totalMass = myCutoffGroup->getMass(); |
622 |
|
|
623 |
< |
} //end for(int i =0 ; i < ngroup; i++) |
624 |
< |
} |
625 |
< |
else{ |
626 |
< |
//using atomic cutoff, every single atom is just a group |
627 |
< |
|
628 |
< |
#ifdef IS_MPI |
629 |
< |
ngroup = mpiSim->getMyNlocal(); |
630 |
< |
#else |
631 |
< |
ngroup = info->n_atoms; |
632 |
< |
#endif |
633 |
< |
|
634 |
< |
for(int i =0 ; i < ngroup; i++){ |
619 |
< |
groupStart.push_back(curIndex++); |
620 |
< |
groupList.push_back((info->atoms[i])->getIndex() + 1); |
621 |
< |
mfact.push_back(1.0); |
622 |
< |
|
623 |
< |
}//end for(int i =0 ; i < ngroup; i++) |
624 |
< |
|
625 |
< |
}//end if (info->useMolecularCutoffs) |
623 |
> |
for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL; |
624 |
> |
cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){ |
625 |
> |
mfact.push_back(cutoffAtom->getMass()/totalMass); |
626 |
> |
groupList.push_back(cutoffAtom->getIndex() + 1); |
627 |
> |
} |
628 |
> |
|
629 |
> |
groupStart.push_back(curIndex); |
630 |
> |
curIndex += myCutoffGroup->getNumAtom(); |
631 |
> |
|
632 |
> |
}//end for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff)) |
633 |
> |
|
634 |
> |
}//end for(int i = 0; i < numMol; i++) |
635 |
|
|
636 |
+ |
ngroup = groupStart.size(); |
637 |
|
} |