ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/visitors/AtomVisitor.cpp
(Generate patch)

Comparing trunk/src/visitors/AtomVisitor.cpp (file contents):
Revision 880 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 881 by xsun, Thu Feb 2 15:49:42 2006 UTC

# Line 338 | Line 338 | namespace oopse {
338  
339      return result;
340    }
341 +
342 +  bool GBLipidAtomVisitor::isGBLipidAtom(const std::string& atomType){
343 +    std::set<std::string>::iterator strIter;
344 +    strIter = GBLipidAtomType.find(atomType);
345 +
346 +    return strIter != GBLipidAtomType.end() ? true : false;
347 +  }
348 +
349 +  void GBLipidAtomVisitor::visit(DirectionalAtom* datom){
350 +    std::vector<AtomInfo*> atoms;
351 +    //we need to convert linear into 4 different atoms
352 +    Vector3d c1(0.0, 0.0, -6.25);
353 +    Vector3d c2(0.0, 0.0, -2.1);
354 +    Vector3d c3(0.0, 0.0,  2.1);
355 +    Vector3d c4(0.0, 0.0,  6.25);
356 +    RotMat3x3d rotMatrix;
357 +    RotMat3x3d rotTrans;
358 +    AtomInfo* atomInfo;
359 +    Vector3d pos;
360 +    Vector3d newVec;
361 +    Quat4d q;
362 +    AtomData* atomData;
363 +    GenericData* data;
364 +    bool haveAtomData;
365 +
366 +    //if atom is not GBlipid atom, just skip it
367 +    if(!isGBLipidAtom(datom->getType()))
368 +      return;
369 +
370 +    data = datom->getPropertyByName("ATOMDATA");
371 +    if(data != NULL){
372 +      atomData = dynamic_cast<AtomData*>(data);  
373 +      if(atomData == NULL){
374 +        std::cerr << "can not get Atom Data from " << datom->getType() << std::endl;
375 +        atomData = new AtomData;
376 +        haveAtomData = false;      
377 +      } else {
378 +        haveAtomData = true;
379 +      }
380 +    } else {
381 +      atomData = new AtomData;
382 +      haveAtomData = false;
383 +    }
384 +  
385 +  
386 +    pos = datom->getPos();
387 +    q = datom->getQ();
388 +    rotMatrix = datom->getA();
389  
390 +    // We need A^T to convert from body-fixed to space-fixed:  
391 +    rotTrans = rotMatrix.transpose();
392 +
393 +    newVec = rotTrans * c1;
394 +    atomInfo = new AtomInfo;
395 +    atomInfo->atomTypeName = "K";
396 +    atomInfo->pos[0] = pos[0] + newVec[0];
397 +    atomInfo->pos[1] = pos[1] + newVec[1];
398 +    atomInfo->pos[2] = pos[2] + newVec[2];
399 +    atomInfo->dipole[0] = 0.0;
400 +    atomInfo->dipole[1] = 0.0;
401 +    atomInfo->dipole[2] = 0.0;
402 +    atomData->addAtomInfo(atomInfo);
403 +
404 +    newVec = rotTrans * c2;
405 +    atomInfo = new AtomInfo;
406 +    atomInfo->atomTypeName = "K";
407 +    atomInfo->pos[0] = pos[0] + newVec[0];
408 +    atomInfo->pos[1] = pos[1] + newVec[1];
409 +    atomInfo->pos[2] = pos[2] + newVec[2];
410 +    atomInfo->dipole[0] = 0.0;
411 +    atomInfo->dipole[1] = 0.0;
412 +    atomInfo->dipole[2] = 0.0;
413 +    atomData->addAtomInfo(atomInfo);
414 +
415 +    newVec = rotTrans * c3;
416 +    atomInfo = new AtomInfo;
417 +    atomInfo->atomTypeName = "K";
418 +    atomInfo->pos[0] = pos[0] + newVec[0];
419 +    atomInfo->pos[1] = pos[1] + newVec[1];
420 +    atomInfo->pos[2] = pos[2] + newVec[2];
421 +    atomInfo->dipole[0] = 0.0;
422 +    atomInfo->dipole[1] = 0.0;
423 +    atomInfo->dipole[2] = 0.0;
424 +    atomData->addAtomInfo(atomInfo);
425 +
426 +    newVec = rotTrans * c4;
427 +    atomInfo = new AtomInfo;
428 +    atomInfo->atomTypeName = "K";
429 +    atomInfo->pos[0] = pos[0] + newVec[0];
430 +    atomInfo->pos[1] = pos[1] + newVec[1];
431 +    atomInfo->pos[2] = pos[2] + newVec[2];
432 +    atomInfo->dipole[0] = 0.0;
433 +    atomInfo->dipole[1] = 0.0;
434 +    atomInfo->dipole[2] = 0.0;
435 +    atomData->addAtomInfo(atomInfo);
436 +
437 +    //add atom data into atom's property
438 +
439 +    if(!haveAtomData){
440 +      atomData->setID("ATOMDATA");
441 +      datom->addProperty(atomData);
442 +    }
443 +
444 +    setVisited(datom);
445 +
446 +  }
447 +
448 +  const std::string GBLipidAtomVisitor::toString(){
449 +    char buffer[65535];
450 +    std::string result;
451 +  
452 +    sprintf(buffer ,"------------------------------------------------------------------\n");
453 +    result += buffer;
454 +
455 +    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
456 +    result += buffer;
457 +
458 +    sprintf(buffer , "Visitor Description: Convert GBlipid into 4 different K atoms\n");
459 +    result += buffer;
460 +
461 +    sprintf(buffer ,"------------------------------------------------------------------\n");
462 +    result += buffer;
463 +
464 +    return result;
465 +  }
466 +
467    //----------------------------------------------------------------------------//
468  
469    void DefaultAtomVisitor::visit(Atom *atom) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines