Changes in / [8ab0407:c7b1e7]
- Location:
- src
- Files:
-
- 4 added
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r8ab0407 rc7b1e7 8 8 ANALYSISHEADER = analysis_bonds.hpp analysis_correlation.hpp 9 9 10 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp11 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp10 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp triangleintersectionlist.cpp vector.cpp verbose.cpp World.cpp 11 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp triangleintersectionlist.cpp vector.hpp verbose.hpp World.hpp 12 12 13 13 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) -
src/analysis_bonds.cpp
r8ab0407 rc7b1e7 37 37 } 38 38 if (((int)Mean % 2) != 0) 39 eLog() << Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl;39 DoeLog(1) && (eLog()<< Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl); 40 40 Mean /= (double)AtomCount; 41 41 }; -
src/analysis_correlation.cpp
r8ab0407 rc7b1e7 15 15 #include "tesselation.hpp" 16 16 #include "tesselationhelpers.hpp" 17 #include "triangleintersectionlist.hpp" 17 18 #include "vector.hpp" 18 19 #include "verbose.hpp" 20 #include "World.hpp" 19 21 20 22 … … 34 36 35 37 if (molecules->ListOfMolecules.empty()) { 36 eLog() << Verbose(1) <<"No molecule given." << endl;38 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 37 39 return outmap; 38 40 } … … 40 42 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 41 43 if ((*MolWalker)->ActiveFlag) { 42 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;44 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 43 45 atom *Walker = (*MolWalker)->start; 44 46 while (Walker->next != (*MolWalker)->end) { … … 55 57 if (Walker->nr < OtherWalker->nr) 56 58 if ((type2 == NULL) || (OtherWalker->type == type2)) { 57 distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);59 distance = Walker->node->PeriodicDistance(OtherWalker->node, World::get()->cell_size); 58 60 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl; 59 61 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) ); … … 90 92 91 93 if (molecules->ListOfMolecules.empty()) { 92 eLog() << Verbose(1) <<"No molecule given." << endl;94 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 93 95 return outmap; 94 96 } … … 96 98 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 97 99 if ((*MolWalker)->ActiveFlag) { 98 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);100 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 99 101 double * FullInverseMatrix = InverseMatrix(FullMatrix); 100 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;102 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 101 103 atom *Walker = (*MolWalker)->start; 102 104 while (Walker->next != (*MolWalker)->end) { … … 174 176 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 175 177 if ((type == NULL) || (Walker->type == type)) { 176 distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);178 distance = Walker->node->PeriodicDistance(point, World::get()->cell_size); 177 179 Log() << Verbose(4) << "Current distance is " << distance << "." << endl; 178 180 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); … … 208 210 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 209 211 if ((*MolWalker)->ActiveFlag) { 210 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);212 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 211 213 double * FullInverseMatrix = InverseMatrix(FullMatrix); 212 214 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; … … 255 257 256 258 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) { 257 Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;259 DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 258 260 return outmap; 259 261 } … … 261 263 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 262 264 if ((*MolWalker)->ActiveFlag) { 263 Log() << Verbose( 2) << "Current molecule is " << *MolWalker<< "." << endl;264 atom *Walker = (*MolWalker)->start; 265 while (Walker->next != (*MolWalker)->end) { 266 Walker = Walker->next; 267 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;265 Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl; 266 atom *Walker = (*MolWalker)->start; 267 while (Walker->next != (*MolWalker)->end) { 268 Walker = Walker->next; 269 //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl; 268 270 if ((type == NULL) || (Walker->type == type)) { 269 triangle = Surface->FindClosestTriangleToVector(Walker->node, LC ); 270 if (triangle != NULL) { 271 distance = DistanceToTrianglePlane(Walker->node, triangle); 272 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 273 } 274 } 275 } 276 } 271 TriangleIntersectionList Intersections(Walker->node,Surface,LC); 272 distance = Intersections.GetSmallestDistance(); 273 triangle = Intersections.GetClosestTriangle(); 274 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 275 } 276 } 277 } else 278 Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl; 279 277 280 278 281 return outmap; … … 312 315 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 313 316 if ((*MolWalker)->ActiveFlag) { 314 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);317 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 315 318 double * FullInverseMatrix = InverseMatrix(FullMatrix); 316 319 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; … … 330 333 checkX.AddVector(&periodicX); 331 334 checkX.MatrixMultiplication(FullMatrix); 332 triangle = Surface->FindClosestTriangleToVector(&checkX, LC); 333 distance = Surface->GetDistanceSquaredToTriangle(checkX, triangle); 335 TriangleIntersectionList Intersections(&checkX,Surface,LC); 336 distance = Intersections.GetSmallestDistance(); 337 triangle = Intersections.GetClosestTriangle(); 334 338 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 335 339 ShortestDistance = distance; … … 338 342 } 339 343 // insert 340 ShortestDistance = sqrt(ShortestDistance);341 344 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) ); 342 345 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; … … 350 353 }; 351 354 352 /** Returns the startof the bin for a given value.355 /** Returns the index of the bin for a given value. 353 356 * \param value value whose bin to look for 354 357 * \param BinWidth width of bin 355 358 * \param BinStart first bin 356 359 */ 357 doubleGetBin ( const double value, const double BinWidth, const double BinStart )358 { 359 Info FunctionInfo(__func__); 360 double bin =(double) (floor((value - BinStart)/BinWidth));361 return (bin *BinWidth+BinStart);360 int GetBin ( const double value, const double BinWidth, const double BinStart ) 361 { 362 Info FunctionInfo(__func__); 363 int bin =(int) (floor((value - BinStart)/BinWidth)); 364 return (bin); 362 365 }; 363 366 … … 372 375 *file << "BinStart\tCount" << endl; 373 376 for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 374 *file << runner->first << "\t" << runner->second << endl;377 *file << setprecision(8) << runner->first << "\t" << runner->second << endl; 375 378 } 376 379 }; … … 385 388 *file << "BinStart\tAtom1\tAtom2" << endl; 386 389 for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 387 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;390 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 388 391 } 389 392 }; … … 400 403 *file << runner->first; 401 404 for (int i=0;i<NDIM;i++) 402 *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]);405 *file << "\t" << setprecision(8) << (runner->second.first->node->x[i] - runner->second.second->x[i]); 403 406 *file << endl; 404 407 } … … 413 416 Info FunctionInfo(__func__); 414 417 *file << "BinStart\tTriangle" << endl; 415 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 416 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 417 } 418 }; 419 418 if (!map->empty()) 419 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 420 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 421 } 422 }; 423 -
src/analysis_correlation.hpp
r8ab0407 rc7b1e7 51 51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] ); 52 52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 53 doubleGetBin ( const double value, const double BinWidth, const double BinStart );53 int GetBin ( const double value, const double BinWidth, const double BinStart ); 54 54 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); 55 55 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map ); … … 71 71 72 72 if (map == NULL) { 73 eLog() << Verbose(0) << "Nothing to min/max, map is NULL!" << endl;73 DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to min/max, map is NULL!" << endl); 74 74 performCriticalExit(); 75 75 return; … … 103 103 { 104 104 BinPairMap *outmap = new BinPairMap; 105 double bin = 0.;105 int bin = 0; 106 106 double start = 0.; 107 107 double end = 0.; … … 109 109 110 110 if (map == NULL) { 111 eLog() << Verbose(0) << "Nothing to bin, is NULL!" << endl;111 DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to bin, is NULL!" << endl); 112 112 performCriticalExit(); 113 113 return outmap; … … 122 122 start = BinStart; 123 123 end = BinEnd; 124 for (double runner = start; runner <= end; runner += BinWidth)125 outmap->insert( pair<double, int> (runner, 0) );126 124 } 125 for (int runner = 0; runner <= ceil((end-start)/BinWidth); runner++) 126 outmap->insert( pair<double, int> ((double)runner*BinWidth+start, 0) ); 127 127 128 128 for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) { 129 129 bin = GetBin (runner->first, BinWidth, start); 130 BinPairMapInserter = outmap->insert ( pair<double, int> ( bin, 1) );130 BinPairMapInserter = outmap->insert ( pair<double, int> ((double)bin*BinWidth+start, 1) ); 131 131 if (!BinPairMapInserter.second) { // bin already present, increase 132 132 BinPairMapInserter.first->second += 1; -
src/analyzer.cpp
r8ab0407 rc7b1e7 96 96 if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) { 97 97 NoHCorrection = true; 98 eLog() << Verbose(2) << "No HCorrection file found, skipping these." << endl;98 DoeLog(2) && (eLog()<< Verbose(2) << "No HCorrection file found, skipping these." << endl); 99 99 } 100 100 … … 102 102 if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) { 103 103 NoHessian = true; 104 eLog() << Verbose(2) << "No Hessian file found, skipping these." << endl;104 DoeLog(2) && (eLog()<< Verbose(2) << "No Hessian file found, skipping these." << endl); 105 105 } 106 106 if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) { 107 107 NoTime = true; 108 eLog() << Verbose(2) << "No speed file found, skipping these." << endl;108 DoeLog(2) && (eLog()<< Verbose(2) << "No speed file found, skipping these." << endl); 109 109 } 110 110 if (periode != NULL) { // also look for PAS values -
src/atom_bondedparticle.cpp
r8ab0407 rc7b1e7 86 86 status = true; 87 87 } else { 88 eLog() << Verbose(1) << *Binder << " does not contain " << *this << "." << endl;88 DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl); 89 89 } 90 90 } else { 91 eLog() << Verbose(1) << "Binder is " << Binder << "." << endl;91 DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl); 92 92 } 93 93 return status; … … 105 105 status = true; 106 106 } else { 107 eLog() << Verbose(1) << *Binder << " does not contain " << *this << "." << endl;107 DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl); 108 108 } 109 109 } else { 110 eLog() << Verbose(1) << "Binder is " << Binder << "." << endl;110 DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl); 111 111 } 112 112 return status; … … 150 150 //Log() << Verbose(2) << "Increased bond degree for bond " << *CandidateBond << "." << endl; 151 151 } else { 152 eLog() << Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl;152 DoeLog(2) && (eLog()<< Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl); 153 153 FalseBondDegree++; 154 154 } -
src/bond.cpp
r8ab0407 rc7b1e7 63 63 if(rightatom == Atom) 64 64 return leftatom; 65 eLog() << Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl;65 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl); 66 66 return NULL; 67 67 }; … … 99 99 bool bond::MarkUsed(const enum Shading color) { 100 100 if (Used == black) { 101 eLog() << Verbose(1) << "Bond " << this << " was already marked black!." << endl;101 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << this << " was already marked black!." << endl); 102 102 return false; 103 103 } else { -
src/bondgraph.cpp
r8ab0407 rc7b1e7 58 58 Log() << Verbose(1) << "Parsing bond length matrix successful." << endl; 59 59 } else { 60 eLog() << Verbose(1) << "Parsing bond length matrix failed." << endl;60 DoeLog(1) && (eLog()<< Verbose(1) << "Parsing bond length matrix failed." << endl); 61 61 } 62 62 … … 159 159 { 160 160 if (BondLengthMatrix == NULL) {// safety measure if no matrix has been parsed yet 161 eLog() << Verbose(2) << "BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl;161 DoeLog(2) && (eLog()<< Verbose(2) << "BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl); 162 162 CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 163 163 } else { -
src/bondgraph.hpp
r8ab0407 rc7b1e7 19 19 20 20 #include <iostream> 21 22 /*********************************************** defines ***********************************/ 23 24 #define BONDTHRESHOLD 0.4 //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii 21 25 22 26 /****************************************** forward declarations *****************************/ -
src/boundary.cpp
r8ab0407 rc7b1e7 17 17 #include "tesselation.hpp" 18 18 #include "tesselationhelpers.hpp" 19 #include "World.hpp" 19 20 20 21 #include<gsl/gsl_poly.h> … … 341 342 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) 342 343 if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0)) 343 eLog() << Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl;344 DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl); 344 345 345 346 Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl; … … 361 362 // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point 362 363 if (!TesselStruct->InsertStraddlingPoints(mol, LCList)) 363 eLog() << Verbose(1) << "Insertion of straddling points failed!" << endl;364 DoeLog(1) && (eLog()<< Verbose(1) << "Insertion of straddling points failed!" << endl); 364 365 365 366 Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl; … … 400 401 // flip the line 401 402 if (TesselStruct->PickFarthestofTwoBaselines(line) == 0.) 402 eLog() << Verbose(1) << "Correction of concave baselines failed!" << endl;403 DoeLog(1) && (eLog()<< Verbose(1) << "Correction of concave baselines failed!" << endl); 403 404 else { 404 405 TesselStruct->FlipBaseline(line); … … 455 456 456 457 if ((TesselStruct == NULL) || (TesselStruct->PointsOnBoundary.empty())) { 457 eLog() << Verbose(1) << "TesselStruct is empty." << endl;458 DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty." << endl); 458 459 return false; 459 460 } … … 520 521 // check whether there is something to work on 521 522 if (TesselStruct == NULL) { 522 eLog() << Verbose(1) << "TesselStruct is empty!" << endl;523 DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty!" << endl); 523 524 return volume; 524 525 } … … 747 748 Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 748 749 if (minimumvolume > cellvolume) { 749 eLog() << Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl;750 DoeLog(1) && (eLog()<< Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl); 750 751 Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl; 751 752 for (int i = 0; i < NDIM; i++) … … 789 790 * \param *filler molecule which the box is to be filled with 790 791 * \param configuration contains box dimensions 792 * \param MaxDistance fills in molecules only up to this distance (set to -1 if whole of the domain) 791 793 * \param distance[NDIM] distance between filling molecules in each direction 792 794 * \param boundary length of boundary zone between molecule and filling mollecules … … 797 799 * \return *mol pointer to new molecule with filled atoms 798 800 */ 799 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)801 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation) 800 802 { 801 803 Info FunctionInfo(__func__); … … 804 806 int N[NDIM]; 805 807 int n[NDIM]; 806 double *M = ReturnFullMatrixforSymmetric( filler->cell_size);808 double *M = ReturnFullMatrixforSymmetric(World::get()->cell_size); 807 809 double Rotations[NDIM*NDIM]; 810 double *MInverse = InverseMatrix(M); 808 811 Vector AtomTranslations; 809 812 Vector FillerTranslations; 810 813 Vector FillerDistance; 814 Vector Inserter; 811 815 double FillIt = false; 812 816 atom *Walker = NULL; 813 817 bond *Binder = NULL; 814 int i = 0;815 LinkedCell *LCList[List->ListOfMolecules.size()];816 818 double phi[NDIM]; 817 class Tesselation *TesselStruct[List->ListOfMolecules.size()];818 819 i=0; 820 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {821 Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;822 LCList[i] = new LinkedCell((*ListRunner), 10.); // get linked cell list823 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);826 i++;827 }819 map<molecule *, Tesselation *> TesselStruct; 820 map<molecule *, LinkedCell *> LCList; 821 822 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) 823 if ((*ListRunner)->AtomCount > 0) { 824 Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl; 825 LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list 826 Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl; 827 TesselStruct[(*ListRunner)] = NULL; 828 FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL); 829 } 828 830 829 831 // Center filler at origin 830 filler->Center Origin();832 filler->CenterEdge(&Inserter); 831 833 filler->Center.Zero(); 834 Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl; 835 Binder = filler->first; 836 while(Binder->next != filler->last) { 837 Binder = Binder->next; 838 Log() << Verbose(2) << " " << *Binder << endl; 839 } 832 840 833 841 filler->CountAtoms(); … … 851 859 CurrentPosition.Init((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 852 860 CurrentPosition.MatrixMultiplication(M); 853 Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "." << endl; 854 // Check whether point is in- or outside 855 FillIt = true; 856 i=0; 857 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 858 // get linked cell list 859 if (TesselStruct[i] == NULL) { 860 eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl; 861 FillIt = false; 861 // create molecule random translation vector ... 862 for (int i=0;i<NDIM;i++) 863 FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.); 864 Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl; 865 866 // go through all atoms 867 for (int i=0;i<filler->AtomCount;i++) 868 CopyAtoms[i] = NULL; 869 Walker = filler->start; 870 while (Walker->next != filler->end) { 871 Walker = Walker->next; 872 873 // create atomic random translation vector ... 874 for (int i=0;i<NDIM;i++) 875 AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.); 876 877 // ... and rotation matrix 878 if (DoRandomRotation) { 879 for (int i=0;i<NDIM;i++) { 880 phi[i] = rand()/(RAND_MAX/(2.*M_PI)); 881 } 882 883 Rotations[0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])); 884 Rotations[3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])); 885 Rotations[6] = cos(phi[1])*sin(phi[2]) ; 886 Rotations[1] = - sin(phi[0])*cos(phi[1]) ; 887 Rotations[4] = cos(phi[0])*cos(phi[1]) ; 888 Rotations[7] = sin(phi[1]) ; 889 Rotations[3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])); 890 Rotations[5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])); 891 Rotations[8] = cos(phi[1])*cos(phi[2]) ; 892 } 893 894 // ... and put at new position 895 Inserter.CopyVector(&(Walker->x)); 896 if (DoRandomRotation) 897 Inserter.MatrixMultiplication(Rotations); 898 Inserter.AddVector(&AtomTranslations); 899 Inserter.AddVector(&FillerTranslations); 900 Inserter.AddVector(&CurrentPosition); 901 902 // check whether inserter is inside box 903 Inserter.MatrixMultiplication(MInverse); 904 FillIt = true; 905 for (int i=0;i<NDIM;i++) 906 FillIt = FillIt && (Inserter.x[i] >= -MYEPSILON) && ((Inserter.x[i]-1.) <= MYEPSILON); 907 Inserter.MatrixMultiplication(M); 908 909 // Check whether point is in- or outside 910 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 911 // get linked cell list 912 if (TesselStruct[(*ListRunner)] != NULL) { 913 const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)])); 914 FillIt = FillIt && (distance > boundary) && ((MaxDistance < 0) || (MaxDistance > distance)); 915 } 916 } 917 // insert into Filling 918 if (FillIt) { 919 Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl; 920 // copy atom ... 921 CopyAtoms[Walker->nr] = new atom(Walker); 922 CopyAtoms[Walker->nr]->x.CopyVector(&Inserter); 923 Filling->AddAtom(CopyAtoms[Walker->nr]); 924 Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl; 862 925 } else { 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 } 871 i++; 926 Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl; 927 CopyAtoms[Walker->nr] = NULL; 928 continue; 872 929 } 873 930 } 874 875 if (FillIt) { 876 // fill in Filler 877 Log() << Verbose(2) << "Space at " << CurrentPosition << " is unoccupied by any molecule, filling in." << endl; 878 879 // create molecule random translation vector ... 880 for (int i=0;i<NDIM;i++) 881 FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.); 882 Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl; 883 884 // go through all atoms 885 Walker = filler->start; 886 while (Walker->next != filler->end) { 887 Walker = Walker->next; 888 // copy atom ... 889 CopyAtoms[Walker->nr] = new atom(Walker); 890 891 // create atomic random translation vector ... 892 for (int i=0;i<NDIM;i++) 893 AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.); 894 895 // ... and rotation matrix 896 if (DoRandomRotation) { 897 for (int i=0;i<NDIM;i++) { 898 phi[i] = rand()/(RAND_MAX/(2.*M_PI)); 899 } 900 901 Rotations[0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])); 902 Rotations[3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])); 903 Rotations[6] = cos(phi[1])*sin(phi[2]) ; 904 Rotations[1] = - sin(phi[0])*cos(phi[1]) ; 905 Rotations[4] = cos(phi[0])*cos(phi[1]) ; 906 Rotations[7] = sin(phi[1]) ; 907 Rotations[3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])); 908 Rotations[5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])); 909 Rotations[8] = cos(phi[1])*cos(phi[2]) ; 910 } 911 912 // ... and put at new position 913 if (DoRandomRotation) 914 CopyAtoms[Walker->nr]->x.MatrixMultiplication(Rotations); 915 CopyAtoms[Walker->nr]->x.AddVector(&AtomTranslations); 916 CopyAtoms[Walker->nr]->x.AddVector(&FillerTranslations); 917 CopyAtoms[Walker->nr]->x.AddVector(&CurrentPosition); 918 919 // insert into Filling 920 921 // FIXME: gives completely different results if CopyAtoms[..] used instead of Walker, why??? 922 Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl; 923 Filling->AddAtom(CopyAtoms[Walker->nr]); 924 } 925 926 // go through all bonds and add as well 927 Binder = filler->first; 928 while(Binder->next != filler->last) { 929 Binder = Binder->next; 930 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 931 // go through all bonds and add as well 932 Binder = filler->first; 933 while(Binder->next != filler->last) { 934 Binder = Binder->next; 935 if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) { 936 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 931 937 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 932 938 } 933 } else {934 // leave empty935 Log() << Verbose(2) << "Space at " << CurrentPosition << " is occupied." << endl;936 939 } 937 940 } 938 941 Free(&M); 939 940 // output to file 941 TesselStruct[0]->LastTriangle = NULL; 942 StoreTrianglesinFile(Filling, TesselStruct[0], "Tesselated", ".dat"); 943 944 for (size_t i=0;i<List->ListOfMolecules.size();i++) { 945 delete(LCList[i]); 946 delete(TesselStruct[i]); 947 } 942 Free(&MInverse); 943 948 944 return Filling; 949 945 }; -
src/boundary.hpp
r8ab0407 rc7b1e7 49 49 50 50 double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation); 52 52 void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename); 53 53 Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol); -
src/builder.cpp
r8ab0407 rc7b1e7 68 68 #include "periodentafel.hpp" 69 69 #include "version.h" 70 #include "World.hpp" 70 71 71 72 /********************************************* Subsubmenu routine ************************************/ … … 84 85 bool valid; 85 86 86 Log()<< Verbose(0) << "===========ADD ATOM============================" << endl;87 Log()<< Verbose(0) << " a - state absolute coordinates of atom" << endl;88 Log()<< Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;89 Log()<< Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;90 Log()<< Verbose(0) << " d - state two atoms, two angles and a distance" << endl;91 Log()<< Verbose(0) << " e - least square distance position to a set of atoms" << endl;92 Log()<< Verbose(0) << "all else - go back" << endl;93 Log()<< Verbose(0) << "===============================================" << endl;94 Log()<< Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;95 Log()<< Verbose(0) << "INPUT: ";87 cout << Verbose(0) << "===========ADD ATOM============================" << endl; 88 cout << Verbose(0) << " a - state absolute coordinates of atom" << endl; 89 cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl; 90 cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl; 91 cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl; 92 cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl; 93 cout << Verbose(0) << "all else - go back" << endl; 94 cout << Verbose(0) << "===============================================" << endl; 95 cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl; 96 cout << Verbose(0) << "INPUT: "; 96 97 cin >> choice; 97 98 98 99 switch (choice) { 99 100 default: 100 eLog() << Verbose(2) << "Not a valid choice." << endl;101 DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl); 101 102 break; 102 103 case 'a': // absolute coordinates of atom 103 Log()<< Verbose(0) << "Enter absolute coordinates." << endl;104 cout << Verbose(0) << "Enter absolute coordinates." << endl; 104 105 first = new atom; 105 first->x.AskPosition( mol->cell_size, false);106 first->x.AskPosition(World::get()->cell_size, false); 106 107 first->type = periode->AskElement(); // give type 107 108 mol->AddAtom(first); // add to molecule … … 112 113 valid = true; 113 114 do { 114 if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;115 Log()<< Verbose(0) << "Enter reference coordinates." << endl;116 x.AskPosition( mol->cell_size, true);117 Log()<< Verbose(0) << "Enter relative coordinates." << endl;118 first->x.AskPosition( mol->cell_size, false);115 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl); 116 cout << Verbose(0) << "Enter reference coordinates." << endl; 117 x.AskPosition(World::get()->cell_size, true); 118 cout << Verbose(0) << "Enter relative coordinates." << endl; 119 first->x.AskPosition(World::get()->cell_size, false); 119 120 first->x.AddVector((const Vector *)&x); 120 Log()<< Verbose(0) << "\n";121 cout << Verbose(0) << "\n"; 121 122 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 122 123 first->type = periode->AskElement(); // give type … … 128 129 valid = true; 129 130 do { 130 if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;131 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl); 131 132 second = mol->AskAtom("Enter atom number: "); 132 133 Log() << Verbose(0) << "Enter relative coordinates." << endl; 133 first->x.AskPosition( mol->cell_size, false);134 first->x.AskPosition(World::get()->cell_size, false); 134 135 for (int i=NDIM;i--;) { 135 136 first->x.x[i] += second->x.x[i]; … … 145 146 do { 146 147 if (!valid) { 147 eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;148 DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl); 148 149 } 149 Log()<< Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;150 cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl; 150 151 second = mol->AskAtom("Enter central atom: "); 151 152 third = mol->AskAtom("Enter second atom (specifying the axis for first angle): "); … … 158 159 c *= M_PI/180.; 159 160 bound(&c, -M_PI, M_PI); 160 Log()<< Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;161 cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl; 161 162 /* 162 163 second->Output(1,1,(ofstream *)&cout); … … 170 171 171 172 if (!z.SolveSystem(&x,&y,&n, b, c, a)) { 172 Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;173 coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl; 173 174 continue; 174 175 } … … 247 248 atoms[i] = NULL; 248 249 int i=0, j=0; 249 Log()<< Verbose(0) << "Now we need at least three molecules.\n";250 cout << Verbose(0) << "Now we need at least three molecules.\n"; 250 251 do { 251 Log()<< Verbose(0) << "Enter " << i+1 << "th atom: ";252 cout << Verbose(0) << "Enter " << i+1 << "th atom: "; 252 253 cin >> j; 253 254 if (j != -1) { … … 264 265 } else { 265 266 delete first; 266 Log()<< Verbose(0) << "Please enter at least two vectors!\n";267 cout << Verbose(0) << "Please enter at least two vectors!\n"; 267 268 } 268 269 break; … … 278 279 char choice; // menu choice char 279 280 280 Log()<< Verbose(0) << "===========CENTER ATOMS=========================" << endl;281 Log()<< Verbose(0) << " a - on origin" << endl;282 Log()<< Verbose(0) << " b - on center of gravity" << endl;283 Log()<< Verbose(0) << " c - within box with additional boundary" << endl;284 Log()<< Verbose(0) << " d - within given simulation box" << endl;285 Log()<< Verbose(0) << "all else - go back" << endl;286 Log()<< Verbose(0) << "===============================================" << endl;287 Log()<< Verbose(0) << "INPUT: ";281 cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl; 282 cout << Verbose(0) << " a - on origin" << endl; 283 cout << Verbose(0) << " b - on center of gravity" << endl; 284 cout << Verbose(0) << " c - within box with additional boundary" << endl; 285 cout << Verbose(0) << " d - within given simulation box" << endl; 286 cout << Verbose(0) << "all else - go back" << endl; 287 cout << Verbose(0) << "===============================================" << endl; 288 cout << Verbose(0) << "INPUT: "; 288 289 cin >> choice; 289 290 290 291 switch (choice) { 291 292 default: 292 Log()<< Verbose(0) << "Not a valid choice." << endl;293 cout << Verbose(0) << "Not a valid choice." << endl; 293 294 break; 294 295 case 'a': 295 Log()<< Verbose(0) << "Centering atoms in config file on origin." << endl;296 cout << Verbose(0) << "Centering atoms in config file on origin." << endl; 296 297 mol->CenterOrigin(); 297 298 break; 298 299 case 'b': 299 Log()<< Verbose(0) << "Centering atoms in config file on center of gravity." << endl;300 cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl; 300 301 mol->CenterPeriodic(); 301 302 break; 302 303 case 'c': 303 Log()<< Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;304 cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl; 304 305 for (int i=0;i<NDIM;i++) { 305 Log()<< Verbose(0) << "Enter axis " << i << " boundary: ";306 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 306 307 cin >> y.x[i]; 307 308 } … … 314 315 break; 315 316 case 'd': 316 Log()<< Verbose(1) << "Centering atoms in config file within given simulation box." << endl;317 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 317 318 for (int i=0;i<NDIM;i++) { 318 Log()<< Verbose(0) << "Enter axis " << i << " boundary: ";319 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 319 320 cin >> x.x[i]; 320 321 } … … 337 338 char choice; // menu choice char 338 339 339 Log()<< Verbose(0) << "===========ALIGN ATOMS=========================" << endl;340 Log()<< Verbose(0) << " a - state three atoms defining align plane" << endl;341 Log()<< Verbose(0) << " b - state alignment vector" << endl;342 Log()<< Verbose(0) << " c - state two atoms in alignment direction" << endl;343 Log()<< Verbose(0) << " d - align automatically by least square fit" << endl;344 Log()<< Verbose(0) << "all else - go back" << endl;345 Log()<< Verbose(0) << "===============================================" << endl;346 Log()<< Verbose(0) << "INPUT: ";340 cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl; 341 cout << Verbose(0) << " a - state three atoms defining align plane" << endl; 342 cout << Verbose(0) << " b - state alignment vector" << endl; 343 cout << Verbose(0) << " c - state two atoms in alignment direction" << endl; 344 cout << Verbose(0) << " d - align automatically by least square fit" << endl; 345 cout << Verbose(0) << "all else - go back" << endl; 346 cout << Verbose(0) << "===============================================" << endl; 347 cout << Verbose(0) << "INPUT: "; 347 348 cin >> choice; 348 349 … … 357 358 break; 358 359 case 'b': // normal vector of mirror plane 359 Log()<< Verbose(0) << "Enter normal vector of mirror plane." << endl;360 n.AskPosition( mol->cell_size,0);360 cout << Verbose(0) << "Enter normal vector of mirror plane." << endl; 361 n.AskPosition(World::get()->cell_size,0); 361 362 n.Normalize(); 362 363 break; … … 377 378 fscanf(stdin, "%3s", shorthand); 378 379 } while ((param.type = periode->FindElement(shorthand)) == NULL); 379 Log()<< Verbose(0) << "Element is " << param.type->name << endl;380 cout << Verbose(0) << "Element is " << param.type->name << endl; 380 381 mol->GetAlignvector(¶m); 381 382 for (int i=NDIM;i--;) { … … 384 385 } 385 386 gsl_vector_free(param.x); 386 Log()<< Verbose(0) << "Offset vector: ";387 cout << Verbose(0) << "Offset vector: "; 387 388 x.Output(); 388 389 Log() << Verbose(0) << endl; … … 425 426 case 'b': // normal vector of mirror plane 426 427 Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl; 427 n.AskPosition( mol->cell_size,0);428 n.AskPosition(World::get()->cell_size,0); 428 429 n.Normalize(); 429 430 break; … … 655 656 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration) 656 657 { 657 atom *first, *second ;658 atom *first, *second, *third; 658 659 molecule *mol = NULL; 659 660 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 667 668 Log() << Verbose(0) << "r - remove an atom" << endl; 668 669 Log() << Verbose(0) << "b - scale a bond between atoms" << endl; 670 Log() << Verbose(0) << "t - turn an atom round another bond" << endl; 669 671 Log() << Verbose(0) << "u - change an atoms element" << endl; 670 672 Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl; … … 672 674 Log() << Verbose(0) << "===============================================" << endl; 673 675 if (molecules->NumberOfActiveMolecules() > 1) 674 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;676 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl); 675 677 Log() << Verbose(0) << "INPUT: "; 676 678 cin >> choice; … … 748 750 break; 749 751 752 case 't': // turn/rotate atom 753 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 754 if ((*ListRunner)->ActiveFlag) { 755 mol = *ListRunner; 756 Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl; 757 first = mol->AskAtom("Enter turning atom: "); 758 second = mol->AskAtom("Enter central atom: "); 759 third = mol->AskAtom("Enter bond atom: "); 760 cout << Verbose(0) << "Enter new angle in degrees: "; 761 double tmp = 0.; 762 cin >> tmp; 763 // calculate old angle 764 x.CopyVector((const Vector *)&first->x); 765 x.SubtractVector((const Vector *)&second->x); 766 y.CopyVector((const Vector *)&third->x); 767 y.SubtractVector((const Vector *)&second->x); 768 double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.); 769 cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 770 cout << Verbose(0) << alpha << " degrees" << endl; 771 // rotate 772 z.MakeNormalVector(&x,&y); 773 x.RotateVector(&z,(alpha-tmp)*M_PI/180.); 774 x.AddVector(&second->x); 775 first->x.CopyVector(&x); 776 // check new angle 777 x.CopyVector((const Vector *)&first->x); 778 x.SubtractVector((const Vector *)&second->x); 779 alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.); 780 cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 781 cout << Verbose(0) << alpha << " degrees" << endl; 782 } 783 break; 784 750 785 case 'u': // change an atom's element 751 786 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) … … 795 830 Log() << Verbose(0) << "===============================================" << endl; 796 831 if (molecules->NumberOfActiveMolecules() > 1) 797 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;832 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl); 798 833 Log() << Verbose(0) << "INPUT: "; 799 834 cin >> choice; … … 828 863 } 829 864 if (count != j) 830 eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;865 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 831 866 x.Zero(); 832 867 y.Zero(); 833 y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude868 y.x[abs(axis)-1] = World::get()->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 834 869 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 835 870 x.AddVector(&y); // per factor one cell width further … … 854 889 mol->Translate(&x); 855 890 } 856 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;891 World::get()->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 857 892 } 858 893 } … … 911 946 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; 912 947 Log() << Verbose(0) << "Enter translation vector." << endl; 913 x.AskPosition( mol->cell_size,0);948 x.AskPosition(World::get()->cell_size,0); 914 949 mol->Center.AddVector((const Vector *)&x); 915 950 } … … 971 1006 // center at set box dimensions 972 1007 mol->CenterEdge(¢er); 973 mol->cell_size[0] = center.x[0]; 974 mol->cell_size[1] = 0; 975 mol->cell_size[2] = center.x[1]; 976 mol->cell_size[3] = 0; 977 mol->cell_size[4] = 0; 978 mol->cell_size[5] = center.x[2]; 1008 double * const cell_size = World::get()->cell_size; 1009 cell_size[0] = center.x[0]; 1010 cell_size[1] = 0; 1011 cell_size[2] = center.x[1]; 1012 cell_size[3] = 0; 1013 cell_size[4] = 0; 1014 cell_size[5] = center.x[2]; 979 1015 molecules->insert(mol); 980 1016 } … … 1172 1208 mol = (molecules->ListOfMolecules.front())->CopyMolecule(); 1173 1209 else { 1174 eLog() << Verbose(0) << "I don't have anything to test on ... ";1210 DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... "); 1175 1211 performCriticalExit(); 1176 1212 return; … … 1253 1289 1254 1290 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1255 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;1291 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl); 1256 1292 } 1257 1293 … … 1357 1393 1358 1394 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1359 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;1395 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl); 1360 1396 } 1361 1397 … … 1387 1423 enum ConfigStatus configPresent = absent; 1388 1424 clock_t start,end; 1425 double MaxDistance = -1; 1389 1426 int argptr; 1390 1427 molecule *mol = NULL; … … 1412 1449 Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl; 1413 1450 Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl; 1414 Log() << Verbose(0) << "\t-C < Z> <output> <bin output>\tPair Correlation analysis." << endl;1451 Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl; 1415 1452 Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl; 1416 1453 Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl; … … 1418 1455 Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl; 1419 1456 Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl; 1420 Log() << Verbose(0) << "\t-F <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl; 1457 Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl; 1458 Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl; 1421 1459 Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl; 1422 1460 Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl; … … 1442 1480 Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl; 1443 1481 Log() << Verbose(0) << "\t-V\t\tGives version information." << endl; 1482 Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl; 1444 1483 Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl; 1445 1484 return (1); … … 1457 1496 return (1); 1458 1497 break; 1498 case 'B': 1499 if (ExitFlag == 0) ExitFlag = 1; 1500 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) { 1501 ExitFlag = 255; 1502 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 1503 performCriticalExit(); 1504 } else { 1505 SaveFlag = true; 1506 j = -1; 1507 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 1508 double * const cell_size = World::get()->cell_size; 1509 for (int i=0;i<6;i++) { 1510 cell_size[i] = atof(argv[argptr+i]); 1511 } 1512 argptr+=6; 1513 } 1514 break; 1459 1515 case 'e': 1460 1516 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1461 eLog() << Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;1517 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl); 1462 1518 performCriticalExit(); 1463 1519 } else { … … 1469 1525 case 'g': 1470 1526 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1471 eLog() << Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl;1527 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl); 1472 1528 performCriticalExit(); 1473 1529 } else { … … 1480 1536 Log() << Verbose(0) << "I won't parse trajectories." << endl; 1481 1537 configuration.FastParsing = true; 1538 break; 1539 case 'X': 1540 { 1541 char **name = &(World::get()->DefaultName); 1542 delete[](*name); 1543 const int length = strlen(argv[argptr]); 1544 *name = new char[length+2]; 1545 strncpy(*name, argv[argptr], length); 1546 Log() << Verbose(0) << "Default name of new molecules set to " << *name << "." << endl; 1547 } 1482 1548 break; 1483 1549 default: // no match? Step on … … 1556 1622 Log() << Verbose(0) << "Bond length table loaded successfully." << endl; 1557 1623 } else { 1558 eLog() << Verbose(1) << "Bond length table loading failed." << endl;1624 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl); 1559 1625 } 1560 1626 } … … 1572 1638 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1573 1639 ExitFlag = 255; 1574 eLog() << Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl;1640 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl); 1575 1641 performCriticalExit(); 1576 1642 } else { … … 1589 1655 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) { 1590 1656 ExitFlag = 255; 1591 eLog() << Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;1657 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl); 1592 1658 performCriticalExit(); 1593 1659 } else { … … 1605 1671 configPresent = present; 1606 1672 } else 1607 eLog() << Verbose(1) << "Could not find the specified element." << endl;1673 DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl); 1608 1674 argptr+=4; 1609 1675 } … … 1618 1684 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1619 1685 ExitFlag = 255; 1620 eLog() << Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;1686 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl); 1621 1687 performCriticalExit(); 1622 1688 } else { … … 1671 1737 } 1672 1738 } 1673 if ( mol == NULL) {1739 if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) { 1674 1740 mol = *(molecules->ListOfMolecules.begin()); 1675 mol->ActiveFlag = true; 1741 if (mol != NULL) 1742 mol->ActiveFlag = true; 1676 1743 } 1677 1744 break; 1678 1745 case 'C': 1679 if (ExitFlag == 0) ExitFlag = 1; 1680 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr][0] == '-') || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-')) { 1681 ExitFlag = 255; 1682 eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C <Z> <output> <bin output>" << endl; 1683 performCriticalExit(); 1684 } else { 1685 ofstream output(argv[argptr+1]); 1686 ofstream binoutput(argv[argptr+2]); 1687 const double radius = 5.; 1688 1689 // get the boundary 1690 class molecule *Boundary = NULL; 1691 class Tesselation *TesselStruct = NULL; 1692 const LinkedCell *LCList = NULL; 1693 // find biggest molecule 1694 int counter = 0; 1695 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1696 if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) { 1697 Boundary = *BigFinder; 1746 { 1747 int ranges[3] = {1, 1, 1}; 1748 bool periodic = (argv[argptr-1][2] =='p'); 1749 if (ExitFlag == 0) ExitFlag = 1; 1750 if ((argptr >= argc)) { 1751 ExitFlag = 255; 1752 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl); 1753 performCriticalExit(); 1754 } else { 1755 switch(argv[argptr][0]) { 1756 case 'E': 1757 { 1758 if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) { 1759 ExitFlag = 255; 1760 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl); 1761 performCriticalExit(); 1762 } else { 1763 ofstream output(argv[argptr+3]); 1764 ofstream binoutput(argv[argptr+4]); 1765 const double BinStart = atof(argv[argptr+5]); 1766 const double BinEnd = atof(argv[argptr+6]); 1767 1768 element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1769 element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2])); 1770 PairCorrelationMap *correlationmap = NULL; 1771 if (periodic) 1772 correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges); 1773 else 1774 correlationmap = PairCorrelation(molecules, elemental, elemental2); 1775 //OutputCorrelationToSurface(&output, correlationmap); 1776 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1777 OutputCorrelation ( &binoutput, binmap ); 1778 output.close(); 1779 binoutput.close(); 1780 delete(binmap); 1781 delete(correlationmap); 1782 argptr+=7; 1783 } 1784 } 1785 break; 1786 1787 case 'P': 1788 { 1789 if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) { 1790 ExitFlag = 255; 1791 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output>" << endl); 1792 performCriticalExit(); 1793 } else { 1794 ofstream output(argv[argptr+5]); 1795 ofstream binoutput(argv[argptr+6]); 1796 const double BinStart = atof(argv[argptr+7]); 1797 const double BinEnd = atof(argv[argptr+8]); 1798 1799 element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1800 Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3])); 1801 CorrelationToPointMap *correlationmap = NULL; 1802 if (periodic) 1803 correlationmap = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges); 1804 else 1805 correlationmap = CorrelationToPoint(molecules, elemental, Point); 1806 //OutputCorrelationToSurface(&output, correlationmap); 1807 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1808 OutputCorrelation ( &binoutput, binmap ); 1809 output.close(); 1810 binoutput.close(); 1811 delete(Point); 1812 delete(binmap); 1813 delete(correlationmap); 1814 argptr+=9; 1815 } 1816 } 1817 break; 1818 1819 case 'S': 1820 { 1821 if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) { 1822 ExitFlag = 255; 1823 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl); 1824 performCriticalExit(); 1825 } else { 1826 ofstream output(argv[argptr+2]); 1827 ofstream binoutput(argv[argptr+3]); 1828 const double radius = 4.; 1829 const double BinWidth = atof(argv[argptr+4]); 1830 const double BinStart = atof(argv[argptr+5]); 1831 const double BinEnd = atof(argv[argptr+6]); 1832 double LCWidth = 20.; 1833 if (BinEnd > 0) { 1834 if (BinEnd > 2.*radius) 1835 LCWidth = BinEnd; 1836 else 1837 LCWidth = 2.*radius; 1838 } 1839 1840 // get the boundary 1841 class molecule *Boundary = NULL; 1842 class Tesselation *TesselStruct = NULL; 1843 const LinkedCell *LCList = NULL; 1844 // find biggest molecule 1845 int counter = 0; 1846 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1847 if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) { 1848 Boundary = *BigFinder; 1849 } 1850 counter++; 1851 } 1852 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives"); 1853 counter = 0; 1854 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1855 Actives[counter++] = (*BigFinder)->ActiveFlag; 1856 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 1857 } 1858 LCList = new LinkedCell(Boundary, LCWidth); 1859 element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1860 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 1861 CorrelationToSurfaceMap *surfacemap = NULL; 1862 if (periodic) 1863 surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges); 1864 else 1865 surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList); 1866 OutputCorrelationToSurface(&output, surfacemap); 1867 // check whether radius was appropriate 1868 { 1869 double start; double end; 1870 GetMinMax( surfacemap, start, end); 1871 if (LCWidth < end) 1872 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl); 1873 } 1874 BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd ); 1875 OutputCorrelation ( &binoutput, binmap ); 1876 output.close(); 1877 binoutput.close(); 1878 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) 1879 (*BigFinder)->ActiveFlag = Actives[counter++]; 1880 Free(&Actives); 1881 delete(LCList); 1882 delete(TesselStruct); 1883 delete(binmap); 1884 delete(surfacemap); 1885 argptr+=7; 1886 } 1887 } 1888 break; 1889 1890 default: 1891 ExitFlag = 255; 1892 DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl); 1893 performCriticalExit(); 1894 break; 1698 1895 } 1699 counter++;1700 1896 } 1701 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives"); 1702 counter = 0; 1703 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1704 Actives[counter++] = (*BigFinder)->ActiveFlag; 1705 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 1706 } 1707 LCList = new LinkedCell(Boundary, 2.*radius); 1708 element *elemental = periode->FindElement((const int) atoi(argv[argptr])); 1709 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 1710 int ranges[NDIM] = {1,1,1}; 1711 CorrelationToSurfaceMap *surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges ); 1712 OutputCorrelationToSurface(&output, surfacemap); 1713 BinPairMap *binmap = BinData( surfacemap, 0.5, 0., 20. ); 1714 OutputCorrelation ( &binoutput, binmap ); 1715 output.close(); 1716 binoutput.close(); 1717 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) 1718 (*BigFinder)->ActiveFlag = Actives[counter++]; 1719 Free(&Actives); 1720 delete(LCList); 1721 delete(TesselStruct); 1722 argptr+=3; 1723 } 1724 break; 1897 break; 1898 } 1725 1899 case 'E': 1726 1900 if (ExitFlag == 0) ExitFlag = 1; 1727 1901 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) { 1728 1902 ExitFlag = 255; 1729 eLog() << Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;1903 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl); 1730 1904 performCriticalExit(); 1731 1905 } else { … … 1739 1913 case 'F': 1740 1914 if (ExitFlag == 0) ExitFlag = 1; 1741 if (argptr+6 >=argc) { 1915 MaxDistance = -1; 1916 if (argv[argptr-1][2] == 'F') { // option is -FF? 1917 // fetch first argument as max distance to surface 1918 MaxDistance = atof(argv[argptr++]); 1919 Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl; 1920 } 1921 if ((argptr+7 >=argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+7]))) { 1742 1922 ExitFlag = 255; 1743 eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl;1923 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <xyz of filler> <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl); 1744 1924 performCriticalExit(); 1745 1925 } else { … … 1748 1928 // construct water molecule 1749 1929 molecule *filler = new molecule(periode); 1930 if (!filler->AddXYZFile(argv[argptr])) { 1931 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl); 1932 } 1933 filler->SetNameFromFilename(argv[argptr]); 1934 configuration.BG->ConstructBondGraph(filler); 1750 1935 molecule *Filling = NULL; 1751 atom *second = NULL, *third = NULL;1752 // first = new atom();1753 // first->type = periode->FindElement(5);1754 // first->x.Zero();1755 // filler->AddAtom(first);1756 first = new atom();1757 first->type = periode->FindElement(1);1758 first->x.Init(0.441, -0.143, 0.);1759 filler->AddAtom(first);1760 second = new atom();1761 second->type = periode->FindElement(1);1762 second->x.Init(-0.464, 1.137, 0.0);1763 filler->AddAtom(second);1764 third = new atom();1765 third->type = periode->FindElement(8);1766 third->x.Init(-0.464, 0.177, 0.);1767 filler->AddAtom(third);1768 filler->AddBond(first, third, 1);1769 filler->AddBond(second, third, 1);1770 1936 // call routine 1771 1937 double distance[NDIM]; 1772 1938 for (int i=0;i<NDIM;i++) 1773 distance[i] = atof(argv[argptr+i ]);1774 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atof(argv[argptr+5]), atoi(argv[argptr+6]));1939 distance[i] = atof(argv[argptr+i+1]); 1940 Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7])); 1775 1941 if (Filling != NULL) { 1776 1942 Filling->ActiveFlag = false; … … 1785 1951 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1786 1952 ExitFlag =255; 1787 eLog() << Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;1953 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl); 1788 1954 performCriticalExit(); 1789 1955 } else { … … 1800 1966 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1801 1967 ExitFlag =255; 1802 eLog() << Verbose(0) << "Missing path of adjacency file: -j <path>" << endl;1968 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -j <path>" << endl); 1803 1969 performCriticalExit(); 1804 1970 } else { 1805 1971 Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl; 1806 1972 configuration.BG->ConstructBondGraph(mol); 1807 mol->StoreAdjacencyToFile( argv[argptr]);1973 mol->StoreAdjacencyToFile(NULL, argv[argptr]); 1808 1974 argptr+=1; 1809 1975 } … … 1814 1980 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1815 1981 ExitFlag =255; 1816 eLog() << Verbose(0) << "Missing path of bonds file: -j <path>" << endl;1982 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl); 1817 1983 performCriticalExit(); 1818 1984 } else { 1819 1985 Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl; 1820 1986 configuration.BG->ConstructBondGraph(mol); 1821 mol->StoreBondsToFile( argv[argptr]);1987 mol->StoreBondsToFile(NULL, argv[argptr]); 1822 1988 argptr+=1; 1823 1989 } … … 1828 1994 if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){ 1829 1995 ExitFlag = 255; 1830 eLog() << Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;1996 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl); 1831 1997 performCriticalExit(); 1832 1998 } else { … … 1864 2030 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1865 2031 ExitFlag = 255; 1866 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl;2032 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl); 1867 2033 performCriticalExit(); 1868 2034 } else { … … 1882 2048 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1883 2049 ExitFlag = 255; 1884 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl;2050 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl); 1885 2051 performCriticalExit(); 1886 2052 } else { … … 1900 2066 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1901 2067 ExitFlag = 255; 1902 eLog() << Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;2068 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl); 1903 2069 performCriticalExit(); 1904 2070 } else { … … 1916 2082 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) { 1917 2083 ExitFlag = 255; 1918 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;2084 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl); 1919 2085 performCriticalExit(); 1920 2086 } else { … … 1933 2099 } 1934 2100 } else { 1935 eLog() << Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl;2101 DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl); 1936 2102 } 1937 2103 argptr+=2; … … 1942 2108 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1943 2109 ExitFlag = 255; 1944 eLog() << Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;2110 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl); 1945 2111 performCriticalExit(); 1946 2112 } else { … … 1958 2124 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1959 2125 ExitFlag = 255; 1960 eLog() << Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl;2126 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl); 1961 2127 performCriticalExit(); 1962 2128 } else { … … 1974 2140 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1975 2141 ExitFlag = 255; 1976 eLog() << Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl;2142 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl); 1977 2143 performCriticalExit(); 1978 2144 } else { … … 1985 2151 factor[2] = atof(argv[argptr+2]); 1986 2152 mol->Scale((const double ** const)&factor); 2153 double * const cell_size = World::get()->cell_size; 1987 2154 for (int i=0;i<NDIM;i++) { 1988 2155 j += i+1; 1989 2156 x.x[i] = atof(argv[NDIM+i]); 1990 mol->cell_size[j]*=factor[i];2157 cell_size[j]*=factor[i]; 1991 2158 } 1992 2159 delete[](factor); … … 1998 2165 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) { 1999 2166 ExitFlag = 255; 2000 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl;2167 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 2001 2168 performCriticalExit(); 2002 2169 } else { … … 2004 2171 j = -1; 2005 2172 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 2173 double * const cell_size = World::get()->cell_size; 2006 2174 for (int i=0;i<6;i++) { 2007 mol->cell_size[i] = atof(argv[argptr+i]);2175 cell_size[i] = atof(argv[argptr+i]); 2008 2176 } 2009 2177 // center … … 2016 2184 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) { 2017 2185 ExitFlag = 255; 2018 eLog() << Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl;2186 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 2019 2187 performCriticalExit(); 2020 2188 } else { … … 2022 2190 j = -1; 2023 2191 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 2192 double * const cell_size = World::get()->cell_size; 2024 2193 for (int i=0;i<6;i++) { 2025 mol->cell_size[i] = atof(argv[argptr+i]);2194 cell_size[i] = atof(argv[argptr+i]); 2026 2195 } 2027 2196 // center … … 2034 2203 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2035 2204 ExitFlag = 255; 2036 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;2205 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl); 2037 2206 performCriticalExit(); 2038 2207 } else { … … 2045 2214 mol->SetBoxDimension(&x); 2046 2215 // translate each coordinate by boundary 2216 double * const cell_size = World::get()->cell_size; 2047 2217 j=-1; 2048 2218 for (int i=0;i<NDIM;i++) { 2049 2219 j += i+1; 2050 2220 x.x[i] = atof(argv[argptr+i]); 2051 mol->cell_size[j] += x.x[i]*2.;2221 cell_size[j] += x.x[i]*2.; 2052 2222 } 2053 2223 mol->Translate((const Vector *)&x); … … 2068 2238 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr]))) { 2069 2239 ExitFlag = 255; 2070 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl;2240 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl); 2071 2241 performCriticalExit(); 2072 2242 } else { … … 2082 2252 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) { 2083 2253 ExitFlag = 255; 2084 eLog() << Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;2254 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl); 2085 2255 performCriticalExit(); 2086 2256 } else { … … 2102 2272 j = atoi(argv[argptr++]); 2103 2273 if ((j<0) || (j>1)) { 2104 eLog() << Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;2274 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl); 2105 2275 j = 0; 2106 2276 } … … 2116 2286 if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){ 2117 2287 ExitFlag = 255; 2118 eLog() << Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl;2288 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl); 2119 2289 performCriticalExit(); 2120 2290 } else { … … 2141 2311 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) { 2142 2312 ExitFlag = 255; 2143 eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;2313 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl); 2144 2314 performCriticalExit(); 2145 2315 } else { … … 2152 2322 if (volume != -1) 2153 2323 ExitFlag = 255; 2154 eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl;2324 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl); 2155 2325 performCriticalExit(); 2156 2326 } else { … … 2160 2330 density = atof(argv[argptr++]); 2161 2331 if (density < 1.0) { 2162 eLog() << Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl;2332 DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl); 2163 2333 density = 1.3; 2164 2334 } … … 2166 2336 // repetition[i] = atoi(argv[argptr++]); 2167 2337 // if (repetition[i] < 1) 2168 // eLog() << Verbose(1) << "repetition value must be greater 1!" << endl;2338 // DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl); 2169 2339 // repetition[i] = 1; 2170 2340 // } … … 2176 2346 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2177 2347 ExitFlag = 255; 2178 eLog() << Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;2348 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl); 2179 2349 performCriticalExit(); 2180 2350 } else { 2181 2351 SaveFlag = true; 2352 double * const cell_size = World::get()->cell_size; 2182 2353 for (int axis = 1; axis <= NDIM; axis++) { 2183 2354 int faktor = atoi(argv[argptr++]); … … 2186 2357 Vector ** vectors; 2187 2358 if (faktor < 1) { 2188 eLog() << Verbose(1) << "Repetition factor mus be greater than 1!" << endl;2359 DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl); 2189 2360 faktor = 1; 2190 2361 } … … 2203 2374 } 2204 2375 if (count != j) 2205 eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;2376 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 2206 2377 x.Zero(); 2207 2378 y.Zero(); 2208 y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude2379 y.x[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 2209 2380 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 2210 2381 x.AddVector(&y); // per factor one cell width further … … 2227 2398 mol->Translate(&x); 2228 2399 } 2229 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;2400 cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 2230 2401 } 2231 2402 } … … 2269 2440 2270 2441 cout << ESPACKVersion << endl; 2442 2443 Log() << Verbose(1) << "test" << endl; 2444 DoLog(3) && (Log() << Verbose(1) << "test"); 2271 2445 2272 2446 setVerbosity(0); … … 2296 2470 if (molecules->ListOfMolecules.size() == 0) { 2297 2471 mol = new molecule(periode); 2298 if (mol->cell_size[0] == 0.) { 2472 double * const cell_size = World::get()->cell_size; 2473 if (cell_size[0] == 0.) { 2299 2474 Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl; 2300 2475 for (int i=0;i<6;i++) { 2301 2476 Log() << Verbose(1) << "Cell size" << i << ": "; 2302 cin >> mol->cell_size[i];2477 cin >> cell_size[i]; 2303 2478 } 2304 2479 } -
src/config.cpp
r8ab0407 rc7b1e7 19 19 #include "molecule.hpp" 20 20 #include "periodentafel.hpp" 21 #include "World.hpp" 21 22 22 23 /******************************** Functions for class ConfigFileBuffer **********************/ … … 73 74 file= new ifstream(filename); 74 75 if (file == NULL) { 75 eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;76 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 76 77 return; 77 78 } … … 88 89 // allocate buffer's 1st dimension 89 90 if (buffer != NULL) { 90 eLog() << Verbose(1) << "FileBuffer->buffer is not NULL!" << endl;91 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl); 91 92 return; 92 93 } else … … 143 144 map<const char *, int, IonTypeCompare> IonTypeLineMap; 144 145 if (LineMapping == NULL) { 145 eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl;146 DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl); 146 147 performCriticalExit(); 147 148 return; … … 159 160 LineMapping[CurrentLine+(nr++)] = runner->second; 160 161 else { 161 eLog() << Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl;162 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl); 162 163 performCriticalExit(); 163 164 } … … 499 500 // case 'j': // BoxLength 500 501 // Log() << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl; 502 // double * const cell_size = World::get()->cell_size; 501 503 // for (int i=0;i<6;i++) { 502 504 // Log() << Verbose(0) << "Cell size" << i << ": "; 503 // cin >> mol->cell_size[i];505 // cin >> cell_size[i]; 504 506 // } 505 507 // break; … … 657 659 { 658 660 if (FileBuffer != NULL) { 659 eLog() << Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl;661 DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl); 660 662 delete(FileBuffer); 661 663 } … … 683 685 684 686 if (mol == NULL) { 685 eLog() << Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit.";687 DoeLog(0) && (eLog()<< Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit."); 686 688 performCriticalExit(); 687 689 } … … 689 691 ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical); 690 692 if (MaxTypes == 0) { 691 eLog() << Verbose(0) << "There are no atoms according to MaxTypes in this config file." << endl;692 performCriticalExit();693 DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms according to MaxTypes in this config file." << endl); 694 //performCriticalExit(); 693 695 } else { 694 696 // prescan number of ions per type … … 708 710 sprintf(name,"Ion_Type%i",MaxTypes); 709 711 if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) { 710 eLog() << Verbose(0) << "There are no atoms in the config file!" << endl;712 DoeLog(0) && (eLog()<< Verbose(0) << "There are no atoms in the config file!" << endl); 711 713 performCriticalExit(); 712 714 return; … … 853 855 ifstream *file = new ifstream(filename); 854 856 if (file == NULL) { 855 eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;857 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 856 858 return; 857 859 } … … 965 967 // Unit cell and magnetic field 966 968 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 967 mol->cell_size[0] = BoxLength[0]; 968 mol->cell_size[1] = BoxLength[3]; 969 mol->cell_size[2] = BoxLength[4]; 970 mol->cell_size[3] = BoxLength[6]; 971 mol->cell_size[4] = BoxLength[7]; 972 mol->cell_size[5] = BoxLength[8]; 969 double * const cell_size = World::get()->cell_size; 970 cell_size[0] = BoxLength[0]; 971 cell_size[1] = BoxLength[3]; 972 cell_size[2] = BoxLength[4]; 973 cell_size[3] = BoxLength[6]; 974 cell_size[4] = BoxLength[7]; 975 cell_size[5] = BoxLength[8]; 973 976 //if (1) fprintf(stderr,"\n"); 974 977 … … 1062 1065 Log() << Verbose(0) << "Bond length table loaded successfully." << endl; 1063 1066 } else { 1064 eLog() << Verbose(1) << "Bond length table loading failed." << endl;1067 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl); 1065 1068 } 1066 1069 } … … 1091 1094 ifstream *file = new ifstream(filename); 1092 1095 if (file == NULL) { 1093 eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;1096 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 1094 1097 return; 1095 1098 } … … 1169 1172 1170 1173 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 1171 mol->cell_size[0] = BoxLength[0]; 1172 mol->cell_size[1] = BoxLength[3]; 1173 mol->cell_size[2] = BoxLength[4]; 1174 mol->cell_size[3] = BoxLength[6]; 1175 mol->cell_size[4] = BoxLength[7]; 1176 mol->cell_size[5] = BoxLength[8]; 1174 double * const cell_size = World::get()->cell_size; 1175 cell_size[0] = BoxLength[0]; 1176 cell_size[1] = BoxLength[3]; 1177 cell_size[2] = BoxLength[4]; 1178 cell_size[3] = BoxLength[6]; 1179 cell_size[4] = BoxLength[7]; 1180 cell_size[5] = BoxLength[8]; 1177 1181 if (1) fprintf(stderr,"\n"); 1178 1182 config::DoPerturbation = 0; … … 1312 1316 // bring MaxTypes up to date 1313 1317 mol->CountElements(); 1318 const double * const cell_size = World::get()->cell_size; 1314 1319 ofstream * const output = new ofstream(filename, ios::out); 1315 1320 if (output != NULL) { … … 1382 1387 *output << endl; 1383 1388 *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl; 1384 *output << mol->cell_size[0] << "\t" << endl;1385 *output << mol->cell_size[1] << "\t" << mol->cell_size[2] << "\t" << endl;1386 *output << mol->cell_size[3] << "\t" << mol->cell_size[4] << "\t" << mol->cell_size[5] << "\t" << endl;1389 *output << cell_size[0] << "\t" << endl; 1390 *output << cell_size[1] << "\t" << cell_size[2] << "\t" << endl; 1391 *output << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5] << "\t" << endl; 1387 1392 // FIXME 1388 1393 *output << endl; … … 1428 1433 return result; 1429 1434 } else { 1430 eLog() << Verbose(1) << "Cannot open output file:" << filename << endl;1435 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file:" << filename << endl); 1431 1436 return false; 1432 1437 } … … 1450 1455 output = new ofstream(fname->str().c_str(), ios::out); 1451 1456 if (output == NULL) { 1452 eLog() << Verbose(1) << "Cannot open mpqc output file:" << fname << endl;1457 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file:" << fname << endl); 1453 1458 delete(fname); 1454 1459 return false; … … 1493 1498 output = new ofstream(fname->str().c_str(), ios::out); 1494 1499 if (output == NULL) { 1495 eLog() << Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl;1500 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl); 1496 1501 delete(fname); 1497 1502 return false; … … 1549 1554 f = fopen(name, "w" ); 1550 1555 if (f == NULL) { 1551 eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;1556 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1552 1557 return false; 1553 1558 } … … 1604 1609 f = fopen(name, "w" ); 1605 1610 if (f == NULL) { 1606 eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;1611 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1607 1612 Free(&elementNo); 1608 1613 return false; … … 1641 1646 /** Stores all atoms in a TREMOLO data input file. 1642 1647 * Note that this format cannot be parsed again. 1648 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded! 1643 1649 * \param *filename name of file (without ".in" suffix!) 1644 1650 * \param *mol pointer to molecule … … 1653 1659 output = new ofstream(fname->str().c_str(), ios::out); 1654 1660 if (output == NULL) { 1655 eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;1661 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl); 1656 1662 delete(fname); 1657 1663 return false; … … 1695 1701 /** Stores all atoms from all molecules in a TREMOLO data input file. 1696 1702 * Note that this format cannot be parsed again. 1703 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded! 1697 1704 * \param *filename name of file (without ".in" suffix!) 1698 1705 * \param *MolList pointer to MoleculeListClass containing all atoms … … 1707 1714 output = new ofstream(fname->str().c_str(), ios::out); 1708 1715 if (output == NULL) { 1709 eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;1716 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl); 1710 1717 delete(fname); 1711 1718 return false; … … 1747 1754 while (Walker->next != (*MolWalker)->end) { 1748 1755 Walker = Walker->next; 1749 *output << AtomNo << "\t";1756 *output << AtomNo+1 << "\t"; 1750 1757 *output << Walker->Name << "\t"; 1751 1758 *output << (*MolWalker)->name << "\t"; 1752 *output << MolCounter << "\t";1759 *output << MolCounter+1 << "\t"; 1753 1760 *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t"; 1754 1761 *output << (double)Walker->type->Valence << "\t"; 1755 1762 *output << Walker->type->symbol << "\t"; 1756 1763 for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++) 1757 *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ] << "\t";1764 *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1 << "\t"; 1758 1765 for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++) 1759 1766 *output << "-\t"; -
src/defs.hpp
r8ab0407 rc7b1e7 12 12 #define MAX_ELEMENTS 128 //!< maximum number of elements for certain lookup tables 13 13 #define AtomicLengthToAngstroem 0.52917721 //!< conversion factor from atomic length/bohrradius to angstroem 14 #define BONDTHRESHOLD 0.5 //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii15 14 #define AtomicEnergyToKelvin 315774.67 //!< conversion factor from atomic energy to kelvin via boltzmann factor 16 15 #define KelvinToAtomicTemperature 3.1668152e-06 //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B) -
src/ellipsoid.cpp
r8ab0407 rc7b1e7 241 241 x = new Vector[PointsToPick]; 242 242 } else { 243 eLog() << Verbose(2) << "Given pointer to vector array seems already allocated." << endl;243 DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl); 244 244 } 245 245 … … 341 341 x = new Vector[PointsToPick]; 342 342 } else { 343 eLog() << Verbose(2) << "Given pointer to vector array seems already allocated." << endl;343 DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl); 344 344 } 345 345 -
src/gslvector.cpp
r8ab0407 rc7b1e7 6 6 */ 7 7 8 #include <cassert> 9 #include <cmath> 10 8 11 #include "gslvector.hpp" 12 #include "defs.hpp" 9 13 10 14 /** Constructor of class GSLVector. … … 27 31 }; 28 32 33 /** Copy constructor of class GSLVector. 34 * Allocates GSL structures and copies components from \a *src. 35 * \param *src source vector 36 */ 37 GSLVector::GSLVector(const GSLVector & src) : dimension(src.dimension) 38 { 39 vector = gsl_vector_alloc(dimension); 40 gsl_vector_memcpy (vector, src.vector); 41 }; 42 29 43 /** Destructor of class GSLVector. 30 44 * Frees GSL structures … … 33 47 { 34 48 gsl_vector_free(vector); 35 dimension = 0;36 49 }; 37 50 … … 52 65 * \return m-th element of vector 53 66 */ 54 double GSLVector::Get(size_t m) 67 double GSLVector::Get(size_t m) const 55 68 { 56 69 return gsl_vector_get (vector, m); … … 72 85 * \return pointer to \a m-th element 73 86 */ 74 double *GSLVector::Pointer(size_t m) 87 double *GSLVector::Pointer(size_t m) const 75 88 { 76 89 return gsl_vector_ptr (vector, m); … … 82 95 * \return const pointer to \a m-th element 83 96 */ 84 const double *GSLVector::const_Pointer(size_t m) 97 const double *GSLVector::const_Pointer(size_t m) const 85 98 { 86 99 return gsl_vector_const_ptr (vector, m); 100 }; 101 102 /** Returns the dimension of the vector. 103 * \return dimension of vector 104 */ 105 #ifdef HAVE_INLINE 106 inline 107 #endif 108 size_t GSLVector::GetDimension() const 109 { 110 return dimension; 87 111 }; 88 112 … … 128 152 return gsl_vector_reverse (vector); 129 153 }; 154 155 156 /* ========================== Operators =============================== */ 157 /** Compares GSLVector \a to GSLVector \a b component-wise. 158 * \param a base GSLVector 159 * \param b GSLVector components to add 160 * \return a == b 161 */ 162 bool operator==(const GSLVector& a, const GSLVector& b) 163 { 164 bool status = true; 165 assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ"); 166 for (size_t i=0;i<a.GetDimension();i++) 167 status = status && (fabs(a.Get(i) - b.Get(i)) < MYEPSILON); 168 return status; 169 }; 170 171 /** Sums GSLVector \a to this lhs component-wise. 172 * \param a base GSLVector 173 * \param b GSLVector components to add 174 * \return lhs + a 175 */ 176 const GSLVector& operator+=(GSLVector& a, const GSLVector& b) 177 { 178 assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ"); 179 for (size_t i=0;i<a.GetDimension();i++) 180 a.Set(i,a.Get(i)+b.Get(i)); 181 return a; 182 }; 183 184 /** Subtracts GSLVector \a from this lhs component-wise. 185 * \param a base GSLVector 186 * \param b GSLVector components to add 187 * \return lhs - a 188 */ 189 const GSLVector& operator-=(GSLVector& a, const GSLVector& b) 190 { 191 assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ"); 192 for (size_t i=0;i<a.GetDimension();i++) 193 a.Set(i,a.Get(i)-b.Get(i)); 194 return a; 195 }; 196 197 /** factor each component of \a a times a double \a m. 198 * \param a base GSLVector 199 * \param m factor 200 * \return lhs.Get(i) * m 201 */ 202 const GSLVector& operator*=(GSLVector& a, const double m) 203 { 204 for (size_t i=0;i<a.GetDimension();i++) 205 a.Set(i,a.Get(i)*m); 206 return a; 207 }; 208 209 /** Sums two GSLVectors \a and \b component-wise. 210 * \param a first GSLVector 211 * \param b second GSLVector 212 * \return a + b 213 */ 214 GSLVector const operator+(const GSLVector& a, const GSLVector& b) 215 { 216 GSLVector x(a); 217 for (size_t i=0;i<a.GetDimension();i++) 218 x.Set(i,a.Get(i)+b.Get(i)); 219 return x; 220 }; 221 222 /** Subtracts GSLVector \a from \b component-wise. 223 * \param a first GSLVector 224 * \param b second GSLVector 225 * \return a - b 226 */ 227 GSLVector const operator-(const GSLVector& a, const GSLVector& b) 228 { 229 assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ"); 230 GSLVector x(a); 231 for (size_t i=0;i<a.GetDimension();i++) 232 x.Set(i,a.Get(i)-b.Get(i)); 233 return x; 234 }; 235 236 /** Factors given GSLVector \a a times \a m. 237 * \param a GSLVector 238 * \param m factor 239 * \return m * a 240 */ 241 GSLVector const operator*(const GSLVector& a, const double m) 242 { 243 GSLVector x(a); 244 for (size_t i=0;i<a.GetDimension();i++) 245 x.Set(i,a.Get(i)*m); 246 return x; 247 }; 248 249 /** Factors given GSLVector \a a times \a m. 250 * \param m factor 251 * \param a GSLVector 252 * \return m * a 253 */ 254 GSLVector const operator*(const double m, const GSLVector& a ) 255 { 256 GSLVector x(a); 257 for (size_t i=0;i<a.GetDimension();i++) 258 x.Set(i,a.Get(i)*m); 259 return x; 260 }; 261 262 ostream& operator<<(ostream& ost, const GSLVector& m) 263 { 264 ost << "("; 265 for (size_t i=0;i<m.GetDimension();i++) { 266 ost << m.Get(i); 267 if (i != 2) 268 ost << ","; 269 } 270 ost << ")"; 271 return ost; 272 }; 273 274 /* ====================== Checking State ============================ */ 275 /** Checks whether vector has all components zero. 276 * @return true - vector is zero, false - vector is not 277 */ 278 bool GSLVector::IsZero() const 279 { 280 return (fabs(Get(0))+fabs(Get(1))+fabs(Get(2)) < MYEPSILON); 281 }; 282 283 /** Checks whether vector has length of 1. 284 * @return true - vector is normalized, false - vector is not 285 */ 286 bool GSLVector::IsOne() const 287 { 288 double NormValue = 0.; 289 for (size_t i=dimension;--i;) 290 NormValue += Get(i)*Get(i); 291 return (fabs(NormValue - 1.) < MYEPSILON); 292 }; 293 -
src/gslvector.hpp
r8ab0407 rc7b1e7 18 18 #endif 19 19 20 #include <iostream> 20 21 #include <gsl/gsl_vector.h> 21 22 … … 32 33 GSLVector(size_t m); 33 34 GSLVector(const GSLVector * const src); 35 GSLVector(const GSLVector & src); 34 36 ~GSLVector(); 35 37 36 38 // Accessing 37 39 void SetFromDoubleArray(double *x); 38 double Get(size_t m) ;40 double Get(size_t m) const; 39 41 void Set(size_t m, double x); 40 double *Pointer(size_t m); 41 const double *const_Pointer(size_t m); 42 double *Pointer(size_t m) const; 43 const double *const_Pointer(size_t m) const; 44 size_t GetDimension() const; 42 45 43 46 // Initializing … … 50 53 int Reverse(); 51 54 55 // checking state 56 bool IsZero() const; 57 bool IsOne() const; 58 52 59 private: 53 60 gsl_vector *vector; 54 61 55 size_t dimension;62 const size_t dimension; 56 63 }; 64 65 ostream & operator << (ostream& ost, const GSLVector &m); 66 bool operator==(const GSLVector& a, const GSLVector& b); 67 const GSLVector& operator+=(GSLVector& a, const GSLVector& b); 68 const GSLVector& operator-=(GSLVector& a, const GSLVector& b); 69 const GSLVector& operator*=(GSLVector& a, const double m); 70 GSLVector const operator*(const GSLVector& a, const double m); 71 GSLVector const operator*(const double m, const GSLVector& a); 72 GSLVector const operator+(const GSLVector& a, const GSLVector& b); 73 GSLVector const operator-(const GSLVector& a, const GSLVector& b); 74 57 75 58 76 -
src/helpers.hpp
r8ab0407 rc7b1e7 134 134 LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable"); 135 135 if (LookupTable == NULL) { 136 eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;136 DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl); 137 137 performCriticalExit(); 138 138 status = false; -
src/linkedcell.cpp
r8ab0407 rc7b1e7 46 46 min.Zero(); 47 47 Log() << Verbose(1) << "Begin of LinkedCell" << endl; 48 if ( set->IsEmpty()) {49 eLog() << Verbose(1) << "set contains no linked cell nodes!" << endl;48 if ((set == NULL) || (set->IsEmpty())) { 49 DoeLog(1) && (eLog()<< Verbose(1) << "set is NULL or contains no linked cell nodes!" << endl); 50 50 return; 51 51 } … … 79 79 Log() << Verbose(2) << "Allocating cells ... "; 80 80 if (LC != NULL) { 81 eLog() << Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl;81 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl); 82 82 return; 83 83 } … … 122 122 Log() << Verbose(1) << "Begin of LinkedCell" << endl; 123 123 if (set->empty()) { 124 eLog() << Verbose(1) << "set contains no linked cell nodes!" << endl;124 DoeLog(1) && (eLog()<< Verbose(1) << "set contains no linked cell nodes!" << endl); 125 125 return; 126 126 } … … 151 151 Log() << Verbose(2) << "Allocating cells ... "; 152 152 if (LC != NULL) { 153 eLog() << Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl;153 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl); 154 154 return; 155 155 } … … 199 199 status = status && ((n[i] >=0) && (n[i] < N[i])); 200 200 if (!status) 201 eLog() << Verbose(1) << "indices are out of bounds!" << endl;201 DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl); 202 202 return status; 203 203 }; … … 260 260 return status; 261 261 } else { 262 eLog() << Verbose(1) << "Node at " << *Walker << " is out of bounds." << endl;262 DoeLog(1) && (eLog()<< Verbose(1) << "Node at " << *Walker << " is out of bounds." << endl); 263 263 return false; 264 264 } -
src/log.cpp
r8ab0407 rc7b1e7 28 28 } 29 29 30 /** Checks verbosity for logger. 31 * Is supposed to be used in construct as this: 32 * DoLog(2) && (Log() << Verbose(2) << "message." << endl); 33 * If DoLog does not return true, the right-hand side is not evaluated and we save some time. 34 * \param verbose verbosity level of this message 35 * \return true - print, false - don't 36 */ 37 bool DoLog(int verbose) { 38 return verbose <= logger::getInstance()->verbosity; 39 } 40 41 /** Checks verbosity for errorlogger. 42 * Is supposed to be used in construct as this: 43 * DoLog(2) && (Log() << Verbose(2) << "message." << endl); 44 * If DoLog does not return true, the right-hand side is not evaluated and we save some time. 45 * \param verbose verbosity level of this message 46 * \return true - print, false - don't 47 */ 48 bool DoeLog(int verbose) { 49 return verbose <= errorLogger::getInstance()->verbosity; 50 } 51 30 52 /** 31 53 * Prints an error log entry. -
src/log.hpp
r8ab0407 rc7b1e7 15 15 class errorLogger * eLog(); 16 16 void setVerbosity(int verbosityLevel); 17 bool DoLog(int verbose); 18 bool DoeLog(int verbose); 17 19 18 20 #endif /* LOG_HPP_ */ -
src/molecule.cpp
r8ab0407 rc7b1e7 23 23 #include "tesselation.hpp" 24 24 #include "vector.hpp" 25 #include "World.hpp" 25 26 26 27 /************************************* Functions for class molecule *********************************/ … … 45 46 for(int i=MAX_ELEMENTS;i--;) 46 47 ElementsInMolecule[i] = 0; 47 cell_size[0] = cell_size[2] = cell_size[5]= 20.; 48 cell_size[1] = cell_size[3] = cell_size[4]= 0.; 49 strcpy(name,"none"); 48 strcpy(name,World::get()->DefaultName); 50 49 }; 51 50 … … 159 158 double *matrix = NULL; 160 159 bond *Binder = NULL; 160 double * const cell_size = World::get()->cell_size; 161 161 162 162 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 194 194 BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1]; 195 195 if (BondRescale == -1) { 196 eLog() << Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;196 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl); 197 197 return false; 198 198 BondRescale = bondlength; … … 237 237 SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin); 238 238 } else { 239 eLog() << Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name;239 DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name); 240 240 } 241 241 } … … 274 274 bondangle = TopOrigin->type->HBondAngle[1]; 275 275 if (bondangle == -1) { 276 eLog() << Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;276 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl); 277 277 return false; 278 278 bondangle = 0; … … 396 396 break; 397 397 default: 398 eLog() << Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl;398 DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl); 399 399 AllWentWell = false; 400 400 break; … … 447 447 Walker->type = elemente->FindElement(shorthand); 448 448 if (Walker->type == NULL) { 449 eLog() << Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.";449 DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H."); 450 450 Walker->type = elemente->FindElement(1); 451 451 } … … 543 543 add(Binder, last); 544 544 } else { 545 eLog() << Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl;545 DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl); 546 546 } 547 547 return Binder; … … 555 555 bool molecule::RemoveBond(bond *pointer) 556 556 { 557 // eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;557 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 558 558 pointer->leftatom->RegisterBond(pointer); 559 559 pointer->rightatom->RegisterBond(pointer); … … 569 569 bool molecule::RemoveBonds(atom *BondPartner) 570 570 { 571 // eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;571 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 572 572 BondList::const_iterator ForeRunner; 573 573 while (!BondPartner->ListOfBonds.empty()) { … … 603 603 void molecule::SetBoxDimension(Vector *dim) 604 604 { 605 double * const cell_size = World::get()->cell_size; 605 606 cell_size[0] = dim->x[0]; 606 607 cell_size[1] = 0.; … … 621 622 AtomCount--; 622 623 } else 623 eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;624 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 624 625 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 625 626 ElementCount--; … … 639 640 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 640 641 else 641 eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;642 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 642 643 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 643 644 ElementCount--; … … 693 694 bool molecule::CheckBounds(const Vector *x) const 694 695 { 696 double * const cell_size = World::get()->cell_size; 695 697 bool result = true; 696 698 int j =-1; -
src/molecule.hpp
r8ab0407 rc7b1e7 82 82 class molecule : public PointCloud { 83 83 public: 84 double cell_size[6];//!< cell size85 84 const periodentafel * const elemente; //!< periodic table with each element 86 85 atom *start; //!< start of atom list -
src/molecule_dynamics.cpp
r8ab0407 rc7b1e7 306 306 for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1 307 307 if (Params.DoubleList[i] > 1) { 308 eLog() << Verbose(0) << "Failed to create an injective PermutationMap!" << endl;308 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl); 309 309 performCriticalExit(); 310 310 } … … 428 428 } 429 429 if (Potential > Params.PenaltyConstants[2]) { 430 eLog() << Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl;430 DoeLog(1) && (eLog()<< Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl); 431 431 exit(255); 432 432 } 433 433 //Log() << Verbose(0) << endl; 434 434 } else { 435 eLog() << Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl;435 DoeLog(1) && (eLog()<< Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl); 436 436 exit(255); 437 437 } … … 568 568 // parse file into ForceMatrix 569 569 if (!Force.ParseMatrix(file, 0,0,0)) { 570 eLog() << Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl;570 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl); 571 571 performCriticalExit(); 572 572 return false; 573 573 } 574 574 if (Force.RowCounter[0] != AtomCount) { 575 eLog() << Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl;575 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl); 576 576 performCriticalExit(); 577 577 return false; -
src/molecule_fragmentation.cpp
r8ab0407 rc7b1e7 18 18 #include "molecule.hpp" 19 19 #include "periodentafel.hpp" 20 #include "World.hpp" 20 21 21 22 /************************************* Functions for class molecule *********************************/ … … 112 113 testGraphInsert = FragmentList->insert(GraphPair (CurrentSet,pair<int,double>(NumberOfFragments++,1))); // store fragment number and current factor 113 114 if (!testGraphInsert.second) { 114 eLog() << Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl;115 DoeLog(0) && (eLog()<< Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl); 115 116 performCriticalExit(); 116 117 } … … 213 214 Log() << Verbose(0) << "done." << endl; 214 215 } else { 215 eLog() << Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl;216 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl); 216 217 performCriticalExit(); 217 218 status = false; … … 371 372 } 372 373 } else { 373 eLog() << Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl;374 DoeLog(0) && (eLog()<< Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl); 374 375 performCriticalExit(); 375 376 } … … 446 447 // transmorph graph keyset list into indexed KeySetList 447 448 if (GlobalKeySetList == NULL) { 448 eLog() << Verbose(1) << "Given global key set list (graph) is NULL!" << endl;449 DoeLog(1) && (eLog()<< Verbose(1) << "Given global key set list (graph) is NULL!" << endl); 449 450 return false; 450 451 } … … 454 455 map<int, pair<double,int> > *AdaptiveCriteriaList = ScanAdaptiveFileIntoMap(path, *IndexKeySetList); // (Root No., (Value, Order)) ! 455 456 if (AdaptiveCriteriaList->empty()) { 456 eLog() << Verbose(2) << "Unable to parse file, incrementing all." << endl;457 DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl); 457 458 while (Walker->next != end) { 458 459 Walker = Walker->next; … … 643 644 MolecularWalker->Leaf->FragmentBOSSANOVA(FragmentList[FragmentCounter], RootStack[FragmentCounter], MinimumRingSize); 644 645 } else { 645 eLog() << Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl;646 DoeLog(1) && (eLog()<< Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl); 646 647 } 647 648 FragmentCounter++; // next fragment list … … 847 848 848 849 Leaf->BondDistance = mol->BondDistance; 849 for(int i=NDIM*2;i--;)850 Leaf->cell_size[i] = mol->cell_size[i];851 850 852 851 // first create the minimal set of atoms from the KeySet … … 907 906 } 908 907 } else { 909 eLog() << Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;908 DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl); 910 909 } 911 910 if ((LonelyFlag) && (Leaf->AtomCount > 1)) { … … 1142 1141 Log() << Verbose(0) << endl; 1143 1142 //if (!CheckForConnectedSubgraph(FragmentSearch->FragmentSet)) 1144 // eLog() << Verbose(1) << "The found fragment is not a connected subgraph!" << endl;1143 //DoeLog(1) && (eLog()<< Verbose(1) << "The found fragment is not a connected subgraph!" << endl); 1145 1144 InsertFragmentIntoGraph(FragmentSearch); 1146 1145 } … … 1658 1657 atom *Walker = NULL; 1659 1658 atom *OtherWalker = NULL; 1659 double * const cell_size = World::get()->cell_size; 1660 1660 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1661 1661 enum Shading *ColorList = NULL; -
src/molecule_geometry.cpp
r8ab0407 rc7b1e7 15 15 #include "memoryallocator.hpp" 16 16 #include "molecule.hpp" 17 #include "World.hpp" 17 18 18 19 /************************************* Functions for class molecule *********************************/ … … 26 27 bool status = true; 27 28 const Vector *Center = DetermineCenterOfAll(); 29 double * const cell_size = World::get()->cell_size; 28 30 double *M = ReturnFullMatrixforSymmetric(cell_size); 29 31 double *Minv = InverseMatrix(M); … … 46 48 { 47 49 bool status = true; 50 double * const cell_size = World::get()->cell_size; 48 51 double *M = ReturnFullMatrixforSymmetric(cell_size); 49 52 double *Minv = InverseMatrix(M); … … 226 229 void molecule::TranslatePeriodically(const Vector *trans) 227 230 { 231 double * const cell_size = World::get()->cell_size; 228 232 double *M = ReturnFullMatrixforSymmetric(cell_size); 229 233 double *Minv = InverseMatrix(M); … … 252 256 { 253 257 atom *Walker = start; 258 double * const cell_size = World::get()->cell_size; 254 259 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 255 260 double *inversematrix = InverseMatrix(cell_size); -
src/molecule_graph.cpp
r8ab0407 rc7b1e7 17 17 #include "memoryallocator.hpp" 18 18 #include "molecule.hpp" 19 #include "World.hpp" 19 20 20 21 struct BFSAccounting … … 106 107 LinkedCell *LC = NULL; 107 108 bool free_BG = false; 109 double * const cell_size = World::get()->cell_size; 108 110 109 111 if (BG == NULL) { … … 493 495 bond *Binder = NULL; 494 496 497 if (AtomCount == 0) 498 return SubGraphs; 495 499 Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl; 496 500 DepthFirstSearchAnalysis_Init(DFS, this); … … 927 931 } 928 932 if (i == vertex->ListOfBonds.size()) { 929 eLog() << Verbose(0) << "Error: All Component entries are already occupied!" << endl;933 DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl); 930 934 performCriticalExit(); 931 935 } 932 936 } else { 933 eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl;937 DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl); 934 938 performCriticalExit(); 935 939 } -
src/moleculelist.cpp
r8ab0407 rc7b1e7 19 19 #include "memoryallocator.hpp" 20 20 #include "periodentafel.hpp" 21 #include "World.hpp" 21 22 22 23 /*********************************** Functions for class MoleculeListClass *************************/ … … 313 314 Tesselation *TesselStruct = NULL; 314 315 if ((srcmol == NULL) || (mol == NULL)) { 315 eLog() << Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl;316 DoeLog(1) && (eLog()<< Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl); 316 317 return false; 317 318 } … … 321 322 FindNonConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, 4., NULL); 322 323 if (TesselStruct == NULL) { 323 eLog() << Verbose(1) << "Could not tesselate the fixed molecule." << endl;324 DoeLog(1) && (eLog()<< Verbose(1) << "Could not tesselate the fixed molecule." << endl); 324 325 return false; 325 326 } … … 442 443 input.open(line.c_str()); 443 444 if (input == NULL) { 444 eLog() << Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl;445 DoeLog(0) && (eLog()<< Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl); 445 446 performCriticalExit(); 446 447 return false; … … 638 639 int FragmentCounter = 0; 639 640 ofstream output; 640 641 double cell_size_backup[6]; 642 double * const cell_size = World::get()->cell_size; 643 644 // backup cell_size 645 for (int i=0;i<6;i++) 646 cell_size_backup[i] = cell_size[i]; 641 647 // store the fragments as config and as xyz 642 648 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { … … 646 652 strcpy(PathBackup, path); 647 653 else { 648 eLog() << Verbose(0) << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl;654 DoeLog(0) && (eLog()<< Verbose(0) << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl); 649 655 performCriticalExit(); 650 656 } … … 682 688 j += k + 1; 683 689 BoxDimension.x[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem); 684 (*ListRunner)->cell_size[j] += BoxDimension.x[k] * 2.;690 cell_size[j] = BoxDimension.x[k] * 2.; 685 691 } 686 692 (*ListRunner)->Translate(&BoxDimension); … … 724 730 // printing final number 725 731 Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl; 732 733 // restore cell_size 734 for (int i=0;i<6;i++) 735 cell_size[i] = cell_size_backup[i]; 726 736 727 737 return result; … … 776 786 777 787 // 1. dissect the molecule into connected subgraphs 778 configuration->BG->ConstructBondGraph(mol); 788 if (!configuration->BG->ConstructBondGraph(mol)) { 789 delete (mol); 790 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 791 return; 792 } 779 793 780 794 // 2. scan for connected subgraphs … … 783 797 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 784 798 delete(BackEdgeStack); 799 if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) { 800 delete (mol); 801 DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl); 802 return; 803 } 785 804 786 805 // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in … … 824 843 Walker = mol->start->next; 825 844 if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) { 826 eLog() << Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl;845 DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl); 827 846 performCriticalExit(); 828 847 } … … 833 852 molecules[FragmentCounter-1]->AddAtom(Walker); // counting starts at 1 834 853 } else { 835 eLog() << Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl;854 DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl); 836 855 performCriticalExit(); 837 856 } -
src/parser.cpp
r8ab0407 rc7b1e7 160 160 //Log() << Verbose(1) << "Opening " << name << " ... " << input << endl; 161 161 if (input == NULL) { 162 eLog() << Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl;162 DoeLog(1) && (eLog()<< Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl); 163 163 //performCriticalExit(); 164 164 return false; … … 183 183 //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl; 184 184 if (ColumnCounter[MatrixNr] == 0) { 185 eLog() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;185 DoeLog(0) && (eLog()<< Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl); 186 186 performCriticalExit(); 187 187 } … … 199 199 //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl; 200 200 if (RowCounter[MatrixNr] == 0) { 201 eLog() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;201 DoeLog(0) && (eLog()<< Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl); 202 202 performCriticalExit(); 203 203 } … … 232 232 } 233 233 } else { 234 eLog() << Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;234 DoeLog(1) && (eLog()<< Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl); 235 235 } 236 236 input.close(); … … 433 433 //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl; 434 434 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 435 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;435 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl); 436 436 performCriticalExit(); 437 437 return false; … … 477 477 output.open(line.str().c_str(), ios::out); 478 478 if (output == NULL) { 479 eLog() << Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl;479 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl); 480 480 performCriticalExit(); 481 481 return false; … … 507 507 output.open(line.str().c_str(), ios::out); 508 508 if (output == NULL) { 509 eLog() << Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl;509 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl); 510 510 performCriticalExit(); 511 511 return false; … … 664 664 int j = Indices[ FragmentNr ][l]; 665 665 if (j > RowCounter[MatrixCounter]) { 666 eLog() << Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl;666 DoeLog(0) && (eLog()<< Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl); 667 667 performCriticalExit(); 668 668 return false; … … 802 802 int j = Indices[ FragmentNr ][l]; 803 803 if (j > RowCounter[MatrixCounter]) { 804 eLog() << Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;804 DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl); 805 805 performCriticalExit(); 806 806 return false; … … 810 810 int k = Indices[ FragmentNr ][m]; 811 811 if (k > ColumnCounter[MatrixCounter]) { 812 eLog() << Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;812 DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl); 813 813 performCriticalExit(); 814 814 return false; … … 863 863 //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl; 864 864 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 865 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;865 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl); 866 866 performCriticalExit(); 867 867 return false; … … 881 881 //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl; 882 882 if (n > ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 883 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;883 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl); 884 884 performCriticalExit(); 885 885 return false; -
src/periodentafel.cpp
r8ab0407 rc7b1e7 314 314 315 315 if (!otherstatus) 316 eLog() << Verbose(2) << "Something went wrong while parsing the other databases!" << endl;316 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl); 317 317 318 318 return status; -
src/stackclass.hpp
r8ab0407 rc7b1e7 72 72 return true; 73 73 } else { 74 eLog() << Verbose(1) << "Stack is full, " << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tNextFreeField " << NextFreeField << "\tEntryCount " << EntryCount << "!" << endl;74 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is full, " << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tNextFreeField " << NextFreeField << "\tEntryCount " << EntryCount << "!" << endl); 75 75 return false; 76 76 } … … 87 87 Walker = StackList[CurrentFirstEntry]; 88 88 if (Walker == NULL) 89 eLog() << Verbose(1) << "Stack's field is empty!" << endl;89 DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl); 90 90 StackList[CurrentFirstEntry] = NULL; 91 91 if (CurrentFirstEntry != CurrentLastEntry) { // hasn't last item been popped as well? … … 96 96 } 97 97 } else 98 eLog() << Verbose(1) << "Stack is empty!" << endl;98 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl); 99 99 return Walker; 100 100 }; … … 111 111 StackList[CurrentLastEntry] = NULL; 112 112 if (Walker == NULL) 113 eLog() << Verbose(1) << "Stack's field is empty!" << endl;113 DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl); 114 114 NextFreeField = CurrentLastEntry; 115 115 if (CurrentLastEntry != CurrentFirstEntry) // has there been more than one item on stack 116 116 CurrentLastEntry = (CurrentLastEntry + (EntryCount-1)) % EntryCount; // step back from current free field to last (modulo does not work in -1, thus go EntryCount-1 instead) 117 117 } else { 118 eLog() << Verbose(1) << "Stack is empty!" << endl;118 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl); 119 119 } 120 120 return Walker; … … 151 151 } while (i!=NextFreeField); 152 152 else 153 eLog() << Verbose(1) << "Stack is already empty!" << endl;153 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is already empty!" << endl); 154 154 if (found) { 155 155 NextFreeField = CurrentLastEntry; -
src/tesselation.cpp
r8ab0407 rc7b1e7 14 14 #include "tesselation.hpp" 15 15 #include "tesselationhelpers.hpp" 16 #include "triangleintersectionlist.hpp" 16 17 #include "vector.hpp" 17 18 #include "verbose.hpp" … … 54 55 //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl; 55 56 if (!lines.empty()) 56 eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl;57 DoeLog(2) && (eLog()<< Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl); 57 58 node = NULL; 58 59 }; … … 187 188 } 188 189 if (!triangles.empty()) 189 eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl;190 DoeLog(2) && (eLog()<< Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl); 190 191 }; 191 192 … … 225 226 // get the two triangles 226 227 if (triangles.size() != 2) { 227 eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl;228 DoeLog(0) && (eLog()<< Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl); 228 229 return true; 229 230 } … … 251 252 BaseLineNormal.CopyVector(&runner->second->NormalVector); // yes, copy second on top of first 252 253 else { 253 eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl;254 DoeLog(0) && (eLog()<< Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl); 254 255 } 255 256 node = runner->second->GetThirdEndpoint(this); … … 262 263 i++; 263 264 } else { 264 eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl;265 DoeLog(1) && (eLog()<< Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl); 265 266 return true; 266 267 } … … 367 368 } 368 369 if (Counter < 3) { 369 eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl;370 DoeLog(0) && (eLog()<< Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl); 370 371 performCriticalExit(); 371 372 } … … 429 430 430 431 if (!Intersection->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, MolCenter, x)) { 431 eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl;432 DoeLog(1) && (eLog()<< Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl); 432 433 return false; 433 434 } … … 474 475 }; 475 476 476 /** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses. 477 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane 477 /** Finds the point on the triangle to the point \a *x. 478 * We call Vector::GetIntersectionWithPlane() with \a * and the center of the triangle to receive an intersection point. 479 * Then we check the in-plane part (the part projected down onto plane). We check whether it crosses one of the 480 * boundary lines. If it does, we return this intersection as closest point, otherwise the projected point down. 478 481 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not. 479 482 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line … … 723 726 Runner[i]++; 724 727 if (Runner[i] == endpoints.end()) { 725 eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl;728 DoeLog(0) && (eLog()<< Verbose(0) << "There are less than three endpoints in the polygon!" << endl); 726 729 performCriticalExit(); 727 730 } … … 1069 1072 runner->second = NULL; 1070 1073 } else 1071 eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl;1074 DoeLog(1) && (eLog()<< Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl); 1072 1075 } 1073 1076 Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl; … … 1322 1325 else 1323 1326 { 1324 eLog() << Verbose(0) << "No starting triangle found." << endl;1327 DoeLog(0) && (eLog()<< Verbose(0) << "No starting triangle found." << endl); 1325 1328 } 1326 1329 } … … 1521 1524 TrianglesOnBoundaryCount++; 1522 1525 } else { 1523 eLog() << Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl;1526 DoeLog(2) && (eLog()<< Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl); 1524 1527 } 1525 1528 … … 1614 1617 if (NewLines[j]->IsConnectedTo(BLS[0])) { 1615 1618 if (n>2) { 1616 eLog() << Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl;1619 DoeLog(2) && (eLog()<< Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl); 1617 1620 return false; 1618 1621 } else … … 1631 1634 } 1632 1635 } else { // something is wrong with FindClosestTriangleToPoint! 1633 eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl;1636 DoeLog(1) && (eLog()<< Verbose(1) << "The closest triangle did not produce an intersection!" << endl); 1634 1637 return false; 1635 1638 } … … 1734 1737 OpenLines.erase(CandidateLine); 1735 1738 } else { 1736 eLog() << Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl;1739 DoeLog(1) && (eLog()<< Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl); 1737 1740 } 1738 1741 … … 1840 1843 triangle->lines[i] = NULL; // free'd or not: disconnect 1841 1844 } else 1842 eLog() << Verbose(1) << "This line " << i << " has already been free'd." << endl;1845 DoeLog(1) && (eLog()<< Verbose(1) << "This line " << i << " has already been free'd." << endl); 1843 1846 } 1844 1847 … … 1894 1897 line->endpoints[i] = NULL; // free'd or not: disconnect 1895 1898 } else 1896 eLog() << Verbose(1) << "Endpoint " << i << " has already been free'd." << endl;1899 DoeLog(1) && (eLog()<< Verbose(1) << "Endpoint " << i << " has already been free'd." << endl); 1897 1900 } 1898 1901 if (!line->triangles.empty()) 1899 eLog() << Verbose(2) << "Memory Leak! I " << *line << " am still connected to some triangles." << endl;1902 DoeLog(2) && (eLog()<< Verbose(2) << "Memory Leak! I " << *line << " am still connected to some triangles." << endl); 1900 1903 1901 1904 if (LinesOnBoundary.erase(line->Nr)) … … 2070 2073 } 2071 2074 } else { 2072 eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;2075 DoeLog(1) && (eLog()<< Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl); 2073 2076 } 2074 2077 } … … 2214 2217 // if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 2215 2218 // // rotated the wrong way! 2216 // eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;2219 // DoeLog(1) && (eLog()<< Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl); 2217 2220 // } 2218 2221 // … … 2271 2274 // } 2272 2275 // } else { 2273 // eLog() << Verbose(2) << "Baseline is connected to two triangles already?" << endl;2276 // DoeLog(2) && (eLog()<< Verbose(2) << "Baseline is connected to two triangles already?" << endl); 2274 2277 // } 2275 2278 // } else { … … 2278 2281 // } 2279 2282 // } else { 2280 // eLog() << Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl;2283 // DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl); 2281 2284 // } 2282 2285 // … … 2344 2347 if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 2345 2348 // rotated the wrong way! 2346 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;2349 DoeLog(1) && (eLog()<< Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl); 2347 2350 } 2348 2351 … … 2355 2358 2356 2359 if (CandidateLine.pointlist.empty()) { 2357 eLog() << Verbose(2) << "Could not find a suitable candidate." << endl;2360 DoeLog(2) && (eLog()<< Verbose(2) << "Could not find a suitable candidate." << endl); 2358 2361 return false; 2359 2362 } … … 2397 2400 // CandidateLine.ShortestAngle = ShortestAngle; 2398 2401 // } else { 2399 //// eLog() << Verbose(1) << "This triangle consisting of ";2402 //// DoeLog(1) && (eLog()<< Verbose(1) << "This triangle consisting of "); 2400 2403 //// Log() << Verbose(0) << *(*it)->point << ", "; 2401 2404 //// Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and "; … … 2418 2421 // 2419 2422 // } else { 2420 //// eLog() << Verbose(1) << "This triangle consisting of " << *(*it)->point << ", " << *BaseRay->endpoints[0]->node << " and " << *BaseRay->endpoints[1]->node << " " << "exists and is not added, as it does not seem helpful!" << endl;2423 //// DoeLog(1) && (eLog()<< Verbose(1) << "This triangle consisting of " << *(*it)->point << ", " << *BaseRay->endpoints[0]->node << " and " << *BaseRay->endpoints[1]->node << " " << "exists and is not added, as it does not seem helpful!" << endl); 2421 2424 // result = false; 2422 2425 // } … … 2434 2437 // BaseRay = BLS[0]; 2435 2438 // if ((BTS != NULL) && (BTS->NormalVector.NormSquared() < MYEPSILON)) { 2436 // eLog() << Verbose(1) << "Triangle " << *BTS << " has zero normal vector!" << endl;2439 // DoeLog(1) && (eLog()<< Verbose(1) << "Triangle " << *BTS << " has zero normal vector!" << endl); 2437 2440 // exit(255); 2438 2441 // } … … 2632 2635 BaseLineNormal.Zero(); 2633 2636 if (Base->triangles.size() < 2) { 2634 eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl;2637 DoeLog(1) && (eLog()<< Verbose(1) << "Less than two triangles are attached to this baseline!" << endl); 2635 2638 return 0.; 2636 2639 } … … 2671 2674 BaseLineNormal.Zero(); 2672 2675 if (Base->triangles.size() < 2) { 2673 eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl;2676 DoeLog(1) && (eLog()<< Verbose(1) << "Less than two triangles are attached to this baseline!" << endl); 2674 2677 return NULL; 2675 2678 } … … 2707 2710 // check whether everything is in place to create new lines and triangles 2708 2711 if (i<4) { 2709 eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl;2712 DoeLog(1) && (eLog()<< Verbose(1) << "We have not gathered enough baselines!" << endl); 2710 2713 return NULL; 2711 2714 } 2712 2715 for (int j=0;j<4;j++) 2713 2716 if (OldLines[j] == NULL) { 2714 eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl;2717 DoeLog(1) && (eLog()<< Verbose(1) << "We have not gathered enough baselines!" << endl); 2715 2718 return NULL; 2716 2719 } 2717 2720 for (int j=0;j<2;j++) 2718 2721 if (OldPoints[j] == NULL) { 2719 eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl;2722 DoeLog(1) && (eLog()<< Verbose(1) << "We have not gathered enough endpoints!" << endl); 2720 2723 return NULL; 2721 2724 } … … 2761 2764 Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl; 2762 2765 } else { 2763 eLog() << Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl;2766 DoeLog(0) && (eLog()<< Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl); 2764 2767 return NULL; 2765 2768 } … … 2792 2795 N[i] = LC->n[i]; 2793 2796 } else { 2794 eLog() << Verbose(1) << "Point " << *a << " is not found in cell " << LC->index << "." << endl;2797 DoeLog(1) && (eLog()<< Verbose(1) << "Point " << *a << " is not found in cell " << LC->index << "." << endl); 2795 2798 return; 2796 2799 } … … 2932 2935 // test whether old center is on the band's plane 2933 2936 if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { 2934 eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;2937 DoeLog(1) && (eLog()<< Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl); 2935 2938 RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal); 2936 2939 } … … 2942 2945 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2943 2946 if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way! 2944 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl;2947 DoeLog(1) && (eLog()<< Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl); 2945 2948 } 2946 2949 … … 2951 2954 //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl; 2952 2955 } else { 2953 eLog() << Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl;2956 DoeLog(1) && (eLog()<< Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl); 2954 2957 return; 2955 2958 } … … 2990 2993 otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter); 2991 2994 if (fabs(radius - otherradius) > HULLEPSILON) { 2992 eLog() << Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl;2995 DoeLog(1) && (eLog()<< Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl); 2993 2996 } 2994 2997 // construct both new centers … … 3057 3060 } 3058 3061 } else { 3059 eLog() << Verbose(1) << "The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;3062 DoeLog(1) && (eLog()<< Verbose(1) << "The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl); 3060 3063 } 3061 3064 } else { … … 3116 3119 3117 3120 if (LinesOnBoundary.empty()) { 3118 eLog() << Verbose(1) << "There is no tesselation structure to compare the point with, please create one first." << endl;3121 DoeLog(1) && (eLog()<< Verbose(1) << "There is no tesselation structure to compare the point with, please create one first." << endl); 3119 3122 return NULL; 3120 3123 } … … 3143 3146 } 3144 3147 } else { 3145 eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;3148 DoeLog(1) && (eLog()<< Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl); 3146 3149 } 3147 3150 } … … 3149 3152 // check whether we found some points 3150 3153 if (points->empty()) { 3151 eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;3154 DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl); 3152 3155 delete(points); 3153 3156 return NULL; … … 3168 3171 DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC); 3169 3172 if (points == NULL) { 3170 eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;3173 DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl); 3171 3174 return NULL; 3172 3175 } … … 3222 3225 }; 3223 3226 3224 3225 3227 /** Finds the triangle that is closest to a given Vector \a *x. 3226 3228 * \param *out output stream for debugging … … 3235 3237 DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC); 3236 3238 if (points == NULL) { 3237 eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;3239 DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl); 3238 3240 return NULL; 3239 3241 } … … 3284 3286 const double distance = BaseLineIntersection.NormSquared(); 3285 3287 if (Center.NormSquared() > BaseLine.NormSquared()) { 3286 eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl;3288 DoeLog(0) && (eLog()<< Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl); 3287 3289 } 3288 3290 if ((ClosestLines.empty()) || (distance < MinDistance)) { … … 3315 3317 * \param *out output stream for debugging 3316 3318 * \param *x Vector to look from 3319 * \param &distance contains found distance on return 3317 3320 * \return list of BoundaryTriangleSet of nearest triangles or NULL. 3318 3321 */ … … 3358 3361 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const 3359 3362 { 3360 return (GetDistanceSquaredToSurface(Point, LC) < MYEPSILON); 3361 } 3363 Info FunctionInfo(__func__); 3364 TriangleIntersectionList Intersections(&Point,this,LC); 3365 3366 return Intersections.IsInside(); 3367 }; 3362 3368 3363 3369 /** Returns the distance to the surface given by the tesselation. … … 3432 3438 }; 3433 3439 3434 /** Calculates distanceto a tesselated surface.3440 /** Calculates minimum distance from \a&Point to a tesselated surface. 3435 3441 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle(). 3436 3442 * \param &Point point to calculate distance from … … 3438 3444 * \return distance squared to closest point on surface 3439 3445 */ 3440 double Tesselation::GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const 3441 { 3442 BoundaryTriangleSet *triangle = FindClosestTriangleToVector(&Point, LC); 3443 const double distance = GetDistanceSquaredToTriangle(Point, triangle); 3444 return Min(distance, LC->RADIUS); 3446 double Tesselation::GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const 3447 { 3448 Info FunctionInfo(__func__); 3449 TriangleIntersectionList Intersections(&Point,this,LC); 3450 3451 return Intersections.GetSmallestDistance(); 3452 }; 3453 3454 /** Calculates minimum distance from \a&Point to a tesselated surface. 3455 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle(). 3456 * \param &Point point to calculate distance from 3457 * \param *LC needed for finding closest points fast 3458 * \return distance squared to closest point on surface 3459 */ 3460 BoundaryTriangleSet * Tesselation::GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const 3461 { 3462 Info FunctionInfo(__func__); 3463 TriangleIntersectionList Intersections(&Point,this,LC); 3464 3465 return Intersections.GetClosestTriangle(); 3445 3466 }; 3446 3467 … … 3464 3485 ReferencePoint = PointRunner->second; 3465 3486 } else { 3466 eLog() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;3487 DoeLog(2) && (eLog()<< Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl); 3467 3488 ReferencePoint = NULL; 3468 3489 } … … 3496 3517 3497 3518 if (connectedPoints->empty()) { // if have not found any points 3498 eLog() << Verbose(1) << "We have not found any connected points to " << *Point<< "." << endl;3519 DoeLog(1) && (eLog()<< Verbose(1) << "We have not found any connected points to " << *Point<< "." << endl); 3499 3520 return NULL; 3500 3521 } … … 3529 3550 3530 3551 if (SetOfNeighbours == NULL) { 3531 eLog() << Verbose(2) << "Could not find any connected points!" << endl;3552 DoeLog(2) && (eLog()<< Verbose(2) << "Could not find any connected points!" << endl); 3532 3553 delete(connectedCircle); 3533 3554 return NULL; … … 3540 3561 PlaneNormal.AddVector(&(*Runner)->NormalVector); 3541 3562 } else { 3542 eLog() << Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl;3563 DoeLog(0) && (eLog()<< Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl); 3543 3564 performCriticalExit(); 3544 3565 } … … 3559 3580 AngleZero.ProjectOntoPlane(&PlaneNormal); 3560 3581 if (AngleZero.NormSquared() < MYEPSILON) { 3561 eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;3582 DoeLog(0) && (eLog()<< Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl); 3562 3583 performCriticalExit(); 3563 3584 } … … 3610 3631 3611 3632 if (SetOfNeighbours == NULL) { 3612 eLog() << Verbose(2) << "Could not find any connected points!" << endl;3633 DoeLog(2) && (eLog()<< Verbose(2) << "Could not find any connected points!" << endl); 3613 3634 delete(connectedCircle); 3614 3635 return NULL; … … 3664 3685 AngleZero.ProjectOntoPlane(&PlaneNormal); 3665 3686 if (AngleZero.NormSquared() < MYEPSILON) { 3666 eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;3687 DoeLog(0) && (eLog()<< Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl); 3667 3688 performCriticalExit(); 3668 3689 } … … 3687 3708 InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner))); 3688 3709 if (!InserterTest.second) { 3689 eLog() << Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl;3710 DoeLog(0) && (eLog()<< Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl); 3690 3711 performCriticalExit(); 3691 3712 } … … 3727 3748 ReferencePoint = PointRunner->second; 3728 3749 } else { 3729 eLog() << Verbose(1) << "GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;3750 DoeLog(1) && (eLog()<< Verbose(1) << "GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl); 3730 3751 return NULL; 3731 3752 } … … 3744 3765 LineRunner = TouchedLine.find(runner->second); 3745 3766 if (LineRunner == TouchedLine.end()) { 3746 eLog() << Verbose(1) << "I could not find " << *runner->second << " in the touched list." << endl;3767 DoeLog(1) && (eLog()<< Verbose(1) << "I could not find " << *runner->second << " in the touched list." << endl); 3747 3768 } else if (!LineRunner->second) { 3748 3769 LineRunner->second = true; … … 3774 3795 } 3775 3796 } else { 3776 eLog() << Verbose(1) << "I could not find " << *triangle << " in the touched list." << endl;3797 DoeLog(1) && (eLog()<< Verbose(1) << "I could not find " << *triangle << " in the touched list." << endl); 3777 3798 triangle = NULL; 3778 3799 } … … 3791 3812 LineRunner = TouchedLine.find(CurrentLine); 3792 3813 if (LineRunner == TouchedLine.end()) 3793 eLog() << Verbose(1) << "I could not find " << *CurrentLine << " in the touched list." << endl;3814 DoeLog(1) && (eLog()<< Verbose(1) << "I could not find " << *CurrentLine << " in the touched list." << endl); 3794 3815 else 3795 3816 LineRunner->second = true; … … 3809 3830 } 3810 3831 } else { 3811 eLog() << Verbose(1) << "There are no lines attached to " << *ReferencePoint << "." << endl;3832 DoeLog(1) && (eLog()<< Verbose(1) << "There are no lines attached to " << *ReferencePoint << "." << endl); 3812 3833 } 3813 3834 … … 3889 3910 3890 3911 if (Point == NULL) { 3891 eLog() << Verbose(1) << "Point given is NULL." << endl;3912 DoeLog(1) && (eLog()<< Verbose(1) << "Point given is NULL." << endl); 3892 3913 } else { 3893 3914 // go through its lines and insert all triangles … … 3921 3942 3922 3943 if (point == NULL) { 3923 eLog() << Verbose(1) << "Cannot remove the point " << point << ", it's NULL!" << endl;3944 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot remove the point " << point << ", it's NULL!" << endl); 3924 3945 return 0.; 3925 3946 } else … … 3931 3952 // get list of connected points 3932 3953 if (point->lines.empty()) { 3933 eLog() << Verbose(1) << "Cannot remove the point " << *point << ", it's connected to no lines!" << endl;3954 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot remove the point " << *point << ", it's connected to no lines!" << endl); 3934 3955 return 0.; 3935 3956 } … … 4012 4033 MiddleNode = EndNode; 4013 4034 if (MiddleNode == connectedPath->end()) { 4014 eLog() << Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl;4035 DoeLog(0) && (eLog()<< Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl); 4015 4036 performCriticalExit(); 4016 4037 } … … 4031 4052 triangle = GetPresentTriangle(TriangleCandidates); 4032 4053 if (triangle != NULL) { 4033 eLog() << Verbose(0) << "New triangle already present, skipping!" << endl;4054 DoeLog(0) && (eLog()<< Verbose(0) << "New triangle already present, skipping!" << endl); 4034 4055 StartNode++; 4035 4056 MiddleNode++; … … 4069 4090 break; 4070 4091 } else if (connectedPath->size() < 2) { // something's gone wrong! 4071 eLog() << Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl;4092 DoeLog(0) && (eLog()<< Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl); 4072 4093 performCriticalExit(); 4073 4094 } else { … … 4222 4243 } 4223 4244 default: 4224 eLog() << Verbose(0) << "Number of wildcards is greater than 3, cannot happen!" << endl;4245 DoeLog(0) && (eLog()<< Verbose(0) << "Number of wildcards is greater than 3, cannot happen!" << endl); 4225 4246 performCriticalExit(); 4226 4247 break; … … 4275 4296 // sanity check 4276 4297 if (LinesOnBoundary.empty()) { 4277 eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.";4298 DoeLog(2) && (eLog()<< Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure."); 4278 4299 return DegeneratedLines; 4279 4300 } … … 4299 4320 Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl; 4300 4321 else 4301 eLog() << Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl;4322 DoeLog(1) && (eLog()<< Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl); 4302 4323 } 4303 4324 … … 4459 4480 NearestBoundaryPoint = PointRunner->second; 4460 4481 } else { 4461 eLog() << Verbose(1) << "I cannot find the boundary point." << endl;4482 DoeLog(1) && (eLog()<< Verbose(1) << "I cannot find the boundary point." << endl); 4462 4483 return; 4463 4484 } … … 4527 4548 if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) { 4528 4549 if (BestLine == BTS->lines[i]){ 4529 eLog() << Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl;4550 DoeLog(0) && (eLog()<< Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl); 4530 4551 performCriticalExit(); 4531 4552 } … … 4719 4740 // connections to either polygon ... 4720 4741 if (T->size() % 2 != 0) { 4721 eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl;4742 DoeLog(0) && (eLog()<< Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl); 4722 4743 performCriticalExit(); 4723 4744 } … … 4754 4775 AddTesselationLine(TPS[1], TPS[2], 2); 4755 4776 if (TriangleNrs.empty()) 4756 eLog() << Verbose(0) << "No more free triangle numbers!" << endl;4777 DoeLog(0) && (eLog()<< Verbose(0) << "No more free triangle numbers!" << endl); 4757 4778 BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ... 4758 4779 AddTesselationTriangle(); // ... and add … … 4763 4784 } 4764 4785 if (!TriangleNrs.empty()) { 4765 eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl;4786 DoeLog(0) && (eLog()<< Verbose(0) << "There have been less triangles created than removed!" << endl); 4766 4787 } 4767 4788 delete(T); // remove the triangleset -
src/tesselation.hpp
r8ab0407 rc7b1e7 318 318 bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const; 319 319 double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const; 320 double GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const; 320 double GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const; 321 BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const; 321 322 bool AddBoundaryPoint(TesselPoint * Walker, const int n); 322 323 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const; -
src/tesselationhelpers.cpp
r8ab0407 rc7b1e7 81 81 82 82 if (fabs(m11) < MYEPSILON) 83 eLog() << Verbose(1) << "three points are colinear." << endl;83 DoeLog(1) && (eLog()<< Verbose(1) << "three points are colinear." << endl); 84 84 85 85 center->x[0] = 0.5 * m12/ m11; … … 88 88 89 89 if (fabs(a.Distance(center) - RADIUS) > MYEPSILON) 90 eLog() << Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl;90 DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl); 91 91 92 92 gsl_matrix_free(A); … … 192 192 //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl; 193 193 if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) { 194 eLog() << Verbose(1) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl;194 DoeLog(1) && (eLog()<< Verbose(1) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl); 195 195 } 196 196 … … 236 236 // test whether new center is on the parameter circle's plane 237 237 if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { 238 eLog() << Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;238 DoeLog(1) && (eLog()<< Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal)) << "!" << endl); 239 239 helper.ProjectOntoPlane(&CirclePlaneNormal); 240 240 } … … 242 242 // test whether the new center vector has length of CircleRadius 243 243 if (fabs(radius - CircleRadius) > HULLEPSILON) 244 eLog() << Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;244 DoeLog(1) && (eLog()<< Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl); 245 245 alpha = helper.Angle(&RelativeOldSphereCenter); 246 246 // make the angle unique by checking the halfplanes/search direction … … 512 512 // Vector BaseLineVector, OrthogonalVector, helper; 513 513 // if (candidate1->BaseLine != candidate2->BaseLine) { // sanity check 514 // eLog() << Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl;514 // DoeLog(1) && (eLog()<< Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl); 515 515 // //return false; 516 516 // exit(1); … … 764 764 } 765 765 } else { 766 eLog() << Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl;766 DoeLog(1) && (eLog()<< Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl); 767 767 } 768 768 delete(center); … … 839 839 *rasterfile << "9\n# terminating special property\n"; 840 840 } else { 841 eLog() << Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl;841 DoeLog(1) && (eLog()<< Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl); 842 842 } 843 843 IncludeSphereinRaster3D(rasterfile, Tess, cloud); … … 951 951 // check number of endpoints in *P 952 952 if (P->endpoints.size() != 4) { 953 eLog() << Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl;953 DoeLog(1) && (eLog()<< Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl); 954 954 return 0; 955 955 } … … 957 957 // check number of triangles in *T 958 958 if (T->size() < 2) { 959 eLog() << Verbose(1) << "Not enough triangles to have pairs!" << endl;959 DoeLog(1) && (eLog()<< Verbose(1) << "Not enough triangles to have pairs!" << endl); 960 960 return 0; 961 961 } -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r8ab0407 rc7b1e7 60 60 61 61 // construct molecule (tetraeder of hydrogens) base 62 TestSurfaceMolecule = new molecule(tafel); 63 Walker = new atom(); 64 Walker->type = hydrogen; 65 Walker->node->Init(1., 0., 1. ); 66 TestSurfaceMolecule->AddAtom(Walker); 67 Walker = new atom(); 68 Walker->type = hydrogen; 69 Walker->node->Init(0., 1., 1. ); 70 TestSurfaceMolecule->AddAtom(Walker); 71 Walker = new atom(); 72 Walker->type = hydrogen; 73 Walker->node->Init(1., 1., 0. ); 74 TestSurfaceMolecule->AddAtom(Walker); 75 Walker = new atom(); 76 Walker->type = hydrogen; 77 Walker->node->Init(0., 0., 0. ); 78 TestSurfaceMolecule->AddAtom(Walker); 79 80 // check that TestMolecule was correctly constructed 81 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 ); 82 83 TestList = new MoleculeListClass; 84 TestSurfaceMolecule->ActiveFlag = true; 85 TestList->insert(TestSurfaceMolecule); 86 87 // init tesselation and linked cell 88 Surface = new Tesselation; 89 LC = new LinkedCell(TestSurfaceMolecule, 5.); 90 FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL); 91 92 // add outer atoms 62 93 TestMolecule = new molecule(tafel); 63 94 Walker = new atom(); 64 Walker->type = hydrogen; 65 Walker->node->Init(1., 0., 1. ); 66 TestMolecule->AddAtom(Walker); 67 Walker = new atom(); 68 Walker->type = hydrogen; 69 Walker->node->Init(0., 1., 1. ); 70 TestMolecule->AddAtom(Walker); 71 Walker = new atom(); 72 Walker->type = hydrogen; 73 Walker->node->Init(1., 1., 0. ); 74 TestMolecule->AddAtom(Walker); 75 Walker = new atom(); 76 Walker->type = hydrogen; 77 Walker->node->Init(0., 0., 0. ); 78 TestMolecule->AddAtom(Walker); 79 80 // check that TestMolecule was correctly constructed 81 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 82 83 TestList = new MoleculeListClass; 95 Walker->type = carbon; 96 Walker->node->Init(4., 0., 4. ); 97 TestMolecule->AddAtom(Walker); 98 Walker = new atom(); 99 Walker->type = carbon; 100 Walker->node->Init(0., 4., 4. ); 101 TestMolecule->AddAtom(Walker); 102 Walker = new atom(); 103 Walker->type = carbon; 104 Walker->node->Init(4., 4., 0. ); 105 TestMolecule->AddAtom(Walker); 106 // add inner atoms 107 Walker = new atom(); 108 Walker->type = carbon; 109 Walker->node->Init(0.5, 0.5, 0.5 ); 110 TestMolecule->AddAtom(Walker); 84 111 TestMolecule->ActiveFlag = true; 85 112 TestList->insert(TestMolecule); 86 87 // init tesselation and linked cell88 Surface = new Tesselation;89 FindNonConvexBorder(TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);90 LC = new LinkedCell(TestMolecule, 5.);91 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );92 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );93 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );94 95 // add outer atoms96 Walker = new atom();97 Walker->type = carbon;98 Walker->node->Init(4., 0., 4. );99 TestMolecule->AddAtom(Walker);100 Walker = new atom();101 Walker->type = carbon;102 Walker->node->Init(0., 4., 4. );103 TestMolecule->AddAtom(Walker);104 Walker = new atom();105 Walker->type = carbon;106 Walker->node->Init(4., 4., 0. );107 TestMolecule->AddAtom(Walker);108 // add inner atoms109 Walker = new atom();110 Walker->type = carbon;111 Walker->node->Init(0.5, 0.5, 0.5 );112 TestMolecule->AddAtom(Walker);113 113 114 114 // init maps … … 136 136 137 137 138 /** Checks whether setup() does the right thing. 139 */ 140 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest() 141 { 142 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount ); 143 CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount ); 144 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() ); 145 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); 146 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() ); 147 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() ); 148 }; 149 138 150 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest() 139 151 { 140 152 // do the pair correlation 141 153 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 154 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 142 155 CPPUNIT_ASSERT( surfacemap != NULL ); 143 156 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() ); … … 149 162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 150 163 // put pair correlation into bins and check with no range 164 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 151 165 binmap = BinData( surfacemap, 0.5, 0., 0. ); 152 166 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() ); 153 //OutputCorrelation (binmap );167 OutputCorrelation ( (ofstream *)&cout, binmap ); 154 168 tester = binmap->begin(); 155 169 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 162 176 BinPairMap::iterator tester; 163 177 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 178 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 164 179 // ... and check with [0., 2.] range 165 180 binmap = BinData( surfacemap, 0.5, 0., 2. ); 166 181 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() ); 167 //OutputCorrelation (binmap );182 // OutputCorrelation ( (ofstream *)&cout, binmap ); 168 183 tester = binmap->begin(); 169 184 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 179 194 BinPairMap::iterator tester; 180 195 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 196 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 181 197 // put pair correlation into bins and check with no range 182 198 binmap = BinData( surfacemap, 0.5, 0., 0. ); … … 184 200 OutputCorrelation ( (ofstream *)&cout, binmap ); 185 201 // inside point is first and must have negative value 186 tester = binmap->lower_bound( 2.95); // start depends on the min value and202 tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and 187 203 CPPUNIT_ASSERT( tester != binmap->end() ); 188 204 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 189 205 // inner point 190 tester = binmap->lower_bound( -0.5);206 tester = binmap->lower_bound(0.); 191 207 CPPUNIT_ASSERT( tester != binmap->end() ); 192 208 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); … … 197 213 BinPairMap::iterator tester; 198 214 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 215 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 199 216 // ... and check with [0., 2.] range 200 217 binmap = BinData( surfacemap, 0.5, -2., 4. ); 201 218 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() ); 202 OutputCorrelation ( (ofstream *)&cout, binmap );219 // OutputCorrelation ( (ofstream *)&cout, binmap ); 203 220 // three outside points 204 tester = binmap->lower_bound( 3.);221 tester = binmap->lower_bound(4.25-0.5); 205 222 CPPUNIT_ASSERT( tester != binmap->end() ); 206 223 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 207 224 // inner point 208 tester = binmap->lower_bound( -0.5);225 tester = binmap->lower_bound(0.); 209 226 CPPUNIT_ASSERT( tester != binmap->end() ); 210 227 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); 211 212 228 }; 213 229 -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r8ab0407 rc7b1e7 23 23 { 24 24 CPPUNIT_TEST_SUITE( AnalysisCorrelationToSurfaceUnitTest ) ; 25 CPPUNIT_TEST ( SurfaceTest ); 25 26 CPPUNIT_TEST ( CorrelationToSurfaceTest ); 26 27 CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinNoRangeTest ); … … 33 34 void setUp(); 34 35 void tearDown(); 36 void SurfaceTest(); 35 37 void CorrelationToSurfaceTest(); 36 38 void CorrelationToSurfaceHydrogenBinNoRangeTest(); … … 43 45 MoleculeListClass *TestList; 44 46 molecule *TestMolecule; 47 molecule *TestSurfaceMolecule; 45 48 element *hydrogen; 46 49 element *carbon; -
src/unittests/gslvectorunittest.cpp
r8ab0407 rc7b1e7 115 115 116 116 117 /** UnitTest for operators. 118 */ 119 void GSLVectorTest::OperatorIsTest() 120 { 121 GSLVector zero(3); 122 GSLVector unit(3); 123 zero.SetZero(); 124 unit.SetZero(); 125 unit.Set(1,1.); 126 // summation and scaling 127 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); 128 CPPUNIT_ASSERT_EQUAL( false, zero.IsOne() ); 129 CPPUNIT_ASSERT_EQUAL( false, unit.IsZero() ); 130 CPPUNIT_ASSERT_EQUAL( true, zero.IsZero() ); 131 }; 132 133 /** UnitTest for operators. 134 */ 135 void GSLVectorTest::OperatorAlgebraTest() 136 { 137 GSLVector zero(3); 138 GSLVector unit(3); 139 zero.SetZero(); 140 unit.SetZero(); 141 unit.Set(1,1.); 142 // summation and scaling 143 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() ); 144 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() ); 145 CPPUNIT_ASSERT_EQUAL( true, (zero-unit).IsOne() ); 146 CPPUNIT_ASSERT_EQUAL( false, (zero-unit).IsZero() ); 147 CPPUNIT_ASSERT_EQUAL( true, (zero+zero).IsZero() ); 148 CPPUNIT_ASSERT_EQUAL( false, (unit*0.98).IsOne() ); 149 CPPUNIT_ASSERT_EQUAL( false, (0.98*unit).IsOne() ); 150 CPPUNIT_ASSERT_EQUAL( true, (unit*1.).IsOne() ); 151 CPPUNIT_ASSERT_EQUAL( true, (1.*unit).IsOne() ); 152 153 CPPUNIT_ASSERT_EQUAL( unit, (zero+unit) ); 154 CPPUNIT_ASSERT_EQUAL( zero, (zero+zero) ); 155 CPPUNIT_ASSERT_EQUAL( unit, (unit+zero) ); 156 157 unit += zero; 158 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); 159 unit *= 1.; 160 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); 161 }; 162 117 163 /********************************************** Main routine **************************************/ 118 164 -
src/unittests/gslvectorunittest.hpp
r8ab0407 rc7b1e7 22 22 CPPUNIT_TEST (CopyTest ); 23 23 CPPUNIT_TEST (ExchangeTest ); 24 CPPUNIT_TEST (OperatorAlgebraTest ); 25 CPPUNIT_TEST (OperatorIsTest ); 24 26 CPPUNIT_TEST_SUITE_END(); 25 27 … … 32 34 void CopyTest(); 33 35 void ExchangeTest(); 36 void OperatorIsTest(); 37 void OperatorAlgebraTest(); 34 38 35 39 private: -
src/unittests/logunittest.cpp
r8ab0407 rc7b1e7 43 43 44 44 Log() << Verbose(0) << "Output a log message." << endl; 45 eLog() << Verbose(0) << "Output an error message." << endl;45 DoeLog(0) && (eLog()<< Verbose(0) << "Output an error message." << endl); 46 46 setVerbosity(3); 47 47 Log() << Verbose(4) << "This should not be printed." << endl; 48 eLog() << Verbose(4) << "This should not be printed." << endl;48 DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl); 49 49 }; 50 50 -
src/vector.cpp
r8ab0407 rc7b1e7 15 15 #include "vector.hpp" 16 16 #include "verbose.hpp" 17 #include "World.hpp" 17 18 18 19 #include <gsl/gsl_linalg.h> … … 26 27 */ 27 28 Vector::Vector() { x[0] = x[1] = x[2] = 0.; }; 29 30 /** Constructor of class vector. 31 */ 32 Vector::Vector(const Vector * const a) 33 { 34 x[0] = a->x[0]; 35 x[1] = a->x[1]; 36 x[2] = a->x[2]; 37 }; 38 39 /** Constructor of class vector. 40 */ 41 Vector::Vector(const Vector &a) 42 { 43 x[0] = a.x[0]; 44 x[1] = a.x[1]; 45 x[2] = a.x[2]; 46 }; 28 47 29 48 /** Constructor of class vector. … … 262 281 return true; 263 282 } else { 264 eLog() << Verbose(2) << "Intersection point " << *this << " is not on plane." << endl;283 DoeLog(2) && (eLog()<< Verbose(2) << "Intersection point " << *this << " is not on plane." << endl); 265 284 return false; 266 285 } 267 286 }; 268 287 269 /** Calculates the minimum distance of this vector to the plane.288 /** Calculates the minimum distance vector of this vector to the plane. 270 289 * \param *out output stream for debugging 271 290 * \param *PlaneNormal normal of plane 272 291 * \param *PlaneOffset offset of plane 273 * \return distance to plane274 */ 275 double Vector::DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const292 * \return distance vector onto to plane 293 */ 294 Vector Vector::GetDistanceVectorToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const 276 295 { 277 296 Vector temp; … … 291 310 sign = 0.; 292 311 293 return (temp.Norm()*sign); 312 temp.Normalize(); 313 temp.Scale(sign); 314 return temp; 315 }; 316 317 /** Calculates the minimum distance of this vector to the plane. 318 * \sa Vector::GetDistanceVectorToPlane() 319 * \param *out output stream for debugging 320 * \param *PlaneNormal normal of plane 321 * \param *PlaneOffset offset of plane 322 * \return distance to plane 323 */ 324 double Vector::DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const 325 { 326 return GetDistanceVectorToPlane(PlaneNormal,PlaneOffset).Norm(); 294 327 }; 295 328 … … 783 816 x[i] = C.x[i]; 784 817 } else { 785 eLog() << Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl;818 DoeLog(1) && (eLog()<< Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl); 786 819 } 787 820 }; … … 835 868 x2.SubtractVector(y2); 836 869 if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) { 837 eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;870 DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl); 838 871 return false; 839 872 } … … 869 902 Zero(); 870 903 if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) { 871 eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;904 DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl); 872 905 return false; 873 906 } -
src/vector.hpp
r8ab0407 rc7b1e7 27 27 28 28 Vector(); 29 Vector(const Vector * const a); 30 Vector(const Vector &a); 29 31 Vector(const double x1, const double x2, const double x3); 30 32 ~Vector(); … … 67 69 void LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors); 68 70 double CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const; 71 Vector GetDistanceVectorToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const; 69 72 bool GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector); 70 73 bool GetIntersectionOfTwoLinesOnPlane(const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *Normal = NULL);
Note:
See TracChangeset
for help on using the changeset viewer.