Ignore:
Timestamp:
Mar 3, 2010, 9:31:24 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
9565ec
Parents:
e49719
Message:

FIX: allowing empty config files, and filling can deal with no molecules being present.

FillBoxWithMolecule():

  • Additional checks whether AtomCount>0
  • FIX: CopyAtoms was not initialised to NULL, hence wrong atoms might get "bonded".
  • if TesselStruct or LCList are NULL, these refer to empty molecules not to an error
  • breaking when atom would be placed was wrong, just continue to next atom of filler molecule.

config::LoadMolecule()

  • we do not performCriticalExit() when MaxTypes==0, indicating present config file with no atoms.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/boundary.cpp

    re49719 r9f03b2  
    819819  map<molecule *, LinkedCell *> LCList;
    820820
    821   for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    822     Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
    823     LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
    824     Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
    825     TesselStruct[(*ListRunner)] = NULL;
    826     FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL);
    827   }
     821  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
     822    if ((*ListRunner)->AtomCount > 0) {
     823      Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
     824      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
     825      Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
     826      TesselStruct[(*ListRunner)] = NULL;
     827      FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL);
     828    }
    828829
    829830  // Center filler at origin
    830   filler->CenterOrigin();
     831  filler->CenterEdge(&Inserter);
    831832  filler->Center.Zero();
    832833
     
    845846
    846847  // go over [0,1]^3 filler grid
    847   for (n[0] = 0; n[0] <= N[0]; n[0]++)
    848     for (n[1] = 0; n[1] <= N[1]; n[1]++)
    849       for (n[2] = 0; n[2] <= N[2]; n[2]++) {
     848  for (n[0] = 0; n[0] < N[0]; n[0]++)
     849    for (n[1] = 0; n[1] < N[1]; n[1]++)
     850      for (n[2] = 0; n[2] < N[2]; n[2]++) {
    850851        // calculate position of current grid vector in untransformed box
    851852        CurrentPosition.Init((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
     
    857858
    858859        // go through all atoms
     860        for (int i=0;i<filler->AtomCount;i++)
     861          CopyAtoms[i] = NULL;
    859862        Walker = filler->start;
    860863        while (Walker->next != filler->end) {
     
    900903          for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    901904            // get linked cell list
    902             if (TesselStruct[(*ListRunner)] == NULL) {
    903               eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
    904               FillIt = false;
    905             } else {
     905            if (TesselStruct[(*ListRunner)] != NULL) {
    906906              const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)]));
    907907              FillIt = FillIt && (distance > boundary) && ((MaxDistance < 0) || (MaxDistance > distance));
     
    919919            Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl;
    920920            CopyAtoms[Walker->nr] = NULL;
    921             break;
     921            continue;
    922922          }
    923923
Note: See TracChangeset for help on using the changeset viewer.