Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    rbdc91e r986ed3  
    1515#include "info.hpp"
    1616#include "linkedcell.hpp"
     17#include "verbose.hpp"
    1718#include "log.hpp"
    18 #include "memoryallocator.hpp"
    1919#include "molecule.hpp"
    2020#include "tesselation.hpp"
     
    2222#include "World.hpp"
    2323#include "Plane.hpp"
     24#include "Matrix.hpp"
     25#include "Box.hpp"
     26
     27#include <iostream>
     28#include <iomanip>
    2429
    2530#include<gsl/gsl_poly.h>
     
    296301 * \param *out output stream for debugging
    297302 * \param *mol molecule structure with Atom's and Bond's.
    298  * \param *BoundaryPts set of boundary points to use or NULL
    299303 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
    300304 * \param *LCList atoms in LinkedCell list
     
    302306 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename.
    303307 */
    304 void FindConvexBorder(const molecule* mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
     308void FindConvexBorder(const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
    305309{
    306310        Info FunctionInfo(__func__);
     
    313317
    314318  // 1. Find all points on the boundary
    315   if (BoundaryPts == NULL) {
    316     BoundaryFreeFlag = true;
    317     BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
     319  if (BoundaryPoints == NULL) {
     320      BoundaryFreeFlag = true;
     321      BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    318322  } else {
    319     BoundaryPoints = BoundaryPts;
    320     DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
     323      DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    321324  }
    322325
    323326// printing all inserted for debugging
    324   for (int axis=0; axis < NDIM; axis++) {
    325     DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
    326     int i=0;
    327     for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    328       if (runner != BoundaryPoints[axis].begin())
    329         DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
    330       else
    331         DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
    332       i++;
    333     }
    334     DoLog(0) && (Log() << Verbose(0) << endl);
    335   }
     327  for (int axis=0; axis < NDIM; axis++)
     328    {
     329      DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
     330      int i=0;
     331      for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
     332        if (runner != BoundaryPoints[axis].begin())
     333          DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
     334        else
     335          DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
     336        i++;
     337      }
     338      DoLog(0) && (Log() << Verbose(0) << endl);
     339    }
    336340
    337341  // 2. fill the boundary point list
     
    339343    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
    340344        if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0))
    341           DoLog(2) && (Log()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present." << endl);
     345          DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl);
    342346
    343347  DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl);
     
    673677
    674678  IsAngstroem = configuration->GetIsAngstroem();
     679  GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    675680  BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    676   GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    677681  LinkedCell *LCList = new LinkedCell(mol, 10.);
    678   FindConvexBorder(mol, BoundaryPoints, TesselStruct, (const LinkedCell *&)LCList, NULL);
     682  FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL);
    679683  delete (LCList);
    680   delete[] BoundaryPoints;
    681684
    682685
     
    686689  else
    687690    clustervolume = ClusterVolume;
    688 
    689   delete TesselStruct;
    690691
    691692  for (int i = 0; i < NDIM; i++)
     
    740741    mol->CenterInBox();
    741742  }
    742   delete GreatestDiameter;
    743743  // update Box of atoms by boundary
    744744  mol->SetBoxDimension(&BoxLengths);
     
    769769  int N[NDIM];
    770770  int n[NDIM];
    771   double *M =  ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    772   double Rotations[NDIM*NDIM];
    773   double *MInverse = InverseMatrix(M);
     771  const Matrix &M = World::getInstance().getDomain().getM();
     772  Matrix Rotations;
     773  const Matrix &MInverse = World::getInstance().getDomain().getMinv();
    774774  Vector AtomTranslations;
    775775  Vector FillerTranslations;
     
    804804
    805805  // calculate filler grid in [0,1]^3
    806   FillerDistance = Vector(distance[0], distance[1], distance[2]);
    807   FillerDistance.InverseMatrixMultiplication(M);
     806  FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]);
    808807  for(int i=0;i<NDIM;i++)
    809808    N[i] = (int) ceil(1./FillerDistance[i]);
     
    818817      for (n[2] = 0; n[2] < N[2]; n[2]++) {
    819818        // calculate position of current grid vector in untransformed box
    820         CurrentPosition = Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    821         CurrentPosition.MatrixMultiplication(M);
     819        CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    822820        // create molecule random translation vector ...
    823821        for (int i=0;i<NDIM;i++)
     
    840838            }
    841839
    842             Rotations[0] =   cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));
    843             Rotations[3] =   sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));
    844             Rotations[6] =               cos(phi[1])*sin(phi[2])                                     ;
    845             Rotations[1] = - sin(phi[0])*cos(phi[1])                                                ;
    846             Rotations[4] =   cos(phi[0])*cos(phi[1])                                                ;
    847             Rotations[7] =               sin(phi[1])                                                ;
    848             Rotations[3] = - cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));
    849             Rotations[5] = - sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));
    850             Rotations[8] =               cos(phi[1])*cos(phi[2])                                     ;
     840            Rotations.set(0,0,  cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])));
     841            Rotations.set(0,1,  sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])));
     842            Rotations.set(0,2,              cos(phi[1])*sin(phi[2])                                        );
     843            Rotations.set(1,0, -sin(phi[0])*cos(phi[1])                                                    );
     844            Rotations.set(1,1,  cos(phi[0])*cos(phi[1])                                                    );
     845            Rotations.set(1,2,              sin(phi[1])                                                    );
     846            Rotations.set(2,0, -cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])));
     847            Rotations.set(2,1, -sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])));
     848            Rotations.set(2,2,              cos(phi[1])*cos(phi[2])                                        );
    851849          }
    852850
     
    854852          Inserter = (*iter)->x;
    855853          if (DoRandomRotation)
    856             Inserter.MatrixMultiplication(Rotations);
     854            Inserter *= Rotations;
    857855          Inserter += AtomTranslations + FillerTranslations + CurrentPosition;
    858856
    859857          // check whether inserter is inside box
    860           Inserter.MatrixMultiplication(MInverse);
     858          Inserter *= MInverse;
    861859          FillIt = true;
    862860          for (int i=0;i<NDIM;i++)
    863861            FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON);
    864           Inserter.MatrixMultiplication(M);
     862          Inserter *= M;
    865863
    866864          // Check whether point is in- or outside
     
    897895            }
    898896      }
    899   for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    900     delete LCList[*ListRunner];
    901     delete TesselStruct[(*ListRunner)];
    902   }
    903   delete[](M);
    904   delete[](MInverse);
    905897
    906898  return Filling;
Note: See TracChangeset for help on using the changeset viewer.