Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    rd6eb80 rb998c3  
    1919
    2020#include<gsl/gsl_poly.h>
    21 #include<time.h>
    2221
    2322// ========================================== F U N C T I O N S =================================
     
    655654 * \param *out output stream for debugging
    656655 * \param *mol molecule with atoms and bonds
    657  * \param *TesselStruct Tesselation with boundary triangles
     656 * \param *&TesselStruct Tesselation with boundary triangles
    658657 * \param *filename prefix of filename
    659658 * \param *extraSuffix intermediate suffix
    660659 */
    661 void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix)
     660void StoreTrianglesinFile(const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix)
    662661{
    663662        Info FunctionInfo(__func__);
     
    790789 * \param configuration contains box dimensions
    791790 * \param distance[NDIM] distance between filling molecules in each direction
    792  * \param boundary length of boundary zone between molecule and filling mollecules
    793  * \param epsilon distance to surface which is not filled
    794791 * \param RandAtomDisplacement maximum distance for random displacement per atom
    795792 * \param RandMolDisplacement maximum distance for random displacement per filler molecule
     
    797794 * \return *mol pointer to new molecule with filled atoms
    798795 */
    799 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
     796molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandomAtomDisplacement, double RandomMolDisplacement, bool DoRandomRotation)
    800797{
    801798        Info FunctionInfo(__func__);
     
    820817  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    821818    Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
    822     LCList[i] = new LinkedCell((*ListRunner), 10.); // get linked cell list
    823     Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
    824     TesselStruct[i] = NULL;
    825     FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL);
     819    LCList[i] = new LinkedCell((*ListRunner), 5.); // get linked cell list
     820    if (TesselStruct[i] == NULL) {
     821      Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
     822      FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL);
     823    }
    826824    i++;
    827825  }
     
    837835  FillerDistance.Init(distance[0], distance[1], distance[2]);
    838836  FillerDistance.InverseMatrixMultiplication(M);
    839   for(int i=0;i<NDIM;i++)
     837  Log() << Verbose(1) << "INFO: Grid steps are ";
     838  for(int i=0;i<NDIM;i++) {
    840839    N[i] = (int) ceil(1./FillerDistance.x[i]);
    841   Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
    842 
    843   // initialize seed of random number generator to current time
    844   srand ( time(NULL) );
     840    Log() << Verbose(1) << N[i];
     841    if (i != NDIM-1)
     842      Log() << Verbose(1)<< ", ";
     843    else
     844      Log() << Verbose(1) << "." << endl;
     845  }
    845846
    846847  // go over [0,1]^3 filler grid
     
    858859          // get linked cell list
    859860          if (TesselStruct[i] == NULL) {
    860             eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
     861            eLog() << Verbose(1) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
    861862            FillIt = false;
    862863          } else {
    863             const double distance = (TesselStruct[i]->GetDistanceSquaredToSurface(CurrentPosition, LCList[i]));
    864             FillIt = FillIt && (distance > boundary*boundary);
    865             if (FillIt) {
    866               Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is outer point." << endl;
    867             } else {
    868               Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is inner point or within boundary." << endl;
    869               break;
    870             }
     864            FillIt = FillIt && (!TesselStruct[i]->IsInnerPoint(CurrentPosition, LCList[i]));
    871865            i++;
    872866          }
     
    937931      }
    938932  Free(&M);
    939 
    940   // output to file
    941   TesselStruct[0]->LastTriangle = NULL;
    942   StoreTrianglesinFile(Filling, TesselStruct[0], "Tesselated", ".dat");
    943 
    944933  for (size_t i=0;i<List->ListOfMolecules.size();i++) {
    945934        delete(LCList[i]);
Note: See TracChangeset for help on using the changeset viewer.