Changes in src/boundary.cpp [bdc91e:986ed3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
rbdc91e r986ed3 15 15 #include "info.hpp" 16 16 #include "linkedcell.hpp" 17 #include "verbose.hpp" 17 18 #include "log.hpp" 18 #include "memoryallocator.hpp"19 19 #include "molecule.hpp" 20 20 #include "tesselation.hpp" … … 22 22 #include "World.hpp" 23 23 #include "Plane.hpp" 24 #include "Matrix.hpp" 25 #include "Box.hpp" 26 27 #include <iostream> 28 #include <iomanip> 24 29 25 30 #include<gsl/gsl_poly.h> … … 296 301 * \param *out output stream for debugging 297 302 * \param *mol molecule structure with Atom's and Bond's. 298 * \param *BoundaryPts set of boundary points to use or NULL299 303 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return 300 304 * \param *LCList atoms in LinkedCell list … … 302 306 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename. 303 307 */ 304 void FindConvexBorder(const molecule* mol, Boundaries *BoundaryPts,Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)308 void FindConvexBorder(const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename) 305 309 { 306 310 Info FunctionInfo(__func__); … … 313 317 314 318 // 1. Find all points on the boundary 315 if (BoundaryP ts == NULL) {316 BoundaryFreeFlag = true;317 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);319 if (BoundaryPoints == NULL) { 320 BoundaryFreeFlag = true; 321 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 318 322 } 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); 321 324 } 322 325 323 326 // 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 } 336 340 337 341 // 2. fill the boundary point list … … 339 343 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) 340 344 if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0)) 341 Do Log(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); 342 346 343 347 DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl); … … 673 677 674 678 IsAngstroem = configuration->GetIsAngstroem(); 679 GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem); 675 680 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 676 GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);677 681 LinkedCell *LCList = new LinkedCell(mol, 10.); 678 FindConvexBorder(mol, BoundaryPoints,TesselStruct, (const LinkedCell *&)LCList, NULL);682 FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL); 679 683 delete (LCList); 680 delete[] BoundaryPoints;681 684 682 685 … … 686 689 else 687 690 clustervolume = ClusterVolume; 688 689 delete TesselStruct;690 691 691 692 for (int i = 0; i < NDIM; i++) … … 740 741 mol->CenterInBox(); 741 742 } 742 delete GreatestDiameter;743 743 // update Box of atoms by boundary 744 744 mol->SetBoxDimension(&BoxLengths); … … 769 769 int N[NDIM]; 770 770 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(); 774 774 Vector AtomTranslations; 775 775 Vector FillerTranslations; … … 804 804 805 805 // 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]); 808 807 for(int i=0;i<NDIM;i++) 809 808 N[i] = (int) ceil(1./FillerDistance[i]); … … 818 817 for (n[2] = 0; n[2] < N[2]; n[2]++) { 819 818 // 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]); 822 820 // create molecule random translation vector ... 823 821 for (int i=0;i<NDIM;i++) … … 840 838 } 841 839 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]) ); 851 849 } 852 850 … … 854 852 Inserter = (*iter)->x; 855 853 if (DoRandomRotation) 856 Inserter .MatrixMultiplication(Rotations);854 Inserter *= Rotations; 857 855 Inserter += AtomTranslations + FillerTranslations + CurrentPosition; 858 856 859 857 // check whether inserter is inside box 860 Inserter .MatrixMultiplication(MInverse);858 Inserter *= MInverse; 861 859 FillIt = true; 862 860 for (int i=0;i<NDIM;i++) 863 861 FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON); 864 Inserter .MatrixMultiplication(M);862 Inserter *= M; 865 863 866 864 // Check whether point is in- or outside … … 897 895 } 898 896 } 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);905 897 906 898 return Filling;
Note:
See TracChangeset
for help on using the changeset viewer.