Changes in / [e588312:b5c53d]
- Files:
-
- 42 added
- 3 deleted
- 138 edited
Legend:
- Unmodified
- Added
- Removed
-
TestRunnerClient.cpp
re588312 rb5c53d 45 45 #endif 46 46 47 #define MAX_HOSTNAME_SIZE 255 47 enum { MAX_HOSTNAME_SIZE=255 }; 48 48 49 49 /* -
src/Actions/AnalysisAction/MolecularVolumeAction.cpp
re588312 rb5c53d 16 16 #include "Helpers/Log.hpp" 17 17 #include "Helpers/Verbose.hpp" 18 #include "tesselation.hpp" 18 19 #include "World.hpp" 19 20 … … 60 61 LCList = new LinkedCell(mol, 10.); 61 62 config * const configuration = World::getInstance().getConfig(); 62 Boundaries *BoundaryPoints = NULL;63 //Boundaries *BoundaryPoints = NULL; 63 64 //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); 64 65 FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL); -
src/Actions/AnalysisAction/PairCorrelationAction.cpp
re588312 rb5c53d 70 70 double BinStart = 0.; 71 71 double BinWidth = 0.; 72 molecule *Boundary = NULL;73 72 string outputname; 74 73 string binoutputname; -
src/Actions/AnalysisAction/PointCorrelationAction.cpp
re588312 rb5c53d 71 71 double BinStart = 0.; 72 72 double BinWidth = 0.; 73 molecule *Boundary = NULL;74 73 string outputname; 75 74 string binoutputname; -
src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
re588312 rb5c53d 10 10 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 11 11 #include "Actions/ActionRegistry.hpp" 12 #include "molecule.hpp"13 12 #include "Helpers/Log.hpp" 14 13 #include "Helpers/Verbose.hpp" 14 #include "LinearAlgebra/Matrix.hpp" 15 #include "LinearAlgebra/Vector.hpp" 16 #include "element.hpp" 17 #include "molecule.hpp" 15 18 16 19 #include <iostream> … … 46 49 Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() { 47 50 molecule *mol = NULL; 51 Matrix InertiaTensor; 48 52 49 53 ValueStorage::getInstance().queryCurrentValue(NAME, mol); … … 51 55 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 52 56 molecule *mol = iter->second; 53 mol->PrincipalAxisSystem(false); 57 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 58 59 // reset inertia tensor 60 InertiaTensor.zero(); 61 62 // sum up inertia tensor 63 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 64 Vector x = (*iter)->getPosition(); 65 x -= *CenterOfGravity; 66 const double mass = (*iter)->getType()->mass; 67 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); 68 InertiaTensor.at(0,1) += mass*(-x[0]*x[1]); 69 InertiaTensor.at(0,2) += mass*(-x[0]*x[2]); 70 InertiaTensor.at(1,0) += mass*(-x[1]*x[0]); 71 InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]); 72 InertiaTensor.at(1,2) += mass*(-x[1]*x[2]); 73 InertiaTensor.at(2,0) += mass*(-x[2]*x[0]); 74 InertiaTensor.at(2,1) += mass*(-x[2]*x[1]); 75 InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]); 76 } 77 // print InertiaTensor for debugging 78 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl); 54 79 } 55 80 return Action::success; -
src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp
re588312 rb5c53d 18 18 #include "molecule.hpp" 19 19 #include "periodentafel.hpp" 20 #include "tesselation.hpp" 20 21 #include "LinearAlgebra/Vector.hpp" 21 22 #include "World.hpp" … … 111 112 // find biggest molecule 112 113 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules(); 113 int counter = molecules.size();114 114 LCList = new LinkedCell(Boundary, LCWidth); 115 115 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); -
src/Actions/AtomAction/AddAction.cpp
re588312 rb5c53d 61 61 // execute action 62 62 atom * first = World::getInstance().createAtom(); 63 first-> type = elemental;64 first-> x = position;65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << *first->type << " at " << (first->x) << "." << endl);63 first->setType(elemental); 64 first->setPosition(position); 65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->getType()->getName() << " at " << (first->getPosition()) << "." << endl); 66 66 // TODO: remove when all of World's atoms are stored. 67 67 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); -
src/Actions/AtomAction/ChangeElementAction.cpp
re588312 rb5c53d 15 15 #include "LinearAlgebra/Vector.hpp" 16 16 #include "Helpers/Verbose.hpp" 17 #include "molecule.hpp" 17 18 #include "World.hpp" 18 19 … … 50 51 Action::state_ptr AtomChangeElementAction::performCall() { 51 52 atom *first = NULL; 52 const element *elemental = NULL; 53 const element *elemental; 54 molecule *mol = NULL; 53 55 54 56 ValueStorage::getInstance().queryCurrentValue(NAME, elemental); … … 57 59 first = iter->second; 58 60 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << *elemental << "." << endl); 59 first->type = elemental; 61 mol = first->getMolecule(); 62 first->removeFromMolecule(); // remove atom 63 first->setType(elemental); 64 mol->AddAtom(first); // add atom to ensure correctness of formula 60 65 } 61 66 return Action::success; -
src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
re588312 rb5c53d 10 10 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 11 11 #include "Actions/ActionRegistry.hpp" 12 #include "Descriptors/MoleculeDescriptor.hpp" 13 12 14 #include "atom.hpp" 15 #include "bond.hpp" 16 #include "bondgraph.hpp" 13 17 #include "config.hpp" 14 18 #include "Helpers/Log.hpp" 15 19 #include "molecule.hpp" 16 #include "Descriptors/MoleculeDescriptor.hpp"17 20 #include "stackclass.hpp" 18 21 #include "World.hpp" … … 53 56 // @TODO rather do the dissection afterwards 54 57 MoleculeListClass *molecules = World::getInstance().getMolecules(); 55 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 58 config * const configuration = World::getInstance().getConfig(); 59 60 // 0a. remove all present molecules 61 vector<molecule *> allmolecules = World::getInstance().getAllMolecules(); 62 for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) { 63 molecules->erase(*MolRunner); 64 World::getInstance().destroyMolecule(*MolRunner); 65 } 66 67 // 0b. remove all bonds and construct a molecule with all atoms 68 molecule *mol = World::getInstance().createMolecule(); 69 vector <atom *> allatoms = World::getInstance().getAllAtoms(); 70 for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) { 71 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 72 delete(*BondRunner); 73 mol->AddAtom(*AtomRunner); 74 } 75 76 // 1. create the bond structure of the single molecule 77 if (configuration->BG != NULL) { 78 if (!configuration->BG->ConstructBondGraph(mol)) { 79 World::getInstance().destroyMolecule(mol); 80 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 81 return Action::failure; 82 } 83 } else { 84 DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl); 85 return Action::failure; 86 } 87 88 // 2. scan for connected subgraphs 89 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 90 class StackClass<bond *> *BackEdgeStack = NULL; 91 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 92 delete(BackEdgeStack); 93 if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) { 94 World::getInstance().destroyMolecule(mol); 95 DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl); 96 return Action::failure; 97 } 98 99 // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in 100 // the original one as parsed in) 101 // TODO: Optimize this, when molecules just contain pointer list of global atoms! 102 103 // 4a. create array of molecules to fill 104 const int MolCount = Subgraphs->next->Count(); 105 char number[MAXSTRINGSIZE]; 106 molecule **moleculelist = new molecule *[MolCount]; 107 MoleculeLeafClass *MolecularWalker = Subgraphs; 108 for (int i=0;i<MolCount;i++) { 109 MolecularWalker = MolecularWalker->next; 110 moleculelist[i] = World::getInstance().createMolecule(); 111 moleculelist[i]->ActiveFlag = true; 112 strncpy(moleculelist[i]->name, mol->name, MAXSTRINGSIZE); 113 if (MolCount > 1) { 114 sprintf(number, "-%d", i+1); 115 strncat(moleculelist[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1); 116 } 117 DoLog(1) && (Log() << Verbose(1) << "MolName is " << moleculelist[i]->name << ", id is " << moleculelist[i]->getId() << endl); 118 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) { 119 DoLog(1) && (Log() << Verbose(1) << **iter << endl); 120 } 121 molecules->insert(moleculelist[i]); 122 } 123 124 // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1) 125 int FragmentCounter = 0; 126 map<int, atom *> AtomToFragmentMap; 127 MolecularWalker = Subgraphs; 128 while (MolecularWalker->next != NULL) { 129 MolecularWalker = MolecularWalker->next; 130 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) { 131 atom * Walker = *iter; 132 DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl); 133 MolecularWalker->Leaf->erase(iter); 134 moleculelist[FragmentCounter]->AddAtom(Walker); // counting starts at 1 135 } 136 FragmentCounter++; 137 } 138 // TODO: When DepthFirstSearchAnalysis does not use AddCopyAtom() anymore, we don't need to delete all original atoms. 139 // 4d. destroy the original molecule 140 for (molecule::iterator AtomRunner = mol->begin(); !mol->empty(); AtomRunner = mol->begin()) 141 World::getInstance().destroyAtom(*AtomRunner); 142 World::getInstance().destroyMolecule(mol); 143 144 // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list 145 // TODO: check whether this is really not needed anymore 146 // 4e. free Leafs 147 MolecularWalker = Subgraphs; 148 while (MolecularWalker->next != NULL) { 149 MolecularWalker = MolecularWalker->next; 150 delete(MolecularWalker->previous); 151 } 152 delete(MolecularWalker); 153 delete[](moleculelist); 154 DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl); 155 56 156 return Action::success; 57 157 } -
src/Actions/Makefile.am
re588312 rb5c53d 85 85 MoleculeAction/FillWithMoleculeAction.cpp \ 86 86 MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \ 87 MoleculeAction/RotateAroundOriginByAngleAction.cpp \ 88 MoleculeAction/RotateAroundSelfByAngleAction.cpp \ 87 89 MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \ 88 90 MoleculeAction/SaveAdjacencyAction.cpp \ … … 97 99 MoleculeAction/FillWithMoleculeAction.hpp \ 98 100 MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \ 101 MoleculeAction/RotateAroundOriginByAngleAction.hpp \ 102 MoleculeAction/RotateAroundSelfByAngleAction.hpp \ 99 103 MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \ 100 104 MoleculeAction/SaveAdjacencyAction.hpp \ -
src/Actions/MapOfActions.cpp
re588312 rb5c53d 55 55 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp" 56 56 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp" 57 #include "Actions/MoleculeAction/RotateAroundOriginByAngleAction.hpp" 58 #include "Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp" 57 59 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp" 58 60 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp" … … 203 205 DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom"; 204 206 DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis"; 207 DescriptionMap["rotate-origin"] = "rotates molecules by a specific angle around origin"; 208 DescriptionMap["rotate-self"] = "rotates molecules by a specific angle around own center of gravity"; 205 209 DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis"; 206 210 DescriptionMap["save-adjacency"] = "name of the adjacency file to write to"; … … 319 323 TypeMap["remove-sphere"] = &typeid(double); 320 324 TypeMap["repeat-box"] = &typeid(VectorValue); 321 TypeMap["rotate-to-pas"] = &typeid(molecule); 325 TypeMap["rotate-origin"] = &typeid(double); 326 TypeMap["rotate-self"] = &typeid(double); 327 TypeMap["rotate-to-pas"] = &typeid(VectorValue); 322 328 TypeMap["save-adjacency"] = &typeid(std::string); 323 329 TypeMap["save-bonds"] = &typeid(std::string); … … 423 429 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") ); 424 430 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") ); 431 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-origin") ); 432 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-self") ); 425 433 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") ); 426 434 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") ); … … 487 495 generic.insert("remove-sphere"); 488 496 generic.insert("repeat-box"); 497 generic.insert("rotate-origin"); 498 generic.insert("rotate-self"); 489 499 generic.insert("rotate-to-pas"); 490 500 generic.insert("save-adjacency"); … … 807 817 new MoleculeFillWithMoleculeAction(); 808 818 new MoleculeLinearInterpolationofTrajectoriesAction(); 819 new MoleculeRotateAroundOriginByAngleAction(); 820 new MoleculeRotateAroundSelfByAngleAction(); 809 821 new MoleculeRotateToPrincipalAxisSystemAction(); 810 822 new MoleculeSaveAdjacencyAction(); -
src/Actions/MoleculeAction/BondFileAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/MoleculeAction/ChangeNameAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/MoleculeAction/FillWithMoleculeAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp"13 12 #include "LinearAlgebra/Vector.hpp" 14 13 -
src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
re588312 rb5c53d 11 11 #include "Actions/ActionRegistry.hpp" 12 12 #include "Helpers/Log.hpp" 13 #include "Helpers/Verbose.hpp" 14 #include "LinearAlgebra/Line.hpp" 15 #include "LinearAlgebra/Matrix.hpp" 16 #include "LinearAlgebra/Vector.hpp" 17 #include "element.hpp" 13 18 #include "molecule.hpp" 14 #include "Helpers/Verbose.hpp"15 19 16 20 … … 48 52 {} 49 53 50 void MoleculeRotateToPrincipalAxisSystem() { 54 void MoleculeRotateToPrincipalAxisSystem(Vector &Axis) { 55 ValueStorage::getInstance().setCurrentValue(MoleculeRotateToPrincipalAxisSystemAction::NAME, Axis); 51 56 ActionRegistry::getInstance().getActionByName(MoleculeRotateToPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive); 52 57 }; … … 55 60 ASSERT(dialog,"No Dialog given when filling action dialog"); 56 61 57 dialog->query Empty(NAME, MapOfActions::getInstance().getDescription(NAME));62 dialog->queryVector(NAME, false, MapOfActions::getInstance().getDescription(NAME)); 58 63 59 64 return dialog; … … 62 67 Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() { 63 68 molecule *mol = NULL; 69 Vector Axis; 70 71 // obtain axis to rotate to 72 ValueStorage::getInstance().queryCurrentValue(NAME, Axis); 64 73 65 74 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 66 75 mol = iter->second; 67 76 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl); 68 mol->PrincipalAxisSystem(true); 77 Matrix InertiaTensor; 78 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 79 80 // reset inertia tensor 81 InertiaTensor.zero(); 82 83 // sum up inertia tensor 84 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 85 Vector x = (*iter)->getPosition(); 86 x -= *CenterOfGravity; 87 const double mass = (*iter)->getType()->mass; 88 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); 89 InertiaTensor.at(0,1) += mass*(-x[0]*x[1]); 90 InertiaTensor.at(0,2) += mass*(-x[0]*x[2]); 91 InertiaTensor.at(1,0) += mass*(-x[1]*x[0]); 92 InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]); 93 InertiaTensor.at(1,2) += mass*(-x[1]*x[2]); 94 InertiaTensor.at(2,0) += mass*(-x[2]*x[0]); 95 InertiaTensor.at(2,1) += mass*(-x[2]*x[1]); 96 InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]); 97 } 98 // print InertiaTensor for debugging 99 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl); 100 101 // diagonalize to determine principal axis system 102 Vector Eigenvalues = InertiaTensor.transformToEigenbasis(); 103 104 for(int i=0;i<NDIM;i++) 105 DoLog(0) && (Log() << Verbose(0) << "eigenvalue = " << Eigenvalues[i] << ", eigenvector = " << InertiaTensor.column(i) << endl); 106 107 // check whether we rotate or not 108 DoLog(0) && (Log() << Verbose(0) << "Transforming molecule into PAS ... "); 109 110 // obtain first column, eigenvector to biggest eigenvalue 111 Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent())); 112 Vector DesiredAxis(Axis); 113 114 // Creation Line that is the rotation axis 115 DesiredAxis.VectorProduct(BiggestEigenvector); 116 Line RotationAxis(Vector(0.,0.,0.), DesiredAxis); 117 118 // determine angle 119 const double alpha = BiggestEigenvector.Angle(Axis); 120 121 DoLog(0) && (Log() << Verbose(0) << alpha << endl); 122 123 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 124 *(*iter) -= *CenterOfGravity; 125 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha)); 126 *(*iter) += *CenterOfGravity; 127 } 128 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 129 130 // summing anew for debugging (resulting matrix has to be diagonal!) 131 // reset inertia tensor 132 InertiaTensor.zero(); 133 134 // sum up inertia tensor 135 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 136 Vector x = (*iter)->getPosition(); 137 x -= *CenterOfGravity; 138 const double mass = (*iter)->getType()->mass; 139 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); 140 InertiaTensor.at(0,1) += mass*(-x[0]*x[1]); 141 InertiaTensor.at(0,2) += mass*(-x[0]*x[2]); 142 InertiaTensor.at(1,0) += mass*(-x[1]*x[0]); 143 InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]); 144 InertiaTensor.at(1,2) += mass*(-x[1]*x[2]); 145 InertiaTensor.at(2,0) += mass*(-x[2]*x[0]); 146 InertiaTensor.at(2,1) += mass*(-x[2]*x[1]); 147 InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]); 148 // print InertiaTensor for debugging 149 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl); 150 } 151 152 // free everything 153 delete(CenterOfGravity); 69 154 } 70 155 return Action::success; -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp"13 12 14 13 class MoleculeListClass; 14 class Vector; 15 15 16 void MoleculeRotateToPrincipalAxisSystem( );16 void MoleculeRotateToPrincipalAxisSystem(Vector &Axis); 17 17 18 18 class MoleculeRotateToPrincipalAxisSystemAction : public Action { 19 friend void MoleculeRotateToPrincipalAxisSystem( );19 friend void MoleculeRotateToPrincipalAxisSystem(Vector &Axis); 20 20 21 21 public: -
src/Actions/MoleculeAction/SaveAdjacencyAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/MoleculeAction/SaveBondsAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/MoleculeAction/SaveTemperatureAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/MoleculeAction/SuspendInWaterAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/MoleculeAction/TranslateAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp"13 12 #include "LinearAlgebra/Vector.hpp" 14 13 -
src/Actions/MoleculeAction/VerletIntegrationAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class MoleculeListClass; -
src/Actions/ParserAction/LoadXyzAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 void ParserLoadXyz(std::string &filename); -
src/Actions/ParserAction/SaveXyzAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 void ParserSaveXyz(std::string &filename); -
src/Actions/TesselationAction/ConvexEnvelopeAction.cpp
re588312 rb5c53d 15 15 #include "Helpers/Log.hpp" 16 16 #include "molecule.hpp" 17 #include "tesselation.hpp" 17 18 #include "Helpers/Verbose.hpp" 18 19 #include "World.hpp" … … 84 85 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl); 85 86 LCList = new LinkedCell(mol, 100.); 86 Boundaries *BoundaryPoints = NULL;87 //Boundaries *BoundaryPoints = NULL; 87 88 //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); 88 89 // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests -
src/Actions/TesselationAction/ConvexEnvelopeAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class TesselationListClass; -
src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
re588312 rb5c53d 14 14 #include "Helpers/Log.hpp" 15 15 #include "molecule.hpp" 16 #include "tesselation.hpp" 16 17 #include "Helpers/Verbose.hpp" 17 18 #include "World.hpp" -
src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp
re588312 rb5c53d 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Actions/Process.hpp" 12 13 13 14 14 class TesselationListClass; -
src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
re588312 rb5c53d 60 60 ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary."); 61 61 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 62 Min = (*AtomRunner)-> x;63 Max = (*AtomRunner)-> x;62 Min = (*AtomRunner)->getPosition(); 63 Max = (*AtomRunner)->getPosition(); 64 64 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 65 65 for (int i=0;i<NDIM;i++) { 66 if ((*AtomRunner)-> x[i]> Max[i])67 Max[i] = (*AtomRunner)-> x[i];68 if ((*AtomRunner)-> x[i]< Min[i])69 Min[i] = (*AtomRunner)-> x[i];66 if ((*AtomRunner)->at(i) > Max[i]) 67 Max[i] = (*AtomRunner)->at(i); 68 if ((*AtomRunner)->at(i) < Min[i]) 69 Min[i] = (*AtomRunner)->at(i); 70 70 } 71 71 } … … 84 84 AtomRunner = AllAtoms.begin(); 85 85 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) 86 (*AtomRunner)->x-= Min - boundary;86 *(*AtomRunner) -= Min - boundary; 87 87 return Action::success; 88 88 } -
src/Actions/WorldAction/CenterOnEdgeAction.cpp
re588312 rb5c53d 55 55 ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); 56 56 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 57 Min = (*AtomRunner)-> x;58 Max = (*AtomRunner)-> x;57 Min = (*AtomRunner)->getPosition(); 58 Max = (*AtomRunner)->getPosition(); 59 59 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 60 60 for (int i=0;i<NDIM;i++) { 61 if ((*AtomRunner)-> x[i]> Max[i])62 Max[i] = (*AtomRunner)-> x[i];63 if ((*AtomRunner)-> x[i]< Min[i])64 Min[i] = (*AtomRunner)-> x[i];61 if ((*AtomRunner)->at(i) > Max[i]) 62 Max[i] = (*AtomRunner)->at(i); 63 if ((*AtomRunner)->at(i) < Min[i]) 64 Min[i] = (*AtomRunner)->at(i); 65 65 } 66 66 } … … 75 75 // translate all atoms, such that Min is aty (0,0,0) 76 76 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) 77 (*AtomRunner)->x-= Min;77 *(*AtomRunner) -= Min; 78 78 79 79 return Action::success; -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
re588312 rb5c53d 62 62 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 63 63 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 64 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 64 if ((*AtomRunner)->DistanceSquared(point) > radius*radius) { // distance to first above radius ... 65 // cout << "Removing " << (*AtomRunner)->getType()->symbol << (*AtomRunner)->getId() << " at " << (*AtomRunner)->getPosition() << " as distance is " << sqrt((*AtomRunner)->DistanceSquared(point)) << endl; 65 66 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 66 67 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) … … 68 69 World::getInstance().destroyAtom(*AtomRunner); 69 70 } 71 // else { 72 // cout << "Keeping" << (*AtomRunner)->getType()->symbol << (*AtomRunner)->getId() << " at " << (*AtomRunner)->getPosition() << " as distance is " << sqrt((*AtomRunner)->DistanceSquared(point)) << endl; 73 // } 70 74 } 71 75 return Action::success; -
src/Actions/WorldAction/RepeatBoxAction.cpp
re588312 rb5c53d 21 21 #include <iostream> 22 22 #include <string> 23 #include <vector> 23 24 24 25 using namespace std; … … 90 91 91 92 molecule *newmol = NULL; 92 Vector ** vectors = NULL;93 std::vector<Vector> vectors; 93 94 for (n[0] = 0; n[0] < Repeater[0]; n[0]++) { 94 95 y[0] = n[0]; … … 105 106 if (count != 0) { // if there is more than none 106 107 Elements = new const element *[count]; 107 vectors = new Vector *[count];108 vectors.resize(count); 108 109 j = 0; 109 110 for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) { 110 Elements[j] = (*AtomRunner)-> type;111 vectors[j] = &(*AtomRunner)->x;111 Elements[j] = (*AtomRunner)->getType(); 112 vectors[j] = (*AtomRunner)->getPosition(); 112 113 j++; 113 114 } … … 120 121 for (int k=count;k--;) { // go through every atom of the original cell 121 122 Walker = World::getInstance().createAtom(); // create a new body 122 Walker-> x = (*vectors[k]) + x;123 Walker-> type = Elements[k]; // insert original element123 Walker->setPosition((vectors[k]) + x); 124 Walker->setType(Elements[k]); // insert original element 124 125 cout << "new atom is " << *Walker << endl; 125 126 newmol->AddAtom(Walker); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) … … 127 128 // free memory 128 129 delete[](Elements); 129 delete[](vectors);130 130 } else { 131 131 DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl); -
src/Actions/WorldAction/ScaleBoxAction.cpp
re588312 rb5c53d 60 60 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 61 61 for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 62 (*AtomRunner)-> x.ScaleAll(x);62 (*AtomRunner)->ScaleAll(x); 63 63 } 64 64 -
src/AtomSet.hpp
re588312 rb5c53d 65 65 workOnNodePointer(Function &_f) : f(_f){} 66 66 void operator()(atom *atom){ 67 if(atom->node) 68 *atom->node = f(*atom->node); 67 atom->setPosition(f(atom->getPosition())); 69 68 } 70 69 Function &f; … … 75 74 inline void AtomSetMixin<Set>::translate(const Vector &translater){ 76 75 BOOST_FOREACH(atom *atom,*this){ 77 if(atom->node){ 78 *(atom->node) += translater; 79 } 76 *(atom) += translater; 80 77 } 81 78 } -
src/ConfigFileBuffer.cpp
re588312 rb5c53d 51 51 /** Constructor for ConfigFileBuffer class. 52 52 */ 53 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 53 ConfigFileBuffer::ConfigFileBuffer() : 54 buffer(NULL), 55 LineMapping(NULL), 56 CurrentLine(0), 57 NoLines(0) 54 58 { 55 59 }; … … 58 62 * \param *filename file name 59 63 */ 60 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 64 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : 65 buffer(NULL), 66 LineMapping(NULL), 67 CurrentLine(0), 68 NoLines(0) 61 69 { 62 70 InitFileBuffer(filename); -
src/Helpers/Info.cpp
re588312 rb5c53d 19 19 * \return Info instance 20 20 */ 21 Info::Info(const char *msg) 21 Info::Info(const char *msg) : 22 FunctionName(msg) 22 23 { 23 24 verbosity++; 24 FunctionName = msg;25 25 DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl); 26 26 }; -
src/Helpers/errorlogger.cpp
re588312 rb5c53d 24 24 */ 25 25 errorLogger::errorLogger() 26 { 27 verbosity = 2; 28 }; 26 {}; 29 27 30 28 /** 31 29 * Destructor. Better use purgeInstance(). 32 30 */ 33 errorLogger::~errorLogger() { 34 verbosity = 2; 35 } 31 errorLogger::~errorLogger() 32 {} 36 33 37 34 CONSTRUCT_SINGLETON(errorLogger) -
src/Helpers/logger.cpp
re588312 rb5c53d 25 25 */ 26 26 logger::logger() 27 { 28 verbosity = 2; 29 }; 27 {}; 30 28 31 29 /** 32 30 * Destructor. Better use purgeInstance(). 33 31 */ 34 logger::~logger() { 35 verbosity = 2; 36 } 32 logger::~logger() {} 37 33 38 34 CONSTRUCT_SINGLETON(logger) -
src/Legacy/oldmenu.cpp
re588312 rb5c53d 89 89 first = World::getInstance().createAtom(); 90 90 std::vector<element *> elements; 91 dialog->queryVector("Please enter coordinates: ",&first-> x,World::getInstance().getDomain(), false);91 dialog->queryVector("Please enter coordinates: ",&first->AtomicPosition,World::getInstance().getDomain(), false); 92 92 dialog->queryElement("Please choose element: ",&elements); 93 93 if(dialog->display()){ 94 94 if (elements.size() == 1) { 95 first-> type = elements.at(0);95 first->setType(elements.at(0)); 96 96 mol->AddAtom(first); // add to molecule 97 97 } else { … … 113 113 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog()); 114 114 dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true); 115 dialog->queryVector("Enter relative coordinates.",&first-> x,World::getInstance().getDomain(), false);115 dialog->queryVector("Enter relative coordinates.",&first->AtomicPosition,World::getInstance().getDomain(), false); 116 116 if((aborted = !dialog->display())){ 117 117 continue; 118 118 } 119 first-> x+= x;120 } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first-> x)));119 first->AtomicPosition += x; 120 } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition))); 121 121 if(!aborted){ 122 first-> type= periode->AskElement(); // give type122 first->AtomicElement = periode->AskElement(); // give type 123 123 mol->AddAtom(first); // add to molecule 124 124 } … … 136 136 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog()); 137 137 second = mol->AskAtom("Enter atom number: "); 138 dialog->queryVector("Enter relative coordinates.",&first-> x,World::getInstance().getDomain(), false);138 dialog->queryVector("Enter relative coordinates.",&first->AtomicPosition,World::getInstance().getDomain(), false); 139 139 dialog->display(); 140 140 for (int i=NDIM;i--;) { 141 first-> x[i] += second->x[i];141 first->AtomicPosition[i] += second->AtomicPosition[i]; 142 142 } 143 } while (!(valid = mol->CheckBounds((const Vector *)&first-> x)));144 first-> type= periode->AskElement(); // give type143 } while (!(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition))); 144 first->AtomicElement = periode->AskElement(); // give type 145 145 mol->AddAtom(first); // add to molecule 146 146 } … … 152 152 do { 153 153 if (!valid) { 154 eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first-> x<< endl;154 eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->AtomicPosition << endl; 155 155 } 156 156 Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl; … … 185 185 */ 186 186 // calc axis vector 187 x= second-> x - third->x;187 x= second->AtomicPosition - third->AtomicPosition; 188 188 x.Normalize(); 189 189 Log() << Verbose(0) << "x: " << x << endl; 190 z = Plane(second-> x,third->x,fourth->x).getNormal();190 z = Plane(second->AtomicPosition,third->AtomicPosition,fourth->AtomicPosition).getNormal(); 191 191 Log() << Verbose(0) << "z: " << z << endl; 192 192 y = Plane(x,z,0).getNormal(); … … 194 194 195 195 // rotate vector around first angle 196 first-> x= x;197 first-> x = Line(zeroVec,z).rotateVector(first->x,b - M_PI);198 Log() << Verbose(0) << "Rotated vector: " << first-> x<< endl,196 first->AtomicPosition = x; 197 first->AtomicPosition = Line(zeroVec,z).rotateVector(first->AtomicPosition,b - M_PI); 198 Log() << Verbose(0) << "Rotated vector: " << first->AtomicPosition << endl, 199 199 // remove the projection onto the rotation plane of the second angle 200 200 n = y; 201 n.Scale(first-> x.ScalarProduct(y));201 n.Scale(first->AtomicPosition.ScalarProduct(y)); 202 202 Log() << Verbose(0) << "N1: " << n << endl; 203 first-> x-= n;204 Log() << Verbose(0) << "Subtracted vector: " << first-> x<< endl;203 first->AtomicPosition -= n; 204 Log() << Verbose(0) << "Subtracted vector: " << first->AtomicPosition << endl; 205 205 n = z; 206 n.Scale(first-> x.ScalarProduct(z));206 n.Scale(first->AtomicPosition.ScalarProduct(z)); 207 207 Log() << Verbose(0) << "N2: " << n << endl; 208 first-> x-= n;209 Log() << Verbose(0) << "2nd subtracted vector: " << first-> x<< endl;208 first->AtomicPosition -= n; 209 Log() << Verbose(0) << "2nd subtracted vector: " << first->AtomicPosition << endl; 210 210 211 211 // rotate another vector around second angle … … 215 215 216 216 // add the two linear independent vectors 217 first-> x+= n;218 first-> x.Normalize();219 first-> x.Scale(a);220 first-> x += second->x;221 222 Log() << Verbose(0) << "resulting coordinates: " << first-> x<< endl;223 } while (!(valid = mol->CheckBounds((const Vector *)&first-> x)));224 first-> type= periode->AskElement(); // give type217 first->AtomicPosition += n; 218 first->AtomicPosition.Normalize(); 219 first->AtomicPosition.Scale(a); 220 first->AtomicPosition += second->AtomicPosition; 221 222 Log() << Verbose(0) << "resulting coordinates: " << first->AtomicPosition << endl; 223 } while (!(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition))); 224 first->AtomicElement = periode->AskElement(); // give type 225 225 mol->AddAtom(first); // add to molecule 226 226 break; … … 239 239 if (j != -1) { 240 240 second = mol->FindAtom(j); 241 atoms[i++] = &(second-> x);241 atoms[i++] = &(second->AtomicPosition); 242 242 } 243 243 } while ((j != -1) && (i<128)); 244 244 if (i >= 2) { 245 LSQdistance(first-> x,(const Vector **)atoms, i);246 247 Log() << Verbose(0) << first-> x;248 first-> type= periode->AskElement(); // give type245 LSQdistance(first->AtomicPosition,(const Vector **)atoms, i); 246 247 Log() << Verbose(0) << first->AtomicPosition; 248 first->AtomicElement = periode->AskElement(); // give type 249 249 mol->AddAtom(first); // add to molecule 250 250 } else { … … 338 338 third = mol->AskAtom("Enter third atom: "); 339 339 340 n = Plane(first-> x,second->x,third->x).getNormal();340 n = Plane(first->AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal(); 341 341 break; 342 342 case 'b': // normal vector of mirror plane … … 354 354 second = mol->AskAtom("Enter second atom: "); 355 355 356 n = first-> x - second->x;356 n = first->AtomicPosition - second->AtomicPosition; 357 357 n.Normalize(); 358 358 break; … … 405 405 third = mol->AskAtom("Enter third atom: "); 406 406 407 n = Plane(first-> x,second->x,third->x).getNormal();407 n = Plane(first->AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal(); 408 408 break; 409 409 case 'b': // normal vector of mirror plane … … 421 421 second = mol->AskAtom("Enter second atom: "); 422 422 423 n = first-> x - second->x;423 n = first->AtomicPosition - second->AtomicPosition; 424 424 n.Normalize(); 425 425 break; … … 464 464 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 465 465 runner = iter++; 466 if ((*runner)-> x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...466 if ((*runner)->AtomicPosition.DistanceSquared((*runner)->AtomicPosition) > tmp1*tmp1) // distance to first above radius ... 467 467 mol->RemoveAtom((*runner)); 468 468 } … … 479 479 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 480 480 runner = iter++; 481 if (((*runner)-> x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...481 if (((*runner)->AtomicPosition[axis] < tmp1) || ((*runner)->AtomicPosition[axis] > tmp2)) {// out of boundary ... 482 482 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 483 483 mol->RemoveAtom((*runner)); … … 526 526 527 527 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 528 Z = (*iter)-> type->Z;528 Z = (*iter)->getType()->Z; 529 529 tmp1 = 0.; 530 530 if (first != (*iter)) { 531 x = first-> x - (*iter)->x;531 x = first->AtomicPosition - (*iter)->AtomicPosition; 532 532 tmp1 = x.Norm(); 533 533 } … … 536 536 } 537 537 for (int i=MAX_ELEMENTS;i--;) 538 if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first-> type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;538 if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->getType()->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl; 539 539 break; 540 540 … … 544 544 for (int i=NDIM;i--;) 545 545 min[i] = 0.; 546 x = first-> x - second->x;546 x = first->AtomicPosition - second->AtomicPosition; 547 547 tmp1 = x.Norm(); 548 548 Log() << Verbose(1) << "Distance vector is " << x << "." << "/n" … … 556 556 third = mol->AskAtom("Enter last atom: "); 557 557 tmp1 = tmp2 = tmp3 = 0.; 558 x = first-> x - second->x;559 y = third-> x - second->x;558 x = first->AtomicPosition - second->AtomicPosition; 559 y = third->AtomicPosition - second->AtomicPosition; 560 560 Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 561 561 Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl; … … 695 695 minBond = 0.; 696 696 for (int i=NDIM;i--;) 697 minBond += (first-> x[i]-second->x[i])*(first->x[i] - second->x[i]);697 minBond += (first->AtomicPosition[i]-second->AtomicPosition[i])*(first->AtomicPosition[i] - second->AtomicPosition[i]); 698 698 minBond = sqrt(minBond); 699 Log() << Verbose(0) << "Current Bond length between " << first-> type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;699 Log() << Verbose(0) << "Current Bond length between " << first->getType()->name << " Atom " << first->nr << " and " << second->getType()->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl; 700 700 Log() << Verbose(0) << "Enter new bond length [a.u.]: "; 701 701 cin >> bond; 702 702 for (int i=NDIM;i--;) { 703 second-> x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);703 second->AtomicPosition[i] -= (second->AtomicPosition[i]-first->AtomicPosition[i])/minBond*(minBond-bond); 704 704 } 705 705 //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: "; … … 757 757 cin >> Z; 758 758 first->setType(Z); 759 Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first-> type->name << "." << endl;759 Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->getType()->name << "." << endl; 760 760 } 761 761 break; … … 785 785 j = 0; 786 786 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 787 Elements[j] = (*iter)-> type;788 vectors[j] = &(*iter)-> x;787 Elements[j] = (*iter)->AtomicElement; 788 vectors[j] = &(*iter)->AtomicPosition; 789 789 j++; 790 790 } … … 798 798 for (int k=count;k--;) { // go through every atom of the original cell 799 799 first = World::getInstance().createAtom(); // create a new body 800 first-> x= (*vectors[k]) + x; // use coordinate of original atom801 first-> type= Elements[k]; // insert original element800 first->AtomicPosition = (*vectors[k]) + x; // use coordinate of original atom 801 first->AtomicElement = Elements[k]; // insert original element 802 802 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 803 803 } -
src/LinearAlgebra/Line.cpp
re588312 rb5c53d 11 11 12 12 #include <cmath> 13 #include <iostream> 13 14 14 15 #include "LinearAlgebra/Vector.hpp" … … 240 241 return Line(x1,x1-x2); 241 242 } 243 244 ostream& operator<<(ostream& ost, const Line& m) 245 { 246 const Vector origin = m.getOrigin(); 247 const Vector direction = m.getDirection(); 248 ost << "("; 249 for (int i=0;i<NDIM;i++) { 250 ost << origin[i]; 251 if (i != 2) 252 ost << ","; 253 } 254 ost << ") -> ("; 255 for (int i=0;i<NDIM;i++) { 256 ost << direction[i]; 257 if (i != 2) 258 ost << ","; 259 } 260 ost << ")"; 261 return ost; 262 }; 263 -
src/LinearAlgebra/Line.hpp
re588312 rb5c53d 11 11 #include "LinearAlgebra/Space.hpp" 12 12 13 #include <iosfwd> 13 14 #include <memory> 14 15 #include <vector> … … 45 46 }; 46 47 48 std::ostream & operator << (std::ostream& ost, const Line &m); 49 47 50 /** 48 51 * Named constructor to make a line through two points -
src/LinearAlgebra/Makefile.am
re588312 rb5c53d 17 17 Plane.cpp \ 18 18 Space.cpp \ 19 Vector.cpp 19 vector_ops.cpp \ 20 Vector.cpp \ 21 VectorInterface.cpp 20 22 21 23 LINALGHEADER = \ … … 27 29 Plane.hpp \ 28 30 Space.hpp \ 29 Vector.hpp 31 vector_ops.hpp \ 32 Vector.hpp \ 33 VectorInterface.hpp 30 34 31 35 -
src/LinearAlgebra/Matrix.cpp
re588312 rb5c53d 16 16 17 17 #include <gsl/gsl_blas.h> 18 #include <gsl/gsl_eigen.h> 19 #include <gsl/gsl_matrix.h> 20 #include <gsl/gsl_multimin.h> 21 #include <gsl/gsl_vector.h> 18 22 #include <cmath> 19 23 #include <iostream> … … 96 100 } 97 101 102 void Matrix::zero(){ 103 for(int i=NDIM;i--;){ 104 for(int j=NDIM;j--;){ 105 set(i,j,0.); 106 } 107 } 108 } 109 98 110 Matrix &Matrix::operator=(const Matrix &src){ 99 111 if(&src!=this){ … … 103 115 } 104 116 105 Matrix &Matrix::operator+=(const Matrix &rhs){117 const Matrix &Matrix::operator+=(const Matrix &rhs){ 106 118 gsl_matrix_add(content->content, rhs.content->content); 107 119 return *this; 108 120 } 109 121 110 Matrix &Matrix::operator-=(const Matrix &rhs){122 const Matrix &Matrix::operator-=(const Matrix &rhs){ 111 123 gsl_matrix_sub(content->content, rhs.content->content); 112 124 return *this; 113 125 } 114 126 115 Matrix &Matrix::operator*=(const Matrix &rhs){127 const Matrix &Matrix::operator*=(const Matrix &rhs){ 116 128 (*this) = (*this)*rhs; 117 129 return *this; 118 130 } 119 131 120 Matrix Matrix::operator+(const Matrix &rhs) const{132 const Matrix Matrix::operator+(const Matrix &rhs) const{ 121 133 Matrix tmp = *this; 122 134 tmp+=rhs; … … 124 136 } 125 137 126 Matrix Matrix::operator-(const Matrix &rhs) const{138 const Matrix Matrix::operator-(const Matrix &rhs) const{ 127 139 Matrix tmp = *this; 128 140 tmp-=rhs; … … 130 142 } 131 143 132 Matrix Matrix::operator*(const Matrix &rhs) const{144 const Matrix Matrix::operator*(const Matrix &rhs) const{ 133 145 gsl_matrix *res = gsl_matrix_alloc(NDIM, NDIM); 134 146 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, content->content, rhs.content->content, 0.0, res); … … 192 204 - at(2,2)*at(1,0)*at(0,1); 193 205 } 206 207 Matrix Matrix::transpose() const 208 { 209 Matrix copy(*this); 210 copy.transpose(); 211 return copy; 212 } 213 214 215 void Matrix::transpose() 216 { 217 double tmp; 218 for (int i=0;i<NDIM;i++) 219 for (int j=i+1;j<NDIM;j++) { 220 tmp = at(j,i); 221 at(i,j) = tmp; 222 at(j,i) = tmp; 223 } 224 } 225 194 226 195 227 Matrix Matrix::invert() const{ … … 213 245 } 214 246 215 Matrix &Matrix::operator*=(const double factor){ 247 Vector Matrix::transformToEigenbasis() 248 { 249 gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM); 250 gsl_vector *eval = gsl_vector_alloc(NDIM); 251 gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM); 252 gsl_eigen_symmv(content->content, eval, evec, T); 253 gsl_eigen_symmv_free(T); 254 gsl_matrix_memcpy(content->content, evec); 255 Vector evalues(gsl_vector_get(eval,0), gsl_vector_get(eval,1), gsl_vector_get(eval,2)); 256 return evalues; 257 } 258 259 const Matrix &Matrix::operator*=(const double factor){ 216 260 gsl_matrix_scale(content->content, factor); 217 261 return *this; 218 262 } 219 263 220 Matrix operator*(const double factor,const Matrix& mat){264 const Matrix operator*(const double factor,const Matrix& mat){ 221 265 Matrix tmp = mat; 222 266 tmp*=factor; … … 224 268 } 225 269 226 Matrix operator*(const Matrix &mat,const double factor){270 const Matrix operator*(const Matrix &mat,const double factor){ 227 271 return factor*mat; 228 272 } -
src/LinearAlgebra/Matrix.hpp
re588312 rb5c53d 51 51 52 52 /** 53 * Set all matrix entries to zero. 54 */ 55 void zero(); 56 57 /** 53 58 * Access the matrix at index (i,j) 54 59 */ … … 96 101 Matrix invert() const; 97 102 103 /** 104 * Diagonalizes a matrix and sets its rows to the resulting eigenvalues. 105 * The eigenvalues are returned as a vector. 106 * 107 * Rather costly, so use precomputation as often as possible. 108 */ 109 Vector transformToEigenbasis(); 110 111 /** 112 * Calculate the transpose of the matrix. 113 */ 114 Matrix transpose() const; 115 void transpose(); 116 98 117 // operators 99 118 Matrix &operator=(const Matrix&); 100 119 101 Matrix &operator+=(const Matrix&);102 Matrix &operator-=(const Matrix&);103 Matrix &operator*=(const Matrix&);120 const Matrix &operator+=(const Matrix&); 121 const Matrix &operator-=(const Matrix&); 122 const Matrix &operator*=(const Matrix&); 104 123 105 Matrix &operator*=(const double);124 const Matrix &operator*=(const double); 106 125 107 Matrix operator+(const Matrix&) const;108 Matrix operator-(const Matrix&) const;109 Matrix operator*(const Matrix&) const;126 const Matrix operator+(const Matrix&) const; 127 const Matrix operator-(const Matrix&) const; 128 const Matrix operator*(const Matrix&) const; 110 129 111 130 bool operator==(const Matrix&) const; … … 121 140 }; 122 141 123 Matrix operator*(const double,const Matrix&);124 Matrix operator*(const Matrix&,const double);142 const Matrix operator*(const double,const Matrix&); 143 const Matrix operator*(const Matrix&,const double); 125 144 126 145 /** -
src/LinearAlgebra/Vector.cpp
re588312 rb5c53d 17 17 #include <iostream> 18 18 #include <gsl/gsl_blas.h> 19 #include <gsl/gsl_vector.h> 19 20 20 21 … … 51 52 }; 52 53 54 /** Constructor of class vector. 55 */ 56 Vector::Vector(const double x[3]) 57 { 58 content = new VectorContent(); 59 gsl_vector_set(content->content,0,x[0]); 60 gsl_vector_set(content->content,1,x[1]); 61 gsl_vector_set(content->content,2,x[2]); 62 }; 63 53 64 Vector::Vector(VectorContent *_content) : 54 65 content(_content) … … 92 103 return (sqrt(DistanceSquared(y))); 93 104 }; 105 106 size_t Vector::GreatestComponent() const 107 { 108 int greatest = 0; 109 for (int i=1;i<NDIM;i++) { 110 if (at(i) > at(greatest)) 111 greatest = i; 112 } 113 return greatest; 114 } 115 116 size_t Vector::SmallestComponent() const 117 { 118 int smallest = 0; 119 for (int i=1;i<NDIM;i++) { 120 if (at(i) < at(smallest)) 121 smallest = i; 122 } 123 return smallest; 124 } 125 94 126 95 127 Vector Vector::getClosestPoint(const Vector &point) const{ -
src/LinearAlgebra/Vector.hpp
re588312 rb5c53d 36 36 Vector(); 37 37 Vector(const double x1, const double x2, const double x3); 38 Vector(const double x[3]); 38 39 Vector(const Vector& src); 39 40 virtual ~Vector(); … … 63 64 std::pair<Vector,Vector> partition(const Vector&) const; 64 65 std::pair<pointset,Vector> partition(const pointset&) const; 66 size_t GreatestComponent() const; 67 size_t SmallestComponent() const; 65 68 66 69 // Accessors ussually come in pairs... and sometimes even more than that -
src/Makefile.am
re588312 rb5c53d 120 120 QTUI_DEFS = 121 121 122 TESSELATIONSOURCE = \ 123 BoundaryLineSet.cpp \ 124 BoundaryPointSet.cpp \ 125 BoundaryPolygonSet.cpp \ 126 BoundaryTriangleSet.cpp \ 127 CandidateForTesselation.cpp \ 128 PointCloud.cpp \ 129 tesselation.cpp \ 130 tesselationhelpers.cpp \ 131 TesselPoint.cpp 132 133 TESSELATIONHEADER = \ 134 BoundaryLineSet.hpp \ 135 BoundaryPointSet.hpp \ 136 BoundaryPolygonSet.hpp \ 137 BoundaryTriangleSet.hpp \ 138 CandidateForTesselation.hpp \ 139 PointCloud.hpp \ 140 tesselation.hpp \ 141 tesselationhelpers.hpp \ 142 TesselPoint.hpp 143 122 144 MOLECUILDERSOURCE = \ 123 145 ${ANALYSISSOURCE} \ … … 125 147 ${ATOMSOURCE} \ 126 148 ${PATTERNSOURCE} \ 127 ${PARSERSOURCE} \128 149 ${SHAPESOURCE} \ 129 150 ${DESCRIPTORSOURCE} \ 151 ${TESSELATIONSOURCE} \ 130 152 bond.cpp \ 131 153 bondgraph.cpp \ … … 135 157 config.cpp \ 136 158 ConfigFileBuffer.cpp \ 159 defs.cpp \ 137 160 element.cpp \ 138 161 elements_db.cpp \ … … 151 174 parser.cpp \ 152 175 periodentafel.cpp \ 153 tesselation.cpp \154 tesselationhelpers.cpp \155 176 ThermoStatContainer.cpp \ 156 177 triangleintersectionlist.cpp \ 157 178 UIElements/UIFactory.cpp \ 158 vector_ops.cpp \159 179 World.cpp 160 180 … … 163 183 ${ACTIONSHEADER} \ 164 184 ${ATOMHEADER} \ 165 ${PARSERHEADER} \166 185 ${PATTERNHEADER} \ 167 186 ${SHAPEHEADER} \ 168 187 ${DESCRIPTORHEADER} \ 188 ${TESSELATIONHEADER} \ 169 189 bond.hpp \ 170 190 bondgraph.hpp \ … … 188 208 periodentafel.hpp \ 189 209 stackclass.hpp \ 190 tesselation.hpp \191 tesselationhelpers.hpp \192 210 ThermoStatContainer.hpp \ 193 211 triangleintersectionlist.hpp \ 194 212 UIElements/UIFactory.hpp \ 195 vector_ops.hpp \196 213 World.hpp 197 214 … … 303 320 joiner_SOURCES = joiner.cpp datacreator.cpp datacreator.hpp periodentafel.hpp 304 321 joiner_LDADD = \ 322 Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \ 305 323 libMolecuilder-@MOLECUILDER_API_VERSION@.la \ 324 Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \ 306 325 LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \ 307 326 Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \ … … 313 332 analyzer_SOURCES = analyzer.cpp datacreator.cpp periodentafel.hpp datacreator.hpp 314 333 analyzer_LDADD = \ 334 Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \ 315 335 libMolecuilder-@MOLECUILDER_API_VERSION@.la \ 336 Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \ 316 337 LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \ 317 338 Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \ -
src/Parser/ChangeTracker.cpp
re588312 rb5c53d 9 9 #include "Parser/ChangeTracker.hpp" 10 10 #include "Patterns/Singleton_impl.hpp" 11 11 #include "Helpers/Log.hpp" 12 #include "Helpers/Verbose.hpp" 12 13 13 14 /** … … 15 16 */ 16 17 ChangeTracker::ChangeTracker() : 17 Observable("ChangeTracker") 18 Observable("ChangeTracker"), 19 isConsistent(true) 18 20 { 19 isConsistent = true;20 21 World::getInstance().signOn(this); 21 22 } … … 49 50 */ 50 51 void ChangeTracker::saveStatus() { 52 DoLog(0) && (Log() << Verbose(0) << "Saving changes." << std::endl); 51 53 if (hasChanged()) { 52 54 notifyAll(); -
src/Parser/FormatParser.cpp
re588312 rb5c53d 17 17 */ 18 18 FormatParser::FormatParser() : 19 Observer("FormatParser") 19 Observer("FormatParser"), 20 saveStream(NULL) 20 21 { 21 22 ChangeTracker::getInstance().signOn(this); 22 saveStream = NULL;23 23 } 24 24 -
src/Parser/MpqcParser.cpp
re588312 rb5c53d 12 12 #include "element.hpp" 13 13 #include "Helpers/Log.hpp" 14 #include "Helpers/Verbose.hpp" 15 #include "LinearAlgebra/Vector.hpp" 14 16 #include "periodentafel.hpp" 15 #include "LinearAlgebra/Vector.hpp"16 #include "Helpers/Verbose.hpp"17 17 #include "World.hpp" 18 18 … … 22 22 */ 23 23 MpqcParser::MpqcParser() : HessianPresent(false) 24 { 25 26 } 24 {} 27 25 28 26 /** Destructor of MpqcParser. 29 27 * 30 28 */ 31 MpqcParser::~MpqcParser() { 32 33 } 29 MpqcParser::~MpqcParser() 30 {} 34 31 35 32 /** Load an MPQC config file into the World. … … 43 40 void MpqcParser::save(ostream *file) 44 41 { 42 DoLog(0) && (Log() << Verbose(0) << "Saving changes to MPQC ." << std::endl); 43 45 44 if (HessianPresent) 46 45 saveHessian(file); … … 60 59 // calculate center 61 60 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner) 62 center += (*runner)-> x;61 center += (*runner)->getPosition(); 63 62 center.Scale(1./allatoms.size()); 64 63 … … 108 107 // calculate center 109 108 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner) 110 center += (*runner)-> x;109 center += (*runner)->getPosition(); 111 110 center.Scale(1./allatoms.size()); 112 111 -
src/Parser/PcpParser.cpp
re588312 rb5c53d 15 15 #include "Helpers/Assert.hpp" 16 16 #include "Helpers/Log.hpp" 17 #include "Helpers/Verbose.hpp" 18 #include "LinearAlgebra/Matrix.hpp" 17 19 #include "molecule.hpp" 18 20 #include "PcpParser.hpp" 19 21 #include "periodentafel.hpp" 20 22 #include "ThermoStatContainer.hpp" 21 #include "Helpers/Verbose.hpp"22 23 #include "World.hpp" 23 #include "LinearAlgebra/Matrix.hpp"24 24 #include "Box.hpp" 25 26 27 PcpParser::StructParallelization::StructParallelization() : 28 ProcPEGamma(8), 29 ProcPEPsi(1) 30 {} 31 32 PcpParser::StructParallelization::~StructParallelization() 33 {} 34 35 PcpParser::StructPaths::StructPaths() : 36 databasepath(NULL), 37 configname(NULL), 38 mainname(NULL), 39 defaultpath(NULL), 40 pseudopotpath(NULL) 41 {} 42 43 PcpParser::StructPaths::~StructPaths() 44 {} 45 46 PcpParser::StructSwitches::StructSwitches() : 47 DoConstrainedMD(0), 48 DoOutVis(0), 49 DoOutMes(1), 50 DoOutNICS(0), 51 DoOutOrbitals(0), 52 DoOutCurrent(0), 53 DoFullCurrent(0), 54 DoPerturbation(0), 55 DoWannier(0) 56 {} 57 58 PcpParser::StructSwitches::~StructSwitches() 59 {} 60 61 PcpParser::StructLocalizedOrbitals::StructLocalizedOrbitals() : 62 CommonWannier(0), 63 SawtoothStart(0.01), 64 VectorPlane(0), 65 VectorCut(0), 66 UseAddGramSch(1), 67 Seed(1), 68 EpsWannier(1e-7) 69 {} 70 71 PcpParser::StructLocalizedOrbitals::~StructLocalizedOrbitals() 72 {} 73 74 PcpParser::StructStepCounts::StructStepCounts() : 75 MaxMinStopStep(1), 76 InitMaxMinStopStep(1), 77 OutVisStep(10), 78 OutSrcStep(5), 79 MaxPsiStep(0), 80 MaxOuterStep(0), 81 MaxMinStep(100), 82 RelEpsTotalEnergy(1e-07), 83 RelEpsKineticEnergy(1e-05), 84 MaxMinGapStopStep(0), 85 MaxInitMinStep(100), 86 InitRelEpsTotalEnergy(1e-05), 87 InitRelEpsKineticEnergy(0.0001), 88 InitMaxMinGapStopStep(0) 89 {} 90 91 PcpParser::StructStepCounts::~StructStepCounts() 92 {} 93 94 PcpParser::StructPlaneWaveSpecifics::StructPlaneWaveSpecifics() : 95 PsiType(0), 96 MaxPsiDouble(0), 97 PsiMaxNoUp(0), 98 PsiMaxNoDown(0), 99 ECut(128), 100 MaxLevel(5), 101 RiemannTensor(0), 102 LevRFactor(0), 103 RiemannLevel(0), 104 Lev0Factor(2), 105 RTActualUse(0), 106 AddPsis(0), 107 RCut(20) 108 {} 109 110 PcpParser::StructPlaneWaveSpecifics::~StructPlaneWaveSpecifics() 111 {} 25 112 26 113 /** Constructor of PcpParser. 27 114 * 28 115 */ 29 PcpParser::PcpParser() 30 { 31 Parallelization.ProcPEGamma = 8; 32 Parallelization.ProcPEPsi = 1; 33 34 Paths.databasepath = NULL; 35 Paths.configname = NULL; 36 Paths.mainname = NULL; 37 Paths.defaultpath = NULL; 38 Paths.pseudopotpath = NULL; 39 40 Switches.DoConstrainedMD = 0; 41 Switches.DoOutVis = 0; 42 Switches.DoOutMes = 1; 43 Switches.DoOutNICS = 0; 44 Switches.DoOutOrbitals = 0; 45 Switches.DoOutCurrent = 0; 46 Switches.DoFullCurrent = 0; 47 Switches.DoPerturbation = 0; 48 Switches.DoWannier = 0; 49 50 LocalizedOrbitals.CommonWannier = 0; 51 LocalizedOrbitals.SawtoothStart = 0.01; 52 LocalizedOrbitals.VectorPlane = 0; 53 LocalizedOrbitals.VectorCut = 0; 54 LocalizedOrbitals.UseAddGramSch = 1; 55 LocalizedOrbitals.Seed = 1; 56 LocalizedOrbitals.EpsWannier = 1e-7; 57 58 StepCounts.MaxMinStopStep = 1; 59 StepCounts.InitMaxMinStopStep = 1; 60 StepCounts.OutVisStep = 10; 61 StepCounts.OutSrcStep = 5; 62 StepCounts.MaxPsiStep = 0; 63 StepCounts.MaxOuterStep = 0; 64 StepCounts.MaxMinStep = 100; 65 StepCounts.RelEpsTotalEnergy = 1e-07; 66 StepCounts.RelEpsKineticEnergy = 1e-05; 67 StepCounts.MaxMinGapStopStep = 0; 68 StepCounts.MaxInitMinStep = 100; 69 StepCounts.InitRelEpsTotalEnergy = 1e-05; 70 StepCounts.InitRelEpsKineticEnergy = 0.0001; 71 StepCounts.InitMaxMinGapStopStep = 0; 72 73 PlaneWaveSpecifics.PsiType = 0; 74 PlaneWaveSpecifics.MaxPsiDouble = 0; 75 PlaneWaveSpecifics.PsiMaxNoUp = 0; 76 PlaneWaveSpecifics.PsiMaxNoDown = 0; 77 PlaneWaveSpecifics.ECut = 128; 78 PlaneWaveSpecifics.MaxLevel = 5; 79 PlaneWaveSpecifics.RiemannTensor = 0; 80 PlaneWaveSpecifics.LevRFactor = 0; 81 PlaneWaveSpecifics.RiemannLevel = 0; 82 PlaneWaveSpecifics.Lev0Factor = 2; 83 PlaneWaveSpecifics.RTActualUse = 0; 84 PlaneWaveSpecifics.AddPsis = 0; 85 PlaneWaveSpecifics.RCut = 20; 86 PlaneWaveSpecifics.PsiType = 0; 87 88 FastParsing = false; 89 90 Deltat = 0.01; 91 IsAngstroem = 1; 92 RelativeCoord = 0; 93 StructOpt = 0; 94 MaxTypes = 0; 95 } 116 PcpParser::PcpParser() : 117 FastParsing(false), 118 Deltat(0.01), 119 IsAngstroem(1), 120 RelativeCoord(0), 121 StructOpt(0), 122 MaxTypes(0) 123 {} 96 124 97 125 /** Destructor of PcpParser. … … 332 360 void PcpParser::save(std::ostream* file) 333 361 { 362 DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl); 363 334 364 const Matrix &domain = World::getInstance().getDomain().getM(); 335 365 class ThermoStatContainer *Thermostats = World::getInstance().getThermostats(); … … 460 490 PlaneWaveSpecifics.MaxPsiDouble = PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.PsiType = 0; 461 491 for (vector<atom *>::iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) { 462 PlaneWaveSpecifics.MaxPsiDouble += (*runner)-> type->NoValenceOrbitals;492 PlaneWaveSpecifics.MaxPsiDouble += (*runner)->getType()->NoValenceOrbitals; 463 493 } 464 494 cout << PlaneWaveSpecifics.MaxPsiDouble << endl; … … 495 525 // insert all found elements into the map 496 526 for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) { 497 Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)-> type->Z, 1));527 Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->getType()->Z, 1)); 498 528 if (!Inserter.second) // increase if present 499 529 Inserter.first->second += 1; … … 526 556 int nr = 0; 527 557 for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) { 528 Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)-> type->Z, 1) );558 Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->getType()->Z, 1) ); 529 559 if (!Inserter.second) 530 560 Inserter.first->second += 1; 531 const int Z = (*AtomRunner)-> type->Z;561 const int Z = (*AtomRunner)->getType()->Z; 532 562 *file << "Ion_Type" << ZtoIndexMap[Z] << "_" << ZtoCountMap[Z] << "\t" << fixed << setprecision(9) << showpoint; 533 *file << (*AtomRunner)-> x[0] << "\t" << (*AtomRunner)->x[1] << "\t" << (*AtomRunner)->x[2];563 *file << (*AtomRunner)->at(0) << "\t" << (*AtomRunner)->at(1) << "\t" << (*AtomRunner)->at(2); 534 564 *file << "\t" << (*AtomRunner)->FixedIon; 535 if ((*AtomRunner)-> v.Norm() > MYEPSILON)536 *file << "\t" << scientific << setprecision(6) << (*AtomRunner)-> v[0] << "\t" << (*AtomRunner)->v[1] << "\t" << (*AtomRunner)->v[2] << "\t";565 if ((*AtomRunner)->AtomicVelocity.Norm() > MYEPSILON) 566 *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->AtomicVelocity[0] << "\t" << (*AtomRunner)->AtomicVelocity[1] << "\t" << (*AtomRunner)->AtomicVelocity[2] << "\t"; 537 567 *file << " # molecule nr " << nr++ << endl; 538 568 } -
src/Parser/PcpParser.hpp
re588312 rb5c53d 31 31 void CalculateOrbitals(vector<atom *> &allatoms); 32 32 33 struct StructParallelization { 33 class StructParallelization { 34 public: 35 StructParallelization(); 36 ~StructParallelization(); 37 34 38 int ProcPEGamma; 35 39 int ProcPEPsi; … … 39 43 * Contains all the paths and names 40 44 */ 41 struct StructPaths { 45 class StructPaths { 46 public: 47 StructPaths(); 48 ~StructPaths(); 49 42 50 char *databasepath; 43 51 char *configname; … … 50 58 * Contains all Do/Don't switches 51 59 */ 52 struct StructSwitches { 60 class StructSwitches { 61 public: 62 StructSwitches(); 63 ~StructSwitches(); 64 53 65 int DoConstrainedMD; 54 66 int DoOutVis; … … 65 77 * Contains parameters regarding localization of orbitals or magnetic perturbation 66 78 */ 67 struct StructLocalizedOrbitals { 79 class StructLocalizedOrbitals { 80 public: 81 StructLocalizedOrbitals(); 82 ~StructLocalizedOrbitals(); 83 68 84 int CommonWannier; 69 85 double SawtoothStart; … … 78 94 * Contains all step count and other epsilon threshold parameters 79 95 */ 80 struct StructStepCounts { 96 class StructStepCounts { 97 public: 98 StructStepCounts(); 99 ~StructStepCounts(); 100 81 101 int MaxMinStopStep; 82 102 int InitMaxMinStopStep; … … 101 121 * Contains all parameters specific to the plane wave basis set 102 122 */ 103 struct StructPlaneWaveSpecifics { 123 class StructPlaneWaveSpecifics { 124 public: 125 StructPlaneWaveSpecifics(); 126 ~StructPlaneWaveSpecifics(); 127 104 128 int PsiType; 105 129 int MaxPsiDouble; -
src/Parser/TremoloParser.cpp
re588312 rb5c53d 9 9 10 10 #include "Helpers/Assert.hpp" 11 #include "Helpers/Log.hpp" 12 #include "Helpers/Verbose.hpp" 11 13 #include "TremoloParser.hpp" 12 14 #include "World.hpp" … … 98 100 */ 99 101 void TremoloParser::save(ostream* file) { 102 DoLog(0) && (Log() << Verbose(0) << "Saving changes to tremolo." << std::endl); 103 100 104 vector<atom*>::iterator atomIt; 101 105 vector<string>::iterator it; … … 139 143 case TremoloKey::x : 140 144 // for the moment, assume there are always three dimensions 141 *file << currentAtom-> x[0]<< "\t";142 *file << currentAtom-> x[1]<< "\t";143 *file << currentAtom-> x[2]<< "\t";145 *file << currentAtom->at(0) << "\t"; 146 *file << currentAtom->at(1) << "\t"; 147 *file << currentAtom->at(2) << "\t"; 144 148 break; 145 149 case TremoloKey::u : 146 150 // for the moment, assume there are always three dimensions 147 *file << currentAtom-> v[0] << "\t";148 *file << currentAtom-> v[1] << "\t";149 *file << currentAtom-> v[2] << "\t";151 *file << currentAtom->AtomicVelocity[0] << "\t"; 152 *file << currentAtom->AtomicVelocity[1] << "\t"; 153 *file << currentAtom->AtomicVelocity[2] << "\t"; 150 154 break; 151 155 case TremoloKey::Type : … … 224 228 string word; 225 229 int oldId; 230 double tmp; 226 231 227 232 lineStream << line; … … 231 236 case TremoloKey::x : 232 237 // for the moment, assume there are always three dimensions 233 lineStream >> newAtom->x[0]; 234 lineStream >> newAtom->x[1]; 235 lineStream >> newAtom->x[2]; 238 for (int i=0;i<NDIM;i++) { 239 lineStream >> tmp; 240 newAtom->set(i, tmp); 241 } 236 242 break; 237 243 case TremoloKey::u : 238 244 // for the moment, assume there are always three dimensions 239 lineStream >> newAtom-> v[0];240 lineStream >> newAtom-> v[1];241 lineStream >> newAtom-> v[2];245 lineStream >> newAtom->AtomicVelocity[0]; 246 lineStream >> newAtom->AtomicVelocity[1]; 247 lineStream >> newAtom->AtomicVelocity[2]; 242 248 break; 243 249 case TremoloKey::Type : … … 384 390 385 391 386 TremoloAtomInfoContainer::TremoloAtomInfoContainer() {387 F = "0";388 stress = "0";389 imprData = "-";390 GroupMeasureTypeNo = "0";391 extType = "-";392 name = "-";393 resName = "-";394 chainID = "0";395 resSeq = "0";396 occupancy = "0";397 tempFactor = "0";398 segID = "0";399 Charge = "0";400 charge = "0";401 GrpTypeNo = "0";402 torsion = "-";403 neighbors = vector<int>(0, 5);404 }392 TremoloAtomInfoContainer::TremoloAtomInfoContainer() : 393 F("0"), 394 stress("0"), 395 imprData("-"), 396 GroupMeasureTypeNo("0"), 397 extType("-"), 398 name("-"), 399 resName("-"), 400 chainID("0"), 401 resSeq("0"), 402 occupancy("0"), 403 tempFactor("0"), 404 segID("0"), 405 Charge("0"), 406 charge("0"), 407 GrpTypeNo("0"), 408 torsion("-"), 409 neighbors(vector<int>(0, 5)) 410 {} 405 411 406 412 void TremoloAtomInfoContainer::set(TremoloKey::atomDataKey key, string value) { -
src/Parser/XyzParser.cpp
re588312 rb5c53d 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 #include "Helpers/Log.hpp" 11 #include "Helpers/Verbose.hpp" 10 12 #include "XyzParser.hpp" 11 13 #include "World.hpp" 12 14 #include "atom.hpp" 15 #include "molecule.hpp" 13 16 #include "element.hpp" 14 17 #include "periodentafel.hpp" … … 19 22 * Constructor. 20 23 */ 21 XyzParser::XyzParser() {22 comment = "";23 }24 XyzParser::XyzParser() : 25 comment("") 26 {} 24 27 25 28 /** … … 35 38 */ 36 39 void XyzParser::load(istream* file) { 37 atom* newAtom; 40 atom* newAtom = NULL; 41 molecule* newmol = NULL; 38 42 int numberOfAtoms; 39 43 char commentBuffer[512], type[3]; 44 double tmp; 40 45 41 46 // the first line tells number of atoms, the second line is always a comment … … 44 49 comment = commentBuffer; 45 50 51 newmol = World::getInstance().createMolecule(); 52 newmol->ActiveFlag = true; 53 World::getInstance().getMolecules()->insert(newmol); 46 54 for (int i = 0; i < numberOfAtoms; i++) { 47 55 newAtom = World::getInstance().createAtom(); 48 *file >> type >> ws >> newAtom->x[0] >> ws >> newAtom->x[1] >> ws >> newAtom->x[2]; 56 *file >> type; 57 for (int j=0;j<NDIM;j++) { 58 *file >> tmp; 59 newAtom->set(j, tmp); 60 } 49 61 newAtom->setType(World::getInstance().getPeriode()->FindElement(type)); 62 newmol->AddAtom(newAtom); 50 63 } 51 64 } … … 57 70 */ 58 71 void XyzParser::save(ostream* file) { 72 DoLog(0) && (Log() << Verbose(0) << "Saving changes to xyz." << std::endl); 59 73 if (comment == "") { 60 74 time_t now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' … … 72 86 vector<atom*> atoms = World::getInstance().getAllAtoms(); 73 87 for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) { 74 *file << noshowpoint << (*it)->getType()->getSymbol() << "\t" << (*it)-> x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2]<< endl;88 *file << noshowpoint << (*it)->getType()->getSymbol() << "\t" << (*it)->at(0) << "\t" << (*it)->at(1) << "\t" << (*it)->at(2) << endl; 75 89 } 76 90 } -
src/ThermoStatContainer.cpp
re588312 rb5c53d 17 17 * 18 18 */ 19 ThermoStatContainer::ThermoStatContainer() : Thermostat(4), ThermostatImplemented(NULL), 20 ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25) 19 ThermoStatContainer::ThermoStatContainer() : 20 Thermostat(4), 21 ThermostatImplemented(NULL), 22 ThermostatNames(NULL), 23 TempFrequency(2.5), 24 alpha(0.), 25 HooverMass(0.), 26 TargetTemp(0.00095004455), 27 ScaleTempStep(25) 21 28 { 22 29 ThermostatImplemented = new int[MaxThermostats]; -
src/ThermoStatContainer.hpp
re588312 rb5c53d 16 16 class ConfigFileBuffer; 17 17 18 #define MaxThermostats 6//!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented18 enum { MaxThermostats=6 }; //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented 19 19 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover }; //!< Thermostat names for output 20 20 -
src/UIElements/Menu/DisplayMenuItem.cpp
re588312 rb5c53d 16 16 17 17 DisplayMenuItem::DisplayMenuItem(Menu* _menu, StringView *_view): 18 MenuItem('\0',"",_menu),19 view(_view),20 title("")18 MenuItem('\0',"",_menu), 19 view(_view), 20 title("") 21 21 { 22 22 } -
src/UIElements/Menu/MenuItem.cpp
re588312 rb5c53d 18 18 */ 19 19 MenuItem::MenuItem(char _trigger, const char* _description,Menu* menu) : 20 trigger(_trigger),21 added(false)20 trigger(_trigger), 21 added(false) 22 22 { 23 23 description = new string(_description); -
src/UIElements/Menu/SeperatorItem.cpp
re588312 rb5c53d 17 17 18 18 SeperatorItem::SeperatorItem(Menu* menu): 19 MenuItem('\0',"",menu),20 spacer(STD_SEPERATOR_SPACER),21 length(STD_MENU_LENGTH)19 MenuItem('\0',"",menu), 20 spacer(STD_SEPERATOR_SPACER), 21 length(STD_MENU_LENGTH) 22 22 { 23 23 // TODO Auto-generated constructor stub … … 26 26 27 27 SeperatorItem::SeperatorItem(Menu* menu,char _spacer, int _length): 28 MenuItem('\0',"",menu),29 spacer(_spacer),30 length(_length)28 MenuItem('\0',"",menu), 29 spacer(_spacer), 30 length(_length) 31 31 { 32 32 // TODO Auto-generated constructor stub -
src/UIElements/Menu/SubMenuItem.cpp
re588312 rb5c53d 11 11 12 12 SubMenuItem::SubMenuItem(char _trigger,const char* _description,Menu* _parent, Menu* _theMenu) : 13 MenuItem(_trigger,_description,_parent),14 theMenu(_theMenu)13 MenuItem(_trigger,_description,_parent), 14 theMenu(_theMenu) 15 15 { 16 16 } -
src/UIElements/Menu/TextMenu.cpp
re588312 rb5c53d 113 113 114 114 TextMenu::LeaveAction::LeaveAction(TextMenu* _menu) : 115 Action(nameBase+_menu->getTitle()),116 menu(_menu)115 Action(nameBase+_menu->getTitle()), 116 menu(_menu) 117 117 {} 118 118 -
src/UIElements/QT4/QTDialog.cpp
re588312 rb5c53d 481 481 parent(_parent) 482 482 { 483 const Matrix& M = World::getInstance().getDomain().getM();484 const char *coords[3] = {"x:","y:","z:"};485 483 mainLayout= new QHBoxLayout(); 486 484 titleLabel = new QLabel(QString(getTitle().c_str())); … … 515 513 parent(_parent) 516 514 { 517 const Matrix& M = World::getInstance().getDomain().getM();518 const char *coords[3] = {"x:","y:","z:"};519 515 mainLayout= new QHBoxLayout(); 520 516 titleLabel = new QLabel(QString(getTitle().c_str())); -
src/UIElements/QT4/QTUIFactory.cpp
re588312 rb5c53d 20 20 #include "Helpers/MemDebug.hpp" 21 21 22 QTUIFactory::QTUIFactory() 22 QTUIFactory::QTUIFactory() : 23 argc(1) 23 24 { 24 25 // For now we just fake the command line parameters to make QT happy 25 argc=1;26 26 argv = new char*[1]; 27 27 argv[0] = new char[256]; -
src/UIElements/TextUI/TextDialog.cpp
re588312 rb5c53d 525 525 } 526 526 } 527 527 528 return true; 528 529 } -
src/UIElements/Views/MethodStringView.cpp
re588312 rb5c53d 13 13 14 14 MethodStringView::MethodStringView(boost::function<string()> _displayMethod) : 15 StringView(),16 displayMethod(_displayMethod)15 StringView(), 16 displayMethod(_displayMethod) 17 17 { 18 18 // TODO Auto-generated constructor stub -
src/UIElements/Views/StreamStringView.cpp
re588312 rb5c53d 16 16 17 17 StreamStringView::StreamStringView(boost::function<void(ostream *)> _displayMethod) : 18 StringView(),19 displayMethod(_displayMethod)18 StringView(), 19 displayMethod(_displayMethod) 20 20 {} 21 21 -
src/analysis_bonds.cpp
re588312 rb5c53d 60 60 int AtomNo = 0; 61 61 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 62 if ((*iter)-> type== type1)62 if ((*iter)->getType() == type1) 63 63 for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++) 64 if ((*BondRunner)->GetOtherAtom((*iter))-> type== type2) {64 if ((*BondRunner)->GetOtherAtom((*iter))->getType() == type2) { 65 65 const double distance = (*BondRunner)->GetDistanceSquared(); 66 66 if (Min > distance) … … 87 87 * \return angle between \a *first and \a *second, both relative to origin at \a *origin. 88 88 */ 89 double CalculateAngle( Vector *first, Vector *central, Vector *second)89 double CalculateAngle(const Vector &first, const Vector ¢ral, const Vector &second) 90 90 { 91 91 Vector OHBond; 92 92 Vector OOBond; 93 93 94 OHBond = (*first) - (*central);95 OOBond = (*second) - (*central);94 OHBond = first - central; 95 OOBond = second - central; 96 96 const double angle = OHBond.Angle(OOBond); 97 97 return angle; … … 110 110 111 111 // check angle 112 if (CalculateAngle( &Hydrogen->x, &Oxygen->x, &OtherOxygen->x) < M_PI*(30./180.)) {112 if (CalculateAngle(Hydrogen->getPosition(), Oxygen->getPosition(), OtherOxygen->getPosition()) < M_PI*(30./180.)) { 113 113 return true; 114 114 } else { … … 138 138 molecule::iterator Runner = (*MolRunner)->begin(); 139 139 for(;Runner!=(*MolRunner)->end();++Runner){ 140 if (((*Walker)-> type->Z == 8) && ((*Runner)->type->Z == 8)) {140 if (((*Walker)->getType()->Z == 8) && ((*Runner)->getType()->Z == 8)) { 141 141 // check distance 142 const double distance = (*Runner)-> x.DistanceSquared((*Walker)->x);142 const double distance = (*Runner)->DistanceSquared(*(*Walker)); 143 143 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 144 144 // on other atom(Runner) we check for bond to interface element and … … 152 152 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner); 153 153 // if hydrogen, check angle to be greater(!) than 30 degrees 154 if (OtherAtom-> type->Z == 1) {155 const double angle = CalculateAngle( &OtherAtom->x, &(*Runner)->x, &(*Walker)->x);154 if (OtherAtom->getType()->Z == 1) { 155 const double angle = CalculateAngle(OtherAtom->getPosition(), (*Runner)->getPosition(), (*Walker)->getPosition()); 156 156 OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON); 157 157 Otherangle += angle; 158 158 OtherHydrogens++; 159 159 } 160 InterfaceFlag = InterfaceFlag || (OtherAtom-> type== InterfaceElement);161 Interface2Flag = Interface2Flag || (OtherAtom-> type== Interface2Element);160 InterfaceFlag = InterfaceFlag || (OtherAtom->getType() == InterfaceElement); 161 Interface2Flag = Interface2Flag || (OtherAtom->getType() == Interface2Element); 162 162 } 163 163 DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl); … … 177 177 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) { 178 178 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker); 179 if (OtherAtom-> type->Z == 1) {179 if (OtherAtom->getType()->Z == 1) { 180 180 // check angle 181 181 if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) { 182 DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle( &OtherAtom->x, &(*Walker)->x, &(*Runner)->x)*(180./M_PI) << "." << endl);182 DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(OtherAtom->getPosition(), (*Walker)->getPosition(), (*Runner)->getPosition())*(180./M_PI) << "." << endl); 183 183 count++; 184 184 break; … … 210 210 for(;Walker!=(*MolWalker)->end();++Walker){ 211 211 atom * theAtom = *Walker; 212 if ((theAtom-> type == first) || (theAtom->type== second)) { // first element matches212 if ((theAtom->getType() == first) || (theAtom->getType() == second)) { // first element matches 213 213 for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) { 214 214 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 215 if (((OtherAtom-> type == first) || (OtherAtom->type== second)) && (theAtom->nr < OtherAtom->nr)) {215 if (((OtherAtom->getType() == first) || (OtherAtom->getType() == second)) && (theAtom->nr < OtherAtom->nr)) { 216 216 count++; 217 217 DoLog(1) && (Log() << Verbose(1) << *first << "-" << *second << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); … … 246 246 for(;Walker!=(*MolWalker)->end();++Walker){ 247 247 atom *theAtom = *Walker; 248 if (theAtom-> type== second) { // first element matches248 if (theAtom->getType() == second) { // first element matches 249 249 for (int i=0;i<2;i++) 250 250 MatchFlag[i] = false; … … 252 252 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 253 253 for (int i=0;i<2;i++) 254 if ((!MatchFlag[i]) && (OtherAtom-> type== ElementArray[i])) {254 if ((!MatchFlag[i]) && (OtherAtom->getType() == ElementArray[i])) { 255 255 MatchFlag[i] = true; 256 256 break; // each bonding atom can match at most one element we are looking for -
src/analysis_bonds.hpp
re588312 rb5c53d 20 20 /*********************************************** defines ***********************************/ 21 21 22 #define HBRIDGEDISTANCE 3.5//!< HBridge distance from PCCP Vol 10. 4802-481322 const double HBRIDGEDISTANCE=3.5; //!< HBridge distance from PCCP Vol 10. 4802-4813 23 23 24 24 /****************************************** forward declarations *****************************/ -
src/analysis_correlation.cpp
re588312 rb5c53d 11 11 #include <iomanip> 12 12 13 #include "BoundaryTriangleSet.hpp" 13 14 #include "analysis_correlation.hpp" 14 15 #include "element.hpp" … … 73 74 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 74 75 if ((*iter)->getId() < (*runner)->getId()){ 75 for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)76 if ((PairRunner->first == (**iter). type) && (PairRunner->second == (**runner).type)) {77 distance = domain.periodicDistance( *(*iter)->node,*(*runner)->node);76 for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 77 if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) { 78 distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition()); 78 79 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 79 80 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); … … 137 138 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 138 139 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 139 periodicX = FullInverseMatrix * ( *(*iter)->node); // x now in [0,1)^3140 periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 140 141 // go through every range in xyz and get distance 141 142 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) … … 149 150 if ((*iter)->getId() < (*runner)->getId()){ 150 151 for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 151 if ((PairRunner->first == (**iter). type) && (PairRunner->second == (**runner).type)) {152 periodicOtherX = FullInverseMatrix * ( *(*runner)->node); // x now in [0,1)^3152 if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) { 153 periodicOtherX = FullInverseMatrix * ((*runner)->getPosition()); // x now in [0,1)^3 153 154 // go through every range in xyz and get distance 154 155 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) … … 196 197 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 197 198 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 198 if ((*type == NULL) || ((*iter)-> type== *type)) {199 distance = domain.periodicDistance( *(*iter)->node,*point);199 if ((*type == NULL) || ((*iter)->getType() == *type)) { 200 distance = domain.periodicDistance((*iter)->getPosition(),*point); 200 201 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 201 202 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); … … 237 238 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 238 239 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 239 if ((*type == NULL) || ((*iter)-> type== *type)) {240 periodicX = FullInverseMatrix * ( *(*iter)->node); // x now in [0,1)^3240 if ((*type == NULL) || ((*iter)->getType() == *type)) { 241 periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 241 242 // go through every range in xyz and get distance 242 243 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) … … 284 285 DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl); 285 286 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 286 if ((*type == NULL) || ((*iter)-> type== *type)) {287 TriangleIntersectionList Intersections((*iter)-> node,Surface,LC);287 if ((*type == NULL) || ((*iter)->getType() == *type)) { 288 TriangleIntersectionList Intersections((*iter)->getPosition(),Surface,LC); 288 289 distance = Intersections.GetSmallestDistance(); 289 290 triangle = Intersections.GetClosestTriangle(); … … 335 336 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 336 337 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 337 if ((*type == NULL) || ((*iter)-> type== *type)) {338 periodicX = FullInverseMatrix * ( *(*iter)->node); // x now in [0,1)^3338 if ((*type == NULL) || ((*iter)->getType() == *type)) { 339 periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 339 340 // go through every range in xyz and get distance 340 341 ShortestDistance = -1.; … … 343 344 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 344 345 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 345 TriangleIntersectionList Intersections( &checkX,Surface,LC);346 TriangleIntersectionList Intersections(checkX,Surface,LC); 346 347 distance = Intersections.GetSmallestDistance(); 347 348 triangle = Intersections.GetClosestTriangle(); … … 411 412 *file << runner->first; 412 413 for (int i=0;i<NDIM;i++) 413 *file << "\t" << setprecision(8) << (runner->second.first-> node->at(i) - runner->second.second->at(i));414 *file << "\t" << setprecision(8) << (runner->second.first->at(i) - runner->second.second->at(i)); 414 415 *file << endl; 415 416 } … … 426 427 if (!map->empty()) 427 428 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 428 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 429 } 430 }; 431 429 *file << setprecision(8) << runner->first << "\t"; 430 *file << *(runner->second.first) << "\t"; 431 *file << *(runner->second.second) << endl; 432 } 433 }; 434 -
src/atom.cpp
re588312 rb5c53d 27 27 */ 28 28 atom::atom() : 29 father(this), sort(&nr), mol(0)30 { 31 node = &x; // TesselPoint::x can only be referenced from here32 };29 father(this), 30 sort(&nr), 31 mol(0) 32 {}; 33 33 34 34 /** Constructor of class atom. 35 35 */ 36 36 atom::atom(atom *pointer) : 37 ParticleInfo(pointer),father(pointer), sort(&nr) 38 { 39 type = pointer->type; // copy element of atom 40 x = pointer->x; // copy coordination 41 v = pointer->v; // copy velocity 37 ParticleInfo(pointer), 38 father(pointer), 39 sort(&nr) 40 { 41 setType(pointer->getType()); // copy element of atom 42 setPosition(pointer->getPosition()); // copy coordination 43 AtomicVelocity = pointer->AtomicVelocity; // copy velocity 42 44 FixedIon = pointer->FixedIon; 43 node = &x;44 45 mol = 0; 45 46 }; … … 49 50 res->father = this; 50 51 res->sort = &res->nr; 51 res-> type = type;52 res-> x = this->x;53 res-> v = this->v;52 res->setType(getType()); 53 res->setPosition(this->getPosition()); 54 res->AtomicVelocity = this->AtomicVelocity; 54 55 res->FixedIon = FixedIon; 55 res->node = &x;56 56 res->mol = 0; 57 57 World::getInstance().registerAtom(res); … … 121 121 bool atom::IsInShape(const Shape& shape) const 122 122 { 123 return shape.isInside( *node);123 return shape.isInside(getPosition()); 124 124 }; 125 125 … … 146 146 if (out != NULL) { 147 147 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint; 148 *out << x[0] << "\t" << x[1] << "\t" << x[2];148 *out << at(0) << "\t" << at(1) << "\t" << at(2); 149 149 *out << "\t" << FixedIon; 150 if ( v.Norm() > MYEPSILON)151 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";150 if (AtomicVelocity.Norm() > MYEPSILON) 151 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 152 152 if (comment != NULL) 153 153 *out << " # " << comment << endl; … … 168 168 bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const 169 169 { 170 AtomNo[type->Z]++; // increment number 171 if (out != NULL) { 172 cout << "Looking for atom with element " << *type << endl; 173 ASSERT(elementLookup.there.find(type)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 174 *out << "Ion_Type" << elementLookup.there.find(type)->second << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint; 175 *out << x[0] << "\t" << x[1] << "\t" << x[2]; 170 AtomNo[getType()->Z]++; // increment number 171 if (out != NULL) { 172 const element *elemental = getType(); 173 cout << "Looking for atom with element " << *elemental << endl; 174 ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 175 *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[elemental->Z] << "\t" << fixed << setprecision(9) << showpoint; 176 *out << at(0) << "\t" << at(1) << "\t" << at(2); 176 177 *out << "\t" << FixedIon; 177 if ( v.Norm() > MYEPSILON)178 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";178 if (AtomicVelocity.Norm() > MYEPSILON) 179 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 179 180 if (comment != NULL) 180 181 *out << " # " << comment << endl; … … 193 194 { 194 195 if (out != NULL) { 195 *out << type->getSymbol() << "\t" << x[0] << "\t" << x[1] << "\t" << x[2]<< "\t" << endl;196 *out << getType()->getSymbol() << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl; 196 197 return true; 197 198 } else … … 208 209 bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const 209 210 { 210 AtomNo[ type->Z]++;211 if (out != NULL) { 212 *out << "Ion_Type" << ElementNo[ type->Z] << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint;211 AtomNo[getType()->Z]++; 212 if (out != NULL) { 213 *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t" << fixed << setprecision(9) << showpoint; 213 214 *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2]; 214 215 *out << "\t" << FixedIon; … … 231 232 { 232 233 if (out != NULL) { 233 *out << type->getSymbol() << "\t";234 *out << getType()->getSymbol() << "\t"; 234 235 *out << Trajectory.R.at(step)[0] << "\t"; 235 236 *out << Trajectory.R.at(step)[1] << "\t"; … … 247 248 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 248 249 { 249 *out << "\t\t" << type->getSymbol() << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; 250 Vector recentered(getPosition()); 251 recentered -= *center; 252 *out << "\t\t" << getType()->getSymbol() << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl; 250 253 if (AtomNo != NULL) 251 254 *AtomNo++; … … 270 273 double atom::DistanceSquaredToVector(const Vector &origin) const 271 274 { 272 return origin.DistanceSquared(x);275 return DistanceSquared(origin); 273 276 }; 274 277 … … 279 282 double atom::DistanceToVector(const Vector &origin) const 280 283 { 281 return origin.distance(x);284 return distance(origin); 282 285 }; 283 286 … … 294 297 }; 295 298 299 std::ostream & atom::operator << (std::ostream &ost) const 300 { 301 ParticleInfo::operator<<(ost); 302 ost << "," << getPosition(); 303 return ost; 304 } 305 306 std::ostream & operator << (std::ostream &ost, const atom &a) 307 { 308 a.ParticleInfo::operator<<(ost); 309 ost << "," << a.getPosition(); 310 return ost; 311 } 296 312 297 313 bool operator < (atom &a, atom &b) … … 333 349 mol = _mol; 334 350 if(!mol->containsAtom(this)){ 335 mol-> AddAtom(this);351 mol->insert(this); 336 352 } 337 353 } -
src/atom.hpp
re588312 rb5c53d 22 22 #include <vector> 23 23 24 #include "Helpers/helpers.hpp" 24 25 #include "atom_atominfo.hpp" 25 26 #include "atom_bondedparticle.hpp" … … 27 28 #include "atom_particleinfo.hpp" 28 29 #include "atom_trajectoryparticle.hpp" 29 #include " tesselation.hpp"30 #include "TesselPoint.hpp" 30 31 #include "types.hpp" 31 32 … … 42 43 * Class incorporates position, type 43 44 */ 44 class atom : public T esselPoint, public TrajectoryParticle, public GraphNode, public BondedParticle, public virtual ParticleInfo, public virtual AtomInfo{45 class atom : public TrajectoryParticle, public GraphNode, public BondedParticle, public TesselPoint { 45 46 friend atom* NewAtom(atomId_t); 46 47 friend void DeleteAtom(atom*); … … 94 95 void removeFromMolecule(); 95 96 97 // Output operator 98 std::ostream & operator << (std::ostream &ost) const; 99 96 100 protected: 97 101 … … 120 124 121 125 /** 126 * Global output operator for class atom. 127 */ 128 std::ostream & operator << (std::ostream &ost, const atom &_atom); 129 130 /** 122 131 * internal method used by the world. Do not use if you don't know what you are doing. 123 132 * You might get burned... -
src/atom_atominfo.cpp
re588312 rb5c53d 10 10 #include "periodentafel.hpp" 11 11 #include "World.hpp" 12 #include "element.hpp" 12 13 #include "atom_atominfo.hpp" 13 14 14 15 /** Constructor of class AtomInfo. 15 16 */ 16 AtomInfo::AtomInfo() : type(NULL) {}; 17 AtomInfo::AtomInfo() : 18 AtomicElement(NULL) 19 {}; 20 21 /** Copy constructor of class AtomInfo. 22 */ 23 AtomInfo::AtomInfo(const AtomInfo &_atom) : 24 AtomicPosition(_atom.AtomicPosition), 25 AtomicElement(_atom.AtomicElement) 26 {}; 27 28 AtomInfo::AtomInfo(const VectorInterface &_v) : 29 AtomicPosition(_v.getPosition()), 30 AtomicElement(NULL) 31 {}; 17 32 18 33 /** Destructor of class AtomInfo. … … 22 37 }; 23 38 24 const element *AtomInfo::getType(){ 25 return type; 39 const element *AtomInfo::getType() const 40 { 41 return AtomicElement; 42 } 43 44 const double& AtomInfo::operator[](size_t i) const 45 { 46 return AtomicPosition[i]; 47 } 48 49 const double& AtomInfo::at(size_t i) const 50 { 51 return AtomicPosition.at(i); 52 } 53 54 void AtomInfo::set(size_t i, const double value) 55 { 56 AtomicPosition.at(i) = value; 57 } 58 59 const Vector& AtomInfo::getPosition() const 60 { 61 return AtomicPosition; 26 62 } 27 63 28 64 void AtomInfo::setType(const element* _type) { 29 type= _type;65 AtomicElement = _type; 30 66 } 31 67 32 void AtomInfo::setType( int Z) {68 void AtomInfo::setType(const int Z) { 33 69 const element *elem = World::getInstance().getPeriode()->FindElement(Z); 34 70 setType(elem); 35 71 } 72 73 void AtomInfo::setPosition(const Vector& _vector) 74 { 75 AtomicPosition = _vector; 76 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; 77 } 78 79 const VectorInterface& AtomInfo::operator+=(const Vector& b) 80 { 81 AtomicPosition += b; 82 return *this; 83 } 84 85 const VectorInterface& AtomInfo::operator-=(const Vector& b) 86 { 87 AtomicPosition -= b; 88 return *this; 89 } 90 91 Vector const AtomInfo::operator+(const Vector& b) const 92 { 93 Vector a(AtomicPosition); 94 a += b; 95 return a; 96 } 97 98 Vector const AtomInfo::operator-(const Vector& b) const 99 { 100 Vector a(AtomicPosition); 101 a -= b; 102 return a; 103 } 104 105 double AtomInfo::distance(const Vector &point) const 106 { 107 return AtomicPosition.distance(point); 108 } 109 110 double AtomInfo::DistanceSquared(const Vector &y) const 111 { 112 return AtomicPosition.DistanceSquared(y); 113 } 114 115 double AtomInfo::distance(const VectorInterface &_atom) const 116 { 117 return _atom.distance(AtomicPosition); 118 } 119 120 double AtomInfo::DistanceSquared(const VectorInterface &_atom) const 121 { 122 return _atom.DistanceSquared(AtomicPosition); 123 } 124 125 VectorInterface &AtomInfo::operator=(const Vector& _vector) 126 { 127 AtomicPosition = _vector; 128 return *this; 129 } 130 131 void AtomInfo::ScaleAll(const double *factor) 132 { 133 AtomicPosition.ScaleAll(factor); 134 } 135 136 void AtomInfo::ScaleAll(const Vector &factor) 137 { 138 AtomicPosition.ScaleAll(factor); 139 } 140 141 void AtomInfo::Scale(const double factor) 142 { 143 AtomicPosition.Scale(factor); 144 } 145 146 void AtomInfo::Zero() 147 { 148 AtomicPosition.Zero(); 149 } 150 151 void AtomInfo::One(const double one) 152 { 153 AtomicPosition.One(one); 154 } 155 156 void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors) 157 { 158 AtomicPosition.LinearCombinationOfVectors(x1,x2,x3,factors); 159 } 160 161 const AtomInfo& operator*=(AtomInfo& a, const double m) 162 { 163 a.Scale(m); 164 return a; 165 } 166 167 AtomInfo const operator*(const AtomInfo& a, const double m) 168 { 169 AtomInfo copy(a); 170 copy *= m; 171 return copy; 172 } 173 174 AtomInfo const operator*(const double m, const AtomInfo& a) 175 { 176 AtomInfo copy(a); 177 copy *= m; 178 return copy; 179 } 180 181 std::ostream & AtomInfo::operator << (std::ostream &ost) const 182 { 183 return (ost << getPosition()); 184 } 185 186 std::ostream & operator << (std::ostream &ost, const AtomInfo &a) 187 { 188 ost << a; 189 return ost; 190 } 191 -
src/atom_atominfo.hpp
re588312 rb5c53d 20 20 21 21 #include "LinearAlgebra/Vector.hpp" 22 #include "LinearAlgebra/VectorInterface.hpp" 22 23 23 24 /****************************************** forward declarations *****************************/ 24 25 26 class AtomInfo; 25 27 class element; 28 class Matrix; 26 29 27 30 /********************************************** declarations *******************************/ 28 31 29 class AtomInfo { 32 class AtomInfo : public VectorInterface { 33 30 34 public: 31 Vector x; //!< coordinate vector of atom, giving last position within cell 32 Vector v; //!< velocity vector of atom, giving last velocity within cell 33 Vector F; //!< Force vector of atom, giving last force within cell 34 const element *type; //!< pointing to element 35 Vector AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell 36 Vector AtomicForce; //!< Force vector of atom, giving last force within cell 35 37 36 38 AtomInfo(); 37 ~AtomInfo(); 39 AtomInfo(const AtomInfo &_atom); 40 AtomInfo(const VectorInterface &_v); 41 virtual ~AtomInfo(); 38 42 39 const element *getType() ;43 const element *getType() const; 40 44 void setType(const element *); 41 void setType(int); 45 void setType(const int); 46 47 ///// manipulation of the atomic position 48 49 // Accessors ussually come in pairs... and sometimes even more than that 50 const double& operator[](size_t i) const; 51 const double& at(size_t i) const; 52 void set(size_t i, const double value); 53 const Vector& getPosition() const; 54 55 // Assignment operator 56 void setPosition(const Vector& _vector); 57 class VectorInterface &operator=(const Vector& _vector); 58 59 // operators for mathematical operations 60 const VectorInterface& operator+=(const Vector& b); 61 const VectorInterface& operator-=(const Vector& b); 62 Vector const operator+(const Vector& b) const; 63 Vector const operator-(const Vector& b) const; 64 65 void Zero(); 66 void One(const double one); 67 void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors); 68 69 double distance(const Vector &point) const; 70 double DistanceSquared(const Vector &y) const; 71 double distance(const VectorInterface &_atom) const; 72 double DistanceSquared(const VectorInterface &_atom) const; 73 74 void ScaleAll(const double *factor); 75 void ScaleAll(const Vector &factor); 76 void Scale(const double factor); 77 78 std::ostream & operator << (std::ostream &ost) const; 42 79 43 80 private: 81 Vector AtomicPosition; //!< coordinate vector of atom, giving last position within cell 82 const element *AtomicElement; //!< pointing to element 44 83 }; 45 84 85 std::ostream & operator << (std::ostream &ost, const AtomInfo &a); 86 87 const AtomInfo& operator*=(AtomInfo& a, const double m); 88 AtomInfo const operator*(const AtomInfo& a, const double m); 89 AtomInfo const operator*(const double m, const AtomInfo& a); 90 46 91 #endif /* ATOM_ATOMINFO_HPP_ */ -
src/atom_bondedparticle.cpp
re588312 rb5c53d 152 152 NoBonds = CountBonds(); 153 153 //Log() << Verbose(3) << "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl; 154 if ((int)( type->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch154 if ((int)(getType()->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch 155 155 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) { 156 156 OtherWalker = (*Runner)->GetOtherAtom(this); 157 157 OtherNoBonds = OtherWalker->CountBonds(); 158 158 //Log() << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << OtherNoBonds << "?" << endl; 159 if ((int)(OtherWalker-> type->NoValenceOrbitals) > OtherNoBonds) { // check if possible candidate159 if ((int)(OtherWalker->getType()->NoValenceOrbitals) > OtherNoBonds) { // check if possible candidate 160 160 if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherWalker->ListOfBonds.size())) { // pick the one with fewer number of bonds first 161 161 CandidateBond = (*Runner); … … 189 189 }; 190 190 191 std::ostream & BondedParticle::operator << (std::ostream &ost) const 192 { 193 ParticleInfo::operator<<(ost); 194 ost << "," << getPosition(); 195 return ost; 196 } 197 198 std::ostream & operator << (std::ostream &ost, const BondedParticle &a) 199 { 200 a.ParticleInfo::operator<<(ost); 201 ost << "," << a.getPosition(); 202 return ost; 203 } 204 -
src/atom_bondedparticle.hpp
re588312 rb5c53d 49 49 void OutputOrder(ofstream *file) const; 50 50 51 std::ostream & operator << (std::ostream &ost) const; 52 51 53 private: 52 54 53 55 }; 54 56 57 std::ostream & operator << (std::ostream &ost, const BondedParticle &a); 55 58 56 59 #endif /* ATOM_BONDEDPARTICLE_HPP_ */ -
src/atom_bondedparticleinfo.cpp
re588312 rb5c53d 12 12 /** Constructor of class BondedParticleInfo. 13 13 */ 14 BondedParticleInfo::BondedParticleInfo() : AdaptiveOrder(0), MaxOrder(false) {}; 14 BondedParticleInfo::BondedParticleInfo() : 15 AdaptiveOrder(0), 16 MaxOrder(false) 17 {}; 15 18 16 19 /** Destructor of class BondedParticleInfo. -
src/atom_bondedparticleinfo.hpp
re588312 rb5c53d 36 36 37 37 BondedParticleInfo(); 38 ~BondedParticleInfo();38 virtual ~BondedParticleInfo(); 39 39 40 40 private: -
src/atom_graphnodeinfo.cpp
re588312 rb5c53d 12 12 /** Constructor of class GraphNodeInfo. 13 13 */ 14 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(0), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(0) {}; 14 GraphNodeInfo::GraphNodeInfo() : 15 GraphNr(-1), 16 ComponentNr(0), 17 LowpointNr(-1), 18 SeparationVertex(false), 19 IsCyclic(false), 20 Ancestor(0) 21 {}; 15 22 16 23 /** Destructor of class GraphNodeInfo. -
src/atom_graphnodeinfo.hpp
re588312 rb5c53d 37 37 38 38 GraphNodeInfo(); 39 ~GraphNodeInfo();39 virtual ~GraphNodeInfo(); 40 40 private: 41 41 -
src/atom_particleinfo.cpp
re588312 rb5c53d 14 14 /** Constructor of ParticleInfo. 15 15 */ 16 ParticleInfo::ParticleInfo() : nr(-1), name("Unknown") { 17 }; 16 ParticleInfo::ParticleInfo() : 17 nr(-1), 18 name("Unknown") 19 {}; 18 20 19 21 ParticleInfo::ParticleInfo(ParticleInfo *pointer) : 20 21 22 22 nr(pointer->nr), 23 name(pointer->name) 24 {} 23 25 24 26 … … 38 40 ostream & operator << (ostream &ost, const ParticleInfo &a) 39 41 { 40 ost << "[" << a.getName() << "|" << &a << "]";42 ost << a.getName(); 41 43 return ost; 42 44 }; … … 44 46 ostream & ParticleInfo::operator << (ostream &ost) const 45 47 { 46 ost << "[" << name << "|" << this << "]";48 ost << getName(); 47 49 return ost; 48 50 }; -
src/atom_particleinfo.hpp
re588312 rb5c53d 32 32 ParticleInfo(); 33 33 ParticleInfo(ParticleInfo*); 34 ~ParticleInfo();34 virtual ~ParticleInfo(); 35 35 36 36 const std::string& getName() const; -
src/atom_trajectoryparticle.cpp
re588312 rb5c53d 38 38 { 39 39 for (int i=NDIM;i--;) 40 *temperature += type->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i];40 *temperature += getType()->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i]; 41 41 }; 42 42 … … 65 65 for(int d=0;d<NDIM;d++) { 66 66 Trajectory.U.at(Step)[d] -= CoGVelocity->at(d); 67 *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d];67 *ActualTemp += 0.5 * getType()->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d]; 68 68 } 69 69 }; … … 113 113 Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d]; 114 114 Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]); // s(t) = s(0) + v * deltat + 1/2 a * deltat^2 115 Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/ type->mass); // F = m * a and s =115 Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/getType()->mass); // F = m * a and s = 116 116 } 117 117 // Update U 118 118 for (int d=0; d<NDIM; d++) { 119 119 Trajectory.U.at(NextStep)[d] = Trajectory.U.at(NextStep-1)[d]; 120 Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/ type->mass); // v = F/m * t120 Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/getType()->mass); // v = F/m * t 121 121 } 122 122 // Update R (and F) … … 137 137 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const 138 138 { 139 *TotalMass += type->mass; // sum up total mass139 *TotalMass += getType()->mass; // sum up total mass 140 140 for(int d=0;d<NDIM;d++) { 141 TotalVelocity->at(d) += Trajectory.U.at(Step)[d]* type->mass;141 TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*getType()->mass; 142 142 } 143 143 }; … … 154 154 for (int d=0; d<NDIM; d++) { 155 155 U[d] *= ScaleTempFactor; 156 *ekin += 0.5* type->mass * U[d]*U[d];156 *ekin += 0.5*getType()->mass * U[d]*U[d]; 157 157 } 158 158 }; … … 170 170 for (int d=0; d<NDIM; d++) { 171 171 *G += U[d] * F[d]; 172 *E += U[d]*U[d]* type->mass;172 *E += U[d]*U[d]*getType()->mass; 173 173 } 174 174 }; … … 185 185 if (FixedIon == 0) // even FixedIon moves, only not by other's forces 186 186 for (int d=0; d<NDIM; d++) { 187 U[d] += configuration->Deltat/ type->mass * ( (G_over_E) * (U[d]*type->mass) );188 *ekin += type->mass * U[d]*U[d];187 U[d] += configuration->Deltat/getType()->mass * ( (G_over_E) * (U[d]*getType()->mass) ); 188 *ekin += getType()->mass * U[d]*U[d]; 189 189 } 190 190 }; … … 198 198 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 199 199 { 200 double sigma = sqrt(configuration->Thermostats->TargetTemp/ type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)200 double sigma = sqrt(configuration->Thermostats->TargetTemp/getType()->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) 201 201 Vector &U = Trajectory.U.at(Step); 202 202 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces … … 211 211 } 212 212 for (int d=0; d<NDIM; d++) 213 *ekin += 0.5* type->mass * U[d]*U[d];213 *ekin += 0.5*getType()->mass * U[d]*U[d]; 214 214 } 215 215 }; … … 227 227 for (int d=0; d<NDIM; d++) { 228 228 U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1)); 229 *ekin += 0.5* type->mass * U[d]*U[d];229 *ekin += 0.5*getType()->mass * U[d]*U[d]; 230 230 } 231 231 } … … 241 241 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 242 242 for (int d=0; d<NDIM; d++) { 243 *delta_alpha += U[d]*U[d]* type->mass;243 *delta_alpha += U[d]*U[d]*getType()->mass; 244 244 } 245 245 } … … 256 256 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 257 257 for (int d=0; d<NDIM; d++) { 258 U[d] += configuration->Deltat/ type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass));259 *ekin += (0.5* type->mass) * U[d]*U[d];258 U[d] += configuration->Deltat/getType()->mass * (configuration->Thermostats->alpha * (U[d] * getType()->mass)); 259 *ekin += (0.5*getType()->mass) * U[d]*U[d]; 260 260 } 261 261 } 262 262 }; 263 264 265 std::ostream & TrajectoryParticle::operator << (std::ostream &ost) const 266 { 267 ParticleInfo::operator<<(ost); 268 ost << "," << getPosition(); 269 return ost; 270 } 271 272 std::ostream & operator << (std::ostream &ost, const TrajectoryParticle &a) 273 { 274 a.ParticleInfo::operator<<(ost); 275 ost << "," << a.getPosition(); 276 return ost; 277 } 278 -
src/atom_trajectoryparticle.hpp
re588312 rb5c53d 63 63 void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration); 64 64 65 std::ostream & operator << (std::ostream &ost) const; 66 65 67 private: 66 67 68 }; 68 69 70 ostream & operator << (ostream &ost, const TrajectoryParticle &a); 69 71 70 72 #endif /* ATOM_TRAJECTORYPARTICLE_HPP_ */ -
src/atom_trajectoryparticleinfo.cpp
re588312 rb5c53d 12 12 /** Constructor of class TrajectoryParticleInfo. 13 13 */ 14 TrajectoryParticleInfo::TrajectoryParticleInfo() : FixedIon(0) {}; 14 TrajectoryParticleInfo::TrajectoryParticleInfo() : 15 FixedIon(0) 16 {}; 15 17 16 18 /** Destructor of class TrajectoryParticleInfo. -
src/atom_trajectoryparticleinfo.hpp
re588312 rb5c53d 36 36 37 37 TrajectoryParticleInfo(); 38 ~TrajectoryParticleInfo();38 virtual ~TrajectoryParticleInfo(); 39 39 40 40 private: -
src/bond.cpp
re588312 rb5c53d 7 7 #include "Helpers/MemDebug.hpp" 8 8 9 #include "Helpers/Log.hpp" 9 10 #include "Helpers/Verbose.hpp" 10 11 #include "atom.hpp" … … 18 19 /** Empty Constructor for class bond. 19 20 */ 20 bond::bond() 21 : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), 22 BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white) 23 { 24 }; 21 bond::bond() : 22 leftatom(NULL), 23 rightatom(NULL), 24 previous(NULL), 25 next(NULL), 26 HydrogenBond(0), 27 BondDegree(0), 28 nr(-1), 29 Cyclic(false), 30 Type(Undetermined), 31 Used(white) 32 {}; 25 33 26 34 /** Constructor for class bond, taking right and left bond partner … … 30 38 * \param number increasing index 31 39 */ 32 bond::bond(atom *left, atom *right, const int degree, const int number) 33 : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), 34 BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white) 40 bond::bond(atom *left, atom *right, const int degree, const int number) : 41 leftatom(left), 42 rightatom(right), 43 previous(NULL), 44 next(NULL), 45 HydrogenBond(0), 46 BondDegree(degree), 47 nr(number), 48 Cyclic(false), 49 Type(Undetermined), 50 Used(white) 35 51 { 36 52 if ((left != NULL) && (right != NULL)) { 37 if ((left-> type != NULL) && (left->type->Z == 1))53 if ((left->getType() != NULL) && (left->getType()->Z == 1)) 38 54 HydrogenBond++; 39 if ((right-> type != NULL) && (right->type->Z == 1))55 if ((right->getType() != NULL) && (right->getType()->Z == 1)) 40 56 HydrogenBond++; 41 57 } … … 126 142 double bond::GetDistance() const 127 143 { 128 return (leftatom-> node->distance(*rightatom->node));144 return (leftatom->distance(*rightatom)); 129 145 }; 130 146 … … 134 150 double bond::GetDistanceSquared() const 135 151 { 136 return (leftatom-> node->DistanceSquared(*rightatom->node));152 return (leftatom->DistanceSquared(*rightatom)); 137 153 }; -
src/bondgraph.cpp
re588312 rb5c53d 22 22 #include "LinearAlgebra/Vector.hpp" 23 23 24 const double BondGraph::BondThreshold = 0.4; //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii 25 24 26 /** Constructor of class BondGraph. 25 27 * This classes contains typical bond lengths and thus may be used to construct a bond graph for a given molecule. 26 28 */ 27 BondGraph::BondGraph(bool IsA) : BondLengthMatrix(NULL), max_distance(0), IsAngstroem(IsA) 28 { 29 }; 29 BondGraph::BondGraph(bool IsA) : 30 BondLengthMatrix(NULL), 31 max_distance(0), 32 IsAngstroem(IsA) 33 {}; 30 34 31 35 /** Destructor of class BondGraph. … … 128 132 129 133 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 130 if ((*iter)-> type->CovalentRadius > max_distance)131 max_distance = (*iter)-> type->CovalentRadius;134 if ((*iter)->getType()->CovalentRadius > max_distance) 135 max_distance = (*iter)->getType()->CovalentRadius; 132 136 } 133 137 max_distance *= 2.; … … 145 149 void BondGraph::CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem) 146 150 { 147 MinDistance = OtherWalker-> type->CovalentRadius + Walker->type->CovalentRadius;151 MinDistance = OtherWalker->getType()->CovalentRadius + Walker->getType()->CovalentRadius; 148 152 MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem; 149 MaxDistance = MinDistance + B ONDTHRESHOLD;150 MinDistance -= B ONDTHRESHOLD;153 MaxDistance = MinDistance + BondThreshold; 154 MinDistance -= BondThreshold; 151 155 }; 152 156 … … 166 170 CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 167 171 } else { 168 MinDistance = GetBondLength(Walker-> type->Z-1, OtherWalker->type->Z-1);172 MinDistance = GetBondLength(Walker->getType()->Z-1, OtherWalker->getType()->Z-1); 169 173 MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem; 170 MaxDistance = MinDistance + B ONDTHRESHOLD;171 MinDistance -= B ONDTHRESHOLD;174 MaxDistance = MinDistance + BondThreshold; 175 MinDistance -= BondThreshold; 172 176 } 173 177 }; -
src/bondgraph.hpp
re588312 rb5c53d 20 20 #include <iosfwd> 21 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 radii25 22 26 23 /****************************************** forward declarations *****************************/ … … 48 45 49 46 private: 47 static const double BondThreshold; 48 50 49 MatrixContainer *BondLengthMatrix; 51 50 double max_distance; -
src/boundary.cpp
re588312 rb5c53d 6 6 #include "Helpers/MemDebug.hpp" 7 7 8 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp" 9 #include "BoundaryPointSet.hpp" 10 #include "BoundaryLineSet.hpp" 11 #include "BoundaryTriangleSet.hpp" 12 #include "CandidateForTesselation.hpp" 13 //#include "TesselPoint.hpp" 8 14 #include "World.hpp" 9 15 #include "atom.hpp" … … 86 92 if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around 87 93 Neighbour = BoundaryPoints[axis].begin(); 88 DistanceVector = runner->second.second->x - Neighbour->second.second->x;94 DistanceVector = (runner->second.second->getPosition()) - (Neighbour->second.second->getPosition()); 89 95 do { // seek for neighbour pair where it flips 90 96 OldComponent = DistanceVector[Othercomponent]; … … 92 98 if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around 93 99 Neighbour = BoundaryPoints[axis].begin(); 94 DistanceVector = runner->second.second->x - Neighbour->second.second->x;100 DistanceVector = (runner->second.second->getPosition()) - (Neighbour->second.second->getPosition()); 95 101 //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl; 96 102 } while ((runner != Neighbour) && (fabs(OldComponent / fabs( … … 104 110 //Log() << Verbose(1) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl; 105 111 // now we have found the pair: Neighbour and OtherNeighbour 106 OtherVector = runner->second.second->x - OtherNeighbour->second.second->x;112 OtherVector = (runner->second.second->getPosition()) - (OtherNeighbour->second.second->getPosition()); 107 113 //Log() << Verbose(1) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl; 108 114 //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl; … … 172 178 // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours 173 179 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 174 ProjectedVector = (*iter)-> x- (*MolCenter);180 ProjectedVector = (*iter)->getPosition() - (*MolCenter); 175 181 ProjectedVector.ProjectOntoPlane(AxisVector); 176 182 … … 198 204 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 199 205 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 200 helper = (*iter)->x; 201 helper -= *MolCenter; 206 helper = (*iter)->getPosition() - (*MolCenter); 202 207 const double oldhelperNorm = helper.NormSquared(); 203 helper = BoundaryTestPair.first->second.second-> x- (*MolCenter);208 helper = BoundaryTestPair.first->second.second->getPosition() - (*MolCenter); 204 209 if (helper.NormSquared() < oldhelperNorm) { 205 210 BoundaryTestPair.first->second.second = (*iter); … … 254 259 { 255 260 Vector SideA, SideB, SideC, SideH; 256 SideA = left->second.second-> x- (*MolCenter);261 SideA = left->second.second->getPosition() - (*MolCenter); 257 262 SideA.ProjectOntoPlane(AxisVector); 258 263 // Log() << Verbose(1) << "SideA: " << SideA << endl; 259 264 260 SideB = right->second.second-> x-(*MolCenter);265 SideB = right->second.second->getPosition() -(*MolCenter); 261 266 SideB.ProjectOntoPlane(AxisVector); 262 267 // Log() << Verbose(1) << "SideB: " << SideB << endl; 263 268 264 SideC = left->second.second-> x - right->second.second->x;269 SideC = left->second.second->getPosition() - right->second.second->getPosition(); 265 270 SideC.ProjectOntoPlane(AxisVector); 266 271 // Log() << Verbose(1) << "SideC: " << SideC << endl; 267 272 268 SideH = runner->second.second-> x-(*MolCenter);273 SideH = runner->second.second->getPosition() -(*MolCenter); 269 274 SideH.ProjectOntoPlane(AxisVector); 270 275 // Log() << Verbose(1) << "SideH: " << SideH << endl; … … 674 679 double cellvolume = 0.; 675 680 676 // transform to PAS 677 mol->PrincipalAxisSystem(true); 681 // transform to PAS by Action 682 Vector MainAxis(0.,0.,1.); 683 MoleculeRotateToPrincipalAxisSystem(MainAxis); 678 684 679 685 IsAngstroem = configuration->GetIsAngstroem(); … … 699 705 // sum up the atomic masses 700 706 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 701 totalmass += (*iter)-> type->mass;707 totalmass += (*iter)->getType()->mass; 702 708 } 703 709 DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl); … … 855 861 856 862 // ... and put at new position 857 Inserter = (*iter)-> x;863 Inserter = (*iter)->getPosition(); 858 864 if (DoRandomRotation) 859 865 Inserter *= Rotations; … … 880 886 // copy atom ... 881 887 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 882 CopyAtoms[(*iter)->nr]->x = Inserter;888 (*CopyAtoms[(*iter)->nr]).setPosition(Inserter); 883 889 Filling->AddAtom(CopyAtoms[(*iter)->nr]); 884 DoLog( 4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl);890 DoLog(1) && (Log() << Verbose(1) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->getPosition()) << "." << endl); 885 891 } else { 886 892 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl); -
src/boundary.hpp
re588312 rb5c53d 34 34 /********************************************** definitions *********************************/ 35 35 36 #define DEBUG 1 37 #define DoSingleStepOutput 0 38 #define SingleStepWidth 10 36 enum { DEBUG=1 }; 37 enum { DoSingleStepOutput=0 }; 38 enum { SingleStepWidth=10 }; 39 39 40 #define DistancePair pair < double, atom* > 41 #define DistanceMap multimap < double, atom* > 42 #define DistanceTestPair pair < DistanceMap::iterator, bool> 40 typedef std::pair < double, class atom* > DistancePair; 41 typedef std::multimap < double, class atom* > DistanceMap; 42 typedef std::pair < DistanceMap::iterator, bool> DistanceTestPair; 43 43 44 #define Boundaries map <double, DistancePair > 45 #define BoundariesPair pair<double, DistancePair > 46 #define BoundariesTestPair pair< Boundaries::iterator, bool> 44 typedef std::map <double, DistancePair > Boundaries; 45 typedef std::pair<double, DistancePair > BoundariesPair; 46 typedef std::pair< Boundaries::iterator, bool> BoundariesTestPair; 47 47 48 48 /********************************************** declarations *******************************/ -
src/config.cpp
re588312 rb5c53d 33 33 /** Constructor for config file class. 34 34 */ 35 config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), 36 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 37 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 38 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), 39 RelEpsKineticEnergy(1e-5), MaxMinGapStopStep(0), MaxInitMinStep(100), InitRelEpsTotalEnergy(1e-5), InitRelEpsKineticEnergy(1e-4), InitMaxMinGapStopStep(0), ECut(128.), 40 MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0), 41 MaxTypes(0) { 35 config::config() : 36 BG(NULL), 37 Thermostats(0), 38 PsiType(0), 39 MaxPsiDouble(0), 40 PsiMaxNoUp(0), 41 PsiMaxNoDown(0), 42 MaxMinStopStep(1), 43 InitMaxMinStopStep(1), 44 ProcPEGamma(8), 45 ProcPEPsi(1), 46 configname(NULL), 47 FastParsing(false), 48 Deltat(0.01), 49 basis(""), 50 databasepath(NULL), 51 DoConstrainedMD(0), 52 MaxOuterStep(0), 53 mainname(NULL), 54 defaultpath(NULL), 55 pseudopotpath(NULL), 56 DoOutVis(0), 57 DoOutMes(1), 58 DoOutNICS(0), 59 DoOutOrbitals(0), 60 DoOutCurrent(0), 61 DoFullCurrent(0), 62 DoPerturbation(0), 63 DoWannier(0), 64 CommonWannier(0), 65 SawtoothStart(0.01), 66 VectorPlane(0), 67 VectorCut(0.), 68 UseAddGramSch(1), 69 Seed(1), 70 OutVisStep(10), 71 OutSrcStep(5), 72 MaxPsiStep(0), 73 EpsWannier(1e-7), 74 MaxMinStep(100), 75 RelEpsTotalEnergy(1e-7), 76 RelEpsKineticEnergy(1e-5), 77 MaxMinGapStopStep(0), 78 MaxInitMinStep(100), 79 InitRelEpsTotalEnergy(1e-5), 80 InitRelEpsKineticEnergy(1e-4), 81 InitMaxMinGapStopStep(0), 82 ECut(128.), 83 MaxLevel(5), 84 RiemannTensor(0), 85 LevRFactor(0), 86 RiemannLevel(0), 87 Lev0Factor(2), 88 RTActualUse(0), 89 AddPsis(0), 90 RCut(20.), 91 StructOpt(0), 92 IsAngstroem(1), 93 RelativeCoord(0), 94 MaxTypes(0) 95 { 42 96 mainname = new char[MAXSTRINGSIZE]; 43 97 defaultpath = new char[MAXSTRINGSIZE]; … … 439 493 map<int, atom *> LinearList; 440 494 atom *neues = NULL; 495 Vector position; 441 496 if (!FastParsing) { 442 497 // parse in trajectories … … 452 507 AtomList[i][j] = neues; 453 508 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 454 neues-> type = elementhash[i]; // find element type509 neues->setType(elementhash[i]); // find element type 455 510 } else 456 511 neues = AtomList[i][j]; 457 512 status = (status && 458 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, & neues->x[0], 1, (repetition == 0) ? critical : optional) &&459 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, & neues->x[1], 1, (repetition == 0) ? critical : optional) &&460 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, & neues->x[2], 1, (repetition == 0) ? critical : optional) &&513 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], 1, (repetition == 0) ? critical : optional) && 514 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], 1, (repetition == 0) ? critical : optional) && 515 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], 1, (repetition == 0) ? critical : optional) && 461 516 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional)); 462 if (!status) break; 517 if (!status) 518 break; 519 neues ->setPosition(position); 463 520 464 521 // check size of vectors … … 472 529 // put into trajectories list 473 530 for (int d=0;d<NDIM;d++) 474 neues->Trajectory.R.at(repetition)[d] = neues-> x[d];531 neues->Trajectory.R.at(repetition)[d] = neues->at(d); 475 532 476 533 // parse velocities if present 477 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues-> v[0], 1,optional))478 neues-> v[0] = 0.;479 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues-> v[1], 1,optional))480 neues-> v[1] = 0.;481 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues-> v[2], 1,optional))482 neues-> v[2] = 0.;534 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->AtomicVelocity[0], 1,optional)) 535 neues->AtomicVelocity[0] = 0.; 536 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->AtomicVelocity[1], 1,optional)) 537 neues->AtomicVelocity[1] = 0.; 538 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->AtomicVelocity[2], 1,optional)) 539 neues->AtomicVelocity[2] = 0.; 483 540 for (int d=0;d<NDIM;d++) 484 neues->Trajectory.U.at(repetition)[d] = neues-> v[d];541 neues->Trajectory.U.at(repetition)[d] = neues->AtomicVelocity[d]; 485 542 486 543 // parse forces if present … … 531 588 AtomList[i][j] = neues; 532 589 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 533 neues-> type = elementhash[i]; // find element type590 neues->setType(elementhash[i]); // find element type 534 591 } else 535 592 neues = AtomList[i][j]; 536 593 // then parse for each atom the coordinates as often as present 537 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], repetition,critical); 538 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], repetition,critical); 539 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], repetition,critical); 594 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], repetition,critical); 595 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], repetition,critical); 596 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], repetition,critical); 597 neues->setPosition(position); 540 598 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical); 541 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues-> v[0], repetition,optional))542 neues-> v[0] = 0.;543 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues-> v[1], repetition,optional))544 neues-> v[1] = 0.;545 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues-> v[2], repetition,optional))546 neues-> v[2] = 0.;599 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->AtomicVelocity[0], repetition,optional)) 600 neues->AtomicVelocity[0] = 0.; 601 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->AtomicVelocity[1], repetition,optional)) 602 neues->AtomicVelocity[1] = 0.; 603 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->AtomicVelocity[2], repetition,optional)) 604 neues->AtomicVelocity[2] = 0.; 547 605 // here we don't care if forces are present (last in trajectories is always equal to current position) 548 neues-> type = elementhash[i]; // find element type606 neues->setType(elementhash[i]); // find element type 549 607 mol->AddAtom(neues); 550 608 } … … 1009 1067 istringstream input2(zeile); 1010 1068 atom *neues = World::getInstance().createAtom(); 1011 input2 >> neues->x[0]; // x 1012 input2 >> neues->x[1]; // y 1013 input2 >> neues->x[2]; // z 1069 double tmp; 1070 for (int j=0;j<NDIM;j++) { 1071 input2 >> tmp; 1072 neues->set(j,tmp); 1073 } 1014 1074 input2 >> l; 1015 neues-> type = elementhash[No]; // find element type1075 neues->setType(elementhash[No]); // find element type 1016 1076 mol->AddAtom(neues); 1017 1077 } … … 1279 1339 AtomNo = 0; 1280 1340 for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) { 1281 sprintf(name, "%2s%2d",(*iter)-> type->getSymbol().c_str(), elementNo[(*iter)->type->Z]);1282 elementNo[(*iter)-> type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits1341 sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->Z]); 1342 elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100; // confine to two digits 1283 1343 fprintf(f, 1284 1344 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", … … 1288 1348 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1289 1349 MolNo, /* residue sequence number */ 1290 (*iter)-> node->at(0), /* position X in Angstroem */1291 (*iter)-> node->at(1), /* position Y in Angstroem */1292 (*iter)-> node->at(2), /* position Z in Angstroem */1293 (double)(*iter)-> type->Valence, /* occupancy */1294 (double)(*iter)-> type->NoValenceOrbitals, /* temperature factor */1350 (*iter)->at(0), /* position X in Angstroem */ 1351 (*iter)->at(1), /* position Y in Angstroem */ 1352 (*iter)->at(2), /* position Z in Angstroem */ 1353 (double)(*iter)->getType()->Valence, /* occupancy */ 1354 (double)(*iter)->getType()->NoValenceOrbitals, /* temperature factor */ 1295 1355 "0", /* segment identifier */ 1296 (*iter)-> type->getSymbol().c_str(), /* element symbol */1356 (*iter)->getType()->getSymbol().c_str(), /* element symbol */ 1297 1357 "0"); /* charge */ 1298 1358 AtomNo++; … … 1332 1392 AtomNo = 0; 1333 1393 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1334 sprintf(name, "%2s%2d",(*iter)-> type->getSymbol().c_str(), elementNo[(*iter)->type->Z]);1335 elementNo[(*iter)-> type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits1394 sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->Z]); 1395 elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100; // confine to two digits 1336 1396 fprintf(f, 1337 1397 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", … … 1341 1401 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1342 1402 0, /* residue sequence number */ 1343 (*iter)-> node->at(0), /* position X in Angstroem */1344 (*iter)-> node->at(1), /* position Y in Angstroem */1345 (*iter)-> node->at(2), /* position Z in Angstroem */1346 (double)(*iter)-> type->Valence, /* occupancy */1347 (double)(*iter)-> type->NoValenceOrbitals, /* temperature factor */1403 (*iter)->at(0), /* position X in Angstroem */ 1404 (*iter)->at(1), /* position Y in Angstroem */ 1405 (*iter)->at(2), /* position Z in Angstroem */ 1406 (double)(*iter)->getType()->Valence, /* occupancy */ 1407 (double)(*iter)->getType()->NoValenceOrbitals, /* temperature factor */ 1348 1408 "0", /* segment identifier */ 1349 (*iter)-> type->getSymbol().c_str(), /* element symbol */1409 (*iter)->getType()->getSymbol().c_str(), /* element symbol */ 1350 1410 "0"); /* charge */ 1351 1411 AtomNo++; … … 1390 1450 *output << mol->name << "\t"; 1391 1451 *output << 0 << "\t"; 1392 *output << (*iter)-> node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";1393 *output << static_cast<double>((*iter)-> type->Valence) << "\t";1394 *output << (*iter)-> type->getSymbol() << "\t";1452 *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t"; 1453 *output << static_cast<double>((*iter)->getType()->Valence) << "\t"; 1454 *output << (*iter)->getType()->getSymbol() << "\t"; 1395 1455 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1396 1456 *output << (*runner)->GetOtherAtom(*iter)->nr << "\t"; … … 1462 1522 *output << (*MolWalker)->name << "\t"; 1463 1523 *output << MolCounter+1 << "\t"; 1464 *output << (*iter)-> node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";1465 *output << (double)(*iter)-> type->Valence << "\t";1466 *output << (*iter)-> type->getSymbol() << "\t";1524 *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t"; 1525 *output << (double)(*iter)->getType()->Valence << "\t"; 1526 *output << (*iter)->getType()->getSymbol() << "\t"; 1467 1527 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1468 1528 *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t"; -
src/defs.hpp
re588312 rb5c53d 8 8 #define DEFS_HPP_ 9 9 10 #define MYEPSILON 1e-13 //!< machine epsilon precision 11 #define NDIM 3 //!< number of spatial dimensions 12 #define MAX_ELEMENTS 128 //!< maximum number of elements for certain lookup tables 13 #define AtomicLengthToAngstroem 0.52917721 //!< conversion factor from atomic length/bohrradius to angstroem 14 #define AtomicEnergyToKelvin 315774.67 //!< conversion factor from atomic energy to kelvin via boltzmann factor 15 #define KelvinToAtomicTemperature 3.1668152e-06 //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B) 16 #define KelvinToeV 8.6173422e-05 //!< conversion factor for Kelvin to Ht (k_B * T = energy), thus Boltzmann constant in eV/K 17 #define AtomicMassUnitsToeV 931494088. //!< conversion factor for atomic weight in units to mass in eV 18 #define AtomicMassUnitsToHt 34480864. //!< conversion factor for atomic weight in units to mass in Ht (protonmass/electronmass * electron_mass_in_Ht 19 #define ElectronMass_Ht 18778.865 //!< electron mass in Ht 20 #define ElectronMass_eV 510998.903 //!< electron mass in eV 21 #define Units2Electronmass (AtomicMassUnitsToeV/ElectronMass_eV) //!< atomic mass unit in eV/ electron mass in eV = 1 822.88863 22 #define Atomictime2Femtoseconds 0.024188843 //!< Atomictime in fs 10 enum { NDIM = 3 }; //!< number of spatial dimensions 11 enum { MAX_ELEMENTS = 128}; //!< maximum number of elements for certain lookup tables 23 12 24 #define VERSIONSTRING "v1.0" 13 extern "C" const double MYEPSILON; //!< machine epsilon precision 14 extern "C" const double AtomicLengthToAngstroem; //!< conversion factor from atomic length/bohrradius to angstroem 15 extern "C" const double AtomicEnergyToKelvin; //!< conversion factor from atomic energy to kelvin via boltzmann factor 16 extern "C" const double KelvinToAtomicTemperature; //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B) 17 extern "C" const double KelvinToeV; //!< conversion factor for Kelvin to Ht (k_B * T = energy), thus Boltzmann constant in eV/K 18 extern "C" const double AtomicMassUnitsToeV; //!< conversion factor for atomic weight in units to mass in eV 19 extern "C" const double AtomicMassUnitsToHt; //!< conversion factor for atomic weight in units to mass in Ht (protonmass/electronmass * electron_mass_in_Ht 20 extern "C" const double ElectronMass_Ht; //!< electron mass in Ht 21 extern "C" const double ElectronMass_eV; //!< electron mass in eV 22 extern "C" const double Units2Electronmass; //!< atomic mass unit in eV/ electron mass in eV = 1 822.88863 23 extern "C" const double Atomictime2Femtoseconds; //!< Atomictime in fs 25 24 26 #define LocalPath "./" 25 extern "C" const char* VERSIONSTRING; 26 27 extern "C" const char* LocalPath; 27 28 28 29 //enum BondOrderScheme { NoScheme, BottomUp, TopDown, ANOVA, Combined }; //!< Fragmentation scheme used in BOSS … … 48 49 49 50 // maximum length of any char array 50 #define MAXSTRINGSIZE 255 51 enum { MAXSTRINGSIZE = 255 }; 51 52 52 53 // various standard filenames 53 #define DEFAULTCONFIG "main_pcp_linux"//!< default filename of config file54 #define CONVEXENVELOPE "ConvexEnvelope.dat"//!< default filename of convex envelope tecplot data file55 #define KEYSETFILE "KeySets.dat"//!< default filename of BOSSANOVA key sets file56 #define ADJACENCYFILE "Adjacency.dat"//!< default filename of BOSSANOVA adjacancy file57 #define TEFACTORSFILE "TE-Factors.dat"//!< default filename of BOSSANOVA total energy factors file58 #define FORCESFILE "Forces-Factors.dat"//!< default filename of BOSSANOVA force factors file59 #define HCORRECTIONSUFFIX "Hcorrection.dat"//!< default filename of BOSSANOVA H correction file (unwanted saturation interaction)60 #define FITCONSTANTSUFFIX "FitConstant.dat"//!< suffix of default filename of BOSSANOVA fit constants file (unwanted saturation interaction)61 #define SHIELDINGSUFFIX "sigma_all.csv"//!< default filename of BOSSANOVA shieldings file62 #define SHIELDINGPASSUFFIX "sigma_all_PAS.csv"//!< default filename of BOSSANOVA shieldings PAS file63 #define ORDERATSITEFILE "OrderAtSite.dat"//!< default filename of BOSSANOVA Bond Order at each atom file64 #define ENERGYPERFRAGMENT "EnergyPerFragment"//!< default filename of BOSSANOVA Energy contribution Per Fragment file65 #define FRAGMENTPREFIX "BondFragment" //!< default filename prefix of BOSSANOVA fragment config and directories 66 #define STANDARDCONFIG "unknown.conf"//!< default filename of standard config file67 #define STANDARDELEMENTSDB "elements.db"//!< default filename of elements data base with masses, Z, VanDerWaals radii, ...68 #define STANDARDVALENCEDB "valence.db"//!< default filename of valence number per element database69 #define STANDARDORBITALDB "orbitals.db"//!< default filename of orbitals per element database70 #define STANDARDHBONDDISTANCEDB "Hbonddistance.db"//!< default filename of typial bond distance to hydrogen database71 #define STANDARDHBONDANGLEDB "Hbondangle.db"//!< default filename of typial bond angle to hydrogen database54 extern "C" const char *DEFAULTCONFIG; //!< default filename of config file 55 extern "C" const char *CONVEXENVELOPE; //!< default filename of convex envelope tecplot data file 56 extern "C" const char *KEYSETFILE; //!< default filename of BOSSANOVA key sets file 57 extern "C" const char *ADJACENCYFILE; //!< default filename of BOSSANOVA adjacancy file 58 extern "C" const char *TEFACTORSFILE; //!< default filename of BOSSANOVA total energy factors file 59 extern "C" const char *FORCESFILE; //!< default filename of BOSSANOVA force factors file 60 extern "C" const char *HCORRECTIONSUFFIX; //!< default filename of BOSSANOVA H correction file (unwanted saturation interaction) 61 extern "C" const char *FITCONSTANTSUFFIX; //!< suffix of default filename of BOSSANOVA fit constants file (unwanted saturation interaction) 62 extern "C" const char *SHIELDINGSUFFIX; //!< default filename of BOSSANOVA shieldings file 63 extern "C" const char *SHIELDINGPASSUFFIX; //!< default filename of BOSSANOVA shieldings PAS file 64 extern "C" const char *ORDERATSITEFILE; //!< default filename of BOSSANOVA Bond Order at each atom file 65 extern "C" const char *ENERGYPERFRAGMENT; //!< default filename of BOSSANOVA Energy contribution Per Fragment file 66 extern "C" const char *FRAGMENTPREFIX; //!< default filename prefix of BOSSANOVA fragment config and directories 67 extern "C" const char *STANDARDCONFIG; //!< default filename of standard config file 68 extern "C" const char *STANDARDELEMENTSDB; //!< default filename of elements data base with masses, Z, VanDerWaals radii, ... 69 extern "C" const char *STANDARDVALENCEDB; //!< default filename of valence number per element database 70 extern "C" const char *STANDARDORBITALDB; //!< default filename of orbitals per element database 71 extern "C" const char *STANDARDHBONDDISTANCEDB; //!< default filename of typial bond distance to hydrogen database 72 extern "C" const char *STANDARDHBONDANGLEDB; //!< default filename of typial bond angle to hydrogen database 72 73 73 74 // some values 74 #define SOLVENTDENSITY_A 0.6022142 75 #define SOLVENTDENSITY_a0 0.089238936 75 extern "C" const double SOLVENTDENSITY_A; 76 extern "C" const double SOLVENTDENSITY_a0; 76 77 77 78 78 #define UPDATECOUNT 10//!< update ten sites per BOSSANOVA interval79 extern "C" const int UPDATECOUNT; //!< update ten sites per BOSSANOVA interval 79 80 80 #define STD_MENU_LENGTH 60 81 #define STD_MENU_TITLE_SPACER '=' 82 #define STD_SEPERATOR_SPACER '-' 81 extern "C" const int STD_MENU_LENGTH; 82 extern "C" const char STD_MENU_TITLE_SPACER; 83 extern "C" const char STD_SEPERATOR_SPACER; 83 84 84 #define MOLECUILDER_NAME "Molecuilder" 85 extern "C" const char *MOLECUILDER_NAME; 85 86 86 87 const extern unsigned int MAX_POOL_FRAGMENTATION; -
src/ellipsoid.cpp
re588312 rb5c53d 15 15 #include <set> 16 16 17 #include "BoundaryPointSet.hpp" 17 18 #include "boundary.hpp" 18 19 #include "ellipsoid.hpp" … … 304 305 if ((current != PickedAtomNrs.end()) && (*current == index)) { 305 306 Candidate = (*Runner); 306 DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << **Runner<< " with index " << index << "." << endl);307 x[PointsPicked++] = *Candidate->node; // we have one more atom picked307 DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << (*Runner)->getName() << " with index " << index << "." << endl); 308 x[PointsPicked++] = Candidate->getPosition(); // we have one more atom picked 308 309 current++; // next pre-picked atom 309 310 } … … 351 352 //Log() << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": "; 352 353 if (value > threshold) { 353 x[PointsPicked] = ( *Runner->second->node->node);354 x[PointsPicked] = (Runner->second->node->getPosition()); 354 355 PointsPicked++; 355 356 //Log() << Verbose(0) << "IN." << endl; … … 388 389 Center.Zero(); 389 390 for (PointMap::iterator Runner = T->PointsOnBoundary.begin(); Runner != T->PointsOnBoundary.end(); Runner++) 390 Center += ( *Runner->second->node->node);391 Center += (Runner->second->node->getPosition()); 391 392 Center.Scale(1./T->PointsOnBoundaryCount); 392 393 DoLog(1) && (Log() << Verbose(1) << "Center is at " << Center << "." << endl); -
src/joiner.cpp
re588312 rb5c53d 209 209 prefix << dir << ForceFragmentSuffix; 210 210 if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 211 if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1; 211 { 212 std::string fileprefix(FRAGMENTPREFIX); 213 fileprefix += ENERGYPERFRAGMENT; 214 if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], fileprefix.c_str(), "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1; 215 } 212 216 if (!NoHessian) { 213 217 prefix.str(" "); -
src/linkedcell.cpp
re588312 rb5c53d 21 21 /** Constructor for class LinkedCell. 22 22 */ 23 LinkedCell::LinkedCell() 24 { 25 LC = NULL; 23 LinkedCell::LinkedCell() : 24 LC(NULL), 25 index(-1), 26 RADIUS(0.) 27 { 26 28 for(int i=0;i<NDIM;i++) 27 29 N[i] = 0; 28 index = -1;29 RADIUS = 0.;30 30 max.Zero(); 31 31 min.Zero(); … … 36 36 * \param RADIUS edge length of cells 37 37 */ 38 LinkedCell::LinkedCell(const PointCloud * const set, const double radius) 38 LinkedCell::LinkedCell(const PointCloud * const set, const double radius) : 39 RADIUS(radius), 40 LC(NULL), 41 index(-1) 39 42 { 40 43 TesselPoint *Walker = NULL; 41 44 42 RADIUS = radius;43 LC = NULL;44 45 for(int i=0;i<NDIM;i++) 45 46 N[i] = 0; 46 index = -1;47 47 max.Zero(); 48 48 min.Zero(); … … 56 56 Walker = set->GetPoint(); 57 57 for (int i=0;i<NDIM;i++) { 58 max[i] = Walker-> node->at(i);59 min[i] = Walker-> node->at(i);58 max[i] = Walker->at(i); 59 min[i] = Walker->at(i); 60 60 } 61 61 set->GoToFirst(); … … 63 63 Walker = set->GetPoint(); 64 64 for (int i=0;i<NDIM;i++) { 65 if (max[i] < Walker-> node->at(i))66 max[i] = Walker-> node->at(i);67 if (min[i] > Walker-> node->at(i))68 min[i] = Walker-> node->at(i);65 if (max[i] < Walker->at(i)) 66 max[i] = Walker->at(i); 67 if (min[i] > Walker->at(i)) 68 min[i] = Walker->at(i); 69 69 } 70 70 set->GoToNext(); … … 96 96 Walker = set->GetPoint(); 97 97 for (int i=0;i<NDIM;i++) { 98 n[i] = static_cast<int>(floor((Walker-> node->at(i) - min[i])/RADIUS));98 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS)); 99 99 } 100 100 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; … … 112 112 * \param RADIUS edge length of cells 113 113 */ 114 LinkedCell::LinkedCell(LinkedNodes *set, const double radius) 114 LinkedCell::LinkedCell(LinkedNodes *set, const double radius) : 115 RADIUS(radius), 116 LC(NULL), 117 index(-1) 115 118 { 116 119 class TesselPoint *Walker = NULL; 117 RADIUS = radius;118 LC = NULL;119 120 for(int i=0;i<NDIM;i++) 120 121 N[i] = 0; 121 index = -1;122 122 max.Zero(); 123 123 min.Zero(); … … 130 130 LinkedNodes::iterator Runner = set->begin(); 131 131 for (int i=0;i<NDIM;i++) { 132 max[i] = (*Runner)-> node->at(i);133 min[i] = (*Runner)-> node->at(i);132 max[i] = (*Runner)->at(i); 133 min[i] = (*Runner)->at(i); 134 134 } 135 135 for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) { 136 136 Walker = *Runner; 137 137 for (int i=0;i<NDIM;i++) { 138 if (max[i] < Walker-> node->at(i))139 max[i] = Walker-> node->at(i);140 if (min[i] > Walker-> node->at(i))141 min[i] = Walker-> node->at(i);138 if (max[i] < Walker->at(i)) 139 max[i] = Walker->at(i); 140 if (min[i] > Walker->at(i)) 141 min[i] = Walker->at(i); 142 142 } 143 143 } … … 167 167 Walker = *Runner; 168 168 for (int i=0;i<NDIM;i++) { 169 n[i] = static_cast<int>(floor((Walker-> node->at(i) - min[i])/RADIUS));169 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS)); 170 170 } 171 171 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; … … 248 248 * \return Vector is inside bounding box - true, else - false 249 249 */ 250 bool LinkedCell::SetIndexToVector(const Vector * constx) const250 bool LinkedCell::SetIndexToVector(const Vector & x) const 251 251 { 252 252 for (int i=0;i<NDIM;i++) 253 n[i] = (int)floor((x ->at(i) - min[i])/RADIUS);253 n[i] = (int)floor((x.at(i) - min[i])/RADIUS); 254 254 255 255 return CheckBounds(); … … 264 264 bool status = false; 265 265 for (int i=0;i<NDIM;i++) { 266 n[i] = static_cast<int>(floor((Walker-> node->at(i) - min[i])/RADIUS));266 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS)); 267 267 } 268 268 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; … … 404 404 Walker = *Runner; 405 405 //Log() << Verbose(1) << "Current neighbour is at " << *Walker->node << "." << endl; 406 if (( center->DistanceSquared(*Walker->node) - radiusSquared) < MYEPSILON) {406 if ((Walker->DistanceSquared(*center) - radiusSquared) < MYEPSILON) { 407 407 TesselList->push_back(Walker); 408 408 } -
src/linkedcell.hpp
re588312 rb5c53d 60 60 const LinkedCell::LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ; 61 61 bool SetIndexToNode(const TesselPoint * const Walker)const ; 62 bool SetIndexToVector(const Vector * constx)const ;62 bool SetIndexToVector(const Vector &x)const ; 63 63 double SetClosestIndexToOutsideVector(const Vector * const x) const; 64 64 bool CheckBounds()const ; -
src/molecule.cpp
re588312 rb5c53d 157 157 atomIds.erase( atom->getId() ); 158 158 atoms.remove( atom ); 159 formula-=atom-> type;159 formula-=atom->getType(); 160 160 atom->removeFromMolecule(); 161 161 return iter; … … 169 169 atomIds.erase( key->getId() ); 170 170 atoms.remove( key ); 171 formula-=key-> type;171 formula-=key->getType(); 172 172 key->removeFromMolecule(); 173 173 } … … 191 191 if (res.second) { // push atom if went well 192 192 atoms.push_back(key); 193 formula+=key-> type;193 formula+=key->getType(); 194 194 return pair<iterator,bool>(molecule::iterator(--end()),res.second); 195 195 } else { … … 212 212 if (pointer != NULL) { 213 213 pointer->sort = &pointer->nr; 214 if (pointer-> type!= NULL) {215 formula += pointer-> type;216 if (pointer-> type->Z != 1)214 if (pointer->getType() != NULL) { 215 formula += pointer->getType(); 216 if (pointer->getType()->Z != 1) 217 217 NoNonHydrogen++; 218 218 if(pointer->getName() == "Unknown"){ 219 219 stringstream sstr; 220 sstr << pointer-> type->getSymbol() << pointer->nr+1;220 sstr << pointer->getType()->getSymbol() << pointer->nr+1; 221 221 pointer->setName(sstr.str()); 222 222 } … … 239 239 if (pointer != NULL) { 240 240 atom *walker = pointer->clone(); 241 formula += walker-> type;241 formula += walker->getType(); 242 242 walker->setName(pointer->getName()); 243 243 walker->nr = last_atom++; // increase number within molecule 244 244 insert(walker); 245 if ((pointer-> type != NULL) && (pointer->type->Z != 1))245 if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1)) 246 246 NoNonHydrogen++; 247 247 retval=walker; … … 301 301 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; 302 302 // create vector in direction of bond 303 InBondvector = TopReplacement-> x - TopOrigin->x;303 InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition(); 304 304 bondlength = InBondvector.Norm(); 305 305 … … 313 313 Orthovector1.Zero(); 314 314 for (int i=NDIM;i--;) { 315 l = TopReplacement-> x[i] - TopOrigin->x[i];315 l = TopReplacement->at(i) - TopOrigin->at(i); 316 316 if (fabs(l) > BondDistance) { // is component greater than bond distance 317 317 Orthovector1[i] = (l < 0) ? -1. : +1.; … … 328 328 InBondvector.Normalize(); 329 329 // get typical bond length and store as scale factor for later 330 ASSERT(TopOrigin-> type!= NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");331 BondRescale = TopOrigin-> type->HBondDistance[TopBond->BondDegree-1];330 ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given."); 331 BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1]; 332 332 if (BondRescale == -1) { 333 333 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 343 343 case 1: 344 344 FirstOtherAtom = World::getInstance().createAtom(); // new atom 345 FirstOtherAtom-> type = elemente->FindElement(1); // element is Hydrogen346 FirstOtherAtom-> v = TopReplacement->v; // copy velocity345 FirstOtherAtom->setType(1); // element is Hydrogen 346 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 347 347 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 348 if (TopReplacement-> type->Z == 1) { // neither rescale nor replace if it's already hydrogen348 if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen 349 349 FirstOtherAtom->father = TopReplacement; 350 350 BondRescale = bondlength; … … 353 353 } 354 354 InBondvector *= BondRescale; // rescale the distance vector to Hydrogen bond length 355 FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ... 356 FirstOtherAtom->x += InBondvector; // ... and add distance vector to replacement atom 355 FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom 357 356 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); 358 357 // Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: "; … … 387 386 // determine the plane of these two with the *origin 388 387 try { 389 Orthovector1 =Plane(TopOrigin-> x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();388 Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal(); 390 389 } 391 390 catch(LinearDependenceException &excp){ … … 408 407 FirstOtherAtom = World::getInstance().createAtom(); 409 408 SecondOtherAtom = World::getInstance().createAtom(); 410 FirstOtherAtom-> type = elemente->FindElement(1);411 SecondOtherAtom-> type = elemente->FindElement(1);412 FirstOtherAtom-> v = TopReplacement->v; // copy velocity409 FirstOtherAtom->setType(1); 410 SecondOtherAtom->setType(1); 411 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 413 412 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 414 SecondOtherAtom-> v = TopReplacement->v; // copy velocity413 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 415 414 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 416 415 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father 417 416 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father 418 bondangle = TopOrigin-> type->HBondAngle[1];417 bondangle = TopOrigin->getType()->HBondAngle[1]; 419 418 if (bondangle == -1) { 420 419 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 430 429 // Log() << Verbose(0) << endl; 431 430 // Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl; 432 FirstOtherAtom-> x.Zero();433 SecondOtherAtom-> x.Zero();431 FirstOtherAtom->Zero(); 432 SecondOtherAtom->Zero(); 434 433 for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction) 435 FirstOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));436 SecondOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));437 } 438 FirstOtherAtom-> x *= BondRescale; // rescale by correct BondDistance439 SecondOtherAtom-> x *= BondRescale;434 FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle))); 435 SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle))); 436 } 437 FirstOtherAtom->Scale(BondRescale); // rescale by correct BondDistance 438 SecondOtherAtom->Scale(BondRescale); 440 439 //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl; 441 for(int i=NDIM;i--;) { // and make relative to origin atom 442 FirstOtherAtom->x[i] += TopOrigin->x[i]; 443 SecondOtherAtom->x[i] += TopOrigin->x[i]; 444 } 440 *FirstOtherAtom += TopOrigin->getPosition(); 441 *SecondOtherAtom += TopOrigin->getPosition(); 445 442 // ... and add to molecule 446 443 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); … … 464 461 SecondOtherAtom = World::getInstance().createAtom(); 465 462 ThirdOtherAtom = World::getInstance().createAtom(); 466 FirstOtherAtom-> type = elemente->FindElement(1);467 SecondOtherAtom-> type = elemente->FindElement(1);468 ThirdOtherAtom-> type = elemente->FindElement(1);469 FirstOtherAtom-> v = TopReplacement->v; // copy velocity463 FirstOtherAtom->setType(1); 464 SecondOtherAtom->setType(1); 465 ThirdOtherAtom->setType(1); 466 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 470 467 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 471 SecondOtherAtom-> v = TopReplacement->v; // copy velocity468 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 472 469 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 473 ThirdOtherAtom-> v = TopReplacement->v; // copy velocity470 ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 474 471 ThirdOtherAtom->FixedIon = TopReplacement->FixedIon; 475 472 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father … … 494 491 495 492 // create correct coordination for the three atoms 496 alpha = (TopOrigin-> type->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database493 alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database 497 494 l = BondRescale; // desired bond length 498 495 b = 2.*l*sin(alpha); // base length of isosceles triangle … … 505 502 factors[1] = f; 506 503 factors[2] = 0.; 507 FirstOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);504 FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 508 505 factors[1] = -0.5*f; 509 506 factors[2] = g; 510 SecondOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);507 SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 511 508 factors[2] = -g; 512 ThirdOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);509 ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 513 510 514 511 // rescale each to correct BondDistance … … 518 515 519 516 // and relative to *origin atom 520 FirstOtherAtom->x += TopOrigin->x;521 SecondOtherAtom->x += TopOrigin->x;522 ThirdOtherAtom->x += TopOrigin->x;517 *FirstOtherAtom += TopOrigin->getPosition(); 518 *SecondOtherAtom += TopOrigin->getPosition(); 519 *ThirdOtherAtom += TopOrigin->getPosition(); 523 520 524 521 // ... and add to molecule … … 596 593 *item >> x[1]; 597 594 *item >> x[2]; 598 Walker-> type = elemente->FindElement(shorthand);599 if (Walker-> type== NULL) {595 Walker->setType(elemente->FindElement(shorthand)); 596 if (Walker->getType() == NULL) { 600 597 DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H."); 601 Walker-> type = elemente->FindElement(1);598 Walker->setType(1); 602 599 } 603 600 if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) { … … 606 603 Walker->Trajectory.F.resize(MDSteps+10); 607 604 } 605 Walker->setPosition(Vector(x)); 608 606 for(j=NDIM;j--;) { 609 Walker->x[j] = x[j];610 607 Walker->Trajectory.R.at(MDSteps-1)[j] = x[j]; 611 608 Walker->Trajectory.U.at(MDSteps-1)[j] = 0; … … 702 699 atom1->RegisterBond(Binder); 703 700 atom2->RegisterBond(Binder); 704 if ((atom1-> type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))701 if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1)) 705 702 NoNonBonds++; 706 703 … … 776 773 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 777 774 OBSERVE; 778 formula-=pointer-> type;775 formula-=pointer->getType(); 779 776 RemoveBonds(pointer); 780 777 erase(pointer); … … 790 787 if (pointer == NULL) 791 788 return false; 792 formula-=pointer-> type;789 formula-=pointer->getType(); 793 790 erase(pointer); 794 791 return true; … … 972 969 for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 973 970 (*iter)->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 974 if ((*iter)-> type->Z != 1) // count non-hydrogen atoms whilst at it971 if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it 975 972 NoNonHydrogen++; 976 973 stringstream sstr; 977 sstr << (*iter)-> type->getSymbol() << (*iter)->nr+1;974 sstr << (*iter)->getType()->getSymbol() << (*iter)->nr+1; 978 975 (*iter)->setName(sstr.str()); 979 976 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl); -
src/molecule.hpp
re588312 rb5c53d 24 24 #include "types.hpp" 25 25 #include "graph.hpp" 26 #include " tesselation.hpp"26 #include "PointCloud.hpp" 27 27 #include "Patterns/Observer.hpp" 28 28 #include "Patterns/ObservedIterator.hpp" … … 165 165 bool IsEnd() const ; 166 166 167 // templates for allowing global manipulation of all vectors168 template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const;169 template <typename res> void ActOnAllVectors( res (Vector::*f)() const) const;170 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const;171 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const;172 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&), T &t ) const;173 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const;174 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const;175 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const;176 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const;177 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const;178 179 167 // templates for allowing global manipulation of molecule with each atom as single argument 180 168 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const; … … 270 258 void Scale(const double ** const factor); 271 259 void DeterminePeriodicCenter(Vector ¢er); 272 Vector * DetermineCenterOfGravity() ;260 Vector * DetermineCenterOfGravity() const; 273 261 Vector * DetermineCenterOfAll() const; 274 262 Vector * DetermineCenterOfBox() const; … … 278 266 bool VerletForceIntegration(char *file, config &configuration, const size_t offset); 279 267 void Thermostats(config &configuration, double ActualTemp, int Thermostat); 280 void PrincipalAxisSystem(bool DoRotate);281 268 double VolumeOfConvexEnvelope(bool IsAngstroem); 282 269 -
src/molecule_dynamics.cpp
re588312 rb5c53d 513 513 Sprinter = mol->AddCopyAtom((*iter)); 514 514 for (int n=NDIM;n--;) { 515 Sprinter-> x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);515 Sprinter->set(n, (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps)); 516 516 // add to Trajectories 517 517 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; -
src/molecule_fragmentation.cpp
re588312 rb5c53d 451 451 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 452 452 #ifdef ADDHYDROGEN 453 if ((*iter)-> type->Z != 1) // skip hydrogen453 if ((*iter)->getType()->Z != 1) // skip hydrogen 454 454 #endif 455 455 { … … 471 471 for(molecule::const_iterator iter = begin(); iter != end(); ++iter) { 472 472 #ifdef ADDHYDROGEN 473 if ((*iter)-> type->Z != 1) // skip hydrogen473 if ((*iter)->getType()->Z != 1) // skip hydrogen 474 474 #endif 475 475 { … … 880 880 for (KeySet::iterator runner = Leaf->begin(); runner != Leaf->end(); runner++) { 881 881 Runner = FindAtom((*runner)); 882 if (Runner-> type->Z != 1) { // skip all those added hydrogens when re-filling snake stack882 if (Runner->getType()->Z != 1) { // skip all those added hydrogens when re-filling snake stack 883 883 if (ShortestPathList[(*runner)] > SP) { // remove the oldest one with longest shortest path 884 884 SP = ShortestPathList[(*runner)]; … … 969 969 ++iter; 970 970 #ifdef ADDHYDROGEN 971 while ((iter != Leaf->end()) && ((*iter)-> type->Z == 1)){ // skip added hydrogen971 while ((iter != Leaf->end()) && ((*iter)->getType()->Z == 1)){ // skip added hydrogen 972 972 iter++; 973 973 } … … 1347 1347 if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end()) 1348 1348 #ifdef ADDHYDROGEN 1349 && (OtherWalker-> type->Z != 1)1349 && (OtherWalker->getType()->Z != 1) 1350 1350 #endif 1351 1351 ) { // skip hydrogens and restrict to fragment … … 1741 1741 Binder = (*BondRunner); 1742 1742 for (int i=NDIM;i--;) { 1743 tmp = fabs(Binder->leftatom-> x[i] - Binder->rightatom->x[i]);1743 tmp = fabs(Binder->leftatom->at(i) - Binder->rightatom->at(i)); 1744 1744 //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl; 1745 1745 if (tmp > BondDistance) { … … 1755 1755 // create translation vector from their periodically modified distance 1756 1756 for (int i=NDIM;i--;) { 1757 tmp = Binder->leftatom-> x[i] - Binder->rightatom->x[i];1757 tmp = Binder->leftatom->at(i) - Binder->rightatom->at(i); 1758 1758 if (fabs(tmp) > BondDistance) 1759 1759 Translationvector[i] = (tmp < 0) ? +1. : -1.; … … 1770 1770 //Log() << Verbose (3) << "Current Walker is: " << *Walker << "." << endl; 1771 1771 ColorList[Walker->nr] = black; // mark as explored 1772 Walker->x+= Translationvector; // translate1772 *Walker += Translationvector; // translate 1773 1773 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1774 1774 if ((*Runner) != Binder) { -
src/molecule_geometry.cpp
re588312 rb5c53d 10 10 #endif 11 11 12 #include "Helpers/helpers.hpp" 13 #include "Helpers/Log.hpp" 12 14 #include "Helpers/MemDebug.hpp" 15 #include "Helpers/Verbose.hpp" 16 #include "LinearAlgebra/Line.hpp" 17 #include "LinearAlgebra/Matrix.hpp" 18 #include "LinearAlgebra/Plane.hpp" 13 19 14 20 #include "atom.hpp" … … 16 22 #include "config.hpp" 17 23 #include "element.hpp" 18 #include "Helpers/helpers.hpp"19 24 #include "leastsquaremin.hpp" 20 #include "Helpers/Verbose.hpp"21 #include "Helpers/Log.hpp"22 25 #include "molecule.hpp" 23 26 #include "World.hpp" 24 #include "LinearAlgebra/Plane.hpp" 25 #include "LinearAlgebra/Matrix.hpp" 27 26 28 #include "Box.hpp" 29 27 30 #include <boost/foreach.hpp> 28 31 … … 45 48 46 49 // go through all atoms 47 ActOnAllVectors( &Vector::SubtractVector, *Center); 48 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 50 BOOST_FOREACH(atom* iter, atoms){ 51 *iter -= *Center; 52 *iter -= *CenterBox; 53 } 49 54 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 50 55 … … 63 68 Box &domain = World::getInstance().getDomain(); 64 69 70 // go through all atoms 65 71 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 66 72 … … 80 86 if (iter != end()) { //list not empty? 81 87 for (int i=NDIM;i--;) { 82 max->at(i) = (*iter)-> x[i];83 min->at(i) = (*iter)-> x[i];88 max->at(i) = (*iter)->at(i); 89 min->at(i) = (*iter)->at(i); 84 90 } 85 91 for (; iter != end(); ++iter) {// continue with second if present 86 92 //(*iter)->Output(1,1,out); 87 93 for (int i=NDIM;i--;) { 88 max->at(i) = (max->at(i) < (*iter)-> x[i]) ? (*iter)->x[i]: max->at(i);89 min->at(i) = (min->at(i) > (*iter)-> x[i]) ? (*iter)->x[i]: min->at(i);94 max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i); 95 min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i); 90 96 } 91 97 } … … 118 124 for (; iter != end(); ++iter) { // continue with second if present 119 125 Num++; 120 Center += (*iter)-> x;126 Center += (*iter)->getPosition(); 121 127 } 122 128 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) … … 140 146 for (; iter != end(); ++iter) { // continue with second if present 141 147 Num++; 142 (*a) += (*iter)-> x;148 (*a) += (*iter)->getPosition(); 143 149 } 144 150 a->Scale(1./(double)Num); // divide through total mass (and sign for direction) … … 162 168 * \return pointer to center of gravity vector 163 169 */ 164 Vector * molecule::DetermineCenterOfGravity() 170 Vector * molecule::DetermineCenterOfGravity() const 165 171 { 166 172 molecule::const_iterator iter = begin(); // start at first in list … … 173 179 if (iter != end()) { //list not empty? 174 180 for (; iter != end(); ++iter) { // continue with second if present 175 Num += (*iter)-> type->mass;176 tmp = (*iter)-> type->mass * (*iter)->x;181 Num += (*iter)->getType()->mass; 182 tmp = (*iter)->getType()->mass * (*iter)->getPosition(); 177 183 (*a) += tmp; 178 184 } … … 218 224 for (int j=0;j<MDSteps;j++) 219 225 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 220 (*iter)-> x.ScaleAll(*factor);226 (*iter)->ScaleAll(*factor); 221 227 } 222 228 }; … … 230 236 for (int j=0;j<MDSteps;j++) 231 237 (*iter)->Trajectory.R.at(j) += (*trans); 232 (*iter)->x+= (*trans);238 *(*iter) += (*trans); 233 239 } 234 240 }; … … 243 249 244 250 // go through all atoms 245 ActOnAllVectors( &Vector::AddVector, *trans); 251 BOOST_FOREACH(atom* iter, atoms){ 252 *iter += *trans; 253 } 246 254 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 247 255 … … 275 283 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 276 284 #ifdef ADDHYDROGEN 277 if ((*iter)-> type->Z != 1) {285 if ((*iter)->getType()->Z != 1) { 278 286 #endif 279 Testvector = inversematrix * (*iter)-> x;287 Testvector = inversematrix * (*iter)->getPosition(); 280 288 Translationvector.Zero(); 281 289 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 282 290 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 283 291 for (int j=0;j<NDIM;j++) { 284 tmp = (*iter)-> x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];292 tmp = (*iter)->at(j) - (*Runner)->GetOtherAtom(*iter)->at(j); 285 293 if ((fabs(tmp)) > BondDistance) { 286 294 flag = false; … … 300 308 // now also change all hydrogens 301 309 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 302 if ((*Runner)->GetOtherAtom((*iter))-> type->Z == 1) {303 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))-> x;310 if ((*Runner)->GetOtherAtom((*iter))->getType()->Z == 1) { 311 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition(); 304 312 Testvector += Translationvector; 305 313 Testvector *= matrix; … … 316 324 }; 317 325 318 /** Transforms/Rotates the given molecule into its principal axis system.319 * \param *out output stream for debugging320 * \param DoRotate whether to rotate (true) or only to determine the PAS.321 * TODO treatment of trajetories missing322 */323 void molecule::PrincipalAxisSystem(bool DoRotate)324 {325 double InertiaTensor[NDIM*NDIM];326 Vector *CenterOfGravity = DetermineCenterOfGravity();327 328 CenterPeriodic();329 330 // reset inertia tensor331 for(int i=0;i<NDIM*NDIM;i++)332 InertiaTensor[i] = 0.;333 334 // sum up inertia tensor335 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {336 Vector x = (*iter)->x;337 //x.SubtractVector(CenterOfGravity);338 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);339 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);340 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);341 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);342 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);343 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);344 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);345 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);346 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);347 }348 // print InertiaTensor for debugging349 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);350 for(int i=0;i<NDIM;i++) {351 for(int j=0;j<NDIM;j++)352 DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ");353 DoLog(0) && (Log() << Verbose(0) << endl);354 }355 DoLog(0) && (Log() << Verbose(0) << endl);356 357 // diagonalize to determine principal axis system358 gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM);359 gsl_matrix_view m = gsl_matrix_view_array(InertiaTensor, NDIM, NDIM);360 gsl_vector *eval = gsl_vector_alloc(NDIM);361 gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM);362 gsl_eigen_symmv(&m.matrix, eval, evec, T);363 gsl_eigen_symmv_free(T);364 gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_DESC);365 366 for(int i=0;i<NDIM;i++) {367 DoLog(1) && (Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i));368 DoLog(0) && (Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl);369 }370 371 // check whether we rotate or not372 if (DoRotate) {373 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... ");374 // the eigenvectors specify the transformation matrix375 Matrix M = Matrix(evec->data);376 377 BOOST_FOREACH(atom* iter, atoms){378 (*iter->node) *= M;379 }380 DoLog(0) && (Log() << Verbose(0) << "done." << endl);381 382 // summing anew for debugging (resulting matrix has to be diagonal!)383 // reset inertia tensor384 for(int i=0;i<NDIM*NDIM;i++)385 InertiaTensor[i] = 0.;386 387 // sum up inertia tensor388 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {389 Vector x = (*iter)->x;390 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);391 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);392 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);393 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);394 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);395 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);396 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);397 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);398 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);399 }400 // print InertiaTensor for debugging401 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);402 for(int i=0;i<NDIM;i++) {403 for(int j=0;j<NDIM;j++)404 DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ");405 DoLog(0) && (Log() << Verbose(0) << endl);406 }407 DoLog(0) && (Log() << Verbose(0) << endl);408 }409 410 // free everything411 delete(CenterOfGravity);412 gsl_vector_free(eval);413 gsl_matrix_free(evec);414 };415 416 417 326 /** Align all atoms in such a manner that given vector \a *n is along z axis. 418 327 * \param n[] alignment vector. … … 431 340 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 432 341 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 433 tmp = (*iter)-> x[0];434 (*iter)-> x[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];435 (*iter)-> x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];342 tmp = (*iter)->at(0); 343 (*iter)->set(0, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 344 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 436 345 for (int j=0;j<MDSteps;j++) { 437 346 tmp = (*iter)->Trajectory.R.at(j)[0]; … … 450 359 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 451 360 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 452 tmp = (*iter)-> x[1];453 (*iter)-> x[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];454 (*iter)-> x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];361 tmp = (*iter)->at(1); 362 (*iter)->set(1, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 363 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 455 364 for (int j=0;j<MDSteps;j++) { 456 365 tmp = (*iter)->Trajectory.R.at(j)[1]; … … 490 399 // go through all atoms 491 400 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 492 if ((*iter)-> type== ((struct lsq_params *)params)->type) { // for specific type493 c = (*iter)-> x- a;401 if ((*iter)->getType() == ((struct lsq_params *)params)->type) { // for specific type 402 c = (*iter)->getPosition() - a; 494 403 t = c.ScalarProduct(b); // get direction parameter 495 404 d = t*b; // and create vector -
src/molecule_graph.cpp
re588312 rb5c53d 184 184 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 185 185 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 186 const double distance = domain.periodicDistanceSquared(OtherWalker-> x,Walker->x);186 const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition()); 187 187 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 188 188 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 737 737 OtherAtom = (*Runner)->GetOtherAtom(Walker); 738 738 #ifdef ADDHYDROGEN 739 if (OtherAtom-> type->Z != 1) {739 if (OtherAtom->getType()->Z != 1) { 740 740 #endif 741 741 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl); -
src/molecule_template.hpp
re588312 rb5c53d 19 19 /********************************************** declarations *******************************/ 20 20 21 // ================== Acting on all Vectors ========================== //22 23 // zero arguments24 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const25 {26 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {27 (((*iter)->node)->*f)();28 }29 };30 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const31 {32 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {33 (((*iter)->node)->*f)();34 }35 };36 // one argument37 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const38 {39 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {40 (((*iter)->node)->*f)(t);41 }42 };43 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const44 {45 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {46 (((*iter)->node)->*f)(t);47 }48 };49 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const50 {51 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {52 (((*iter)->node)->*f)(t);53 }54 };55 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const56 {57 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {58 (((*iter)->node)->*f)(t);59 }60 };61 // two arguments62 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const63 {64 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {65 (((*iter)->node)->*f)(t, u);66 }67 };68 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const69 {70 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {71 (((*iter)->node)->*f)(t, u);72 }73 };74 // three arguments75 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const76 {77 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {78 (((*iter)->node)->*f)(t, u, v);79 }80 };81 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const82 {83 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {84 (((*iter)->node)->*f)(t, u, v);85 }86 };87 21 88 22 // ========================= Summing over each Atoms =================================== // … … 370 304 int inc = 1; 371 305 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 372 (*Setor) (&array[((*iter)-> type->*index)], &inc);306 (*Setor) (&array[((*iter)->getType()->*index)], &inc); 373 307 } 374 308 }; … … 376 310 { 377 311 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 378 (*Setor) (&array[((*iter)-> type->*index)], &value);312 (*Setor) (&array[((*iter)->getType()->*index)], &value); 379 313 } 380 314 }; … … 382 316 { 383 317 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 384 (*Setor) (&array[((*iter)-> type->*index)], value);318 (*Setor) (&array[((*iter)->getType()->*index)], value); 385 319 } 386 320 }; -
src/moleculelist.cpp
re588312 rb5c53d 30 30 #include "molecule.hpp" 31 31 #include "periodentafel.hpp" 32 #include "tesselation.hpp" 32 33 #include "Helpers/Assert.hpp" 33 34 #include "LinearAlgebra/Matrix.hpp" … … 43 44 MoleculeListClass::MoleculeListClass(World *_world) : 44 45 Observable("MoleculeListClass"), 45 world(_world) 46 { 47 // empty lists 48 ListOfMolecules.clear(); 49 MaxIndex = 1; 50 }; 46 world(_world), 47 MaxIndex(1) 48 {}; 51 49 52 50 /** Destructor for MoleculeListClass. … … 182 180 size=0.; 183 181 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 184 counts[(*iter)-> type->getNumber()]++;185 if ((*iter)-> x.DistanceSquared(Origin) > size)186 size = (*iter)-> x.DistanceSquared(Origin);182 counts[(*iter)->getType()->getNumber()]++; 183 if ((*iter)->DistanceSquared(Origin) > size) 184 size = (*iter)->DistanceSquared(Origin); 187 185 } 188 186 // output Index, Name, number of atoms, chemical formula … … 354 352 for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 355 353 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl); 356 if (!TesselStruct->IsInnerPoint((*iter)-> x, LCList)) {354 if (!TesselStruct->IsInnerPoint((*iter)->getPosition(), LCList)) { 357 355 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 358 356 mol->AddAtom(CopyAtoms[(*iter)->nr]); … … 501 499 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 502 500 //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 503 if (((*iter)-> type->Z == 1) && (((*iter)->father == NULL)504 || ((*iter)->father-> type->Z != 1))) { // if it's a hydrogen501 if (((*iter)->getType()->Z == 1) && (((*iter)->father == NULL) 502 || ((*iter)->father->getType()->Z != 1))) { // if it's a hydrogen 505 503 for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) { 506 504 //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 507 505 // 3. take every other hydrogen that is the not the first and not bound to same bonding partner 508 506 Binder = *((*runner)->ListOfBonds.begin()); 509 if (((*runner)-> type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)507 if (((*runner)->getType()->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!) 510 508 // 4. evaluate the morse potential for each matrix component and add up 511 distance = (*runner)-> x.distance((*iter)->x);509 distance = (*runner)->distance(*(*iter)); 512 510 //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl; 513 511 for (int k = 0; k < a; k++) { … … 599 597 if ((*ListRunner)->hasElement((*elemIter).first)) { // if this element got atoms 600 598 for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){ 601 if ((*atomIter)-> type->getNumber() == (*elemIter).first) {599 if ((*atomIter)->getType()->getNumber() == (*elemIter).first) { 602 600 if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea 603 601 //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it … … 952 950 */ 953 951 //MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL) 954 MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL) 952 MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL) : 953 Leaf(NULL), 954 previous(PreviousLeaf) 955 955 { 956 956 // if (Up != NULL) … … 959 959 // UpLeaf = Up; 960 960 // DownLeaf = NULL; 961 Leaf = NULL;962 previous = PreviousLeaf;963 961 if (previous != NULL) { 964 962 MoleculeLeafClass *Walker = previous->next; … … 1089 1087 if (AtomMask[Father->nr]) // apply mask 1090 1088 #ifdef ADDHYDROGEN 1091 if ((*iter)-> type->Z != 1) // skip hydrogen1089 if ((*iter)->getType()->Z != 1) // skip hydrogen 1092 1090 #endif 1093 1091 RootStack[FragmentCounter].push_front((*iter)->nr); -
src/parser.cpp
re588312 rb5c53d 59 59 /** Constructor of MatrixContainer class. 60 60 */ 61 MatrixContainer::MatrixContainer() { 62 Indices = NULL; 61 MatrixContainer::MatrixContainer() : 62 Indices(NULL) 63 { 63 64 Header = new char*[1]; 64 65 Matrix = new double**[1]; // one more each for the total molecule … … 850 851 /** Constructor for class HessianMatrix. 851 852 */ 852 HessianMatrix::HessianMatrix() : MatrixContainer()853 { 854 IsSymmetric = true;855 }853 HessianMatrix::HessianMatrix() : 854 MatrixContainer(), 855 IsSymmetric(true) 856 {} 856 857 857 858 /** Sums the hessian entries with each factor and put into last element of \a ***Matrix. … … 995 996 /** Constructor of KeySetsContainer class. 996 997 */ 997 KeySetsContainer::KeySetsContainer() {998 KeySets = NULL;999 AtomCounter = NULL;1000 FragmentCounter = 0;1001 Order = 0;1002 FragmentsPerOrder = 0;1003 OrderSet = NULL;1004 };998 KeySetsContainer::KeySetsContainer() : 999 KeySets(NULL), 1000 AtomCounter(NULL), 1001 FragmentCounter(0), 1002 Order(0), 1003 FragmentsPerOrder(0), 1004 OrderSet(NULL) 1005 {}; 1005 1006 1006 1007 /** Destructor of KeySetsContainer class. -
src/tesselation.cpp
re588312 rb5c53d 13 13 #include "Helpers/helpers.hpp" 14 14 #include "Helpers/Info.hpp" 15 #include "BoundaryPointSet.hpp" 16 #include "BoundaryLineSet.hpp" 17 #include "BoundaryTriangleSet.hpp" 18 #include "BoundaryPolygonSet.hpp" 19 #include "TesselPoint.hpp" 20 #include "CandidateForTesselation.hpp" 21 #include "PointCloud.hpp" 15 22 #include "linkedcell.hpp" 16 23 #include "Helpers/Log.hpp" … … 20 27 #include "LinearAlgebra/Vector.hpp" 21 28 #include "LinearAlgebra/Line.hpp" 22 #include " vector_ops.hpp"29 #include "LinearAlgebra/vector_ops.hpp" 23 30 #include "Helpers/Verbose.hpp" 24 31 #include "LinearAlgebra/Plane.hpp" … … 28 35 class molecule; 29 36 30 // ======================================== Points on Boundary ================================= 31 32 /** Constructor of BoundaryPointSet. 33 */ 34 BoundaryPointSet::BoundaryPointSet() : 35 LinesCount(0), value(0.), Nr(-1) 36 { 37 Info FunctionInfo(__func__); 38 DoLog(1) && (Log() << Verbose(1) << "Adding noname." << endl); 39 } 40 ; 41 42 /** Constructor of BoundaryPointSet with Tesselpoint. 43 * \param *Walker TesselPoint this boundary point represents 44 */ 45 BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) : 46 LinesCount(0), node(Walker), value(0.), Nr(Walker->nr) 47 { 48 Info FunctionInfo(__func__); 49 DoLog(1) && (Log() << Verbose(1) << "Adding Node " << *Walker << endl); 50 } 51 ; 52 53 /** Destructor of BoundaryPointSet. 54 * Sets node to NULL to avoid removing the original, represented TesselPoint. 55 * \note When removing point from a class Tesselation, use RemoveTesselationPoint() 56 */ 57 BoundaryPointSet::~BoundaryPointSet() 58 { 59 Info FunctionInfo(__func__); 60 //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl; 61 if (!lines.empty()) 62 DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl); 63 node = NULL; 64 } 65 ; 66 67 /** Add a line to the LineMap of this point. 68 * \param *line line to add 69 */ 70 void BoundaryPointSet::AddLine(BoundaryLineSet * const line) 71 { 72 Info FunctionInfo(__func__); 73 DoLog(1) && (Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "." << endl); 74 if (line->endpoints[0] == this) { 75 lines.insert(LinePair(line->endpoints[1]->Nr, line)); 76 } else { 77 lines.insert(LinePair(line->endpoints[0]->Nr, line)); 78 } 79 LinesCount++; 80 } 81 ; 82 83 /** output operator for BoundaryPointSet. 84 * \param &ost output stream 85 * \param &a boundary point 86 */ 87 ostream & operator <<(ostream &ost, const BoundaryPointSet &a) 88 { 89 ost << "[" << a.Nr << "|" << a.node->getName() << " at " << *a.node->node << "]"; 90 return ost; 91 } 92 ; 93 94 // ======================================== Lines on Boundary ================================= 95 96 /** Constructor of BoundaryLineSet. 97 */ 98 BoundaryLineSet::BoundaryLineSet() : 99 Nr(-1) 100 { 101 Info FunctionInfo(__func__); 102 for (int i = 0; i < 2; i++) 103 endpoints[i] = NULL; 104 } 105 ; 106 107 /** Constructor of BoundaryLineSet with two endpoints. 108 * Adds line automatically to each endpoints' LineMap 109 * \param *Point[2] array of two boundary points 110 * \param number number of the list 111 */ 112 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number) 113 { 114 Info FunctionInfo(__func__); 115 // set number 116 Nr = number; 117 // set endpoints in ascending order 118 SetEndpointsOrdered(endpoints, Point[0], Point[1]); 119 // add this line to the hash maps of both endpoints 120 Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding. 121 Point[1]->AddLine(this); // 122 // set skipped to false 123 skipped = false; 124 // clear triangles list 125 DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl); 126 } 127 ; 128 129 /** Constructor of BoundaryLineSet with two endpoints. 130 * Adds line automatically to each endpoints' LineMap 131 * \param *Point1 first boundary point 132 * \param *Point2 second boundary point 133 * \param number number of the list 134 */ 135 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number) 136 { 137 Info FunctionInfo(__func__); 138 // set number 139 Nr = number; 140 // set endpoints in ascending order 141 SetEndpointsOrdered(endpoints, Point1, Point2); 142 // add this line to the hash maps of both endpoints 143 Point1->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding. 144 Point2->AddLine(this); // 145 // set skipped to false 146 skipped = false; 147 // clear triangles list 148 DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl); 149 } 150 ; 151 152 /** Destructor for BoundaryLineSet. 153 * Removes itself from each endpoints' LineMap, calling RemoveTrianglePoint() when point not connected anymore. 154 * \note When removing lines from a class Tesselation, use RemoveTesselationLine() 155 */ 156 BoundaryLineSet::~BoundaryLineSet() 157 { 158 Info FunctionInfo(__func__); 159 int Numbers[2]; 160 161 // get other endpoint number of finding copies of same line 162 if (endpoints[1] != NULL) 163 Numbers[0] = endpoints[1]->Nr; 164 else 165 Numbers[0] = -1; 166 if (endpoints[0] != NULL) 167 Numbers[1] = endpoints[0]->Nr; 168 else 169 Numbers[1] = -1; 170 171 for (int i = 0; i < 2; i++) { 172 if (endpoints[i] != NULL) { 173 if (Numbers[i] != -1) { // as there may be multiple lines with same endpoints, we have to go through each and find in the endpoint's line list this line set 174 pair<LineMap::iterator, LineMap::iterator> erasor = endpoints[i]->lines.equal_range(Numbers[i]); 175 for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++) 176 if ((*Runner).second == this) { 177 //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl; 178 endpoints[i]->lines.erase(Runner); 179 break; 180 } 181 } else { // there's just a single line left 182 if (endpoints[i]->lines.erase(Nr)) { 183 //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl; 184 } 185 } 186 if (endpoints[i]->lines.empty()) { 187 //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl; 188 if (endpoints[i] != NULL) { 189 delete (endpoints[i]); 190 endpoints[i] = NULL; 191 } 192 } 193 } 194 } 195 if (!triangles.empty()) 196 DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl); 197 } 198 ; 199 200 /** Add triangle to TriangleMap of this boundary line. 201 * \param *triangle to add 202 */ 203 void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle) 204 { 205 Info FunctionInfo(__func__); 206 DoLog(0) && (Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl); 207 triangles.insert(TrianglePair(triangle->Nr, triangle)); 208 } 209 ; 210 211 /** Checks whether we have a common endpoint with given \a *line. 212 * \param *line other line to test 213 * \return true - common endpoint present, false - not connected 214 */ 215 bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const 216 { 217 Info FunctionInfo(__func__); 218 if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1])) 219 return true; 220 else 221 return false; 222 } 223 ; 224 225 /** Checks whether the adjacent triangles of a baseline are convex or not. 226 * We sum the two angles of each height vector with respect to the center of the baseline. 227 * If greater/equal M_PI than we are convex. 228 * \param *out output stream for debugging 229 * \return true - triangles are convex, false - concave or less than two triangles connected 230 */ 231 bool BoundaryLineSet::CheckConvexityCriterion() const 232 { 233 Info FunctionInfo(__func__); 234 double angle = CalculateConvexity(); 235 if (angle > -MYEPSILON) { 236 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 237 return true; 238 } else { 239 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 240 return false; 241 } 242 } 243 244 245 /** Calculates the angle between two triangles with respect to their normal vector. 246 * We sum the two angles of each height vector with respect to the center of the baseline. 247 * \return angle > 0 then convex, if < 0 then concave 248 */ 249 double BoundaryLineSet::CalculateConvexity() const 250 { 251 Info FunctionInfo(__func__); 252 Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck; 253 // get the two triangles 254 if (triangles.size() != 2) { 255 DoeLog(0) && (eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl); 256 return true; 257 } 258 // check normal vectors 259 // have a normal vector on the base line pointing outwards 260 //Log() << Verbose(0) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl; 261 BaseLineCenter = (1./2.)*((*endpoints[0]->node->node) + (*endpoints[1]->node->node)); 262 BaseLine = (*endpoints[0]->node->node) - (*endpoints[1]->node->node); 263 264 //Log() << Verbose(0) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl; 265 266 BaseLineNormal.Zero(); 267 NormalCheck.Zero(); 268 double sign = -1.; 269 int i = 0; 270 class BoundaryPointSet *node = NULL; 271 for (TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) { 272 //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl; 273 NormalCheck += runner->second->NormalVector; 274 NormalCheck *= sign; 275 sign = -sign; 276 if (runner->second->NormalVector.NormSquared() > MYEPSILON) 277 BaseLineNormal = runner->second->NormalVector; // yes, copy second on top of first 278 else { 279 DoeLog(0) && (eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl); 280 } 281 node = runner->second->GetThirdEndpoint(this); 282 if (node != NULL) { 283 //Log() << Verbose(0) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl; 284 helper[i] = (*node->node->node) - BaseLineCenter; 285 helper[i].MakeNormalTo(BaseLine); // we want to compare the triangle's heights' angles! 286 //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl; 287 i++; 288 } else { 289 DoeLog(1) && (eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl); 290 return true; 291 } 292 } 293 //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl; 294 if (NormalCheck.NormSquared() < MYEPSILON) { 295 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl); 296 return true; 297 } 298 BaseLineNormal.Scale(-1.); 299 double angle = GetAngle(helper[0], helper[1], BaseLineNormal); 300 return (angle - M_PI); 301 } 302 303 /** Checks whether point is any of the two endpoints this line contains. 304 * \param *point point to test 305 * \return true - point is of the line, false - is not 306 */ 307 bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 308 { 309 Info FunctionInfo(__func__); 310 for (int i = 0; i < 2; i++) 311 if (point == endpoints[i]) 312 return true; 313 return false; 314 } 315 ; 316 317 /** Returns other endpoint of the line. 318 * \param *point other endpoint 319 * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise 320 */ 321 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const 322 { 323 Info FunctionInfo(__func__); 324 if (endpoints[0] == point) 325 return endpoints[1]; 326 else if (endpoints[1] == point) 327 return endpoints[0]; 328 else 329 return NULL; 330 } 331 ; 332 333 /** Returns other triangle of the line. 334 * \param *point other endpoint 335 * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise 336 */ 337 class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const 338 { 339 Info FunctionInfo(__func__); 340 if (triangles.size() == 2) { 341 for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner) 342 if (TriangleRunner->second != triangle) 343 return TriangleRunner->second; 344 } 345 return NULL; 346 } 347 ; 348 349 /** output operator for BoundaryLineSet. 350 * \param &ost output stream 351 * \param &a boundary line 352 */ 353 ostream & operator <<(ostream &ost, const BoundaryLineSet &a) 354 { 355 ost << "[" << a.Nr << "|" << a.endpoints[0]->node->getName() << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->getName() << " at " << *a.endpoints[1]->node->node << "]"; 356 return ost; 357 } 358 ; 359 360 // ======================================== Triangles on Boundary ================================= 361 362 /** Constructor for BoundaryTriangleSet. 363 */ 364 BoundaryTriangleSet::BoundaryTriangleSet() : 365 Nr(-1) 366 { 367 Info FunctionInfo(__func__); 368 for (int i = 0; i < 3; i++) { 369 endpoints[i] = NULL; 370 lines[i] = NULL; 371 } 372 } 373 ; 374 375 /** Constructor for BoundaryTriangleSet with three lines. 376 * \param *line[3] lines that make up the triangle 377 * \param number number of triangle 378 */ 379 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) : 380 Nr(number) 381 { 382 Info FunctionInfo(__func__); 383 // set number 384 // set lines 385 for (int i = 0; i < 3; i++) { 386 lines[i] = line[i]; 387 lines[i]->AddTriangle(this); 388 } 389 // get ascending order of endpoints 390 PointMap OrderMap; 391 for (int i = 0; i < 3; i++) { 392 // for all three lines 393 for (int j = 0; j < 2; j++) { // for both endpoints 394 OrderMap.insert(pair<int, class BoundaryPointSet *> (line[i]->endpoints[j]->Nr, line[i]->endpoints[j])); 395 // and we don't care whether insertion fails 396 } 397 } 398 // set endpoints 399 int Counter = 0; 400 DoLog(0) && (Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl); 401 for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) { 402 endpoints[Counter] = runner->second; 403 DoLog(0) && (Log() << Verbose(0) << " " << *endpoints[Counter] << endl); 404 Counter++; 405 } 406 ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!"); 407 }; 408 409 410 /** Destructor of BoundaryTriangleSet. 411 * Removes itself from each of its lines' LineMap and removes them if necessary. 412 * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle() 413 */ 414 BoundaryTriangleSet::~BoundaryTriangleSet() 415 { 416 Info FunctionInfo(__func__); 417 for (int i = 0; i < 3; i++) { 418 if (lines[i] != NULL) { 419 if (lines[i]->triangles.erase(Nr)) { 420 //Log() << Verbose(0) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl; 421 } 422 if (lines[i]->triangles.empty()) { 423 //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl; 424 delete (lines[i]); 425 lines[i] = NULL; 426 } 427 } 428 } 429 //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl; 430 } 431 ; 432 433 /** Calculates the normal vector for this triangle. 434 * Is made unique by comparison with \a OtherVector to point in the other direction. 435 * \param &OtherVector direction vector to make normal vector unique. 436 */ 437 void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector) 438 { 439 Info FunctionInfo(__func__); 440 // get normal vector 441 NormalVector = Plane(*(endpoints[0]->node->node), 442 *(endpoints[1]->node->node), 443 *(endpoints[2]->node->node)).getNormal(); 444 445 // make it always point inward (any offset vector onto plane projected onto normal vector suffices) 446 if (NormalVector.ScalarProduct(OtherVector) > 0.) 447 NormalVector.Scale(-1.); 448 DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl); 449 } 450 ; 451 452 /** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses. 453 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane 454 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not. 455 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line 456 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between 457 * the first two basepoints) or not. 458 * \param *out output stream for debugging 459 * \param *MolCenter offset vector of line 460 * \param *x second endpoint of line, minus \a *MolCenter is directional vector of line 461 * \param *Intersection intersection on plane on return 462 * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle. 463 */ 464 465 bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const 466 { 467 Info FunctionInfo(__func__); 468 Vector CrossPoint; 469 Vector helper; 470 471 try { 472 Line centerLine = makeLineThrough(*MolCenter, *x); 473 *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(centerLine); 474 475 DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl); 476 DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl); 477 DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl); 478 479 if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) { 480 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl); 481 return true; 482 } else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) { 483 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl); 484 return true; 485 } else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) { 486 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl); 487 return true; 488 } 489 // Calculate cross point between one baseline and the line from the third endpoint to intersection 490 int i = 0; 491 do { 492 Line line1 = makeLineThrough(*(endpoints[i%3]->node->node),*(endpoints[(i+1)%3]->node->node)); 493 Line line2 = makeLineThrough(*(endpoints[(i+2)%3]->node->node),*Intersection); 494 CrossPoint = line1.getIntersection(line2); 495 helper = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node); 496 CrossPoint -= (*endpoints[i%3]->node->node); // cross point was returned as absolute vector 497 const double s = CrossPoint.ScalarProduct(helper)/helper.NormSquared(); 498 DoLog(1) && (Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl); 499 if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) { 500 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl); 501 return false; 502 } 503 i++; 504 } while (i < 3); 505 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl); 506 return true; 507 } 508 catch (MathException &excp) { 509 Log() << Verbose(1) << excp; 510 DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl); 511 return false; 512 } 513 } 514 ; 515 516 /** Finds the point on the triangle to the point \a *x. 517 * We call Vector::GetIntersectionWithPlane() with \a * and the center of the triangle to receive an intersection point. 518 * Then we check the in-plane part (the part projected down onto plane). We check whether it crosses one of the 519 * boundary lines. If it does, we return this intersection as closest point, otherwise the projected point down. 520 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not. 521 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line 522 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between 523 * the first two basepoints) or not. 524 * \param *x point 525 * \param *ClosestPoint desired closest point inside triangle to \a *x, is absolute vector 526 * \return Distance squared between \a *x and closest point inside triangle 527 */ 528 double BoundaryTriangleSet::GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const 529 { 530 Info FunctionInfo(__func__); 531 Vector Direction; 532 533 // 1. get intersection with plane 534 DoLog(1) && (Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl); 535 GetCenter(&Direction); 536 try { 537 Line l = makeLineThrough(*x, Direction); 538 *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(l); 539 } 540 catch (MathException &excp) { 541 (*ClosestPoint) = (*x); 542 } 543 544 // 2. Calculate in plane part of line (x, intersection) 545 Vector InPlane = (*x) - (*ClosestPoint); // points from plane intersection to straight-down point 546 InPlane.ProjectOntoPlane(NormalVector); 547 InPlane += *ClosestPoint; 548 549 DoLog(2) && (Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl); 550 DoLog(2) && (Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl); 551 DoLog(2) && (Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl); 552 553 // Calculate cross point between one baseline and the desired point such that distance is shortest 554 double ShortestDistance = -1.; 555 bool InsideFlag = false; 556 Vector CrossDirection[3]; 557 Vector CrossPoint[3]; 558 Vector helper; 559 for (int i = 0; i < 3; i++) { 560 // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point 561 Direction = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node); 562 // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal); 563 Line l = makeLineThrough(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node)); 564 CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l); 565 CrossDirection[i] = CrossPoint[i] - InPlane; 566 CrossPoint[i] -= (*endpoints[i%3]->node->node); // cross point was returned as absolute vector 567 const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared(); 568 DoLog(2) && (Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl); 569 if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) { 570 CrossPoint[i] += (*endpoints[i%3]->node->node); // make cross point absolute again 571 DoLog(2) && (Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i % 3]->node->node << " and " << *endpoints[(i + 1) % 3]->node->node << "." << endl); 572 const double distance = CrossPoint[i].DistanceSquared(*x); 573 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 574 ShortestDistance = distance; 575 (*ClosestPoint) = CrossPoint[i]; 576 } 577 } else 578 CrossPoint[i].Zero(); 579 } 580 InsideFlag = true; 581 for (int i = 0; i < 3; i++) { 582 const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]); 583 const double othersign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 2) % 3]); 584 585 if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign 586 InsideFlag = false; 587 } 588 if (InsideFlag) { 589 (*ClosestPoint) = InPlane; 590 ShortestDistance = InPlane.DistanceSquared(*x); 591 } else { // also check endnodes 592 for (int i = 0; i < 3; i++) { 593 const double distance = x->DistanceSquared(*endpoints[i]->node->node); 594 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 595 ShortestDistance = distance; 596 (*ClosestPoint) = (*endpoints[i]->node->node); 597 } 598 } 599 } 600 DoLog(1) && (Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl); 601 return ShortestDistance; 602 } 603 ; 604 605 /** Checks whether lines is any of the three boundary lines this triangle contains. 606 * \param *line line to test 607 * \return true - line is of the triangle, false - is not 608 */ 609 bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const 610 { 611 Info FunctionInfo(__func__); 612 for (int i = 0; i < 3; i++) 613 if (line == lines[i]) 614 return true; 615 return false; 616 } 617 ; 618 619 /** Checks whether point is any of the three endpoints this triangle contains. 620 * \param *point point to test 621 * \return true - point is of the triangle, false - is not 622 */ 623 bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 624 { 625 Info FunctionInfo(__func__); 626 for (int i = 0; i < 3; i++) 627 if (point == endpoints[i]) 628 return true; 629 return false; 630 } 631 ; 632 633 /** Checks whether point is any of the three endpoints this triangle contains. 634 * \param *point TesselPoint to test 635 * \return true - point is of the triangle, false - is not 636 */ 637 bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const 638 { 639 Info FunctionInfo(__func__); 640 for (int i = 0; i < 3; i++) 641 if (point == endpoints[i]->node) 642 return true; 643 return false; 644 } 645 ; 646 647 /** Checks whether three given \a *Points coincide with triangle's endpoints. 648 * \param *Points[3] pointer to BoundaryPointSet 649 * \return true - is the very triangle, false - is not 650 */ 651 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const 652 { 653 Info FunctionInfo(__func__); 654 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking " << Points[0] << "," << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl); 655 return (((endpoints[0] == Points[0]) || (endpoints[0] == Points[1]) || (endpoints[0] == Points[2])) && ((endpoints[1] == Points[0]) || (endpoints[1] == Points[1]) || (endpoints[1] == Points[2])) && ((endpoints[2] == Points[0]) || (endpoints[2] == Points[1]) || (endpoints[2] == Points[2]) 656 657 )); 658 } 659 ; 660 661 /** Checks whether three given \a *Points coincide with triangle's endpoints. 662 * \param *Points[3] pointer to BoundaryPointSet 663 * \return true - is the very triangle, false - is not 664 */ 665 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const 666 { 667 Info FunctionInfo(__func__); 668 return (((endpoints[0] == T->endpoints[0]) || (endpoints[0] == T->endpoints[1]) || (endpoints[0] == T->endpoints[2])) && ((endpoints[1] == T->endpoints[0]) || (endpoints[1] == T->endpoints[1]) || (endpoints[1] == T->endpoints[2])) && ((endpoints[2] == T->endpoints[0]) || (endpoints[2] == T->endpoints[1]) || (endpoints[2] == T->endpoints[2]) 669 670 )); 671 } 672 ; 673 674 /** Returns the endpoint which is not contained in the given \a *line. 675 * \param *line baseline defining two endpoints 676 * \return pointer third endpoint or NULL if line does not belong to triangle. 677 */ 678 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const 679 { 680 Info FunctionInfo(__func__); 681 // sanity check 682 if (!ContainsBoundaryLine(line)) 683 return NULL; 684 for (int i = 0; i < 3; i++) 685 if (!line->ContainsBoundaryPoint(endpoints[i])) 686 return endpoints[i]; 687 // actually, that' impossible :) 688 return NULL; 689 } 690 ; 691 692 /** Returns the baseline which does not contain the given boundary point \a *point. 693 * \param *point endpoint which is neither endpoint of the desired line 694 * \return pointer to desired third baseline 695 */ 696 class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const 697 { 698 Info FunctionInfo(__func__); 699 // sanity check 700 if (!ContainsBoundaryPoint(point)) 701 return NULL; 702 for (int i = 0; i < 3; i++) 703 if (!lines[i]->ContainsBoundaryPoint(point)) 704 return lines[i]; 705 // actually, that' impossible :) 706 return NULL; 707 } 708 ; 709 710 /** Calculates the center point of the triangle. 711 * Is third of the sum of all endpoints. 712 * \param *center central point on return. 713 */ 714 void BoundaryTriangleSet::GetCenter(Vector * const center) const 715 { 716 Info FunctionInfo(__func__); 717 center->Zero(); 718 for (int i = 0; i < 3; i++) 719 (*center) += (*endpoints[i]->node->node); 720 center->Scale(1. / 3.); 721 DoLog(1) && (Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl); 722 } 723 724 /** 725 * gets the Plane defined by the three triangle Basepoints 726 */ 727 Plane BoundaryTriangleSet::getPlane() const{ 728 ASSERT(endpoints[0] && endpoints[1] && endpoints[2], "Triangle not fully defined"); 729 730 return Plane(*endpoints[0]->node->node, 731 *endpoints[1]->node->node, 732 *endpoints[2]->node->node); 733 } 734 735 Vector BoundaryTriangleSet::getEndpoint(int i) const{ 736 ASSERT(i>=0 && i<3,"Index of Endpoint out of Range"); 737 738 return *endpoints[i]->node->node; 739 } 740 741 string BoundaryTriangleSet::getEndpointName(int i) const{ 742 ASSERT(i>=0 && i<3,"Index of Endpoint out of Range"); 743 744 return endpoints[i]->node->getName(); 745 } 746 747 /** output operator for BoundaryTriangleSet. 748 * \param &ost output stream 749 * \param &a boundary triangle 750 */ 751 ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a) 752 { 753 ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]"; 754 // ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," 755 // << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]"; 756 return ost; 757 } 758 ; 759 760 // ======================================== Polygons on Boundary ================================= 761 762 /** Constructor for BoundaryPolygonSet. 763 */ 764 BoundaryPolygonSet::BoundaryPolygonSet() : 765 Nr(-1) 766 { 767 Info FunctionInfo(__func__); 768 } 769 ; 770 771 /** Destructor of BoundaryPolygonSet. 772 * Just clears endpoints. 773 * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle() 774 */ 775 BoundaryPolygonSet::~BoundaryPolygonSet() 776 { 777 Info FunctionInfo(__func__); 778 endpoints.clear(); 779 DoLog(1) && (Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl); 780 } 781 ; 782 783 /** Calculates the normal vector for this triangle. 784 * Is made unique by comparison with \a OtherVector to point in the other direction. 785 * \param &OtherVector direction vector to make normal vector unique. 786 * \return allocated vector in normal direction 787 */ 788 Vector * BoundaryPolygonSet::GetNormalVector(const Vector &OtherVector) const 789 { 790 Info FunctionInfo(__func__); 791 // get normal vector 792 Vector TemporaryNormal; 793 Vector *TotalNormal = new Vector; 794 PointSet::const_iterator Runner[3]; 795 for (int i = 0; i < 3; i++) { 796 Runner[i] = endpoints.begin(); 797 for (int j = 0; j < i; j++) { // go as much further 798 Runner[i]++; 799 if (Runner[i] == endpoints.end()) { 800 DoeLog(0) && (eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl); 801 performCriticalExit(); 802 } 803 } 804 } 805 TotalNormal->Zero(); 806 int counter = 0; 807 for (; Runner[2] != endpoints.end();) { 808 TemporaryNormal = Plane(*((*Runner[0])->node->node), 809 *((*Runner[1])->node->node), 810 *((*Runner[2])->node->node)).getNormal(); 811 for (int i = 0; i < 3; i++) // increase each of them 812 Runner[i]++; 813 (*TotalNormal) += TemporaryNormal; 814 } 815 TotalNormal->Scale(1. / (double) counter); 816 817 // make it always point inward (any offset vector onto plane projected onto normal vector suffices) 818 if (TotalNormal->ScalarProduct(OtherVector) > 0.) 819 TotalNormal->Scale(-1.); 820 DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl); 821 822 return TotalNormal; 823 } 824 ; 825 826 /** Calculates the center point of the triangle. 827 * Is third of the sum of all endpoints. 828 * \param *center central point on return. 829 */ 830 void BoundaryPolygonSet::GetCenter(Vector * const center) const 831 { 832 Info FunctionInfo(__func__); 833 center->Zero(); 834 int counter = 0; 835 for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 836 (*center) += (*(*Runner)->node->node); 837 counter++; 838 } 839 center->Scale(1. / (double) counter); 840 DoLog(1) && (Log() << Verbose(1) << "Center is at " << *center << "." << endl); 841 } 842 843 /** Checks whether the polygons contains all three endpoints of the triangle. 844 * \param *triangle triangle to test 845 * \return true - triangle is contained polygon, false - is not 846 */ 847 bool BoundaryPolygonSet::ContainsBoundaryTriangle(const BoundaryTriangleSet * const triangle) const 848 { 849 Info FunctionInfo(__func__); 850 return ContainsPresentTupel(triangle->endpoints, 3); 851 } 852 ; 853 854 /** Checks whether the polygons contains both endpoints of the line. 855 * \param *line line to test 856 * \return true - line is of the triangle, false - is not 857 */ 858 bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const 859 { 860 Info FunctionInfo(__func__); 861 return ContainsPresentTupel(line->endpoints, 2); 862 } 863 ; 864 865 /** Checks whether point is any of the three endpoints this triangle contains. 866 * \param *point point to test 867 * \return true - point is of the triangle, false - is not 868 */ 869 bool BoundaryPolygonSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 870 { 871 Info FunctionInfo(__func__); 872 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 873 DoLog(0) && (Log() << Verbose(0) << "Checking against " << **Runner << endl); 874 if (point == (*Runner)) { 875 DoLog(0) && (Log() << Verbose(0) << " Contained." << endl); 876 return true; 877 } 878 } 879 DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl); 880 return false; 881 } 882 ; 883 884 /** Checks whether point is any of the three endpoints this triangle contains. 885 * \param *point TesselPoint to test 886 * \return true - point is of the triangle, false - is not 887 */ 888 bool BoundaryPolygonSet::ContainsBoundaryPoint(const TesselPoint * const point) const 889 { 890 Info FunctionInfo(__func__); 891 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) 892 if (point == (*Runner)->node) { 893 DoLog(0) && (Log() << Verbose(0) << " Contained." << endl); 894 return true; 895 } 896 DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl); 897 return false; 898 } 899 ; 900 901 /** Checks whether given array of \a *Points coincide with polygons's endpoints. 902 * \param **Points pointer to an array of BoundaryPointSet 903 * \param dim dimension of array 904 * \return true - set of points is contained in polygon, false - is not 905 */ 906 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const 907 { 908 Info FunctionInfo(__func__); 909 int counter = 0; 910 DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl); 911 for (int i = 0; i < dim; i++) { 912 DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl); 913 if (ContainsBoundaryPoint(Points[i])) { 914 counter++; 915 } 916 } 917 918 if (counter == dim) 919 return true; 920 else 921 return false; 922 } 923 ; 924 925 /** Checks whether given PointList coincide with polygons's endpoints. 926 * \param &endpoints PointList 927 * \return true - set of points is contained in polygon, false - is not 928 */ 929 bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const 930 { 931 Info FunctionInfo(__func__); 932 size_t counter = 0; 933 DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl); 934 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 935 DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << **Runner << endl); 936 if (ContainsBoundaryPoint(*Runner)) 937 counter++; 938 } 939 940 if (counter == endpoints.size()) 941 return true; 942 else 943 return false; 944 } 945 ; 946 947 /** Checks whether given set of \a *Points coincide with polygons's endpoints. 948 * \param *P pointer to BoundaryPolygonSet 949 * \return true - is the very triangle, false - is not 950 */ 951 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const 952 { 953 return ContainsPresentTupel((const PointSet) P->endpoints); 954 } 955 ; 956 957 /** Gathers all the endpoints' triangles in a unique set. 958 * \return set of all triangles 959 */ 960 TriangleSet * BoundaryPolygonSet::GetAllContainedTrianglesFromEndpoints() const 961 { 962 Info FunctionInfo(__func__); 963 pair<TriangleSet::iterator, bool> Tester; 964 TriangleSet *triangles = new TriangleSet; 965 966 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) 967 for (LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++) 968 for (TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) { 969 //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl; 970 if (ContainsBoundaryTriangle(Sprinter->second)) { 971 Tester = triangles->insert(Sprinter->second); 972 if (Tester.second) 973 DoLog(0) && (Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl); 974 } 975 } 976 977 DoLog(1) && (Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl); 978 return triangles; 979 } 980 ; 981 982 /** Fills the endpoints of this polygon from the triangles attached to \a *line. 983 * \param *line lines with triangles attached 984 * \return true - polygon contains endpoints, false - line was NULL 985 */ 986 bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line) 987 { 988 Info FunctionInfo(__func__); 989 pair<PointSet::iterator, bool> Tester; 990 if (line == NULL) 991 return false; 992 DoLog(1) && (Log() << Verbose(1) << "Filling polygon from line " << *line << endl); 993 for (TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) { 994 for (int i = 0; i < 3; i++) { 995 Tester = endpoints.insert((Runner->second)->endpoints[i]); 996 if (Tester.second) 997 DoLog(1) && (Log() << Verbose(1) << " Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl); 998 } 999 } 1000 1001 return true; 1002 } 1003 ; 1004 1005 /** output operator for BoundaryPolygonSet. 1006 * \param &ost output stream 1007 * \param &a boundary polygon 1008 */ 1009 ostream &operator <<(ostream &ost, const BoundaryPolygonSet &a) 1010 { 1011 ost << "[" << a.Nr << "|"; 1012 for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) { 1013 ost << (*Runner)->node->getName(); 1014 Runner++; 1015 if (Runner != a.endpoints.end()) 1016 ost << ","; 1017 } 1018 ost << "]"; 1019 return ost; 1020 } 1021 ; 1022 1023 // =========================================================== class TESSELPOINT =========================================== 1024 1025 /** Constructor of class TesselPoint. 1026 */ 1027 TesselPoint::TesselPoint() 1028 { 1029 //Info FunctionInfo(__func__); 1030 node = NULL; 1031 nr = -1; 1032 } 1033 ; 1034 1035 /** Destructor for class TesselPoint. 1036 */ 1037 TesselPoint::~TesselPoint() 1038 { 1039 //Info FunctionInfo(__func__); 1040 } 1041 ; 1042 1043 /** Prints LCNode to screen. 1044 */ 1045 ostream & operator <<(ostream &ost, const TesselPoint &a) 1046 { 1047 ost << "[" << a.getName() << "|" << *a.node << "]"; 1048 return ost; 1049 } 1050 ; 1051 1052 /** Prints LCNode to screen. 1053 */ 1054 ostream & TesselPoint::operator <<(ostream &ost) 1055 { 1056 Info FunctionInfo(__func__); 1057 ost << "[" << (nr) << "|" << this << "]"; 1058 return ost; 1059 } 1060 ; 1061 1062 // =========================================================== class POINTCLOUD ============================================ 1063 1064 /** Constructor of class PointCloud. 1065 */ 1066 PointCloud::PointCloud() 1067 { 1068 //Info FunctionInfo(__func__); 1069 } 1070 ; 1071 1072 /** Destructor for class PointCloud. 1073 */ 1074 PointCloud::~PointCloud() 1075 { 1076 //Info FunctionInfo(__func__); 1077 } 1078 ; 1079 1080 // ============================ CandidateForTesselation ============================= 1081 1082 /** Constructor of class CandidateForTesselation. 1083 */ 1084 CandidateForTesselation::CandidateForTesselation(BoundaryLineSet* line) : 1085 BaseLine(line), ThirdPoint(NULL), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI) 1086 { 1087 Info FunctionInfo(__func__); 1088 } 1089 ; 1090 1091 /** Constructor of class CandidateForTesselation. 1092 */ 1093 CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) : 1094 BaseLine(line), ThirdPoint(point), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI) 1095 { 1096 Info FunctionInfo(__func__); 1097 OptCenter = OptCandidateCenter; 1098 OtherOptCenter = OtherOptCandidateCenter; 1099 }; 1100 1101 1102 /** Destructor for class CandidateForTesselation. 1103 */ 1104 CandidateForTesselation::~CandidateForTesselation() 1105 { 1106 } 1107 ; 1108 1109 /** Checks validity of a given sphere of a candidate line. 1110 * Sphere must touch all candidates and the baseline endpoints and there must be no other atoms inside. 1111 * \param RADIUS radius of sphere 1112 * \param *LC LinkedCell structure with other atoms 1113 * \return true - sphere is valid, false - sphere contains other points 1114 */ 1115 bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell *LC) const 1116 { 1117 Info FunctionInfo(__func__); 1118 1119 const double radiusSquared = RADIUS * RADIUS; 1120 list<const Vector *> VectorList; 1121 VectorList.push_back(&OptCenter); 1122 //VectorList.push_back(&OtherOptCenter); // don't check the other (wrong) center 1123 1124 if (!pointlist.empty()) 1125 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl); 1126 else 1127 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl); 1128 // check baseline for OptCenter and OtherOptCenter being on sphere's surface 1129 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) { 1130 for (int i = 0; i < 2; i++) { 1131 const double distance = fabs((*VRunner)->DistanceSquared(*BaseLine->endpoints[i]->node->node) - radiusSquared); 1132 if (distance > HULLEPSILON) { 1133 DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << *BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl); 1134 return false; 1135 } 1136 } 1137 } 1138 1139 // check Candidates for OptCenter and OtherOptCenter being on sphere's surface 1140 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) { 1141 const TesselPoint *Walker = *Runner; 1142 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) { 1143 const double distance = fabs((*VRunner)->DistanceSquared(*Walker->node) - radiusSquared); 1144 if (distance > HULLEPSILON) { 1145 DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << *Walker << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl); 1146 return false; 1147 } else { 1148 DoLog(1) && (Log() << Verbose(1) << "Candidate " << *Walker << " is inside by " << distance << "." << endl); 1149 } 1150 } 1151 } 1152 1153 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl); 1154 bool flag = true; 1155 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) { 1156 // get all points inside the sphere 1157 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner)); 1158 1159 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl); 1160 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1161 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl); 1162 1163 // remove baseline's endpoints and candidates 1164 for (int i = 0; i < 2; i++) { 1165 DoLog(1) && (Log() << Verbose(1) << "INFO: removing baseline tesselpoint " << *BaseLine->endpoints[i]->node << "." << endl); 1166 ListofPoints->remove(BaseLine->endpoints[i]->node); 1167 } 1168 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) { 1169 DoLog(1) && (Log() << Verbose(1) << "INFO: removing candidate tesselpoint " << *(*Runner) << "." << endl); 1170 ListofPoints->remove(*Runner); 1171 } 1172 if (!ListofPoints->empty()) { 1173 DoeLog(1) && (eLog() << Verbose(1) << "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere." << endl); 1174 flag = false; 1175 DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl); 1176 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1177 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl); 1178 1179 // check with animate_sphere.tcl VMD script 1180 if (ThirdPoint != NULL) { 1181 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl); 1182 } else { 1183 DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl); 1184 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl); 1185 } 1186 } 1187 delete (ListofPoints); 1188 1189 } 1190 return flag; 1191 } 1192 ; 1193 1194 /** output operator for CandidateForTesselation. 1195 * \param &ost output stream 1196 * \param &a boundary line 1197 */ 1198 ostream & operator <<(ostream &ost, const CandidateForTesselation &a) 1199 { 1200 ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->getName() << "," << a.BaseLine->endpoints[1]->node->getName() << "] with "; 1201 if (a.pointlist.empty()) 1202 ost << "no candidate."; 1203 else { 1204 ost << "candidate"; 1205 if (a.pointlist.size() != 1) 1206 ost << "s "; 1207 else 1208 ost << " "; 1209 for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++) 1210 ost << *(*Runner) << " "; 1211 ost << " at angle " << (a.ShortestAngle) << "."; 1212 } 1213 1214 return ost; 1215 } 1216 ; 1217 1218 // =========================================================== class TESSELATION =========================================== 37 const char *TecplotSuffix=".dat"; 38 const char *Raster3DSuffix=".r3d"; 39 const char *VRMLSUffix=".wrl"; 40 41 const double ParallelEpsilon=1e-3; 42 const double Tesselation::HULLEPSILON = 1e-9; 1219 43 1220 44 /** Constructor of class Tesselation. 1221 45 */ 1222 46 Tesselation::Tesselation() : 1223 PointsOnBoundaryCount(0), LinesOnBoundaryCount(0), TrianglesOnBoundaryCount(0), LastTriangle(NULL), TriangleFilesWritten(0), InternalPointer(PointsOnBoundary.begin()) 47 PointsOnBoundaryCount(0), 48 LinesOnBoundaryCount(0), 49 TrianglesOnBoundaryCount(0), 50 LastTriangle(NULL), 51 TriangleFilesWritten(0), 52 InternalPointer(PointsOnBoundary.begin()) 1224 53 { 1225 54 Info FunctionInfo(__func__); … … 1254 83 int num = 0; 1255 84 for (GoToFirst(); (!IsEnd()); GoToNext()) { 1256 (*Center) += ( *GetPoint()->node);85 (*Center) += (GetPoint()->getPosition()); 1257 86 num++; 1258 87 } … … 1337 166 C++; 1338 167 for (; C != PointsOnBoundary.end(); C++) { 1339 tmp = A->second->node-> node->DistanceSquared(*B->second->node->node);168 tmp = A->second->node->DistanceSquared(B->second->node->getPosition()); 1340 169 distance = tmp * tmp; 1341 tmp = A->second->node-> node->DistanceSquared(*C->second->node->node);170 tmp = A->second->node->DistanceSquared(C->second->node->getPosition()); 1342 171 distance += tmp * tmp; 1343 tmp = B->second->node-> node->DistanceSquared(*C->second->node->node);172 tmp = B->second->node->DistanceSquared(C->second->node->getPosition()); 1344 173 distance += tmp * tmp; 1345 174 DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C))); … … 1360 189 // 2. next, we have to check whether all points reside on only one side of the triangle 1361 190 // 3. construct plane vector 1362 PlaneVector = Plane( *A->second->node->node,1363 *baseline->second.first->second->node->node,1364 *baseline->second.second->second->node->node).getNormal();191 PlaneVector = Plane(A->second->node->getPosition(), 192 baseline->second.first->second->node->getPosition(), 193 baseline->second.second->second->node->getPosition()).getNormal(); 1365 194 DoLog(2) && (Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl); 1366 195 // 4. loop over all points … … 1372 201 continue; 1373 202 // 4a. project onto plane vector 1374 TrialVector = (*checker->second->node->node); 1375 TrialVector.SubtractVector(*A->second->node->node); 203 TrialVector = (checker->second->node->getPosition() - A->second->node->getPosition()); 1376 204 distance = TrialVector.ScalarProduct(PlaneVector); 1377 205 if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok … … 1389 217 } 1390 218 // 4d. Check whether the point is inside the triangle (check distance to each node 1391 tmp = checker->second->node-> node->DistanceSquared(*A->second->node->node);219 tmp = checker->second->node->DistanceSquared(A->second->node->getPosition()); 1392 220 int innerpoint = 0; 1393 if ((tmp < A->second->node-> node->DistanceSquared(*baseline->second.first->second->node->node)) && (tmp < A->second->node->node->DistanceSquared(*baseline->second.second->second->node->node)))221 if ((tmp < A->second->node->DistanceSquared(baseline->second.first->second->node->getPosition())) && (tmp < A->second->node->DistanceSquared(baseline->second.second->second->node->getPosition()))) 1394 222 innerpoint++; 1395 tmp = checker->second->node-> node->DistanceSquared(*baseline->second.first->second->node->node);1396 if ((tmp < baseline->second.first->second->node-> node->DistanceSquared(*A->second->node->node)) && (tmp < baseline->second.first->second->node->node->DistanceSquared(*baseline->second.second->second->node->node)))223 tmp = checker->second->node->DistanceSquared(baseline->second.first->second->node->getPosition()); 224 if ((tmp < baseline->second.first->second->node->DistanceSquared(A->second->node->getPosition())) && (tmp < baseline->second.first->second->node->DistanceSquared(baseline->second.second->second->node->getPosition()))) 1397 225 innerpoint++; 1398 tmp = checker->second->node-> node->DistanceSquared(*baseline->second.second->second->node->node);1399 if ((tmp < baseline->second.second->second->node-> node->DistanceSquared(*baseline->second.first->second->node->node)) && (tmp < baseline->second.second->second->node->node->DistanceSquared(*A->second->node->node)))226 tmp = checker->second->node->DistanceSquared(baseline->second.second->second->node->getPosition()); 227 if ((tmp < baseline->second.second->second->node->DistanceSquared(baseline->second.first->second->node->getPosition())) && (tmp < baseline->second.second->second->node->DistanceSquared(A->second->node->getPosition()))) 1400 228 innerpoint++; 1401 229 // 4e. If so, break 4. loop and continue with next candidate in 1. loop … … 1478 306 // prepare some auxiliary vectors 1479 307 Vector BaseLineCenter, BaseLine; 1480 BaseLineCenter = 0.5 * (( *baseline->second->endpoints[0]->node->node) +1481 ( *baseline->second->endpoints[1]->node->node));1482 BaseLine = ( *baseline->second->endpoints[0]->node->node) - (*baseline->second->endpoints[1]->node->node);308 BaseLineCenter = 0.5 * ((baseline->second->endpoints[0]->node->getPosition()) + 309 (baseline->second->endpoints[1]->node->getPosition())); 310 BaseLine = (baseline->second->endpoints[0]->node->getPosition()) - (baseline->second->endpoints[1]->node->getPosition()); 1483 311 1484 312 // offset to center of triangle … … 1498 326 // project center vector onto triangle plane (points from intersection plane-NormalVector to plane-CenterVector intersection) 1499 327 PropagationVector = Plane(BaseLine, NormalVector,0).getNormal(); 1500 TempVector = CenterVector - ( *baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center!328 TempVector = CenterVector - (baseline->second->endpoints[0]->node->getPosition()); // TempVector is vector on triangle plane pointing from one baseline egde towards center! 1501 329 //Log() << Verbose(0) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl; 1502 330 if (PropagationVector.ScalarProduct(TempVector) > 0) // make sure normal propagation vector points outward from baseline … … 1511 339 1512 340 // first check direction, so that triangles don't intersect 1513 VirtualNormalVector = ( *target->second->node->node) - BaseLineCenter;341 VirtualNormalVector = (target->second->node->getPosition()) - BaseLineCenter; 1514 342 VirtualNormalVector.ProjectOntoPlane(NormalVector); 1515 343 TempAngle = VirtualNormalVector.Angle(PropagationVector); … … 1540 368 1541 369 // check for linear dependence 1542 TempVector = ( *baseline->second->endpoints[0]->node->node) - (*target->second->node->node);1543 helper = ( *baseline->second->endpoints[1]->node->node) - (*target->second->node->node);370 TempVector = (baseline->second->endpoints[0]->node->getPosition()) - (target->second->node->getPosition()); 371 helper = (baseline->second->endpoints[1]->node->getPosition()) - (target->second->node->getPosition()); 1544 372 helper.ProjectOntoPlane(TempVector); 1545 373 if (fabs(helper.NormSquared()) < MYEPSILON) { … … 1550 378 // in case NOT both were found, create virtually this triangle, get its normal vector, calculate angle 1551 379 flag = true; 1552 VirtualNormalVector = Plane( *(baseline->second->endpoints[0]->node->node),1553 *(baseline->second->endpoints[1]->node->node),1554 *(target->second->node->node)).getNormal();1555 TempVector = (1./3.) * (( *baseline->second->endpoints[0]->node->node) +1556 ( *baseline->second->endpoints[1]->node->node) +1557 ( *target->second->node->node));380 VirtualNormalVector = Plane((baseline->second->endpoints[0]->node->getPosition()), 381 (baseline->second->endpoints[1]->node->getPosition()), 382 (target->second->node->getPosition())).getNormal(); 383 TempVector = (1./3.) * ((baseline->second->endpoints[0]->node->getPosition()) + 384 (baseline->second->endpoints[1]->node->getPosition()) + 385 (target->second->node->getPosition())); 1558 386 TempVector -= (*Center); 1559 387 // make it always point outward … … 1569 397 } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle) 1570 398 // hence, check the angles to some normal direction from our base line but in this common plane of both targets... 1571 helper = ( *target->second->node->node) - BaseLineCenter;399 helper = (target->second->node->getPosition()) - BaseLineCenter; 1572 400 helper.ProjectOntoPlane(BaseLine); 1573 401 // ...the one with the smaller angle is the better candidate 1574 TempVector = ( *target->second->node->node) - BaseLineCenter;402 TempVector = (target->second->node->getPosition()) - BaseLineCenter; 1575 403 TempVector.ProjectOntoPlane(VirtualNormalVector); 1576 404 TempAngle = TempVector.Angle(helper); 1577 TempVector = ( *winner->second->node->node) - BaseLineCenter;405 TempVector = (winner->second->node->getPosition()) - BaseLineCenter; 1578 406 TempVector.ProjectOntoPlane(VirtualNormalVector); 1579 407 if (TempAngle < TempVector.Angle(helper)) { … … 1614 442 BLS[2] = LineChecker[1]->second; 1615 443 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 1616 BTS->GetCenter( &helper);444 BTS->GetCenter(helper); 1617 445 helper -= (*Center); 1618 446 helper *= -1; … … 1662 490 DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl); 1663 491 // get the next triangle 1664 triangles = FindClosestTrianglesToVector(Walker-> node, BoundaryPoints);492 triangles = FindClosestTrianglesToVector(Walker->getPosition(), BoundaryPoints); 1665 493 if (triangles != NULL) 1666 494 BTS = triangles->front(); … … 1676 504 DoLog(0) && (Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl); 1677 505 // get the intersection point 1678 if (BTS->GetIntersectionInsideTriangle( Center, Walker->node, &Intersection)) {506 if (BTS->GetIntersectionInsideTriangle(*Center, Walker->getPosition(), Intersection)) { 1679 507 DoLog(0) && (Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl); 1680 508 // we have the intersection, check whether in- or outside of boundary 1681 if ((Center->DistanceSquared( *Walker->node) - Center->DistanceSquared(Intersection)) < -MYEPSILON) {509 if ((Center->DistanceSquared(Walker->getPosition()) - Center->DistanceSquared(Intersection)) < -MYEPSILON) { 1682 510 // inside, next! 1683 511 DoLog(0) && (Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl); … … 2086 914 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << CandidateLine.OtherOptCenter << ":" << endl); 2087 915 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 2088 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)-> node->distance(CandidateLine.OtherOptCenter) << "." << endl);916 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->distance(CandidateLine.OtherOptCenter) << "." << endl); 2089 917 2090 918 // remove triangles's endpoints … … 2102 930 DoLog(1) && (Log() << Verbose(1) << "External atoms inside of sphere at " << CandidateLine.OtherOptCenter << ":" << endl); 2103 931 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 2104 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)-> node->distance(CandidateLine.OtherOptCenter) << "." << endl);932 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->distance(CandidateLine.OtherOptCenter) << "." << endl); 2105 933 } 2106 934 delete (ListofPoints); … … 2257 1085 if (List != NULL) { 2258 1086 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2259 if ((*Runner)-> node->at(map[0]) > maxCoordinate[map[0]]) {2260 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << *(*Runner)->node<< "." << endl);2261 maxCoordinate[map[0]] = (*Runner)-> node->at(map[0]);1087 if ((*Runner)->at(map[0]) > maxCoordinate[map[0]]) { 1088 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << (*Runner)->getPosition() << "." << endl); 1089 maxCoordinate[map[0]] = (*Runner)->at(map[0]); 2262 1090 MaxPoint[map[0]] = (*Runner); 2263 1091 } … … 2295 1123 2296 1124 // construct center of circle 2297 CircleCenter = 0.5 * (( *BaseLine->endpoints[0]->node->node) + (*BaseLine->endpoints[1]->node->node));1125 CircleCenter = 0.5 * ((BaseLine->endpoints[0]->node->getPosition()) + (BaseLine->endpoints[1]->node->getPosition())); 2298 1126 2299 1127 // construct normal vector of circle 2300 CirclePlaneNormal = ( *BaseLine->endpoints[0]->node->node) - (*BaseLine->endpoints[1]->node->node);1128 CirclePlaneNormal = (BaseLine->endpoints[0]->node->getPosition()) - (BaseLine->endpoints[1]->node->getPosition()); 2301 1129 2302 1130 double radius = CirclePlaneNormal.NormSquared(); … … 2515 1343 2516 1344 // construct center of circle 2517 CircleCenter = 0.5 * (( *CandidateLine.BaseLine->endpoints[0]->node->node) +2518 ( *CandidateLine.BaseLine->endpoints[1]->node->node));1345 CircleCenter = 0.5 * ((CandidateLine.BaseLine->endpoints[0]->node->getPosition()) + 1346 (CandidateLine.BaseLine->endpoints[1]->node->getPosition())); 2519 1347 2520 1348 // construct normal vector of circle 2521 CirclePlaneNormal = ( *CandidateLine.BaseLine->endpoints[0]->node->node) -2522 ( *CandidateLine.BaseLine->endpoints[1]->node->node);1349 CirclePlaneNormal = (CandidateLine.BaseLine->endpoints[0]->node->getPosition()) - 1350 (CandidateLine.BaseLine->endpoints[1]->node->getPosition()); 2523 1351 2524 1352 // calculate squared radius of circle … … 2536 1364 // construct SearchDirection and an "outward pointer" 2537 1365 SearchDirection = Plane(RelativeSphereCenter, CirclePlaneNormal,0).getNormal(); 2538 helper = CircleCenter - ( *ThirdPoint->node->node);1366 helper = CircleCenter - (ThirdPoint->node->getPosition()); 2539 1367 if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards! 2540 1368 SearchDirection.Scale(-1.); … … 2611 1439 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) 2612 1440 SetOfNeighbours.insert(*Runner); 2613 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node-> node);1441 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->getPosition()); 2614 1442 2615 1443 DoLog(0) && (Log() << Verbose(0) << "List of Candidates for Turning Point " << *TurningPoint << ":" << endl); … … 2712 1540 2713 1541 // create normal vector 2714 BTS->GetCenter( &Center);1542 BTS->GetCenter(Center); 2715 1543 Center -= CandidateLine.OptCenter; 2716 1544 BTS->SphereCenter = CandidateLine.OptCenter; … … 2791 1619 2792 1620 // create normal vector 2793 BTS->GetCenter( &Center);1621 BTS->GetCenter(Center); 2794 1622 Center.SubtractVector(*OptCenter); 2795 1623 BTS->SphereCenter = *OptCenter; … … 2837 1665 Vector DistanceToIntersection[2], BaseLine; 2838 1666 double distance[2]; 2839 BaseLine = ( *Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);1667 BaseLine = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition()); 2840 1668 for (int i = 0; i < 2; i++) { 2841 DistanceToIntersection[i] = (*ClosestPoint) - ( *Base->endpoints[i]->node->node);1669 DistanceToIntersection[i] = (*ClosestPoint) - (Base->endpoints[i]->node->getPosition()); 2842 1670 distance[i] = BaseLine.ScalarProduct(DistanceToIntersection[i]); 2843 1671 } … … 2919 1747 2920 1748 // calculate volume 2921 volume = CalculateVolumeofGeneralTetraeder( *Base->endpoints[1]->node->node, *OtherBase->endpoints[0]->node->node, *OtherBase->endpoints[1]->node->node, *Base->endpoints[0]->node->node);1749 volume = CalculateVolumeofGeneralTetraeder(Base->endpoints[1]->node->getPosition(), OtherBase->endpoints[0]->node->getPosition(), OtherBase->endpoints[1]->node->getPosition(), Base->endpoints[0]->node->getPosition()); 2922 1750 2923 1751 // delete the temporary other base line and the closest points … … 3125 1953 3126 1954 OrthogonalizedOben = Oben; 3127 aCandidate = ( *a->node) - (*Candidate->node);1955 aCandidate = (a->getPosition()) - (Candidate->getPosition()); 3128 1956 OrthogonalizedOben.ProjectOntoPlane(aCandidate); 3129 1957 OrthogonalizedOben.Normalize(); … … 3132 1960 OrthogonalizedOben.Scale(scaleFactor); 3133 1961 3134 Center = 0.5 * (( *Candidate->node) + (*a->node));1962 Center = 0.5 * ((Candidate->getPosition()) + (a->getPosition())); 3135 1963 Center += OrthogonalizedOben; 3136 1964 3137 AngleCheck = Center - ( *a->node);1965 AngleCheck = Center - (a->getPosition()); 3138 1966 norm = aCandidate.Norm(); 3139 1967 // second point shall have smallest angle with respect to Oben vector … … 3220 2048 3221 2049 // construct center of circle 3222 CircleCenter = 0.5 * (( *CandidateLine.BaseLine->endpoints[0]->node->node) +3223 ( *CandidateLine.BaseLine->endpoints[1]->node->node));2050 CircleCenter = 0.5 * ((CandidateLine.BaseLine->endpoints[0]->node->getPosition()) + 2051 (CandidateLine.BaseLine->endpoints[1]->node->getPosition())); 3224 2052 3225 2053 // construct normal vector of circle 3226 CirclePlaneNormal = ( *CandidateLine.BaseLine->endpoints[0]->node->node) -3227 ( *CandidateLine.BaseLine->endpoints[1]->node->node);2054 CirclePlaneNormal = (CandidateLine.BaseLine->endpoints[0]->node->getPosition()) - 2055 (CandidateLine.BaseLine->endpoints[1]->node->getPosition()); 3228 2056 3229 2057 RelativeOldSphereCenter = OldSphereCenter - CircleCenter; … … 3252 2080 3253 2081 // get cell for the starting point 3254 if (LC->SetIndexToVector( &CircleCenter)) {2082 if (LC->SetIndexToVector(CircleCenter)) { 3255 2083 for (int i = 0; i < NDIM; i++) // store indices of this cell 3256 2084 N[i] = LC->n[i]; … … 3282 2110 3283 2111 // find center on the plane 3284 GetCenterofCircumcircle( &NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);2112 GetCenterofCircumcircle(NewPlaneCenter, CandidateLine.BaseLine->endpoints[0]->node->getPosition(), CandidateLine.BaseLine->endpoints[1]->node->getPosition(), Candidate->getPosition()); 3285 2113 DoLog(1) && (Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl); 3286 2114 3287 2115 try { 3288 NewNormalVector = Plane( *(CandidateLine.BaseLine->endpoints[0]->node->node),3289 *(CandidateLine.BaseLine->endpoints[1]->node->node),3290 *(Candidate->node)).getNormal();2116 NewNormalVector = Plane((CandidateLine.BaseLine->endpoints[0]->node->getPosition()), 2117 (CandidateLine.BaseLine->endpoints[1]->node->getPosition()), 2118 (Candidate->getPosition())).getNormal(); 3291 2119 DoLog(1) && (Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl); 3292 radius = CandidateLine.BaseLine->endpoints[0]->node-> node->DistanceSquared(NewPlaneCenter);2120 radius = CandidateLine.BaseLine->endpoints[0]->node->DistanceSquared(NewPlaneCenter); 3293 2121 DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl); 3294 2122 DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl); 3295 2123 DoLog(1) && (Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl); 3296 2124 if (radius < RADIUS * RADIUS) { 3297 otherradius = CandidateLine.BaseLine->endpoints[1]->node-> node->DistanceSquared(NewPlaneCenter);2125 otherradius = CandidateLine.BaseLine->endpoints[1]->node->DistanceSquared(NewPlaneCenter); 3298 2126 if (fabs(radius - otherradius) < HULLEPSILON) { 3299 2127 // construct both new centers … … 3309 2137 OtherNewSphereCenter += helper; 3310 2138 DoLog(2) && (Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl); 3311 alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection );3312 Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection );2139 alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection, HULLEPSILON); 2140 Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection, HULLEPSILON); 3313 2141 if ((ThirdPoint != NULL) && (Candidate == ThirdPoint->node)) { // in that case only the other circlecenter is valid 3314 2142 if (OldSphereCenter.DistanceSquared(NewSphereCenter) < OldSphereCenter.DistanceSquared(OtherNewSphereCenter)) … … 3422 2250 * \return map of BoundaryPointSet of closest points sorted by squared distance or NULL. 3423 2251 */ 3424 DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const2252 DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector &x, const LinkedCell* LC) const 3425 2253 { 3426 2254 Info FunctionInfo(__func__); … … 3450 2278 FindPoint = PointsOnBoundary.find((*Runner)->nr); 3451 2279 if (FindPoint != PointsOnBoundary.end()) { 3452 points->insert(DistanceToPointPair(FindPoint->second->node-> node->DistanceSquared(*x), FindPoint->second));2280 points->insert(DistanceToPointPair(FindPoint->second->node->DistanceSquared(x), FindPoint->second)); 3453 2281 DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl); 3454 2282 } … … 3474 2302 * \return closest BoundaryLineSet or NULL in degenerate case. 3475 2303 */ 3476 BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const2304 BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell* LC) const 3477 2305 { 3478 2306 Info FunctionInfo(__func__); … … 3485 2313 3486 2314 // for each point, check its lines, remember closest 3487 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl);2315 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << x << " ... " << endl); 3488 2316 BoundaryLineSet *ClosestLine = NULL; 3489 2317 double MinDistance = -1.; … … 3494 2322 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3495 2323 // calculate closest point on line to desired point 3496 helper = 0.5 * (( *(LineRunner->second)->endpoints[0]->node->node) +3497 ( *(LineRunner->second)->endpoints[1]->node->node));3498 Center = ( *x) - helper;3499 BaseLine = ( *(LineRunner->second)->endpoints[0]->node->node) -3500 ( *(LineRunner->second)->endpoints[1]->node->node);2324 helper = 0.5 * (((LineRunner->second)->endpoints[0]->node->getPosition()) + 2325 ((LineRunner->second)->endpoints[1]->node->getPosition())); 2326 Center = (x) - helper; 2327 BaseLine = ((LineRunner->second)->endpoints[0]->node->getPosition()) - 2328 ((LineRunner->second)->endpoints[1]->node->getPosition()); 3501 2329 Center.ProjectOntoPlane(BaseLine); 3502 2330 const double distance = Center.NormSquared(); 3503 2331 if ((ClosestLine == NULL) || (distance < MinDistance)) { 3504 2332 // additionally calculate intersection on line (whether it's on the line section or not) 3505 helper = ( *x) - (*(LineRunner->second)->endpoints[0]->node->node) - Center;2333 helper = (x) - ((LineRunner->second)->endpoints[0]->node->getPosition()) - Center; 3506 2334 const double lengthA = helper.ScalarProduct(BaseLine); 3507 helper = ( *x) - (*(LineRunner->second)->endpoints[1]->node->node) - Center;2335 helper = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition()) - Center; 3508 2336 const double lengthB = helper.ScalarProduct(BaseLine); 3509 2337 if (lengthB * lengthA < 0) { // if have different sign … … 3534 2362 * \return BoundaryTriangleSet of nearest triangle or NULL. 3535 2363 */ 3536 TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const2364 TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector &x, const LinkedCell* LC) const 3537 2365 { 3538 2366 Info FunctionInfo(__func__); … … 3545 2373 3546 2374 // for each point, check its lines, remember closest 3547 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl);2375 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << x << " ... " << endl); 3548 2376 LineSet ClosestLines; 3549 2377 double MinDistance = 1e+16; … … 3555 2383 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3556 2384 3557 BaseLine = ( *(LineRunner->second)->endpoints[0]->node->node) -3558 ( *(LineRunner->second)->endpoints[1]->node->node);2385 BaseLine = ((LineRunner->second)->endpoints[0]->node->getPosition()) - 2386 ((LineRunner->second)->endpoints[1]->node->getPosition()); 3559 2387 const double lengthBase = BaseLine.NormSquared(); 3560 2388 3561 BaseLineIntersection = ( *x) - (*(LineRunner->second)->endpoints[0]->node->node);2389 BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[0]->node->getPosition()); 3562 2390 const double lengthEndA = BaseLineIntersection.NormSquared(); 3563 2391 3564 BaseLineIntersection = ( *x) - (*(LineRunner->second)->endpoints[1]->node->node);2392 BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition()); 3565 2393 const double lengthEndB = BaseLineIntersection.NormSquared(); 3566 2394 … … 3580 2408 } else { // intersection is closer, calculate 3581 2409 // calculate closest point on line to desired point 3582 BaseLineIntersection = ( *x) - (*(LineRunner->second)->endpoints[1]->node->node);2410 BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition()); 3583 2411 Center = BaseLineIntersection; 3584 2412 Center.ProjectOntoPlane(BaseLine); … … 3621 2449 * \return list of BoundaryTriangleSet of nearest triangles or NULL. 3622 2450 */ 3623 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const2451 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector &x, const LinkedCell* LC) const 3624 2452 { 3625 2453 Info FunctionInfo(__func__); … … 3636 2464 double MinAlignment = 2. * M_PI; 3637 2465 for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) { 3638 (*Runner)->GetCenter( &Center);3639 helper = ( *x) - Center;2466 (*Runner)->GetCenter(Center); 2467 helper = (x) - Center; 3640 2468 const double Alignment = helper.Angle((*Runner)->NormalVector); 3641 2469 if (Alignment < MinAlignment) { … … 3663 2491 { 3664 2492 Info FunctionInfo(__func__); 3665 TriangleIntersectionList Intersections( &Point, this, LC);2493 TriangleIntersectionList Intersections(Point, this, LC); 3666 2494 3667 2495 return Intersections.IsInside(); … … 3703 2531 } 3704 2532 3705 triangle->GetCenter( &Center);2533 triangle->GetCenter(Center); 3706 2534 DoLog(2) && (Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl); 3707 2535 DistanceToCenter = Center - Point; … … 3714 2542 Center = Point - triangle->NormalVector; // points towards MolCenter 3715 2543 DoLog(1) && (Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl); 3716 if (triangle->GetIntersectionInsideTriangle( &Center, &DistanceToCenter, &Intersection)) {2544 if (triangle->GetIntersectionInsideTriangle(Center, DistanceToCenter, Intersection)) { 3717 2545 DoLog(1) && (Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl); 3718 2546 return 0.; … … 3723 2551 } else { 3724 2552 // calculate smallest distance 3725 distance = triangle->GetClosestPointInsideTriangle( &Point, &Intersection);2553 distance = triangle->GetClosestPointInsideTriangle(Point, Intersection); 3726 2554 DoLog(1) && (Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl); 3727 2555 … … 3747 2575 { 3748 2576 Info FunctionInfo(__func__); 3749 TriangleIntersectionList Intersections( &Point, this, LC);2577 TriangleIntersectionList Intersections(Point, this, LC); 3750 2578 3751 2579 return Intersections.GetSmallestDistance(); … … 3762 2590 { 3763 2591 Info FunctionInfo(__func__); 3764 TriangleIntersectionList Intersections( &Point, this, LC);2592 TriangleIntersectionList Intersections(Point, this, LC); 3765 2593 3766 2594 return Intersections.GetClosestTriangle(); … … 3839 2667 * @return list of the all points linked to the provided one 3840 2668 */ 3841 TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * constReference) const2669 TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const 3842 2670 { 3843 2671 Info FunctionInfo(__func__); … … 3871 2699 3872 2700 // construct one orthogonal vector 3873 if (Reference != NULL) { 3874 AngleZero = (*Reference) - (*Point->node); 3875 AngleZero.ProjectOntoPlane(PlaneNormal); 3876 } 3877 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON)) { 3878 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl); 3879 AngleZero = (*(*SetOfNeighbours->begin())->node) - (*Point->node); 2701 AngleZero = (Reference) - (Point->getPosition()); 2702 AngleZero.ProjectOntoPlane(PlaneNormal); 2703 if ((AngleZero.NormSquared() < MYEPSILON)) { 2704 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << (*SetOfNeighbours->begin())->getPosition() << " as angle 0 referencer." << endl); 2705 AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition()); 3880 2706 AngleZero.ProjectOntoPlane(PlaneNormal); 3881 2707 if (AngleZero.NormSquared() < MYEPSILON) { … … 3893 2719 // go through all connected points and calculate angle 3894 2720 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3895 helper = ( *(*listRunner)->node) - (*Point->node);2721 helper = ((*listRunner)->getPosition()) - (Point->getPosition()); 3896 2722 helper.ProjectOntoPlane(PlaneNormal); 3897 2723 double angle = GetAngle(helper, AngleZero, OrthogonalVector); … … 3915 2741 * @param *SetOfNeighbours all points for which the angle should be calculated 3916 2742 * @param *Point of which get all connected points 3917 * @param *Reference Reference vector for zero angle or NULLfor no preference2743 * @param *Reference Reference vector for zero angle or (0,0,0) for no preference 3918 2744 * @return list of the all points linked to the provided one 3919 2745 */ 3920 TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * constReference) const2746 TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const 3921 2747 { 3922 2748 Info FunctionInfo(__func__); … … 3942 2768 } 3943 2769 3944 DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl);2770 DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << Reference << "." << endl); 3945 2771 // calculate central point 3946 2772 TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin(); … … 3952 2778 int counter = 0; 3953 2779 while (TesselC != SetOfNeighbours->end()) { 3954 helper = Plane( *((*TesselA)->node),3955 *((*TesselB)->node),3956 *((*TesselC)->node)).getNormal();2780 helper = Plane(((*TesselA)->getPosition()), 2781 ((*TesselB)->getPosition()), 2782 ((*TesselC)->getPosition())).getNormal(); 3957 2783 DoLog(0) && (Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl); 3958 2784 counter++; … … 3974 2800 3975 2801 // construct one orthogonal vector 3976 if ( Reference != NULL) {3977 AngleZero = ( *Reference) - (*Point->node);2802 if (!Reference.IsZero()) { 2803 AngleZero = (Reference) - (Point->getPosition()); 3978 2804 AngleZero.ProjectOntoPlane(PlaneNormal); 3979 2805 } 3980 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {3981 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node<< " as angle 0 referencer." << endl);3982 AngleZero = ( *(*SetOfNeighbours->begin())->node) - (*Point->node);2806 if ((Reference.IsZero()) || (AngleZero.NormSquared() < MYEPSILON )) { 2807 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << (*SetOfNeighbours->begin())->getPosition() << " as angle 0 referencer." << endl); 2808 AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition()); 3983 2809 AngleZero.ProjectOntoPlane(PlaneNormal); 3984 2810 if (AngleZero.NormSquared() < MYEPSILON) { … … 3997 2823 pair<map<double, TesselPoint*>::iterator, bool> InserterTest; 3998 2824 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3999 helper = ( *(*listRunner)->node) - (*Point->node);2825 helper = ((*listRunner)->getPosition()) - (Point->getPosition()); 4000 2826 helper.ProjectOntoPlane(PlaneNormal); 4001 2827 double angle = GetAngle(helper, AngleZero, OrthogonalVector); … … 4242 3068 4243 3069 // copy old location for the volume 4244 OldPoint = ( *point->node->node);3070 OldPoint = (point->node->getPosition()); 4245 3071 4246 3072 // get list of connected points … … 4305 3131 StartNode--; 4306 3132 //Log() << Verbose(3) << "INFO: StartNode is " << **StartNode << "." << endl; 4307 Point = ( *(*StartNode)->node) - (*(*MiddleNode)->node);3133 Point = ((*StartNode)->getPosition()) - ((*MiddleNode)->getPosition()); 4308 3134 StartNode = MiddleNode; 4309 3135 StartNode++; … … 4311 3137 StartNode = connectedPath->begin(); 4312 3138 //Log() << Verbose(3) << "INFO: EndNode is " << **StartNode << "." << endl; 4313 Reference = ( *(*StartNode)->node) - (*(*MiddleNode)->node);4314 OrthogonalVector = ( *(*MiddleNode)->node) - OldPoint;3139 Reference = ((*StartNode)->getPosition()) - ((*MiddleNode)->getPosition()); 3140 OrthogonalVector = ((*MiddleNode)->getPosition()) - OldPoint; 4315 3141 OrthogonalVector.MakeNormalTo(Reference); 4316 3142 angle = GetAngle(Point, Reference, OrthogonalVector); … … 4367 3193 AddTesselationTriangle(); 4368 3194 // calculate volume summand as a general tetraeder 4369 volume += CalculateVolumeofGeneralTetraeder( *TPS[0]->node->node, *TPS[1]->node->node, *TPS[2]->node->node, OldPoint);3195 volume += CalculateVolumeofGeneralTetraeder(TPS[0]->node->getPosition(), TPS[1]->node->getPosition(), TPS[2]->node->getPosition(), OldPoint); 4370 3196 // advance number 4371 3197 count++; … … 4752 3578 // find nearest boundary point 4753 3579 class TesselPoint *BackupPoint = NULL; 4754 class TesselPoint *NearestPoint = FindClosestTesselPoint(point-> node, BackupPoint, LC);3580 class TesselPoint *NearestPoint = FindClosestTesselPoint(point->getPosition(), BackupPoint, LC); 4755 3581 class BoundaryPointSet *NearestBoundaryPoint = NULL; 4756 3582 PointMap::iterator PointRunner; … … 4773 3599 class BoundaryLineSet *BestLine = NULL; 4774 3600 for (LineMap::iterator Runner = NearestBoundaryPoint->lines.begin(); Runner != NearestBoundaryPoint->lines.end(); Runner++) { 4775 BaseLine = ( *Runner->second->endpoints[0]->node->node) -4776 ( *Runner->second->endpoints[1]->node->node);4777 CenterToPoint = 0.5 * (( *Runner->second->endpoints[0]->node->node) +4778 ( *Runner->second->endpoints[1]->node->node));4779 CenterToPoint -= ( *point->node);3601 BaseLine = (Runner->second->endpoints[0]->node->getPosition()) - 3602 (Runner->second->endpoints[1]->node->getPosition()); 3603 CenterToPoint = 0.5 * ((Runner->second->endpoints[0]->node->getPosition()) + 3604 (Runner->second->endpoints[1]->node->getPosition())); 3605 CenterToPoint -= (point->getPosition()); 4780 3606 angle = CenterToPoint.Angle(BaseLine); 4781 3607 if (fabs(angle - M_PI/2.) < fabs(BestAngle - M_PI/2.)) { -
src/tesselation.hpp
re588312 rb5c53d 2 2 * tesselation.hpp 3 3 * 4 * The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors. As we actually mean this stuff for atoms, we have to encapsulate it all a bit. 4 * The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors. 5 * As we actually mean this stuff for atoms, we have to encapsulate it all a bit. 5 6 * 6 7 * Created on: Aug 3, 2009 … … 25 26 #include <stack> 26 27 28 #include "BoundaryMaps.hpp" 29 #include "PointCloud.hpp" 30 #include "TesselPoint.hpp" 27 31 #include "atom_particleinfo.hpp" 28 32 #include "Helpers/helpers.hpp" 29 33 #include "LinearAlgebra/Vector.hpp" 34 30 35 31 36 /****************************************** forward declarations *****************************/ … … 34 39 class BoundaryLineSet; 35 40 class BoundaryTriangleSet; 41 class CandidateForTesselation; 36 42 class LinkedCell; 37 class TesselPoint;38 class PointCloud;39 43 class Tesselation; 40 44 class Plane; … … 42 46 /********************************************** definitions *********************************/ 43 47 44 #define DoTecplotOutput 1 45 #define DoRaster3DOutput 1 46 #define DoVRMLOutput 0 47 #define TecplotSuffix ".dat" 48 #define Raster3DSuffix ".r3d" 49 #define VRMLSUffix ".wrl" 48 enum { DoTecplotOutput=1 }; 49 enum { DoRaster3DOutput=1 }; 50 enum { DoVRMLOutput=0 }; 50 51 51 #define ParallelEpsilon 1e-3 52 extern "C" const char *TecplotSuffix; 53 extern "C" const char *Raster3DSuffix; 54 extern "C" const char *VRMLSUffix; 55 56 extern "C" const double ParallelEpsilon; 52 57 53 58 // ======================================================= some template functions ========================================= 54 59 55 #define IndexToIndex map <int, int>56 57 #define PointMap map < int, class BoundaryPointSet * >58 #define PointSet set < class BoundaryPointSet * >59 #define PointList list < class BoundaryPointSet * >60 #define PointPair pair < int, class BoundaryPointSet * >61 #define PointTestPair pair < PointMap::iterator, bool >62 63 #define CandidateList list <class CandidateForTesselation *>64 #define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>65 66 #define LineMap multimap < int, class BoundaryLineSet * >67 #define LineSet set < class BoundaryLineSet * >68 #define LineList list < class BoundaryLineSet * >69 #define LinePair pair < int, class BoundaryLineSet * >70 #define LineTestPair pair < LineMap::iterator, bool >71 72 #define TriangleMap map < int, class BoundaryTriangleSet * >73 #define TriangleSet set < class BoundaryTriangleSet * >74 #define TriangleList list < class BoundaryTriangleSet * >75 #define TrianglePair pair < int, class BoundaryTriangleSet * >76 #define TriangleTestPair pair < TrianglePair::iterator, bool >77 78 #define PolygonMap map < int, class BoundaryPolygonSet * >79 #define PolygonSet set < class BoundaryPolygonSet * >80 #define PolygonList list < class BoundaryPolygonSet * >81 82 #define DistanceToPointMap multimap <double, class BoundaryPointSet * >83 #define DistanceToPointPair pair <double, class BoundaryPointSet * >84 85 #define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >86 #define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >87 88 #define TesselPointList list <TesselPoint *>89 #define TesselPointSet set <TesselPoint *>90 91 #define ListOfTesselPointList list<list <TesselPoint *> *>92 93 enum centers {Opt, OtherOpt};94 95 60 /********************************************** declarations *******************************/ 96 97 template <typename T> void SetEndpointsOrdered(T endpoints[2], T endpoint1, T endpoint2)98 {99 if (endpoint1->Nr < endpoint2->Nr) {100 endpoints[0] = endpoint1;101 endpoints[1] = endpoint2;102 } else {103 endpoints[0] = endpoint2;104 endpoints[1] = endpoint1;105 }106 };107 108 // ======================================================== class BoundaryPointSet =========================================109 110 class BoundaryPointSet {111 public:112 BoundaryPointSet();113 BoundaryPointSet(TesselPoint * const Walker);114 ~BoundaryPointSet();115 116 void AddLine(BoundaryLineSet * const line);117 118 LineMap lines;119 int LinesCount;120 TesselPoint *node;121 double value;122 int Nr;123 };124 125 ostream & operator << (ostream &ost, const BoundaryPointSet &a);126 127 // ======================================================== class BoundaryLineSet ==========================================128 129 class BoundaryLineSet {130 public:131 BoundaryLineSet();132 BoundaryLineSet(BoundaryPointSet * const Point[2], const int number);133 BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number);134 ~BoundaryLineSet();135 136 void AddTriangle(BoundaryTriangleSet * const triangle);137 bool IsConnectedTo(const BoundaryLineSet * const line) const;138 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;139 bool CheckConvexityCriterion() const;140 double CalculateConvexity() const;141 class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;142 class BoundaryTriangleSet *GetOtherTriangle(const BoundaryTriangleSet * const triangle) const;143 144 class BoundaryPointSet *endpoints[2];145 TriangleMap triangles;146 int Nr;147 bool skipped;148 };149 150 ostream & operator << (ostream &ost, const BoundaryLineSet &a);151 152 // ======================================================== class BoundaryTriangleSet =======================================153 154 class BoundaryTriangleSet {155 public:156 BoundaryTriangleSet();157 BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);158 ~BoundaryTriangleSet();159 160 void GetNormalVector(const Vector &NormalVector);161 void GetCenter(Vector * const center) const;162 bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const;163 double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const;164 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;165 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;166 bool ContainsBoundaryPoint(const TesselPoint * const point) const;167 class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;168 class BoundaryLineSet *GetThirdLine(const BoundaryPointSet * const point) const;169 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;170 bool IsPresentTupel(const BoundaryTriangleSet * const T) const;171 172 Plane getPlane() const;173 Vector getEndpoint(int) const;174 std::string getEndpointName(int) const;175 176 class BoundaryPointSet *endpoints[3];177 class BoundaryLineSet *lines[3];178 Vector NormalVector;179 Vector SphereCenter;180 int Nr;181 182 private:183 184 };185 186 ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);187 188 189 // ======================================================== class BoundaryTriangleSet =======================================190 191 /** Set of BoundaryPointSet.192 * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has193 * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation194 * class (i.e. no allocation, no deletion).195 * \note we assume that the set of endpoints reside (more or less) on a plane.196 */197 class BoundaryPolygonSet {198 public:199 BoundaryPolygonSet();200 ~BoundaryPolygonSet();201 202 Vector * GetNormalVector(const Vector &NormalVector) const;203 void GetCenter(Vector *center) const;204 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;205 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;206 bool ContainsBoundaryPoint(const TesselPoint * const point) const;207 bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;208 bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;209 bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;210 bool ContainsPresentTupel(const PointSet &endpoints) const;211 TriangleSet * GetAllContainedTrianglesFromEndpoints() const;212 bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);213 214 PointSet endpoints;215 int Nr;216 };217 218 ostream & operator << (ostream &ost, const BoundaryPolygonSet &a);219 220 // =========================================================== class TESSELPOINT ===========================================221 222 /** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.223 */224 class TesselPoint : virtual public ParticleInfo {225 public:226 TesselPoint();227 virtual ~TesselPoint();228 229 Vector *node; // pointer to position of the dot in space230 231 virtual ostream & operator << (ostream &ost);232 };233 234 ostream & operator << (ostream &ost, const TesselPoint &a);235 236 // =========================================================== class POINTCLOUD ============================================237 238 /** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.239 * This basically encapsulates a list structure.240 */241 class PointCloud {242 public:243 PointCloud();244 virtual ~PointCloud();245 246 virtual const char * const GetName() const { return "unknown"; };247 virtual Vector *GetCenter() const { return NULL; };248 virtual TesselPoint *GetPoint() const { return NULL; };249 virtual int GetMaxId() const { return 0; };250 virtual void GoToNext() const {};251 virtual void GoToFirst() const {};252 virtual bool IsEmpty() const { return true; };253 virtual bool IsEnd() const { return true; };254 };255 256 // ======================================================== class CandidateForTesselation =========================================257 258 class CandidateForTesselation {259 public :260 CandidateForTesselation(BoundaryLineSet* currentBaseLine);261 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);262 ~CandidateForTesselation();263 264 bool CheckValidity(const double RADIUS, const LinkedCell *LC) const;265 266 TesselPointList pointlist;267 const BoundaryLineSet * BaseLine;268 const BoundaryPointSet * ThirdPoint;269 const BoundaryTriangleSet *T;270 Vector OldCenter;271 Vector OptCenter;272 Vector OtherOptCenter;273 double ShortestAngle;274 double OtherShortestAngle;275 };276 277 ostream & operator <<(ostream &ost, const CandidateForTesselation &a);278 61 279 62 // =========================================================== class TESSELATION =========================================== … … 289 72 void AddTesselationPoint(TesselPoint* Candidate, const int n); 290 73 void SetTesselationPoint(TesselPoint* Candidate, const int n) const; 291 void AddTesselationLine(const Vector * constOptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);74 void AddTesselationLine(const Vector * OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 292 75 void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 293 76 void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n); … … 330 113 ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const; 331 114 ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const; 332 TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const;333 TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * constReference) const;115 TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const; 116 TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const; 334 117 class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const; 335 118 TriangleList * FindTriangles(const TesselPoint* const Points[3]) const; 336 TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const;337 BoundaryTriangleSet * FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const;119 TriangleList * FindClosestTrianglesToVector(const Vector &x, const LinkedCell* LC) const; 120 BoundaryTriangleSet * FindClosestTriangleToVector(const Vector &x, const LinkedCell* LC) const; 338 121 bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const; 339 122 double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const; … … 341 124 BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const; 342 125 bool AddBoundaryPoint(TesselPoint * Walker, const int n); 343 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;344 BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const;126 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector &x, const LinkedCell* LC) const; 127 BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell* LC) const; 345 128 346 129 // print for debugging … … 375 158 376 159 private: 160 static const double HULLEPSILON; //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities 161 377 162 mutable class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions 378 163 -
src/tesselationhelpers.cpp
re588312 rb5c53d 10 10 #include <fstream> 11 11 12 #include "BoundaryLineSet.hpp" 13 #include "BoundaryPointSet.hpp" 14 #include "BoundaryPolygonSet.hpp" 15 #include "BoundaryTriangleSet.hpp" 16 #include "CandidateForTesselation.hpp" 12 17 #include "Helpers/Info.hpp" 13 18 #include "linkedcell.hpp" … … 18 23 #include "LinearAlgebra/Vector.hpp" 19 24 #include "LinearAlgebra/Line.hpp" 20 #include " vector_ops.hpp"25 #include "LinearAlgebra/vector_ops.hpp" 21 26 #include "Helpers/Verbose.hpp" 22 27 #include "LinearAlgebra/Plane.hpp" … … 144 149 * \param *c third point 145 150 */ 146 void GetCenterofCircumcircle(Vector * constCenter, const Vector &a, const Vector &b, const Vector &c)151 void GetCenterofCircumcircle(Vector &Center, const Vector &a, const Vector &b, const Vector &c) 147 152 { 148 153 Info FunctionInfo(__func__); … … 156 161 helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared()); 157 162 158 Center ->Zero();159 *Center += helper[0] * a;160 *Center += helper[1] * b;161 *Center += helper[2] * c;162 Center ->Scale(1./(helper[0]+helper[1]+helper[2]));163 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl;163 Center.Zero(); 164 Center += helper[0] * a; 165 Center += helper[1] * b; 166 Center += helper[2] * c; 167 Center.Scale(1./(helper[0]+helper[1]+helper[2])); 168 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << Center << "." << endl; 164 169 }; 165 170 … … 175 180 * \param NormalVector normal vector 176 181 * \param SearchDirection search direction to make angle unique on return. 182 * \param HULLEPSILON machine precision for tesselation points 177 183 * \return Angle between \a NewSphereCenter and \a OldSphereCenter relative to \a CircleCenter, 2.*M_PI if one test fails 178 184 */ 179 double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection )185 double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection, const double HULLEPSILON) 180 186 { 181 187 Info FunctionInfo(__func__); … … 388 394 * @return point which is second closest to the provided one 389 395 */ 390 TesselPoint* FindSecondClosestTesselPoint(const Vector *Point, const LinkedCell* const LC)396 TesselPoint* FindSecondClosestTesselPoint(const Vector& Point, const LinkedCell* const LC) 391 397 { 392 398 Info FunctionInfo(__func__); … … 412 418 if (List != NULL) { 413 419 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 414 helper = ( *Point) - (*(*Runner)->node);420 helper = (Point) - ((*Runner)->getPosition()); 415 421 double currentNorm = helper. Norm(); 416 422 if (currentNorm < distance) { … … 441 447 * @return point which is closest to the provided one, NULL if none found 442 448 */ 443 TesselPoint* FindClosestTesselPoint(const Vector *Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)449 TesselPoint* FindClosestTesselPoint(const Vector& Point, TesselPoint *&SecondPoint, const LinkedCell* const LC) 444 450 { 445 451 Info FunctionInfo(__func__); … … 465 471 if (List != NULL) { 466 472 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 467 helper = ( *Point) - (*(*Runner)->node);473 helper = (Point) - ((*Runner)->getPosition()); 468 474 double currentNorm = helper.NormSquared(); 469 475 if (currentNorm < distance) { … … 503 509 Info FunctionInfo(__func__); 504 510 // construct the plane of the two baselines (i.e. take both their directional vectors) 505 Vector Baseline = ( *Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);506 Vector OtherBaseline = ( *OtherBase->endpoints[1]->node->node) - (*OtherBase->endpoints[0]->node->node);511 Vector Baseline = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition()); 512 Vector OtherBaseline = (OtherBase->endpoints[1]->node->getPosition()) - (OtherBase->endpoints[0]->node->getPosition()); 507 513 Vector Normal = Baseline; 508 514 Normal.VectorProduct(OtherBaseline); … … 511 517 512 518 // project one offset point of OtherBase onto this plane (and add plane offset vector) 513 Vector NewOffset = ( *OtherBase->endpoints[0]->node->node) - (*Base->endpoints[0]->node->node);519 Vector NewOffset = (OtherBase->endpoints[0]->node->getPosition()) - (Base->endpoints[0]->node->getPosition()); 514 520 NewOffset.ProjectOntoPlane(Normal); 515 NewOffset += ( *Base->endpoints[0]->node->node);521 NewOffset += (Base->endpoints[0]->node->getPosition()); 516 522 Vector NewDirection = NewOffset + OtherBaseline; 517 523 518 524 // calculate the intersection between this projected baseline and Base 519 525 Vector *Intersection = new Vector; 520 Line line1 = makeLineThrough( *(Base->endpoints[0]->node->node),*(Base->endpoints[1]->node->node));526 Line line1 = makeLineThrough((Base->endpoints[0]->node->getPosition()),(Base->endpoints[1]->node->getPosition())); 521 527 Line line2 = makeLineThrough(NewOffset, NewDirection); 522 528 *Intersection = line1.getIntersection(line2); 523 Normal = (*Intersection) - ( *Base->endpoints[0]->node->node);529 Normal = (*Intersection) - (Base->endpoints[0]->node->getPosition()); 524 530 DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(Baseline)/Baseline.NormSquared()) << "." << endl); 525 531 … … 566 572 *vrmlfile << "Sphere {" << endl << " "; // 2 is sphere type 567 573 for (i=0;i<NDIM;i++) 568 *vrmlfile << Walker-> node->at(i)-center->at(i) << " ";574 *vrmlfile << Walker->at(i)-center->at(i) << " "; 569 575 *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour 570 576 cloud->GoToNext(); … … 576 582 for (i=0;i<3;i++) { // print each node 577 583 for (int j=0;j<NDIM;j++) // and for each node all NDIM coordinates 578 *vrmlfile << TriangleRunner->second->endpoints[i]->node-> node->at(j)-center->at(j) << " ";584 *vrmlfile << TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j) << " "; 579 585 *vrmlfile << "\t"; 580 586 } … … 603 609 Vector *center = cloud->GetCenter(); 604 610 // make the circumsphere's center absolute again 605 Vector helper = (1./3.) * (( *Tess->LastTriangle->endpoints[0]->node->node) +606 ( *Tess->LastTriangle->endpoints[1]->node->node) +607 ( *Tess->LastTriangle->endpoints[2]->node->node));611 Vector helper = (1./3.) * ((Tess->LastTriangle->endpoints[0]->node->getPosition()) + 612 (Tess->LastTriangle->endpoints[1]->node->getPosition()) + 613 (Tess->LastTriangle->endpoints[2]->node->getPosition())); 608 614 helper -= (*center); 609 615 // and add to file plus translucency object … … 638 644 *rasterfile << "2" << endl << " "; // 2 is sphere type 639 645 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 640 const double tmp = Walker-> node->at(j)-center->at(j);646 const double tmp = Walker->at(j)-center->at(j); 641 647 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 642 648 } … … 651 657 for (i=0;i<3;i++) { // print each node 652 658 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 653 const double tmp = TriangleRunner->second->endpoints[i]->node-> node->at(j)-center->at(j);659 const double tmp = TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j); 654 660 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 655 661 } … … 705 711 LookupList[Walker->nr] = Counter++; 706 712 for (int i=0;i<NDIM;i++) { 707 const double tmp = Walker-> node->at(i);713 const double tmp = Walker->at(i); 708 714 *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 709 715 } … … 754 760 TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second); 755 761 for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 756 totalarea += CalculateAreaofGeneralTriangle( *(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);762 totalarea += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition()); 757 763 } 758 764 ConcavityPerLine *= totalarea; … … 763 769 line = (*TriangleRunner)->GetThirdLine(PointRunner->second); 764 770 triangle = line->GetOtherTriangle(*TriangleRunner); 765 area = CalculateAreaofGeneralTriangle( *triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node);766 area += CalculateAreaofGeneralTriangle( *(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);771 area = CalculateAreaofGeneralTriangle(triangle->endpoints[0]->node->getPosition() , triangle->endpoints[1]->node->getPosition() , triangle->endpoints[2]->node->getPosition()); 772 area += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition()); 767 773 area *= -line->CalculateConvexity(); 768 774 if (area > 0) … … 797 803 distance = 0.; 798 804 for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) { 799 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle( *PointRunner->second->node->node, TriangleRunner->second);805 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(PointRunner->second->node->getPosition() , TriangleRunner->second); 800 806 if (CurrentDistance < distance) 801 807 distance = CurrentDistance; -
src/tesselationhelpers.hpp
re588312 rb5c53d 22 22 #include <iosfwd> 23 23 24 #include "BoundaryMaps.hpp" 24 25 #include "defs.hpp" 25 26 … … 29 30 class BoundaryLineSet; 30 31 class BoundaryTriangleSet; 32 class BoundaryPolygonSet; 33 class CandidateForTesselation; 31 34 class LinkedCell; 32 35 class TesselPoint; … … 37 40 /********************************************** definitions *********************************/ 38 41 39 #define HULLEPSILON 1e-9 //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities40 41 42 /********************************************** declarations *******************************/ 42 43 43 void GetSphere(Vector * constCenter, const Vector &a, const Vector &b, const Vector &c, const double RADIUS);44 void GetCenterOfSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* constDirection, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius);45 void GetCenterofCircumcircle(Vector * constCenter, const Vector &a, const Vector &b, const Vector &c);46 double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection );44 void GetSphere(Vector & Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS); 45 void GetCenterOfSphere(Vector& Center, const Vector &a, const Vector &b, const Vector &c, Vector &NewUmkreismittelpunkt, const Vector &Direction, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius); 46 void GetCenterofCircumcircle(Vector & Center, const Vector &a, const Vector &b, const Vector &c); 47 double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection, const double HULLEPSILON); 47 48 double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d); 48 49 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C); … … 51 52 bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3]); 52 53 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation *candidate2); 53 TesselPoint* FindClosestTesselPoint(const Vector *Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);54 TesselPoint* FindSecondClosestTesselPoint(const Vector *, const LinkedCell* const LC);54 TesselPoint* FindClosestTesselPoint(const Vector & Point, TesselPoint *&SecondPoint, const LinkedCell* const LC); 55 TesselPoint* FindSecondClosestTesselPoint(const Vector &, const LinkedCell* const LC); 55 56 Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase); 56 57 … … 61 62 void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct); 62 63 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex); 63 double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle);64 double DistanceToTrianglePlane(const Vector &x, const BoundaryTriangleSet * const triangle); 64 65 65 66 bool CheckListOfBaselines(const Tesselation * const TesselStruct); -
src/triangleintersectionlist.cpp
re588312 rb5c53d 16 16 17 17 #include "Helpers/Info.hpp" 18 #include "BoundaryMaps.hpp" 19 #include "BoundaryPointSet.hpp" 20 #include "BoundaryLineSet.hpp" 21 #include "BoundaryTriangleSet.hpp" 18 22 #include "tesselation.hpp" 19 23 #include "LinearAlgebra/Vector.hpp" … … 23 27 * 24 28 */ 25 TriangleIntersectionList::TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC) :29 TriangleIntersectionList::TriangleIntersectionList(const Vector &x, const Tesselation *surface, const LinkedCell* LC) : 26 30 Point(x), 27 31 Tess(surface), … … 70 74 } 71 75 // return reference, if none can be found 72 return *Point;76 return Point; 73 77 }; 74 78 … … 99 103 if (runner != IntersectionList.end()) { 100 104 // if we have found one, check Scalarproduct between the vector 101 Vector TestVector = ( *Point) - (*(*runner).second);105 Vector TestVector = (Point) - (*(*runner).second); 102 106 if (fabs(TestVector.NormSquared()) < MYEPSILON) // 103 107 return true; … … 138 142 // get intersection with triangle plane 139 143 Intersection = new Vector; 140 (*TriangleRunner)->GetClosestPointInsideTriangle(Point, Intersection);141 //Log() << Verbose(1) << "Intersection between " << *Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl;144 (*TriangleRunner)->GetClosestPointInsideTriangle(Point, *Intersection); 145 //Log() << Verbose(1) << "Intersection between " << Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl; 142 146 IntersectionList.insert( pair<BoundaryTriangleSet *, Vector * > (*TriangleRunner, Intersection) ); 143 147 } … … 151 155 if (DistanceList.empty()) 152 156 for (TriangleVectorMap::const_iterator runner = IntersectionList.begin(); runner != IntersectionList.end(); runner++) 153 DistanceList.insert( pair<double, BoundaryTriangleSet *> (Point ->distance(*(*runner).second), (*runner).first) );157 DistanceList.insert( pair<double, BoundaryTriangleSet *> (Point.distance(*(*runner).second), (*runner).first) ); 154 158 155 159 //for (DistanceTriangleMap::const_iterator runner = DistanceList.begin(); runner != DistanceList.end(); runner++) -
src/triangleintersectionlist.hpp
re588312 rb5c53d 39 39 { 40 40 public: 41 TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC);41 TriangleIntersectionList(const Vector &x, const Tesselation *surface, const LinkedCell* LC); 42 42 ~TriangleIntersectionList(); 43 43 … … 52 52 void FillDistanceList() const; 53 53 54 const Vector *Point;54 const Vector &Point; 55 55 const Tesselation *Tess; 56 56 const LinkedCell *Vicinity; -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
re588312 rb5c53d 53 53 TestMolecule = World::getInstance().createMolecule(); 54 54 Walker = World::getInstance().createAtom(); 55 Walker-> type = hydrogen;56 *Walker->node = Vector(1., 0., 1.);55 Walker->setType(hydrogen); 56 Walker->setPosition(Vector(1., 0., 1. )); 57 57 TestMolecule->AddAtom(Walker); 58 58 Walker = World::getInstance().createAtom(); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(0., 1., 1.);59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(0., 1., 1. )); 61 61 TestMolecule->AddAtom(Walker); 62 62 Walker = World::getInstance().createAtom(); 63 Walker-> type = hydrogen;64 *Walker->node = Vector(1., 1., 0.);63 Walker->setType(hydrogen); 64 Walker->setPosition(Vector(1., 1., 0. )); 65 65 TestMolecule->AddAtom(Walker); 66 66 Walker = World::getInstance().createAtom(); 67 Walker-> type = hydrogen;68 *Walker->node = Vector(0., 0., 0.);67 Walker->setType(hydrogen); 68 Walker->setPosition(Vector(0., 0., 0. )); 69 69 TestMolecule->AddAtom(Walker); 70 70 -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
re588312 rb5c53d 44 44 ASSERT_DO(Assert::Throw); 45 45 46 setVerbosity(5); 47 46 48 atom *Walker = NULL; 47 49 … … 62 64 63 65 Walker = World::getInstance().createAtom(); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(1., 0., 1.);66 TestSurfaceMolecule->AddAtom(Walker); 67 68 Walker = World::getInstance().createAtom(); 69 Walker-> type = hydrogen;70 *Walker->node = Vector(0., 1., 1.);71 TestSurfaceMolecule->AddAtom(Walker); 72 73 Walker = World::getInstance().createAtom(); 74 Walker-> type = hydrogen;75 *Walker->node = Vector(1., 1., 0.);76 TestSurfaceMolecule->AddAtom(Walker); 77 78 Walker = World::getInstance().createAtom(); 79 Walker-> type = hydrogen;80 *Walker->node = Vector(0., 0., 0.);66 Walker->setType(hydrogen); 67 Walker->setPosition(Vector(1., 0., 1. )); 68 TestSurfaceMolecule->AddAtom(Walker); 69 70 Walker = World::getInstance().createAtom(); 71 Walker->setType(hydrogen); 72 Walker->setPosition(Vector(0., 1., 1. )); 73 TestSurfaceMolecule->AddAtom(Walker); 74 75 Walker = World::getInstance().createAtom(); 76 Walker->setType(hydrogen); 77 Walker->setPosition(Vector(1., 1., 0. )); 78 TestSurfaceMolecule->AddAtom(Walker); 79 80 Walker = World::getInstance().createAtom(); 81 Walker->setType(hydrogen); 82 Walker->setPosition(Vector(0., 0., 0. )); 81 83 TestSurfaceMolecule->AddAtom(Walker); 82 84 … … 95 97 TestSurfaceMolecule = World::getInstance().createMolecule(); 96 98 Walker = World::getInstance().createAtom(); 97 Walker-> type = carbon;98 *Walker->node = Vector(4., 0., 4.);99 TestSurfaceMolecule->AddAtom(Walker); 100 101 Walker = World::getInstance().createAtom(); 102 Walker-> type = carbon;103 *Walker->node = Vector(0., 4., 4.);104 TestSurfaceMolecule->AddAtom(Walker); 105 106 Walker = World::getInstance().createAtom(); 107 Walker-> type = carbon;108 *Walker->node = Vector(4., 4., 0.);99 Walker->setType(carbon); 100 Walker->setPosition(Vector(4., 0., 4. )); 101 TestSurfaceMolecule->AddAtom(Walker); 102 103 Walker = World::getInstance().createAtom(); 104 Walker->setType(carbon); 105 Walker->setPosition(Vector(0., 4., 4. )); 106 TestSurfaceMolecule->AddAtom(Walker); 107 108 Walker = World::getInstance().createAtom(); 109 Walker->setType(carbon); 110 Walker->setPosition(Vector(4., 4., 0. )); 109 111 TestSurfaceMolecule->AddAtom(Walker); 110 112 111 113 // add inner atoms 112 114 Walker = World::getInstance().createAtom(); 113 Walker-> type = carbon;114 *Walker->node = Vector(0.5, 0.5, 0.5);115 Walker->setType(carbon); 116 Walker->setPosition(Vector(0.5, 0.5, 0.5 )); 115 117 TestSurfaceMolecule->AddAtom(Walker); 116 118 -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
re588312 rb5c53d 58 58 TestMolecule = World::getInstance().createMolecule(); 59 59 Walker = World::getInstance().createAtom(); 60 Walker-> type = hydrogen;61 *Walker->node = Vector(1., 0., 1.);60 Walker->setType(hydrogen); 61 Walker->setPosition(Vector(1., 0., 1. )); 62 62 TestMolecule->AddAtom(Walker); 63 63 Walker = World::getInstance().createAtom(); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(0., 1., 1.);64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(0., 1., 1. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 Walker = World::getInstance().createAtom(); 68 Walker-> type = hydrogen;69 *Walker->node = Vector(1., 1., 0.);68 Walker->setType(hydrogen); 69 Walker->setPosition(Vector(1., 1., 0. )); 70 70 TestMolecule->AddAtom(Walker); 71 71 Walker = World::getInstance().createAtom(); 72 Walker-> type = hydrogen;73 *Walker->node = Vector(0., 0., 0.);72 Walker->setType(hydrogen); 73 Walker->setPosition(Vector(0., 0., 0. )); 74 74 TestMolecule->AddAtom(Walker); 75 75 -
src/unittests/AtomDescriptorTest.hpp
re588312 rb5c53d 13 13 #include "types.hpp" 14 14 15 #define ATOM_COUNT (10) 15 // we prefer enum over define 16 enum { ATOM_COUNT = 10 }; 16 17 17 18 class atom; -
src/unittests/CountBondsUnitTest.cpp
re588312 rb5c53d 54 54 Walker = World::getInstance().createAtom(); 55 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 56 Walker-> type = hydrogen;57 *Walker->node = Vector(-0.2418, 0.9350, 0.);56 Walker->setType(hydrogen); 57 Walker->setPosition(Vector(-0.2418, 0.9350, 0. )); 58 58 TestMolecule1->AddAtom(Walker); 59 59 Walker = World::getInstance().createAtom(); 60 60 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 61 Walker-> type = hydrogen;62 *Walker->node = Vector(0.9658, 0., 0.);61 Walker->setType(hydrogen); 62 Walker->setPosition(Vector(0.9658, 0., 0. )); 63 63 TestMolecule1->AddAtom(Walker); 64 64 Walker = World::getInstance().createAtom(); 65 65 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 66 Walker-> type = oxygen;67 *Walker->node = Vector(0., 0., 0.);66 Walker->setType(oxygen); 67 Walker->setPosition(Vector(0., 0., 0. )); 68 68 TestMolecule1->AddAtom(Walker); 69 69 … … 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = hydrogen;75 *Walker->node = Vector(-0.2418, 0.9350, 0.);74 Walker->setType(hydrogen); 75 Walker->setPosition(Vector(-0.2418, 0.9350, 0. )); 76 76 TestMolecule2->AddAtom(Walker); 77 77 Walker = World::getInstance().createAtom(); 78 78 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 79 Walker-> type = hydrogen;80 *Walker->node = Vector(0.9658, 0., 0.);79 Walker->setType(hydrogen); 80 Walker->setPosition(Vector(0.9658, 0., 0. )); 81 81 TestMolecule2->AddAtom(Walker); 82 82 Walker = World::getInstance().createAtom(); 83 83 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 84 Walker-> type = oxygen;85 *Walker->node = Vector(0., 0., 0.);84 Walker->setType(oxygen); 85 Walker->setPosition(Vector(0., 0., 0. )); 86 86 TestMolecule2->AddAtom(Walker); 87 87 -
src/unittests/LinkedCellUnitTest.cpp
re588312 rb5c53d 50 50 Walker = World::getInstance().createAtom(); 51 51 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 52 Walker-> type = hydrogen;53 *Walker->node = Vector(x, y, z);52 Walker->setType(hydrogen); 53 Walker->setPosition(Vector(x, y, z )); 54 54 TestMolecule->AddAtom(Walker); 55 55 } … … 192 192 atom *newAtom = World::getInstance().createAtom(); 193 193 newAtom->setName("test"); 194 newAtom-> x= Vector(1,1,1);194 newAtom->setPosition(Vector(1,1,1)); 195 195 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); 196 196 World::getInstance().destroyAtom(newAtom); … … 199 199 newAtom = World::getInstance().createAtom(); 200 200 newAtom->setName("test"); 201 newAtom-> x = Vector(0,-1,0);201 newAtom->setPosition(Vector(0,-1,0)); 202 202 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); 203 203 World::getInstance().destroyAtom(newAtom); … … 216 216 for (double z=0.5;z<3;z+=1.) { 217 217 tester = Vector(x,y,z); 218 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector( &tester) );218 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); 219 219 } 220 220 // check corners of each cell … … 224 224 tester= Vector(x,y,z); 225 225 cout << "Tester is at " << tester << "." << endl; 226 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector( &tester) );226 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); 227 227 } 228 228 // check out of bounds … … 232 232 tester = Vector(x,y,z); 233 233 cout << "The following test is supposed to fail and produce an ERROR." << endl; 234 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector( &tester) );234 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); 235 235 } 236 236 // check nonsense vectors 237 237 tester= Vector(-423598,3245978,29349); 238 238 cout << "The following test is supposed to fail and produce an ERROR." << endl; 239 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector( &tester) );239 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); 240 240 }; 241 241 … … 249 249 250 250 tester= Vector(0.5,0.5,0.5); 251 LC->SetIndexToVector( &tester);251 LC->SetIndexToVector(tester); 252 252 LC->GetNeighbourBounds(lower, upper); 253 253 for (int i=0;i<NDIM;i++) … … 268 268 // get all atoms 269 269 tester= Vector(1.5,1.5,1.5); 270 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );270 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 271 271 ListOfPoints = LC->GetallNeighbours(); 272 272 size = ListOfPoints->size(); … … 285 285 // get all atoms in one corner 286 286 tester= Vector(0.5, 0.5, 0.5); 287 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );287 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 288 288 ListOfPoints = LC->GetallNeighbours(); 289 289 size=ListOfPoints->size(); 290 290 CPPUNIT_ASSERT_EQUAL( (size_t)8, size ); 291 291 for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ 292 if (((*iter)-> x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2]<2)) {292 if (((*iter)->at(0) <2) && ((*iter)->at(1) <2) && ((*iter)->at(2) <2)) { 293 293 ListOfPoints->remove(*iter); 294 294 size--; … … 303 303 // get all atoms from one corner 304 304 tester = Vector(0.5, 0.5, 0.5); 305 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );305 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 306 306 ListOfPoints = LC->GetallNeighbours(3); 307 307 size=ListOfPoints->size(); … … 329 329 // get all points around central arom with radius 1. 330 330 tester= Vector(1.5,1.5,1.5); 331 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );331 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 332 332 ListOfPoints = LC->GetPointsInsideSphere(1., &tester); 333 333 size = ListOfPoints->size(); 334 334 CPPUNIT_ASSERT_EQUAL( (size_t)7, size ); 335 335 for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ 336 if (((*iter)-> x.DistanceSquared(tester) - 1.) < MYEPSILON ) {336 if (((*iter)->DistanceSquared(tester) - 1.) < MYEPSILON ) { 337 337 ListOfPoints->remove(*iter); 338 338 size--; -
src/unittests/MoleculeDescriptorTest.hpp
re588312 rb5c53d 13 13 #include "types.hpp" 14 14 15 #define MOLECULE_COUNT (10) 15 // we prefer enum over define 16 enum { MOLECULE_COUNT = 10 }; 16 17 17 18 class molecule; -
src/unittests/ParserUnitTest.cpp
re588312 rb5c53d 208 208 input << Tremolo_Atomdata2; 209 209 testParser->load(&input); 210 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))-> x[0]== 3.0);210 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0); 211 211 input.clear(); 212 212 } … … 219 219 input << Tremolo_velocity; 220 220 testParser->load(&input); 221 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))-> v[0] == 3.0);221 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->AtomicVelocity[0] == 3.0); 222 222 input.clear(); 223 223 } … … 271 271 // with the maximum number of fields and minimal information, default values are printed 272 272 atom* newAtom = World::getInstance().createAtom(); 273 newAtom-> type = World::getInstance().getPeriode()->FindElement(1);273 newAtom->setType(1); 274 274 testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion"); 275 275 testParser->save(&output); … … 304 304 atom *Walker = NULL; 305 305 Walker = World::getInstance().createAtom(); 306 Walker-> type = World::getInstance().getPeriode()->FindElement(8);307 Walker-> x = Vector(0,0,0);306 Walker->setType(8); 307 Walker->setPosition(Vector(0,0,0)); 308 308 Walker = World::getInstance().createAtom(); 309 Walker-> type = World::getInstance().getPeriode()->FindElement(1);310 Walker-> x = Vector(0.758602,0,0.504284);309 Walker->setType(1); 310 Walker->setPosition(Vector(0.758602,0,0.504284)); 311 311 Walker = World::getInstance().createAtom(); 312 Walker-> type = World::getInstance().getPeriode()->FindElement(1);313 Walker-> x = Vector(0.758602,0,-0.504284);312 Walker->setType(1); 313 Walker->setPosition(Vector(0.758602,0,-0.504284)); 314 314 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 315 315 -
src/unittests/analysisbondsunittest.cpp
re588312 rb5c53d 16 16 #include <cstring> 17 17 18 #include "World.hpp"19 18 #include "analysis_bonds.hpp" 20 19 #include "analysisbondsunittest.hpp" … … 25 24 #include "molecule.hpp" 26 25 #include "periodentafel.hpp" 26 #include "LinearAlgebra/Vector.hpp" 27 27 #include "World.hpp" 28 28 … … 52 52 Walker = World::getInstance().createAtom(); 53 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker-> type = hydrogen;55 *Walker->node = Vector(1.5, 0., 1.5);54 Walker->setType(hydrogen); 55 Walker->setPosition(Vector(1.5, 0., 1.5 )); 56 56 TestMolecule->AddAtom(Walker); 57 57 Walker = World::getInstance().createAtom(); 58 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(0., 1.5, 1.5);59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(0., 1.5, 1.5 )); 61 61 TestMolecule->AddAtom(Walker); 62 62 Walker = World::getInstance().createAtom(); 63 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(1.5, 1.5, 0.);64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(1.5, 1.5, 0. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 Walker = World::getInstance().createAtom(); 68 68 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 69 Walker-> type = hydrogen;70 *Walker->node = Vector(0., 0., 0.);69 Walker->setType(hydrogen); 70 Walker->setPosition(Vector(0., 0., 0. )); 71 71 TestMolecule->AddAtom(Walker); 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = carbon;75 *Walker->node = Vector(0.5, 0.5, 0.5);74 Walker->setType(carbon); 75 Walker->setPosition(Vector(0.5, 0.5, 0.5 )); 76 76 TestMolecule->AddAtom(Walker); 77 77 -
src/unittests/atomsCalculationTest.hpp
re588312 rb5c53d 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 #define ATOM_COUNT (10) 13 // we prefer enum over define 14 enum { ATOM_COUNT = 10 }; 14 15 15 16 #include "types.hpp" -
src/unittests/bondgraphunittest.cpp
re588312 rb5c53d 54 54 Walker = World::getInstance().createAtom(); 55 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 56 Walker-> type = carbon;57 *Walker->node = Vector(1., 0., 1.);56 Walker->setType(carbon); 57 Walker->setPosition(Vector(1., 0., 1. )); 58 58 TestMolecule->AddAtom(Walker); 59 59 60 60 Walker = World::getInstance().createAtom(); 61 61 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 62 Walker-> type = carbon;63 *Walker->node = Vector(0., 1., 1.);62 Walker->setType(carbon); 63 Walker->setPosition(Vector(0., 1., 1. )); 64 64 TestMolecule->AddAtom(Walker); 65 65 66 66 Walker = World::getInstance().createAtom(); 67 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 68 Walker-> type = carbon;69 *Walker->node = Vector(1., 1., 0.);68 Walker->setType(carbon); 69 Walker->setPosition(Vector(1., 1., 0. )); 70 70 TestMolecule->AddAtom(Walker); 71 71 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = carbon;75 *Walker->node = Vector(0., 0., 0.);74 Walker->setType(carbon); 75 Walker->setPosition(Vector(0., 0., 0. )); 76 76 TestMolecule->AddAtom(Walker); 77 77 -
src/unittests/listofbondsunittest.cpp
re588312 rb5c53d 47 47 Walker = World::getInstance().createAtom(); 48 48 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 49 Walker-> type = hydrogen;50 *Walker->node = Vector(1., 0., 1.);51 TestMolecule->AddAtom(Walker); 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker-> type = hydrogen;55 *Walker->node = Vector(0., 1., 1.);56 TestMolecule->AddAtom(Walker); 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(1., 1., 0.);61 TestMolecule->AddAtom(Walker); 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(0., 0., 0.);49 Walker->setType(hydrogen); 50 Walker->setPosition(Vector(1., 0., 1. )); 51 TestMolecule->AddAtom(Walker); 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker->setType(hydrogen); 55 Walker->setPosition(Vector(0., 1., 1. )); 56 TestMolecule->AddAtom(Walker); 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(1., 1., 0. )); 61 TestMolecule->AddAtom(Walker); 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(0., 0., 0. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 -
src/unittests/manipulateAtomsTest.hpp
re588312 rb5c53d 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 #define ATOM_COUNT (10) 13 // we prefer enum over define 14 enum { ATOM_COUNT = 10 }; 14 15 15 16 class atom; -
src/unittests/tesselation_boundarytriangleunittest.cpp
re588312 rb5c53d 13 13 14 14 #include <cstring> 15 #include <iostream> 15 16 16 17 #include "defs.hpp" 17 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryPointSet.hpp" 20 #include "BoundaryLineSet.hpp" 21 #include "BoundaryTriangleSet.hpp" 22 #include "CandidateForTesselation.hpp" 18 23 #include "tesselation_boundarytriangleunittest.hpp" 19 24 … … 22 27 #endif /*HAVE_TESTRUNNER*/ 23 28 24 #define SPHERERADIUS 2. 29 const double TesselationBoundaryTriangleTest::SPHERERADIUS=2.; 25 30 26 31 /********************************************** Test classes **************************************/ … … 36 41 // create nodes 37 42 tesselpoints[0] = new TesselPoint; 38 tesselpoints[0]-> node = new Vector(0., 0., 0.);43 tesselpoints[0]->setPosition(Vector(0., 0., 0.)); 39 44 tesselpoints[0]->setName("1"); 40 45 tesselpoints[0]->nr = 1; 41 46 points[0] = new BoundaryPointSet(tesselpoints[0]); 42 47 tesselpoints[1] = new TesselPoint; 43 tesselpoints[1]-> node = new Vector(0., 1., 0.);48 tesselpoints[1]->setPosition(Vector(0., 1., 0.)); 44 49 tesselpoints[1]->setName("2"); 45 50 tesselpoints[1]->nr = 2; 46 51 points[1] = new BoundaryPointSet(tesselpoints[1]); 47 52 tesselpoints[2] = new TesselPoint; 48 tesselpoints[2]-> node = new Vector(1., 0., 0.);53 tesselpoints[2]->setPosition(Vector(1., 0., 0.)); 49 54 tesselpoints[2]->setName("3"); 50 55 tesselpoints[2]->nr = 3; … … 67 72 for (int i=0;i<3;++i) { 68 73 // TesselPoint does not delete its vector as it only got a reference 69 delete tesselpoints[i]->node;70 74 delete tesselpoints[i]; 71 75 } … … 83 87 // simple test on y line 84 88 Point = Vector(-1.,0.5,0.); 85 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );89 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 86 90 Point = Vector(0.,0.5,0.); 87 91 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 88 92 Point = Vector(-4.,0.5,0.); 89 CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );93 CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 90 94 Point = Vector(0.,0.5,0.); 91 95 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 93 97 // simple test on x line 94 98 Point = Vector(0.5,-1.,0.); 95 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );99 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 96 100 Point = Vector(0.5,0.,0.); 97 101 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 98 102 Point = Vector(0.5,-6.,0.); 99 CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );103 CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 100 104 Point = Vector(0.5,0.,0.); 101 105 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 103 107 // simple test on slanted line 104 108 Point = Vector(1.,1.,0.); 105 CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );109 CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 106 110 Point = Vector(0.5,0.5,0.); 107 111 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 108 112 Point = Vector(5.,5.,0.); 109 CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );113 CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 110 114 Point = Vector(0.5,0.5,0.); 111 115 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 113 117 // simple test on first node 114 118 Point = Vector(-1.,-1.,0.); 115 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );119 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 116 120 Point = Vector(0.,0.,0.); 117 121 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 119 123 // simple test on second node 120 124 Point = Vector(0.,2.,0.); 121 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );125 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 122 126 Point = Vector(0.,1.,0.); 123 127 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 125 129 // simple test on third node 126 130 Point = Vector(2.,0.,0.); 127 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );131 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 128 132 Point = Vector(1.,0.,0.); 129 133 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 139 143 // straight down/up 140 144 Point = Vector(1./3.,1./3.,+5.); 141 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );145 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 142 146 Point = Vector(1./3.,1./3.,0.); 143 147 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 144 148 Point = Vector(1./3.,1./3.,-5.); 145 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );149 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 146 150 Point = Vector(1./3.,1./3.,0.); 147 151 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 149 153 // simple test on y line 150 154 Point = Vector(-1.,0.5,+2.); 151 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );155 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 152 156 Point = Vector(0.,0.5,0.); 153 157 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 154 158 Point = Vector(-1.,0.5,-3.); 155 CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );159 CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 156 160 Point = Vector(0.,0.5,0.); 157 161 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 159 163 // simple test on x line 160 164 Point = Vector(0.5,-1.,+1.); 161 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );165 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 162 166 Point = Vector(0.5,0.,0.); 163 167 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 164 168 Point = Vector(0.5,-1.,-2.); 165 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );169 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 166 170 Point = Vector(0.5,0.,0.); 167 171 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 169 173 // simple test on slanted line 170 174 Point = Vector(1.,1.,+3.); 171 CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );175 CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 172 176 Point = Vector(0.5,0.5,0.); 173 177 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 174 178 Point = Vector(1.,1.,-4.); 175 CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );179 CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 176 180 Point = Vector(0.5,0.5,0.); 177 181 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 179 183 // simple test on first node 180 184 Point = Vector(-1.,-1.,5.); 181 CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );185 CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 182 186 Point = Vector(0.,0.,0.); 183 187 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 185 189 // simple test on second node 186 190 Point = Vector(0.,2.,5.); 187 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );191 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 188 192 Point = Vector(0.,1.,0.); 189 193 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 191 195 // simple test on third node 192 196 Point = Vector(2.,0.,5.); 193 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );197 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 194 198 Point = Vector(1.,0.,0.); 195 199 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); -
src/unittests/tesselation_boundarytriangleunittest.hpp
re588312 rb5c53d 16 16 #include "tesselation.hpp" 17 17 18 class TesselPoint; 19 18 20 /********************************************** Test classes **************************************/ 19 21 … … 32 34 33 35 private: 36 static const double SPHERERADIUS; 37 34 38 class BoundaryTriangleSet *triangle; 35 39 class BoundaryLineSet *lines[3]; -
src/unittests/tesselation_insideoutsideunittest.cpp
re588312 rb5c53d 13 13 14 14 #include <cstring> 15 #include <iostream> 15 16 16 17 #include "defs.hpp" 17 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryLineSet.hpp" 20 #include "BoundaryTriangleSet.hpp" 21 #include "CandidateForTesselation.hpp" 18 22 #include "tesselation_insideoutsideunittest.hpp" 19 23 #include "Helpers/Verbose.hpp" … … 23 27 #endif /*HAVE_TESTRUNNER*/ 24 28 25 #define SPHERERADIUS 2. 29 const double TesselationInOutsideTest::SPHERERADIUS=2.; 26 30 27 31 /********************************************** Test classes **************************************/ … … 29 33 // Registers the fixture into the 'registry' 30 34 CPPUNIT_TEST_SUITE_REGISTRATION( TesselationInOutsideTest ); 31 32 35 33 36 void TesselationInOutsideTest::setUp() … … 38 41 class TesselPoint *Walker; 39 42 Walker = new TesselPoint; 40 Walker-> node = new Vector(0., 0., 0.);43 Walker->setPosition(Vector(0., 0., 0.)); 41 44 Walker->setName("1"); 42 45 Walker->nr = 1; 43 46 Corners.push_back(Walker); 44 47 Walker = new TesselPoint; 45 Walker-> node = new Vector(0., 1., 0.);48 Walker->setPosition(Vector(0., 1., 0.)); 46 49 Walker->setName("2"); 47 50 Walker->nr = 2; 48 51 Corners.push_back(Walker); 49 52 Walker = new TesselPoint; 50 Walker-> node = new Vector(1., 0., 0.);53 Walker->setPosition(Vector(1., 0., 0.)); 51 54 Walker->setName("3"); 52 55 Walker->nr = 3; 53 56 Corners.push_back(Walker); 54 57 Walker = new TesselPoint; 55 Walker-> node = new Vector(1., 1., 0.);58 Walker->setPosition(Vector(1., 1., 0.)); 56 59 Walker->setName("4"); 57 60 Walker->nr = 4; 58 61 Corners.push_back(Walker); 59 62 Walker = new TesselPoint; 60 Walker-> node = new Vector(0., 0., 1.);63 Walker->setPosition(Vector(0., 0., 1.)); 61 64 Walker->setName("5"); 62 65 Walker->nr = 5; 63 66 Corners.push_back(Walker); 64 67 Walker = new TesselPoint; 65 Walker-> node = new Vector(0., 1., 1.);68 Walker->setPosition(Vector(0., 1., 1.)); 66 69 Walker->setName("6"); 67 70 Walker->nr = 6; 68 71 Corners.push_back(Walker); 69 72 Walker = new TesselPoint; 70 Walker-> node = new Vector(1., 0., 1.);73 Walker->setPosition(Vector(1., 0., 1.)); 71 74 Walker->setName("7"); 72 75 Walker->nr = 7; 73 76 Corners.push_back(Walker); 74 77 Walker = new TesselPoint; 75 Walker-> node = new Vector(1., 1., 1.);78 Walker->setPosition(Vector(1., 1., 1.)); 76 79 Walker->setName("8"); 77 80 Walker->nr = 8; … … 130 133 delete(LinkedList); 131 134 delete(TesselStruct); 132 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 133 delete((*Runner)->node); 135 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 134 136 delete(*Runner); 135 }136 137 Corners.clear(); 137 138 logger::purgeInstance(); -
src/unittests/tesselation_insideoutsideunittest.hpp
re588312 rb5c53d 30 30 31 31 private: 32 static const double SPHERERADIUS; 33 32 34 class Tesselation *TesselStruct; 33 35 LinkedCell::LinkedNodes Corners; -
src/unittests/tesselationunittest.cpp
re588312 rb5c53d 16 16 17 17 #include "defs.hpp" 18 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryLineSet.hpp" 20 #include "BoundaryTriangleSet.hpp" 21 #include "CandidateForTesselation.hpp" 19 22 #include "tesselationunittest.hpp" 20 23 … … 23 26 #endif /*HAVE_TESTRUNNER*/ 24 27 25 #define SPHERERADIUS 2. 28 const double TesselationTest::SPHERERADIUS=2.; 26 29 27 30 /********************************************** Test classes **************************************/ … … 36 39 class TesselPoint *Walker; 37 40 Walker = new TesselPoint; 38 Walker-> node = new Vector(1., 0., -1.);41 Walker->setPosition(Vector(1., 0., -1.)); 39 42 Walker->setName("1"); 40 43 Walker->nr = 1; 41 44 Corners.push_back(Walker); 42 45 Walker = new TesselPoint; 43 Walker-> node = new Vector(-1., 1., -1.);46 Walker->setPosition(Vector(-1., 1., -1.)); 44 47 Walker->setName("2"); 45 48 Walker->nr = 2; 46 49 Corners.push_back(Walker); 47 50 Walker = new TesselPoint; 48 Walker-> node = new Vector(-1., -1., -1.);51 Walker->setPosition(Vector(-1., -1., -1.)); 49 52 Walker->setName("3"); 50 53 Walker->nr = 3; 51 54 Corners.push_back(Walker); 52 55 Walker = new TesselPoint; 53 Walker-> node = new Vector(-1., 0., 1.);56 Walker->setPosition(Vector(-1., 0., 1.)); 54 57 Walker->setName("4"); 55 58 Walker->nr = 4; … … 101 104 delete(LinkedList); 102 105 delete(TesselStruct); 103 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 104 delete((*Runner)->node); 106 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 105 107 delete(*Runner); 106 }107 108 Corners.clear(); 108 109 logger::purgeInstance(); -
src/unittests/tesselationunittest.hpp
re588312 rb5c53d 33 33 34 34 private: 35 static const double SPHERERADIUS; 36 35 37 class Tesselation *TesselStruct; 36 38 LinkedCell::LinkedNodes Corners; -
src/unittests/vectorunittest.cpp
re588312 rb5c53d 16 16 #include "Helpers/Log.hpp" 17 17 #include "LinearAlgebra/Vector.hpp" 18 #include " vector_ops.hpp"18 #include "LinearAlgebra/vector_ops.hpp" 19 19 #include "vectorunittest.hpp" 20 20 #include "LinearAlgebra/Plane.hpp" … … 52 52 errorLogger::purgeInstance(); 53 53 }; 54 55 /** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne(). 56 */ 57 void VectorTest::AssignmentTest() 58 { 59 // test with zero 60 zero.at(0) = 0; 61 zero.at(1) = 0; 62 zero.at(2) = 0; 63 double zero_array[3] = {0., 0., 0.}; 64 65 CPPUNIT_ASSERT_EQUAL( zero, Vector(0,0,0)); 66 CPPUNIT_ASSERT_EQUAL( zero, Vector(0.,0.,0.)); 67 CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array[0], zero_array[1], zero_array[2])); 68 CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array)); 69 70 // test with unit 71 unit.at(0) = 1; 72 unit.at(1) = 0; 73 unit.at(2) = 0; 74 double unit_array[3] = {1., 0., 0.}; 75 76 CPPUNIT_ASSERT_EQUAL( unit, Vector(1,0,0)); 77 CPPUNIT_ASSERT_EQUAL( unit, Vector(1.,0.,0.)); 78 CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array[0], unit_array[1], unit_array[2])); 79 CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array)); 80 81 // test with two 82 two.at(0) = 2; 83 two.at(1) = 1; 84 two.at(2) = 0; 85 double two_array[3] = {2., 1., 0.}; 86 87 CPPUNIT_ASSERT_EQUAL( two, Vector(2,1,0)); 88 CPPUNIT_ASSERT_EQUAL( two, Vector(2.,1.,0.)); 89 CPPUNIT_ASSERT_EQUAL( two, Vector(two_array[0], two_array[1], two_array[2])); 90 CPPUNIT_ASSERT_EQUAL( two, Vector(two_array)); 91 92 // test with three 93 three.at(0) = 1; 94 three.at(1) = 2; 95 three.at(2) = 3; 96 double three_array[3] = {1., 2., 3.}; 97 98 CPPUNIT_ASSERT_EQUAL( three, Vector(1,2,3)); 99 CPPUNIT_ASSERT_EQUAL( three, Vector(1.,2.,3.)); 100 CPPUNIT_ASSERT_EQUAL( three, Vector(three_array[0], three_array[1], three_array[2])); 101 CPPUNIT_ASSERT_EQUAL( three, Vector(three_array)); 102 } 54 103 55 104 /** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne(). -
src/unittests/vectorunittest.hpp
re588312 rb5c53d 18 18 { 19 19 CPPUNIT_TEST_SUITE( VectorTest) ; 20 CPPUNIT_TEST ( AssignmentTest ); 20 21 CPPUNIT_TEST ( UnityTest ); 21 22 CPPUNIT_TEST ( SimpleAlgebraTest ); … … 33 34 void tearDown(); 34 35 36 void AssignmentTest(); 35 37 void UnityTest(); 36 38 void OperatorAlgebraTest(); -
tests/Tesselations/defs.in
re588312 rb5c53d 54 54 #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME." 55 55 if [ -e $mol.dbond ]; then 56 $MOLECUILDER $mol.conf -e $exec_prefix -p../$mol.xyz -A $mol.dbond --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?56 $MOLECUILDER -i ../$mol.xyz -A $mol.dbond --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 57 57 else 58 $MOLECUILDER $mol.conf -e $exec_prefix -p../$mol.xyz --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?58 $MOLECUILDER -i ../$mol.xyz --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 59 59 fi 60 60 #echo "Molecuilder done with exitcode $exitcode." -
tests/regression/Makefile.am
re588312 rb5c53d 3 3 TESTSUITE = $(srcdir)/testsuite 4 4 5 max_jobs = 4 6 5 7 check-local: atconfig atlocal package.m4 $(TESTSUITE) 6 $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) 8 nrjobs=; \ 9 for flag in $$MAKEFLAGS; do \ 10 case $$flag in \ 11 --* | =*=) ;; \ 12 *j*) nrjobs="-j$(max_jobs)" ;; \ 13 esac; \ 14 done; \ 15 $(SHELL) '$(TESTSUITE)' $$nrjobs $(TESTSUITEFLAGS) 7 16 8 17 installcheck-local: atconfig atlocal $(TESTSUITE) 9 10 11 18 $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ 19 $(TESTSUITEFLAGS) 20 12 21 clean-local: 13 14 22 test ! -f '$(TESTSUITE)' || \ 23 $(SHELL) '$(TESTSUITE)' --clean 15 24 16 25 AUTOTEST = $(AUTOM4TE) --language=autotest 17 26 $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/testsuite-*.at 18 19 27 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at 28 mv $@.tmp $@ 20 29 21 30 # The `:;' works around a Bash 3.2 bug when the output is not writeable. 22 31 $(srcdir)/package.m4: $(top_srcdir)/configure.ac 23 24 25 26 27 28 29 30 32 :;{ \ 33 echo '# Signature of the current package.' && \ 34 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])' && \ 35 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])' && \ 36 echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])' && \ 37 echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])' && \ 38 echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ 39 } >'$(srcdir)/package.m4' -
tests/regression/testsuite-molecules.at
re588312 rb5c53d 61 61 62 62 # 8. Rotate to PAS 63 AT_SETUP([Molecules - BROKEN:Rotate to PAS])63 AT_SETUP([Molecules - Rotate to PAS]) 64 64 AT_KEYWORDS([Molecules]) 65 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test.* .], 0) 66 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m 0], 0, [stdout], [stderr]) 67 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 65 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test-*.xyz .], 0) 66 AT_CHECK([../../molecuilder -i test-rotated-z90.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 67 AT_CHECK([file="test-rotated-z90.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 68 AT_CHECK([../../molecuilder -i test-rotated-z180.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 69 AT_CHECK([file="test-rotated-z180.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 70 AT_CHECK([../../molecuilder -i test-rotated-z360.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 71 AT_CHECK([file="test-rotated-z360.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 72 AT_CHECK([../../molecuilder -i test-rotated-xYz20.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 73 AT_CHECK([file="test-rotated-xYz20.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 68 74 AT_CLEANUP 69 75 76 # 9. Rotate around origin 77 AT_SETUP([Molecules - Rotate around origin]) 78 AT_KEYWORDS([Molecules]) 79 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0) 80 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 90. --position "0,0,1"], 0, [stdout], [stderr]) 81 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z90.xyz], 0, [ignore], [ignore]) 82 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0) 83 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 180. --position "0,0,1"], 0, [stdout], [stderr]) 84 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z180.xyz], 0, [ignore], [ignore]) 85 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0) 86 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 360. --position "0,0,1"], 0, [stdout], [stderr]) 87 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z360.xyz], 0, [ignore], [ignore]) 88 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz], 0, [ignore], [ignore]) 89 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0) 90 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 20. --position "1,2,1"], 0, [stdout], [stderr]) 91 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-xYz20.xyz], 0, [ignore], [ignore]) 92 AT_CLEANUP 93 94 # 9. Rotate around self 95 AT_SETUP([Molecules - Rotate around self]) 96 AT_KEYWORDS([Molecules]) 97 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0) 98 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 90. --position "0,0,1"], 0, [stdout], [stderr]) 99 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z90.xyz], 0, [ignore], [ignore]) 100 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0) 101 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 180. --position "0,0,1"], 0, [stdout], [stderr]) 102 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z180.xyz], 0, [ignore], [ignore]) 103 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0) 104 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 360. --position "0,0,1"], 0, [stdout], [stderr]) 105 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z360.xyz], 0, [ignore], [ignore]) 106 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz], 0, [ignore], [ignore]) 107 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0) 108 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 20. --position "1,2,1"], 0, [stdout], [stderr]) 109 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-xYz20.xyz], 0, [ignore], [ignore]) 110 AT_CLEANUP 111
Note:
See TracChangeset
for help on using the changeset viewer.