Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    rb998c3 rd6eb80  
    1919
    2020#include<gsl/gsl_poly.h>
     21#include<time.h>
    2122
    2223// ========================================== F U N C T I O N S =================================
     
    654655 * \param *out output stream for debugging
    655656 * \param *mol molecule with atoms and bonds
    656  * \param *&TesselStruct Tesselation with boundary triangles
     657 * \param *TesselStruct Tesselation with boundary triangles
    657658 * \param *filename prefix of filename
    658659 * \param *extraSuffix intermediate suffix
    659660 */
    660 void StoreTrianglesinFile(const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix)
     661void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix)
    661662{
    662663        Info FunctionInfo(__func__);
     
    789790 * \param configuration contains box dimensions
    790791 * \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
    791794 * \param RandAtomDisplacement maximum distance for random displacement per atom
    792795 * \param RandMolDisplacement maximum distance for random displacement per filler molecule
     
    794797 * \return *mol pointer to new molecule with filled atoms
    795798 */
    796 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandomAtomDisplacement, double RandomMolDisplacement, bool DoRandomRotation)
     799molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
    797800{
    798801        Info FunctionInfo(__func__);
     
    817820  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    818821    Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
    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     }
     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);
    824826    i++;
    825827  }
     
    835837  FillerDistance.Init(distance[0], distance[1], distance[2]);
    836838  FillerDistance.InverseMatrixMultiplication(M);
    837   Log() << Verbose(1) << "INFO: Grid steps are ";
    838   for(int i=0;i<NDIM;i++) {
     839  for(int i=0;i<NDIM;i++)
    839840    N[i] = (int) ceil(1./FillerDistance.x[i]);
    840     Log() << Verbose(1) << N[i];
    841     if (i != NDIM-1)
    842       Log() << Verbose(1)<< ", ";
    843     else
    844       Log() << Verbose(1) << "." << endl;
    845   }
     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) );
    846845
    847846  // go over [0,1]^3 filler grid
     
    859858          // get linked cell list
    860859          if (TesselStruct[i] == NULL) {
    861             eLog() << Verbose(1) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
     860            eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
    862861            FillIt = false;
    863862          } else {
    864             FillIt = FillIt && (!TesselStruct[i]->IsInnerPoint(CurrentPosition, LCList[i]));
     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            }
    865871            i++;
    866872          }
     
    931937      }
    932938  Free(&M);
     939
     940  // output to file
     941  TesselStruct[0]->LastTriangle = NULL;
     942  StoreTrianglesinFile(Filling, TesselStruct[0], "Tesselated", ".dat");
     943
    933944  for (size_t i=0;i<List->ListOfMolecules.size();i++) {
    934945        delete(LCList[i]);
Note: See TracChangeset for help on using the changeset viewer.