| 15 |
|
} |
| 16 |
|
|
| 17 |
|
void IgnoreVisitor::visit(RigidBody* rb){ |
| 18 |
< |
if(isIgnoreType(rb->getType())) |
| 18 |
> |
vector<Atom*> myAtoms; |
| 19 |
> |
vector<Atom*>::iterator atomIter; |
| 20 |
> |
AtomInfo* atomInfo; |
| 21 |
> |
|
| 22 |
> |
if(isIgnoreType(rb->getType())){ |
| 23 |
> |
|
| 24 |
|
internalVisit(rb); |
| 25 |
+ |
|
| 26 |
+ |
myAtoms = rb->getAtoms(); |
| 27 |
+ |
|
| 28 |
+ |
for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter) |
| 29 |
+ |
internalVisit(*atomIter); |
| 30 |
+ |
|
| 31 |
+ |
} |
| 32 |
+ |
|
| 33 |
|
} |
| 34 |
|
|
| 35 |
|
bool IgnoreVisitor::isIgnoreType(const string& name){ |
| 51 |
|
|
| 52 |
|
const string IgnoreVisitor::toString(){ |
| 53 |
|
char buffer[65535]; |
| 54 |
+ |
string result; |
| 55 |
|
set<string>::iterator i; |
| 56 |
|
|
| 57 |
< |
sprintf(buffer,"------------------------------------------------------------------\n"); |
| 58 |
< |
sprintf(buffer,"Visitor name: %s", visitorName.c_str()); |
| 57 |
> |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 58 |
> |
result += buffer; |
| 59 |
|
|
| 60 |
+ |
sprintf(buffer ,"Visitor name: %s", visitorName.c_str()); |
| 61 |
+ |
result += buffer; |
| 62 |
+ |
|
| 63 |
+ |
sprintf(buffer ,"Visitor Description: ignore stuntdoubles\n"); |
| 64 |
+ |
result += buffer; |
| 65 |
+ |
|
| 66 |
|
//print the ignore type list |
| 67 |
< |
sprintf(buffer, "Ignore type list contains below types:\n"); |
| 68 |
< |
for(i = itList.begin(); i != itList.end(); ++i) |
| 49 |
< |
sprintf(buffer,"%s,\t", i->c_str()); |
| 50 |
< |
sprintf(buffer,"\n"); |
| 67 |
> |
sprintf(buffer , "Ignore type list contains below types:\n"); |
| 68 |
> |
result += buffer; |
| 69 |
|
|
| 70 |
< |
sprintf(buffer,"------------------------------------------------------------------\n"); |
| 70 |
> |
for(i = itList.begin(); i != itList.end(); ++i){ |
| 71 |
> |
sprintf(buffer ,"%s\t", i->c_str()); |
| 72 |
> |
result += buffer; |
| 73 |
|
|
| 74 |
< |
return buffer; |
| 74 |
> |
} |
| 75 |
> |
sprintf(buffer ,"\n"); |
| 76 |
> |
result += buffer; |
| 77 |
> |
|
| 78 |
> |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 79 |
> |
result += buffer; |
| 80 |
> |
|
| 81 |
> |
return result; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
//----------------------------------------------------------------------------// |
| 98 |
|
GenericData* data; |
| 99 |
|
AtomData* atomData; |
| 100 |
|
AtomInfo* atomInfo; |
| 74 |
– |
double pos[3]; |
| 101 |
|
vector<AtomInfo*>::iterator i; |
| 102 |
|
|
| 103 |
|
data = sd->getProperty("ATOMDATA"); |
| 104 |
< |
if(data != NULL) |
| 104 |
> |
if(data != NULL){ |
| 105 |
|
atomData = dynamic_cast<AtomData*>(data); |
| 106 |
|
if(atomData == NULL) |
| 107 |
|
return; |
| 108 |
+ |
} |
| 109 |
|
else |
| 110 |
|
return; |
| 111 |
|
|
| 112 |
< |
for(atomInfo = atomData->beginAtomInfo(i); atomInfo != NULL; atomData->nextAtomInfo(i)) |
| 112 |
> |
for(atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i)) |
| 113 |
|
info->wrapVector(atomInfo->pos); |
| 114 |
+ |
|
| 115 |
|
|
| 116 |
+ |
} |
| 117 |
+ |
|
| 118 |
+ |
const string WrappingVisitor::toString(){ |
| 119 |
+ |
char buffer[65535]; |
| 120 |
+ |
string result; |
| 121 |
+ |
|
| 122 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 123 |
+ |
result += buffer; |
| 124 |
+ |
|
| 125 |
+ |
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
| 126 |
+ |
result += buffer; |
| 127 |
+ |
|
| 128 |
+ |
sprintf(buffer ,"Visitor Description: wrapping atoms back to periodic box\n"); |
| 129 |
+ |
result += buffer; |
| 130 |
+ |
|
| 131 |
+ |
sprintf(buffer,"------------------------------------------------------------------\n"); |
| 132 |
+ |
result += buffer; |
| 133 |
+ |
|
| 134 |
+ |
return result; |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
//----------------------------------------------------------------------------// |
| 138 |
|
|
| 139 |
< |
ReplicateVisitor::ReplicateVisitor(SimInfo* info, IntVec3 replicateOpt) : BaseVisitor(){ |
| 139 |
> |
ReplicateVisitor::ReplicateVisitor(SimInfo* info, IntVec3 opt) : BaseVisitor(){ |
| 140 |
|
this->info = info; |
| 141 |
|
visitorName = "ReplicateVisitor"; |
| 142 |
< |
this->replicateOpt = replicateOpt; |
| 142 |
> |
this->replicateOpt = opt; |
| 143 |
|
//generate the replicate directions |
| 144 |
< |
for(int i = 0; i < replicateOpt[0]; i ++) |
| 145 |
< |
for(int j = 0; i < replicateOpt[1]; j ++) |
| 146 |
< |
for(int k = 0; i < replicateOpt[2]; k ++) |
| 144 |
> |
for(int i = 0; i <= replicateOpt[0]; i ++) |
| 145 |
> |
for(int j = 0; j <= replicateOpt[1]; j ++) |
| 146 |
> |
for(int k = 0; k <= replicateOpt[2]; k ++) |
| 147 |
|
//skip original frame |
| 148 |
|
if(i == 0 && j ==0 && k ==0) |
| 149 |
|
continue; |
| 172 |
|
|
| 173 |
|
//if there is not atom data, just skip it |
| 174 |
|
data = sd->getProperty("ATOMDATA"); |
| 175 |
< |
if(data != NULL) |
| 175 |
> |
if(data != NULL){ |
| 176 |
|
atomData = dynamic_cast<AtomData*>(data); |
| 177 |
|
if(atomData == NULL) |
| 178 |
|
return; |
| 179 |
+ |
} |
| 180 |
|
else |
| 181 |
|
return; |
| 182 |
|
|
| 209 |
|
|
| 210 |
|
const string ReplicateVisitor::toString(){ |
| 211 |
|
char buffer[65535]; |
| 212 |
+ |
string result; |
| 213 |
|
set<string>::iterator i; |
| 214 |
|
|
| 215 |
< |
sprintf(buffer,"------------------------------------------------------------------\n"); |
| 216 |
< |
sprintf(buffer,"Visitor name: %s", visitorName.c_str()); |
| 215 |
> |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 216 |
> |
result += buffer; |
| 217 |
|
|
| 218 |
+ |
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
| 219 |
+ |
result += buffer; |
| 220 |
+ |
|
| 221 |
+ |
sprintf(buffer ,"Visitor Description: replicate the atoms in different direction\n"); |
| 222 |
+ |
result += buffer; |
| 223 |
+ |
|
| 224 |
|
//print the replicate direction |
| 225 |
< |
sprintf(buffer, "repeatX = %d:\n", replicateOpt[0]); |
| 226 |
< |
sprintf(buffer, "repeatY = %d:\n", replicateOpt[1]); |
| 172 |
< |
sprintf(buffer, "repeatZ = %d:\n", replicateOpt[2]); |
| 225 |
> |
sprintf(buffer , "repeatX = %d:\n", replicateOpt[0]); |
| 226 |
> |
result += buffer; |
| 227 |
|
|
| 228 |
+ |
sprintf(buffer , "repeatY = %d:\n", replicateOpt[1]); |
| 229 |
+ |
result += buffer; |
| 230 |
|
|
| 231 |
+ |
sprintf(buffer , "repeatZ = %d:\n", replicateOpt[2]); |
| 232 |
+ |
result += buffer; |
| 233 |
+ |
|
| 234 |
+ |
|
| 235 |
|
sprintf(buffer,"------------------------------------------------------------------\n"); |
| 236 |
+ |
result += buffer; |
| 237 |
|
|
| 238 |
< |
return buffer; |
| 238 |
> |
return result; |
| 239 |
|
} |
| 240 |
|
|
| 241 |
|
//----------------------------------------------------------------------------// |
| 271 |
|
|
| 272 |
|
//if there is not atom data, just skip it |
| 273 |
|
data = sd->getProperty("ATOMDATA"); |
| 274 |
< |
if(data != NULL) |
| 274 |
> |
if(data != NULL){ |
| 275 |
|
atomData = dynamic_cast<AtomData*>(data); |
| 276 |
|
if(atomData == NULL) |
| 277 |
|
return; |
| 278 |
+ |
} |
| 279 |
|
else |
| 280 |
|
return; |
| 281 |
|
|
| 283 |
|
|
| 284 |
|
if(printDipole) |
| 285 |
|
sprintf(buffer, "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f", |
| 286 |
< |
atomInfo->AtomType, |
| 286 |
> |
atomInfo->AtomType.c_str(), |
| 287 |
|
atomInfo->pos[0], |
| 288 |
|
atomInfo->pos[1], |
| 289 |
|
atomInfo->pos[2], |
| 292 |
|
atomInfo->dipole[2]); |
| 293 |
|
else |
| 294 |
|
sprintf(buffer, "%s%15.8f%15.8f%15.8f", |
| 295 |
< |
atomInfo->AtomType, |
| 295 |
> |
atomInfo->AtomType.c_str(), |
| 296 |
|
atomInfo->pos[0], |
| 297 |
|
atomInfo->pos[1], |
| 298 |
< |
atomInfo->pos[2]); |
| 298 |
> |
atomInfo->pos[2]); |
| 299 |
> |
|
| 300 |
> |
frame.push_back(buffer); |
| 301 |
> |
|
| 302 |
|
} |
| 303 |
|
|
| 239 |
– |
frame.push_back(buffer); |
| 240 |
– |
|
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
bool XYZVisitor::isIgnore(StuntDouble* sd){ |
| 333 |
|
|
| 334 |
|
for(i = frame.begin(); i != frame.end(); ++i) |
| 335 |
|
outStream << *i << endl; |
| 336 |
+ |
} |
| 337 |
+ |
|
| 338 |
+ |
const string XYZVisitor::toString(){ |
| 339 |
+ |
char buffer[65535]; |
| 340 |
+ |
string result; |
| 341 |
+ |
|
| 342 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 343 |
+ |
result += buffer; |
| 344 |
+ |
|
| 345 |
+ |
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
| 346 |
+ |
result += buffer; |
| 347 |
+ |
|
| 348 |
+ |
sprintf(buffer ,"Visitor Description: assemble the atom data and output xyz file\n"); |
| 349 |
+ |
result += buffer; |
| 350 |
+ |
|
| 351 |
+ |
sprintf(buffer,"------------------------------------------------------------------\n"); |
| 352 |
+ |
result += buffer; |
| 353 |
+ |
|
| 354 |
+ |
return result; |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
//----------------------------------------------------------------------------// |
| 358 |
|
|
| 359 |
< |
void PrepareVisitor::internalVisit(StuntDouble * sd){ |
| 359 |
> |
void PrepareVisitor::internalVisit(Atom * atom){ |
| 360 |
|
GenericData* data; |
| 361 |
|
AtomData* atomData; |
| 362 |
|
|
| 363 |
|
//if visited property is existed, remove it |
| 364 |
< |
data = sd->getProperty("VISITED"); |
| 364 |
> |
data = atom->getProperty("VISITED"); |
| 365 |
|
if(data != NULL){ |
| 366 |
< |
sd->removeProperty("VISITED"); |
| 366 |
> |
atom->removeProperty("VISITED"); |
| 367 |
|
} |
| 368 |
|
|
| 369 |
|
//remove atomdata |
| 370 |
< |
data = sd->getProperty("ATOMDATA"); |
| 371 |
< |
if(data != NULL) |
| 370 |
> |
data = atom->getProperty("ATOMDATA"); |
| 371 |
> |
if(data != NULL){ |
| 372 |
|
atomData = dynamic_cast<AtomData*>(data); |
| 373 |
|
if(atomData != NULL) |
| 374 |
< |
sd->removeProperty("ATOMDATA"); |
| 374 |
> |
atom->removeProperty("ATOMDATA"); |
| 375 |
> |
} |
| 376 |
> |
|
| 377 |
|
} |
| 378 |
|
|
| 379 |
+ |
void PrepareVisitor::internalVisit(RigidBody * rb){ |
| 380 |
+ |
GenericData* data; |
| 381 |
+ |
AtomData* atomData; |
| 382 |
+ |
vector<Atom*> myAtoms; |
| 383 |
+ |
vector<Atom*>::iterator atomIter; |
| 384 |
+ |
|
| 385 |
+ |
//if visited property is existed, remove it |
| 386 |
+ |
data = rb->getProperty("VISITED"); |
| 387 |
+ |
if(data != NULL){ |
| 388 |
+ |
rb->removeProperty("VISITED"); |
| 389 |
+ |
} |
| 390 |
+ |
|
| 391 |
+ |
//remove atomdata |
| 392 |
+ |
data = rb->getProperty("ATOMDATA"); |
| 393 |
+ |
if(data != NULL){ |
| 394 |
+ |
atomData = dynamic_cast<AtomData*>(data); |
| 395 |
+ |
if(atomData != NULL) |
| 396 |
+ |
rb->removeProperty("ATOMDATA"); |
| 397 |
+ |
} |
| 398 |
+ |
|
| 399 |
+ |
myAtoms = rb->getAtoms(); |
| 400 |
+ |
|
| 401 |
+ |
for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter) |
| 402 |
+ |
internalVisit (*atomIter); |
| 403 |
+ |
} |
| 404 |
+ |
|
| 405 |
+ |
const string PrepareVisitor::toString(){ |
| 406 |
+ |
char buffer[65535]; |
| 407 |
+ |
string result; |
| 408 |
+ |
|
| 409 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 410 |
+ |
result += buffer; |
| 411 |
+ |
|
| 412 |
+ |
sprintf(buffer ,"Visitor name: %s", visitorName.c_str()); |
| 413 |
+ |
result += buffer; |
| 414 |
+ |
|
| 415 |
+ |
sprintf(buffer ,"Visitor Description: prepare for operation of other vistors\n"); |
| 416 |
+ |
result += buffer; |
| 417 |
+ |
|
| 418 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 419 |
+ |
result += buffer; |
| 420 |
+ |
|
| 421 |
+ |
return result; |
| 422 |
+ |
} |
| 423 |
+ |
|
| 424 |
+ |
//----------------------------------------------------------------------------// |
| 425 |
+ |
|
| 426 |
+ |
WaterTypeVisitor:: WaterTypeVisitor(){ |
| 427 |
+ |
visitorName = "WaterTypeVisitor"; |
| 428 |
+ |
waterTypeList.insert("TIP3P_RB_0"); |
| 429 |
+ |
waterTypeList.insert("TIP4P_RB_0"); |
| 430 |
+ |
waterTypeList.insert("TIP5P_RB_0"); |
| 431 |
+ |
waterTypeList.insert("SPCE_RB_0"); |
| 432 |
+ |
} |
| 433 |
+ |
|
| 434 |
+ |
|
| 435 |
+ |
void WaterTypeVisitor:: visit(RigidBody* rb){ |
| 436 |
+ |
string rbName; |
| 437 |
+ |
vector<Atom*> myAtoms; |
| 438 |
+ |
vector<Atom*>::iterator atomIter; |
| 439 |
+ |
GenericData* data; |
| 440 |
+ |
AtomData* atomData; |
| 441 |
+ |
AtomInfo* atomInfo; |
| 442 |
+ |
vector<AtomInfo*>::iterator i; |
| 443 |
+ |
|
| 444 |
+ |
rbName = rb->getType(); |
| 445 |
+ |
|
| 446 |
+ |
if(waterTypeList.find(rbName) != waterTypeList.end()){ |
| 447 |
+ |
|
| 448 |
+ |
myAtoms = rb->getAtoms(); |
| 449 |
+ |
for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter){ |
| 450 |
+ |
|
| 451 |
+ |
data = (*atomIter)->getProperty("ATOMDATA"); |
| 452 |
+ |
if(data != NULL){ |
| 453 |
+ |
atomData = dynamic_cast<AtomData*>(data); |
| 454 |
+ |
if(atomData == NULL) |
| 455 |
+ |
continue; |
| 456 |
+ |
} |
| 457 |
+ |
else |
| 458 |
+ |
continue; |
| 459 |
+ |
|
| 460 |
+ |
for(atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i)){ |
| 461 |
+ |
replaceType(atomInfo->AtomType); |
| 462 |
+ |
}//end for(atomInfo) |
| 463 |
+ |
|
| 464 |
+ |
}//end for(atomIter) |
| 465 |
+ |
|
| 466 |
+ |
}//end if (waterTypeList.find(rbName) != waterTypeList.end()) |
| 467 |
+ |
|
| 468 |
+ |
} |
| 469 |
+ |
|
| 470 |
+ |
void WaterTypeVisitor:: replaceType(string& atomType){ |
| 471 |
+ |
atomType = atomType.substr(0, atomType.find('_')); |
| 472 |
+ |
} |
| 473 |
+ |
|
| 474 |
+ |
const string WaterTypeVisitor:: toString(){ |
| 475 |
+ |
char buffer[65535]; |
| 476 |
+ |
string result; |
| 477 |
+ |
|
| 478 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 479 |
+ |
result += buffer; |
| 480 |
+ |
|
| 481 |
+ |
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
| 482 |
+ |
result += buffer; |
| 483 |
+ |
|
| 484 |
+ |
sprintf(buffer ,"Visitor Description: Replace the atom type in water model\n"); |
| 485 |
+ |
result += buffer; |
| 486 |
+ |
|
| 487 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 488 |
+ |
result += buffer; |
| 489 |
+ |
|
| 490 |
+ |
return result; |
| 491 |
+ |
} |
| 492 |
+ |
|