Changes in src/analysis_correlation.cpp [1614174:244a84]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.cpp
r1614174 r244a84 10 10 #include "analysis_correlation.hpp" 11 11 #include "element.hpp" 12 #include "info.hpp" 12 13 #include "log.hpp" 13 14 #include "molecule.hpp" … … 28 29 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2 ) 29 30 { 31 Info FunctionInfo(__func__); 30 32 PairCorrelationMap *outmap = NULL; 31 33 double distance = 0.; … … 77 79 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] ) 78 80 { 81 Info FunctionInfo(__func__); 79 82 PairCorrelationMap *outmap = NULL; 80 83 double distance = 0.; … … 154 157 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point ) 155 158 { 159 Info FunctionInfo(__func__); 156 160 CorrelationToPointMap *outmap = NULL; 157 161 double distance = 0.; … … 190 194 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] ) 191 195 { 196 Info FunctionInfo(__func__); 192 197 CorrelationToPointMap *outmap = NULL; 193 198 double distance = 0.; … … 243 248 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC ) 244 249 { 250 Info FunctionInfo(__func__); 245 251 CorrelationToSurfaceMap *outmap = NULL; 246 252 double distance = 0; … … 261 267 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 262 268 if ((type == NULL) || (Walker->type == type)) { 263 triangle = Surface->FindClosestTriangleTo Point(Walker->node, LC );269 triangle = Surface->FindClosestTriangleToVector(Walker->node, LC ); 264 270 if (triangle != NULL) { 265 271 distance = DistanceToTrianglePlane(Walker->node, triangle); … … 288 294 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 289 295 { 296 Info FunctionInfo(__func__); 290 297 CorrelationToSurfaceMap *outmap = NULL; 291 298 double distance = 0; … … 301 308 } 302 309 outmap = new CorrelationToSurfaceMap; 310 double ShortestDistance = 0.; 311 BoundaryTriangleSet *ShortestTriangle = NULL; 303 312 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 304 313 if ((*MolWalker)->ActiveFlag) { … … 314 323 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 315 324 // go through every range in xyz and get distance 325 ShortestDistance = -1.; 316 326 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 317 327 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) … … 320 330 checkX.AddVector(&periodicX); 321 331 checkX.MatrixMultiplication(FullMatrix); 322 triangle = Surface->FindClosestTriangleToPoint(&checkX, LC ); 323 if (triangle != NULL) { 324 distance = DistanceToTrianglePlane(&checkX, triangle); 325 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 332 triangle = Surface->FindClosestTriangleToVector(&checkX, LC); 333 distance = Surface->GetDistanceSquaredToTriangle(checkX, triangle); 334 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 335 ShortestDistance = distance; 336 ShortestTriangle = triangle; 326 337 } 327 } 338 } 339 // insert 340 ShortestDistance = sqrt(ShortestDistance); 341 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) ); 342 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 328 343 } 329 344 } … … 342 357 double GetBin ( const double value, const double BinWidth, const double BinStart ) 343 358 { 359 Info FunctionInfo(__func__); 344 360 double bin =(double) (floor((value - BinStart)/BinWidth)); 345 361 return (bin*BinWidth+BinStart); … … 353 369 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ) 354 370 { 371 Info FunctionInfo(__func__); 355 372 *file << "# BinStart\tCount" << endl; 356 373 for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { … … 365 382 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map ) 366 383 { 384 Info FunctionInfo(__func__); 367 385 *file << "# BinStart\tAtom1\tAtom2" << endl; 368 386 for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { … … 377 395 void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map ) 378 396 { 397 Info FunctionInfo(__func__); 379 398 *file << "# BinStart\tAtom::x[i]-point.x[i]" << endl; 380 399 for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { … … 392 411 void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map ) 393 412 { 413 Info FunctionInfo(__func__); 394 414 *file << "# BinStart\tTriangle" << endl; 395 415 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 396 *file << runner->first << "\t" << *(runner->second. second) << endl;397 } 398 }; 399 416 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 417 } 418 }; 419
Note:
See TracChangeset
for help on using the changeset viewer.