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