Changes in / [ba9f5b:be97a8]
- Files:
-
- 29 added
- 5 deleted
- 124 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionRegistry.hpp
rba9f5b rbe97a8 9 9 #define ACTIONREGISTRY_HPP_ 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 #include <string> 13 13 #include <map> -
src/Actions/AnalysisAction/PairCorrelationAction.cpp
rba9f5b rbe97a8 12 12 #include "boundary.hpp" 13 13 #include "linkedcell.hpp" 14 #include "verbose.hpp" 14 15 #include "log.hpp" 15 16 #include "element.hpp" … … 67 68 dialog = UIFactory::getInstance().makeDialog(); 68 69 if (type == "P") 69 dialog->queryVector("position", &Point, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription("position"));70 dialog->queryVector("position", &Point, false, MapOfActions::getInstance().getDescription("position")); 70 71 if (type == "S") 71 72 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id")); -
src/Actions/AtomAction/AddAction.cpp
rba9f5b rbe97a8 41 41 42 42 dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME)); 43 dialog->queryVector("position", &position, World::getInstance().getDomain(),true, MapOfActions::getInstance().getDescription("position"));43 dialog->queryVector("position", &position, true, MapOfActions::getInstance().getDescription("position")); 44 44 cout << "pre-dialog" << endl; 45 45 -
src/Actions/AtomsCalculation_impl.hpp
rba9f5b rbe97a8 11 11 #include "Actions/AtomsCalculation.hpp" 12 12 #include "Actions/Calculation_impl.hpp" 13 14 #include <iostream>15 13 16 14 using namespace std; … … 35 33 Process::setMaxSteps(steps); 36 34 Process::start(); 37 for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){ 35 for(World::internal_AtomIterator 36 iter=world->getAtomIter_internal(descr); 37 iter!=world->atomEnd_internal(); 38 ++iter){ 39 38 40 Process::setCurrStep(iter.getCount()); 39 41 res->push_back(op(*iter)); -
src/Actions/ManipulateAtomsProcess.cpp
rba9f5b rbe97a8 53 53 setMaxSteps(world->numAtoms()); 54 54 start(); 55 for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){ 55 for(World::internal_AtomIterator 56 iter=world->getAtomIter_internal(descr); 57 iter!=world->atomEnd_internal(); 58 ++iter){ 59 56 60 setCurrStep(iter.getCount()); 57 61 operation(*iter); -
src/Actions/MapOfActions.cpp
rba9f5b rbe97a8 17 17 #include <boost/optional.hpp> 18 18 #include <boost/program_options.hpp> 19 20 #include <iostream> 19 21 20 22 #include "CommandLineParser.hpp" … … 321 323 TypeMap["MaxDistance"] = Double; 322 324 TypeMap["molecule-by-id"] = Molecule; 323 TypeMap["molecule-by-name"] = Molecule;325 TypeMap["molecule-by-name"] = String; 324 326 TypeMap["nonconvex-file"] = String; 325 327 TypeMap["order"] = Integer; -
src/Actions/MoleculeAction/BondFileAction.cpp
rba9f5b rbe97a8 24 24 #include "config.hpp" 25 25 #include "defs.hpp" 26 #include "verbose.hpp" 26 27 #include "log.hpp" 27 28 #include "molecule.hpp" -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
rba9f5b rbe97a8 62 62 63 63 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 64 dialog->queryVector("distances", &distances, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription("distances"));65 dialog->queryVector("lengths", &lengths, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription("lengths"));64 dialog->queryVector("distances", &distances, false, MapOfActions::getInstance().getDescription("distances")); 65 dialog->queryVector("lengths", &lengths, false, MapOfActions::getInstance().getDescription("lengths")); 66 66 dialog->queryBoolean("DoRotate", &DoRotate, MapOfActions::getInstance().getDescription("DoRotate")); 67 67 dialog->queryDouble("MaxDistance", &MaxDistance, MapOfActions::getInstance().getDescription("MaxDistance")); -
src/Actions/MoleculeAction/SuspendInWaterAction.cpp
rba9f5b rbe97a8 22 22 #include "boundary.hpp" 23 23 #include "config.hpp" 24 #include "verbose.hpp" 24 25 #include "log.hpp" 25 26 #include "config.hpp" -
src/Actions/MoleculeAction/TranslateAction.cpp
rba9f5b rbe97a8 55 55 bool periodic = false; 56 56 57 dialog->queryVector(NAME, &x, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription(NAME));57 dialog->queryVector(NAME, &x, false, MapOfActions::getInstance().getDescription(NAME)); 58 58 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 59 59 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic")); -
src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
rba9f5b rbe97a8 41 41 int j=0; 42 42 43 dialog->queryVector(NAME, &boundary, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription(NAME));43 dialog->queryVector(NAME, &boundary, false, MapOfActions::getInstance().getDescription(NAME)); 44 44 45 45 if(dialog->display()) { … … 59 59 } 60 60 // set new box size 61 double * const cell_size = World::getInstance().getDomain();61 double * const cell_size = new double[6]; 62 62 for (j=0;j<6;j++) 63 63 cell_size[j] = 0.; … … 67 67 cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]); 68 68 } 69 World::getInstance().setDomain(cell_size); 70 delete[] cell_size; 69 71 // translate all atoms, such that Min is aty (0,0,0) 70 72 AtomRunner = AllAtoms.begin(); -
src/Actions/WorldAction/CenterInBoxAction.cpp
rba9f5b rbe97a8 34 34 Dialog *dialog = UIFactory::getInstance().makeDialog(); 35 35 36 double *cell_size = World::getInstance().getDomain();36 Box& cell_size = World::getInstance().getDomain(); 37 37 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 38 38 39 39 if(dialog->display()) { 40 World::getInstance().setDomain(cell_size);41 40 // center 42 41 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); -
src/Actions/WorldAction/CenterOnEdgeAction.cpp
rba9f5b rbe97a8 13 13 #include "vector.hpp" 14 14 #include "World.hpp" 15 #include "Matrix.hpp" 15 16 16 17 #include <iostream> … … 37 38 Vector Min; 38 39 Vector Max; 39 int j=0;40 40 41 41 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); … … 57 57 } 58 58 // set new box size 59 double * const cell_size = World::getInstance().getDomain(); 60 for (j=0;j<6;j++) 61 cell_size[j] = 0.; 62 j=-1; 59 Matrix domain; 63 60 for (int i=0;i<NDIM;i++) { 64 j += i+1; 65 cell_size[j] = (Max[i]-Min[i]); 61 double tmp = Max[i]-Min[i]; 62 tmp = fabs(tmp)>=1. ? tmp : 1.0; 63 domain.at(i,i) = tmp; 66 64 } 67 World::getInstance().setDomain( cell_size);65 World::getInstance().setDomain(domain); 68 66 // translate all atoms, such that Min is aty (0,0,0) 69 67 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) -
src/Actions/WorldAction/ChangeBoxAction.cpp
rba9f5b rbe97a8 12 12 #include "verbose.hpp" 13 13 #include "World.hpp" 14 #include "Box.hpp" 15 #include "Matrix.hpp" 14 16 15 17 #include <iostream> … … 34 36 Dialog *dialog = UIFactory::getInstance().makeDialog(); 35 37 36 double *cell_size = World::getInstance().getDomain();38 Box& cell_size = World::getInstance().getDomain(); 37 39 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 38 40 39 41 if(dialog->display()) { 40 DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size [0] << "," << cell_size[1] << "," << cell_size[2] << "," << cell_size[3] << "," << cell_size[4] << "," << cell_size[5] << ","<< endl);41 World::getInstance().setDomain(cell_size );42 DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size.getM() << endl); 43 World::getInstance().setDomain(cell_size.getM()); 42 44 delete dialog; 43 45 return Action::success; -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
rba9f5b rbe97a8 41 41 42 42 dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME)); 43 dialog->queryVector("position", &point, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription("position"));43 dialog->queryVector("position", &point, false, MapOfActions::getInstance().getDescription("position")); 44 44 45 45 if(dialog->display()) { -
src/Actions/WorldAction/RepeatBoxAction.cpp
rba9f5b rbe97a8 13 13 #include "molecule.hpp" 14 14 #include "vector.hpp" 15 #include "Matrix.hpp" 15 16 #include "verbose.hpp" 16 17 #include "World.hpp" 18 #include "Box.hpp" 17 19 18 20 #include <iostream> … … 46 48 MoleculeListClass *molecules = World::getInstance().getMolecules(); 47 49 48 dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription(NAME));50 dialog->queryVector(NAME, &Repeater, false, MapOfActions::getInstance().getDescription(NAME)); 49 51 //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id")); 50 52 vector<molecule *> AllMolecules; … … 59 61 if(dialog->display()) { 60 62 (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl); 61 double * const cell_size = World::getInstance().getDomain();62 double *M = ReturnFullMatrixforSymmetric(cell_size);63 Matrix M = World::getInstance().getDomain().getM(); 64 Matrix newM = M; 63 65 Vector x,y; 64 66 int n[NDIM]; 67 Matrix repMat; 65 68 for (int axis = 0; axis < NDIM; axis++) { 66 69 Repeater[axis] = floor(Repeater[axis]); … … 69 72 Repeater[axis] = 1; 70 73 } 71 cell_size[ ((axis == 1) ? 2 : (axis == 2) ? 5 : 0) ] *= Repeater[axis];74 repMat.at(axis,axis) = Repeater[axis]; 72 75 } 76 newM *= repMat; 77 World::getInstance().setDomain(newM); 73 78 74 World::getInstance().setDomain(cell_size);75 79 molecule *newmol = NULL; 76 80 Vector ** vectors = NULL; … … 99 103 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 100 104 x = y; 101 x .MatrixMultiplication(M);105 x *= M; 102 106 newmol = World::getInstance().createMolecule(); 103 107 molecules->insert(newmol); … … 119 123 } 120 124 } 121 delete(M);122 125 delete dialog; 123 126 return Action::success; -
src/Actions/WorldAction/ScaleBoxAction.cpp
rba9f5b rbe97a8 14 14 #include "verbose.hpp" 15 15 #include "World.hpp" 16 #include "Box.hpp" 17 #include "Matrix.hpp" 16 18 17 19 #include <iostream> … … 37 39 Vector Scaler; 38 40 double x[NDIM]; 39 int j=0;40 41 41 dialog->queryVector(NAME, &Scaler, World::getInstance().getDomain(),false, MapOfActions::getInstance().getDescription(NAME));42 dialog->queryVector(NAME, &Scaler, false, MapOfActions::getInstance().getDescription(NAME)); 42 43 43 44 if(dialog->display()) { … … 49 50 (*AtomRunner)->x.ScaleAll(x); 50 51 } 51 j = -1; 52 double * const cell_size = World::getInstance().getDomain(); 52 53 Matrix M = World::getInstance().getDomain().getM(); 54 Matrix scale; 55 53 56 for (int i=0;i<NDIM;i++) { 54 j += i+1; 55 cell_size[j]*=x[i]; 57 scale.at(i,i) = x[i]; 56 58 } 57 World::getInstance().setDomain(cell_size); 59 M *= scale; 60 World::getInstance().setDomain(M); 58 61 59 62 delete dialog; -
src/ConfigFileBuffer.cpp
rba9f5b rbe97a8 9 9 #include "helpers.hpp" 10 10 #include "lists.hpp" 11 #include "verbose.hpp" 11 12 #include "log.hpp" 12 13 #include "World.hpp" -
src/ConfigFileBuffer.hpp
rba9f5b rbe97a8 17 17 #endif 18 18 19 #include <ios tream>19 #include <iosfwd> 20 20 21 21 /****************************************** forward declarations *****************************/ -
src/Descriptors/AtomDescriptor.cpp
rba9f5b rbe97a8 13 13 #include "World.hpp" 14 14 #include "atom.hpp" 15 #include "Patterns/ObservedContainer_impl.hpp" 15 16 16 17 #include <boost/bind.hpp> … … 20 21 using namespace std; 21 22 22 typedef World::AtomSet::i terator atoms_iter_t;23 typedef World::AtomSet::internal_iterator atoms_iter_t; 23 24 24 25 /************************ Forwarding object **************************************/ … … 73 74 74 75 atom* AtomDescriptor_impl::find() { 75 World::AtomSet atoms = getAtoms();76 atoms_iter_t res = find_if(atoms.begin (),atoms.end(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));77 return (res!=atoms.end ())?((*res).second):0;76 World::AtomSet &atoms = getAtoms(); 77 atoms_iter_t res = find_if(atoms.begin_internal(),atoms.end_internal(),boost::bind(&AtomDescriptor_impl::predicate,this,_1)); 78 return (res!=atoms.end_internal())?((*res).second):0; 78 79 } 79 80 … … 81 82 vector<atom*> res; 82 83 World::AtomSet atoms = getAtoms(); 83 atoms_iter_t iter; 84 for(iter=atoms.begin();iter!=atoms.end();++iter) { 85 if(predicate(*iter)){ 86 res.push_back((*iter).second); 87 } 84 for_each(atoms.begin_internal(), 85 atoms.end_internal(), 86 boost::bind(&AtomDescriptor_impl::checkAndAdd, 87 this,&res,_1)); 88 return res; 89 } 90 91 void AtomDescriptor_impl::checkAndAdd(std::vector<atom*> *v,std::pair<atomId_t,atom*> p){ 92 if(predicate(p)){ 93 v->push_back(p.second); 88 94 } 89 return res;90 95 } 91 96 -
src/Descriptors/AtomDescriptor_impl.hpp
rba9f5b rbe97a8 50 50 */ 51 51 World::AtomSet& getAtoms(); 52 53 void checkAndAdd(std::vector<atom*>*,std::pair<atomId_t,atom*>); 52 54 }; 53 55 -
src/Descriptors/AtomIdDescriptor.cpp
rba9f5b rbe97a8 12 12 13 13 #include "atom.hpp" 14 #include "Patterns/ObservedContainer_impl.hpp" 14 15 15 16 using namespace std; … … 32 33 33 34 atom *AtomIdDescriptor_impl::find(){ 34 World::AtomSet atoms = getAtoms();35 World::AtomSet &atoms = getAtoms(); 35 36 World::AtomSet::iterator res = atoms.find(id); 36 37 return (res!=atoms.end())?((*res).second):0; -
src/Descriptors/MoleculeDescriptor.cpp
rba9f5b rbe97a8 12 12 13 13 #include "World.hpp" 14 #include "Patterns/ObservedContainer_impl.hpp" 14 15 15 16 #include "molecule.hpp" … … 20 21 using namespace std; 21 22 22 typedef World::MoleculeSet::i terator molecules_iter_t;23 typedef World::MoleculeSet::internal_iterator molecules_iter_t; 23 24 24 25 /************************ Forwarding object **************************************/ … … 73 74 74 75 molecule* MoleculeDescriptor_impl::find() { 75 World::MoleculeSet molecules = getMolecules();76 molecules_iter_t res = find_if(molecules.begin (),molecules.end(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));77 return (res!=molecules.end ())?((*res).second):0;76 World::MoleculeSet &molecules = getMolecules(); 77 molecules_iter_t res = find_if(molecules.begin_internal(),molecules.end_internal(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1)); 78 return (res!=molecules.end_internal())?((*res).second):0; 78 79 } 79 80 80 81 vector<molecule*> MoleculeDescriptor_impl::findAll() { 81 82 vector<molecule*> res; 82 World::MoleculeSet molecules = getMolecules(); 83 molecules_iter_t iter; 84 for(iter=molecules.begin();iter!=molecules.end();++iter) { 85 if(predicate(*iter)){ 86 res.push_back((*iter).second); 87 } 83 World::MoleculeSet &molecules = getMolecules(); 84 for_each(molecules.begin_internal(), 85 molecules.end_internal(), 86 boost::bind(&MoleculeDescriptor_impl::checkAndAdd, 87 this,&res,_1)); 88 return res; 89 } 90 91 void MoleculeDescriptor_impl::checkAndAdd(std::vector<molecule*> *v,std::pair<moleculeId_t,molecule*> p){ 92 if(predicate(p)){ 93 v->push_back(p.second); 88 94 } 89 return res;90 95 } 91 96 -
src/Descriptors/MoleculeDescriptor_impl.hpp
rba9f5b rbe97a8 50 50 */ 51 51 World::MoleculeSet& getMolecules(); 52 53 void checkAndAdd(std::vector<molecule*>*,std::pair<moleculeId_t,molecule*>); 52 54 }; 53 55 -
src/Descriptors/MoleculeIdDescriptor.cpp
rba9f5b rbe97a8 10 10 #include "MoleculeIdDescriptor.hpp" 11 11 #include "MoleculeIdDescriptor_impl.hpp" 12 13 #include "Patterns/ObservedContainer_impl.hpp" 12 14 13 15 #include "molecule.hpp" … … 32 34 33 35 molecule *MoleculeIdDescriptor_impl::find(){ 34 World::MoleculeSet molecules = getMolecules();36 World::MoleculeSet &molecules = getMolecules(); 35 37 World::MoleculeSet::iterator res = molecules.find(id); 36 38 return (res!=molecules.end())?((*res).second):0; -
src/Exceptions/CustomException.cpp
rba9f5b rbe97a8 9 9 10 10 #include "CustomException.hpp" 11 #include <iostream> 11 12 12 13 using namespace std; -
src/Exceptions/CustomException.hpp
rba9f5b rbe97a8 10 10 11 11 #include <exception> 12 #include <iostream> 12 #include <iosfwd> 13 #include <string> 13 14 14 15 /** -
src/Helpers/Assert.hpp
rba9f5b rbe97a8 11 11 #include<sstream> 12 12 #include<string> 13 #include<ios tream>13 #include<iosfwd> 14 14 #include<vector> 15 15 #include<map> -
src/Helpers/MemDebug.cpp
rba9f5b rbe97a8 6 6 */ 7 7 8 #ifndef NDEBUG 9 #ifndef NO_MEMDEBUG 8 // NDEBUG implies NO_MEMDEBUG 9 #ifdef NDEBUG 10 # ifndef NO_MEMDEBUG 11 # define NO_MEMDEBUG 12 # endif 13 #endif 14 15 // NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set 16 #ifdef NO_MEMDEBUG 17 # ifdef MEMDEBUG 18 # undef MEMDEBUG 19 # endif 20 #else 21 # ifndef MEMDEBUG 22 # define MEMDEBUG 23 # endif 24 #endif 25 26 #ifdef MEMDEBUG 10 27 11 28 #include <iostream> … … 489 506 } 490 507 #endif 491 #endif -
src/Helpers/MemDebug.hpp
rba9f5b rbe97a8 21 21 * your sourcefiles. 22 22 */ 23 #ifndef NDEBUG24 #ifndef NO_MEMDEBUG25 23 26 #ifndef MEMDEBUG 27 #define MEMDEBUG 24 // Set all flags in a way that makes sense 25 26 // NDEBUG implies NO_MEMDEBUG 27 #ifdef NDEBUG 28 # ifndef NO_MEMDEBUG 29 # define NO_MEMDEBUG 30 # endif 28 31 #endif 32 33 // NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set 34 #ifdef NO_MEMDEBUG 35 # ifdef MEMDEBUG 36 # undef MEMDEBUG 37 # endif 38 #else 39 # ifndef MEMDEBUG 40 # define MEMDEBUG 41 # endif 42 #endif 43 44 #ifdef MEMDEBUG 29 45 30 46 #include <new> … … 83 99 #endif 84 100 85 #endif 86 #endif 87 88 89 #ifdef NDEBUG 90 #undef MEMDEBUG 91 #endif 92 93 #ifndef MEMDEBUG 101 #else 94 102 // memory debugging was disabled 95 103 … … 104 112 105 113 #endif 114 115 106 116 #endif /* MEMDEBUG_HPP_ */ -
src/Line.cpp
rba9f5b rbe97a8 215 215 } 216 216 217 std::vector<Vector> Line::getSphereIntersections() const{ 218 std::vector<Vector> res; 219 220 // line is kept in normalized form, so we can skip a lot of calculations 221 double discriminant = 1-origin->NormSquared(); 222 // we might have 2, 1 or 0 solutions, depending on discriminant 223 if(discriminant>=0){ 224 if(discriminant==0){ 225 res.push_back(*origin); 226 } 227 else{ 228 Vector helper = sqrt(discriminant)*(*direction); 229 res.push_back(*origin+helper); 230 res.push_back(*origin-helper); 231 } 232 } 233 return res; 234 } 235 217 236 Line makeLineThrough(const Vector &x1, const Vector &x2){ 218 237 if(x1==x2){ -
src/Line.hpp
rba9f5b rbe97a8 38 38 Plane getOrthogonalPlane(const Vector &origin) const; 39 39 40 std::vector<Vector> getSphereIntersections() const; 41 40 42 private: 41 43 std::auto_ptr<Vector> origin; -
src/Makefile.am
rba9f5b rbe97a8 38 38 vector.cpp 39 39 40 LINALGHEADER = gslmatrix.hpp \ 40 LINALGHEADER = \ 41 gslmatrix.hpp \ 41 42 gslvector.hpp \ 42 43 linearsystemofequations.hpp \ … … 75 76 Actions/MethodAction.hpp \ 76 77 Actions/Process.hpp 77 78 79 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \ 80 Exceptions/LinearDependenceException.cpp \ 81 Exceptions/MathException.cpp \ 82 Exceptions/NotInvertibleException.cpp \ 83 Exceptions/SkewException.cpp \ 84 Exceptions/ZeroVectorException.cpp 85 86 EXCEPTIONHEADER = Exceptions/CustomException.hpp \ 87 Exceptions/LinearDependenceException.hpp \ 88 Exceptions/MathException.hpp \ 89 Exceptions/NotInvertibleException.hpp \ 90 Exceptions/SkewException.hpp \ 91 Exceptions/ZeroVectorException.hpp 78 92 79 93 PARSERSOURCE = \ … … 101 115 Patterns/Observer.hpp \ 102 116 Patterns/Singleton.hpp 117 118 SHAPESOURCE = \ 119 Shapes/BaseShapes.cpp \ 120 Shapes/Shape.cpp \ 121 Shapes/ShapeOps.cpp 122 SHAPEHEADER = \ 123 Shapes/BaseShapes.hpp \ 124 Shapes/Shape.hpp \ 125 Shapes/ShapeOps.hpp 126 103 127 104 128 QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \ … … 120 144 DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \ 121 145 Descriptors/AtomIdDescriptor.cpp \ 146 Descriptors/AtomSelectionDescriptor.cpp \ 122 147 Descriptors/AtomTypeDescriptor.cpp \ 123 148 Descriptors/MoleculeDescriptor.cpp \ 124 149 Descriptors/MoleculeIdDescriptor.cpp \ 125 150 Descriptors/MoleculeNameDescriptor.cpp \ 126 Descriptors/MoleculePtrDescriptor.cpp 151 Descriptors/MoleculePtrDescriptor.cpp \ 152 Descriptors/MoleculeSelectionDescriptor.cpp 127 153 128 154 129 155 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \ 130 156 Descriptors/AtomIdDescriptor.hpp \ 157 Descriptors/AtomSelectionDescriptor.hpp \ 131 158 Descriptors/AtomTypeDescriptor.hpp \ 132 159 Descriptors/MoleculeDescriptor.hpp \ 133 160 Descriptors/MoleculeIdDescriptor.hpp \ 134 161 Descriptors/MoleculeNameDescriptor.hpp \ 135 Descriptors/MoleculePtrDescriptor.hpp 136 137 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \ 138 Exceptions/LinearDependenceException.cpp \ 139 Exceptions/MathException.cpp \ 140 Exceptions/SkewException.cpp \ 141 Exceptions/ZeroVectorException.cpp 142 143 EXCEPTIONHEADER = Exceptions/CustomException.hpp \ 144 Exceptions/LinearDependenceException.hpp \ 145 Exceptions/MathException.hpp \ 146 Exceptions/SkewException.hpp \ 147 Exceptions/ZeroVectorException.hpp 162 Descriptors/MoleculePtrDescriptor.hpp \ 163 Descriptors/MoleculeSelectionDescriptor.cpp 148 164 149 165 QTUISOURCE = ${QTUIMOC_TARGETS} \ … … 165 181 ${ACTIONSSOURCE} \ 166 182 ${ATOMSOURCE} \ 183 ${EXCEPTIONSOURCE} \ 167 184 ${PATTERNSOURCE} \ 168 185 ${PARSERSOURCE} \ 186 ${SHAPESOURCE} \ 169 187 ${DESCRIPTORSOURCE} \ 170 188 ${HELPERSOURCE} \ 171 ${EXCEPTIONSOURCE} \172 189 bond.cpp \ 173 190 bondgraph.cpp \ 174 191 boundary.cpp \ 192 Box.cpp \ 175 193 CommandLineParser.cpp \ 176 194 config.cpp \ … … 188 206 log.cpp \ 189 207 logger.cpp \ 208 Matrix.cpp \ 190 209 moleculelist.cpp \ 191 210 molecule.cpp \ … … 212 231 ${ACTIONSHEADER} \ 213 232 ${ATOMHEADER} \ 233 ${EXCEPTIONHEADER} \ 214 234 ${PARSERHEADER} \ 215 235 ${PATTERNHEADER} \ 236 ${SHAPEHEADER} \ 216 237 ${DESCRIPTORHEADER} \ 217 ${EXCEPTIONHEADER} \218 238 bond.hpp \ 219 239 bondgraph.hpp \ 220 240 boundary.hpp \ 241 Box.hpp \ 221 242 CommandLineParser.hpp \ 222 243 config.hpp \ … … 236 257 log.hpp \ 237 258 logger.hpp \ 259 Matrix.hpp \ 238 260 molecule.hpp \ 239 261 molecule_template.hpp \ -
src/Parser/MpqcParser.hpp
rba9f5b rbe97a8 11 11 #include "FormatParser.hpp" 12 12 13 #include <ios tream>13 #include <iosfwd> 14 14 15 15 /** -
src/Parser/PcpParser.cpp
rba9f5b rbe97a8 7 7 8 8 #include <iostream> 9 #include <iomanip> 9 10 10 11 #include "atom.hpp" … … 20 21 #include "verbose.hpp" 21 22 #include "World.hpp" 23 #include "Matrix.hpp" 24 #include "Box.hpp" 22 25 23 26 /** Constructor of PcpParser. … … 210 213 // Unit cell and magnetic field 211 214 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 212 double * const cell_size = World::getInstance().getDomain();215 double *cell_size = new double[6]; 213 216 cell_size[0] = BoxLength[0]; 214 217 cell_size[1] = BoxLength[3]; … … 217 220 cell_size[4] = BoxLength[7]; 218 221 cell_size[5] = BoxLength[8]; 222 World::getInstance().setDomain(cell_size); 223 delete[] cell_size; 219 224 //if (1) fprintf(stderr,"\n"); 220 225 … … 327 332 void PcpParser::save(std::ostream* file) 328 333 { 329 const double * const cell_size = World::getInstance().getDomain();334 const Matrix &domain = World::getInstance().getDomain().getM(); 330 335 class ThermoStatContainer *Thermostats = World::getInstance().getThermostats(); 331 336 if (!file->fail()) { … … 412 417 *file << endl; 413 418 *file << "BoxLength\t\t\t# (Length of a unit cell)" << endl; 414 *file << cell_size[0]<< "\t" << endl;415 *file << cell_size[1] << "\t" << cell_size[2]<< "\t" << endl;416 *file << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5]<< "\t" << endl;419 *file << domain.at(0,0) << "\t" << endl; 420 *file << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl; 421 *file << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl; 417 422 // FIXME 418 423 *file << endl; -
src/Parser/PcpParser.hpp
rba9f5b rbe97a8 9 9 #define PCPPARSER_HPP_ 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 #include "Parser/FormatParser.hpp" 13 13 -
src/Patterns/Cacheable.hpp
rba9f5b rbe97a8 12 12 #include <boost/function.hpp> 13 13 #include <boost/shared_ptr.hpp> 14 #include <iostream>15 14 16 15 #include "Helpers/Assert.hpp" -
src/Patterns/ObservedIterator.hpp
rba9f5b rbe97a8 108 108 } 109 109 110 value_type *operator->(){ 111 acquireLock(); 112 return &(*iter); 113 } 114 110 115 // when we turn into a const iterator we can loose our lock 111 116 operator typename _Set::const_iterator() { -
src/Patterns/Observer.hpp
rba9f5b rbe97a8 170 170 //! @cond 171 171 // Structure for RAII-Style notification 172 p rotected:172 public: 173 173 /** 174 174 * This structure implements the Observer-mechanism RAII-Idiom. … … 241 241 #define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this) 242 242 #define NOTIFY(notification) do{Observable::enque_notification_internal(this,notification);}while(0) 243 #define LOCK_OBSERVABLE(observable) Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(&(observable)) 243 244 244 245 #endif /* OBSERVER_HPP_ */ -
src/Plane.hpp
rba9f5b rbe97a8 11 11 #include <memory> 12 12 #include <vector> 13 #include <ios tream>13 #include <iosfwd> 14 14 #include "Space.hpp" 15 15 #include "Exceptions/LinearDependenceException.hpp" -
src/UIElements/CommandLineUI/CommandLineDialog.cpp
rba9f5b rbe97a8 27 27 #include "verbose.hpp" 28 28 #include "World.hpp" 29 #include "Box.hpp" 29 30 30 31 #include "atom.hpp" … … 77 78 } 78 79 79 void CommandLineDialog::queryVector(const char* title, Vector *target, const double *const cellSize,bool check, string _description) {80 registerQuery(new VectorCommandLineQuery(title,target,c ellSize,check, _description));81 } 82 83 void CommandLineDialog::queryBox(const char* title, double ** constcellSize, string _description) {80 void CommandLineDialog::queryVector(const char* title, Vector *target, bool check, string _description) { 81 registerQuery(new VectorCommandLineQuery(title,target,check, _description)); 82 } 83 84 void CommandLineDialog::queryBox(const char* title, Box* cellSize, string _description) { 84 85 registerQuery(new BoxCommandLineQuery(title,cellSize,_description)); 85 86 } … … 222 223 } 223 224 224 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize,bool _check, string _description) :225 Dialog::VectorQuery(title,_target,_c ellSize,_check, _description)225 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, bool _check, string _description) : 226 Dialog::VectorQuery(title,_target,_check, _description) 226 227 {} 227 228 … … 244 245 245 246 246 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const_cellSize, string _description) :247 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, Box* _cellSize, string _description) : 247 248 Dialog::BoxQuery(title,_cellSize, _description) 248 249 {} -
src/UIElements/CommandLineUI/CommandLineDialog.hpp
rba9f5b rbe97a8 35 35 virtual void queryAtom(const char*,atom**, std::string = ""); 36 36 virtual void queryMolecule(const char*,molecule**,std::string = ""); 37 virtual void queryVector(const char*,Vector *, const double * const,bool, std::string = "");38 virtual void queryBox(const char*, double ** const, std::string = "");37 virtual void queryVector(const char*,Vector *,bool, std::string = ""); 38 virtual void queryBox(const char*,Box *, std::string = ""); 39 39 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 40 40 … … 99 99 class VectorCommandLineQuery : public Dialog::VectorQuery { 100 100 public: 101 VectorCommandLineQuery(std::string title,Vector *_target, const double *const _cellSize,bool _check, std::string _description = "");101 VectorCommandLineQuery(std::string title,Vector *_target,bool _check, std::string _description = ""); 102 102 virtual ~VectorCommandLineQuery(); 103 103 virtual bool handle(); … … 106 106 class BoxCommandLineQuery : public Dialog::BoxQuery { 107 107 public: 108 BoxCommandLineQuery(std::string title, double ** const_cellSize, std::string _description = "");108 BoxCommandLineQuery(std::string title,Box* _cellSize, std::string _description = ""); 109 109 virtual ~BoxCommandLineQuery(); 110 110 virtual bool handle(); -
src/UIElements/Dialog.cpp
rba9f5b rbe97a8 10 10 #include "Dialog.hpp" 11 11 12 #include "verbose.hpp" 12 13 #include "atom.hpp" 13 14 #include "element.hpp" 14 15 #include "molecule.hpp" 15 16 #include "vector.hpp" 17 #include "Matrix.hpp" 18 #include "Box.hpp" 16 19 17 20 using namespace std; … … 185 188 // Vector Queries 186 189 187 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target, const double *const _cellSize,bool _check, std::string _description) :190 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,bool _check, std::string _description) : 188 191 Query(title, _description), 189 cellSize(_cellSize),190 192 check(_check), 191 193 target(_target) … … 205 207 // Box Queries 206 208 207 Dialog::BoxQuery::BoxQuery(std::string title, double ** const_cellSize, std::string _description) :209 Dialog::BoxQuery::BoxQuery(std::string title, Box* _cellSize, std::string _description) : 208 210 Query(title, _description), 209 211 target(_cellSize) … … 218 220 219 221 void Dialog::BoxQuery::setResult() { 220 for (int i=0;i<6;i++) { 221 (*target)[i] = tmp[i]; 222 } 222 (*target)= ReturnFullMatrixforSymmetric(tmp); 223 223 } 224 224 -
src/UIElements/Dialog.hpp
rba9f5b rbe97a8 14 14 15 15 class atom; 16 class Box; 16 17 class element; 17 18 class molecule; … … 43 44 virtual void queryAtom(const char*,atom**,std::string = "")=0; 44 45 virtual void queryMolecule(const char*,molecule**, std::string = "")=0; 45 virtual void queryVector(const char*,Vector *, const double *const,bool, std::string = "")=0;46 virtual void queryBox(const char*, double ** const, std::string = "")=0;46 virtual void queryVector(const char*,Vector *,bool, std::string = "")=0; 47 virtual void queryBox(const char*,Box*, std::string = "")=0; 47 48 virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0; 48 49 … … 176 177 class VectorQuery : public Query { 177 178 public: 178 VectorQuery(std::string title,Vector *_target, const double *const _cellSize,bool _check, std::string _description = "");179 VectorQuery(std::string title,Vector *_target,bool _check, std::string _description = ""); 179 180 virtual ~VectorQuery(); 180 181 virtual bool handle()=0; … … 182 183 protected: 183 184 Vector *tmp; 184 const double *const cellSize;185 185 bool check; 186 186 private: … … 190 190 class BoxQuery : public Query { 191 191 public: 192 BoxQuery(std::string title, double ** const_cellSize, std::string _description = "");192 BoxQuery(std::string title,Box *_cellSize, std::string _description = ""); 193 193 virtual ~BoxQuery(); 194 194 virtual bool handle()=0; 195 195 virtual void setResult(); 196 196 protected: 197 double *tmp;197 double* tmp; 198 198 private: 199 double **target;199 Box* target; 200 200 }; 201 201 -
src/UIElements/QT4/QTDialog.cpp
rba9f5b rbe97a8 29 29 #include "molecule.hpp" 30 30 #include "Descriptors/MoleculeIdDescriptor.hpp" 31 #include "Matrix.hpp" 32 #include "Box.hpp" 31 33 32 34 … … 93 95 } 94 96 95 void QTDialog::queryBox(char const*, double**, string){97 void QTDialog::queryBox(char const*, Box*, string){ 96 98 // TODO 97 99 ASSERT(false, "Not implemented yet"); … … 123 125 } 124 126 125 void QTDialog::queryVector(const char* title, Vector *target, const double *const cellSize,bool check,string) {126 registerQuery(new VectorQTQuery(title,target,c ellSize,check,inputLayout,this));127 void QTDialog::queryVector(const char* title, Vector *target, bool check,string) { 128 registerQuery(new VectorQTQuery(title,target,check,inputLayout,this)); 127 129 } 128 130 … … 291 293 } 292 294 293 QTDialog::VectorQTQuery::VectorQTQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : 294 Dialog::VectorQuery(title,_target,_cellSize,_check), 295 parent(_parent) 296 { 297 // About the j: I don't know why it was done this way, but it was used this way in Vector::AskPosition, so I reused it 298 int j = -1; 295 QTDialog::VectorQTQuery::VectorQTQuery(std::string title, Vector *_target, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : 296 Dialog::VectorQuery(title,_target,_check), 297 parent(_parent) 298 { 299 const Matrix& M = World::getInstance().getDomain().getM(); 299 300 const char *coords[3] = {"x:","y:","z:"}; 300 301 mainLayout= new QHBoxLayout(); … … 304 305 mainLayout->addLayout(subLayout); 305 306 for(int i=0; i<3; i++) { 306 j+=i+1;307 307 coordLayout[i] = new QHBoxLayout(); 308 308 subLayout->addLayout(coordLayout[i]); … … 310 310 coordLayout[i]->addWidget(coordLabel[i]); 311 311 coordInput[i] = new QDoubleSpinBox(); 312 coordInput[i]->setRange(0, cellSize[j]);312 coordInput[i]->setRange(0,M.at(i,i)); 313 313 coordInput[i]->setDecimals(3); 314 314 coordLayout[i]->addWidget(coordInput[i]); -
src/UIElements/QT4/QTDialog.hpp
rba9f5b rbe97a8 43 43 virtual void queryAtom(const char*,atom**,std::string = ""); 44 44 virtual void queryMolecule(const char*,molecule**,std::string = ""); 45 virtual void queryVector(const char*,Vector *, const double *const,bool,std::string = "");46 virtual void queryBox(const char*, double ** const, std::string = "");45 virtual void queryVector(const char*,Vector *,bool,std::string = ""); 46 virtual void queryBox(const char*,Box*, std::string = ""); 47 47 virtual void queryElement(const char*,std::vector<element *> *_target,std::string = ""); 48 48 … … 124 124 class VectorQTQuery : public Dialog::VectorQuery { 125 125 public: 126 VectorQTQuery(std::string title,Vector *_target, const double *const _cellSize,bool _check,QBoxLayout *,QTDialog *);126 VectorQTQuery(std::string title,Vector *_target,bool _check,QBoxLayout *,QTDialog *); 127 127 virtual ~VectorQTQuery(); 128 128 virtual bool handle(); -
src/UIElements/QT4/QTMainWindow.cpp
rba9f5b rbe97a8 21 21 #include "atom.hpp" 22 22 #include "molecule.hpp" 23 #include "verbose.hpp" 23 24 #include "Actions/Action.hpp" 24 25 #include "Actions/ActionRegistry.hpp" -
src/UIElements/TextUI/TextDialog.cpp
rba9f5b rbe97a8 25 25 #include "molecule.hpp" 26 26 #include "vector.hpp" 27 #include "Matrix.hpp" 28 #include "Box.hpp" 27 29 28 30 using namespace std; … … 70 72 } 71 73 72 void TextDialog::queryVector(const char* title, Vector *target, const double *const cellSize,bool check, string description) {73 registerQuery(new VectorTextQuery(title,target,c ellSize,check,description));74 } 75 76 void TextDialog::queryBox(const char* title, double ** constcellSize, string description) {74 void TextDialog::queryVector(const char* title, Vector *target, bool check, string description) { 75 registerQuery(new VectorTextQuery(title,target,check,description)); 76 } 77 78 void TextDialog::queryBox(const char* title,Box* cellSize, string description) { 77 79 registerQuery(new BoxTextQuery(title,cellSize,description)); 78 80 } … … 270 272 } 271 273 272 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize,bool _check, std::string _description) :273 Dialog::VectorQuery(title,_target,_c ellSize,_check,_description)274 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, bool _check, std::string _description) : 275 Dialog::VectorQuery(title,_target,_check,_description) 274 276 {} 275 277 … … 280 282 Log() << Verbose(0) << getTitle(); 281 283 284 const Matrix &M = World::getInstance().getDomain().getM(); 282 285 char coords[3] = {'x','y','z'}; 283 int j = -1;284 286 for (int i=0;i<3;i++) { 285 j += i+1;286 287 do { 287 Log() << Verbose(0) << coords[i] << "[0.." << cellSize[j]<< "]: ";288 Log() << Verbose(0) << coords[i] << "[0.." << M.at(i,i) << "]: "; 288 289 cin >> (*tmp)[i]; 289 } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= cellSize[j])) && (check));290 } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= M.at(i,i))) && (check)); 290 291 } 291 292 return true; 292 293 } 293 294 294 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, double ** const_cellSize, std::string _description) :295 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, Box* _cellSize, std::string _description) : 295 296 Dialog::BoxQuery(title,_cellSize,_description) 296 297 {} -
src/UIElements/TextUI/TextDialog.hpp
rba9f5b rbe97a8 32 32 virtual void queryAtom(const char*,atom**,std::string = ""); 33 33 virtual void queryMolecule(const char*,molecule**,std::string = ""); 34 virtual void queryVector(const char*,Vector *, const double * const,bool, std::string = "");35 virtual void queryBox(const char*, double ** const, std::string = "");34 virtual void queryVector(const char*,Vector *,bool, std::string = ""); 35 virtual void queryBox(const char*,Box*, std::string = ""); 36 36 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 37 37 … … 96 96 class VectorTextQuery : public Dialog::VectorQuery { 97 97 public: 98 VectorTextQuery(std::string title,Vector *_target, const double *const _cellSize,bool _check, std::string _description = NULL);98 VectorTextQuery(std::string title,Vector *_target,bool _check, std::string _description = NULL); 99 99 virtual ~VectorTextQuery(); 100 100 virtual bool handle(); … … 103 103 class BoxTextQuery : public Dialog::BoxQuery { 104 104 public: 105 BoxTextQuery(std::string title, double ** const_cellSize, std::string _description = NULL);105 BoxTextQuery(std::string title,Box* _cellSize, std::string _description = NULL); 106 106 virtual ~BoxTextQuery(); 107 107 virtual bool handle(); -
src/UIElements/TextUI/TextWindow.hpp
rba9f5b rbe97a8 11 11 #include "MainWindow.hpp" 12 12 13 #include <string> 13 14 #include <set> 14 15 -
src/UIElements/Views/StreamStringView.hpp
rba9f5b rbe97a8 10 10 11 11 #include <boost/function.hpp> 12 #include <ios tream>12 #include <iosfwd> 13 13 14 14 #include "Views/StringView.hpp" -
src/VectorSet.hpp
rba9f5b rbe97a8 12 12 #include <functional> 13 13 #include <algorithm> 14 #include <limits> 14 15 15 16 /** … … 19 20 */ 20 21 21 class Vector; 22 #include "vector.hpp" 23 #include <list> 22 24 23 25 // this tests, whether we actually have a Vector … … 48 50 void translate(const Vector &translater){ 49 51 // this is needed to allow template lookup 50 transform(this->begin(),this->end(),this->begin(),bind1st(plus<Vector>(),translater)); 52 transform(this->begin(),this->end(),this->begin(),std::bind1st(std::plus<Vector>(),translater)); 53 } 54 55 double minDistSquared(const Vector &point){ 56 if(!this->size()) 57 return std::numeric_limits<double>::infinity(); 58 std::list<double> helper; 59 helper.resize(this->size()); 60 transform(this->begin(),this->end(), 61 helper.begin(), 62 std::bind2nd(std::mem_fun_ref(&Vector::DistanceSquared),point)); 63 return *min_element(helper.begin(),helper.end()); 51 64 } 52 65 }; 53 66 67 // allows simpler definition of VectorSets 68 #define VECTORSET(container_type) VectorSet<container_type<Vector> > 69 54 70 #endif /* VECTORSET_HPP_ */ -
src/World.cpp
rba9f5b rbe97a8 9 9 10 10 #include "World.hpp" 11 12 #include <functional> 11 13 12 14 #include "atom.hpp" … … 22 24 #include "Actions/ManipulateAtomsProcess.hpp" 23 25 #include "Helpers/Assert.hpp" 26 #include "Box.hpp" 27 #include "Matrix.hpp" 28 #include "defs.hpp" 24 29 25 30 #include "Patterns/Singleton_impl.hpp" 31 #include "Patterns/ObservedContainer_impl.hpp" 26 32 27 33 using namespace std; … … 74 80 // system 75 81 76 double * World::getDomain() { 77 return cell_size; 82 Box& World::getDomain() { 83 return *cell_size; 84 } 85 86 void World::setDomain(const Matrix &mat){ 87 OBSERVE; 88 *cell_size = mat; 78 89 } 79 90 … … 81 92 { 82 93 OBSERVE; 83 cell_size[0] = matrix[0]; 84 cell_size[1] = matrix[1]; 85 cell_size[2] = matrix[2]; 86 cell_size[3] = matrix[3]; 87 cell_size[4] = matrix[4]; 88 cell_size[5] = matrix[5]; 94 Matrix M = ReturnFullMatrixforSymmetric(matrix); 95 cell_size->setM(M); 89 96 } 90 97 … … 95 102 void World::setDefaultName(std::string name) 96 103 { 104 OBSERVE; 97 105 defaultName = name; 98 106 }; … … 119 127 molecule *mol = NULL; 120 128 mol = NewMolecule(); 121 ASSERT(!molecules.count(currMoleculeId),"currMoleculeId did not specify an unused ID"); 122 mol->setId(currMoleculeId++); 129 moleculeId_t id = getNextMoleculeId(); 130 ASSERT(!molecules.count(id),"proposed id did not specify an unused ID"); 131 mol->setId(id); 123 132 // store the molecule by ID 124 133 molecules[mol->getId()] = mol; … … 138 147 DeleteMolecule(mol); 139 148 molecules.erase(id); 140 } 141 142 double *World::cell_size = NULL; 149 releaseMoleculeId(id); 150 } 143 151 144 152 atom *World::createAtom(){ 145 153 OBSERVE; 146 154 atomId_t id = getNextAtomId(); 155 ASSERT(!atoms.count(id),"proposed id did not specify an unused ID"); 147 156 atom *res = NewAtom(id); 148 157 res->setWorld(this); … … 221 230 222 231 atomId_t World::getNextAtomId(){ 223 // see if we can reuse some Id 224 if(atomIdPool.empty()){ 225 return currAtomId++; 226 } 227 else{ 228 // we give out the first ID from the pool 229 atomId_t id = *(atomIdPool.begin()); 230 atomIdPool.erase(id); 232 // try to find an Id in the pool; 233 if(!atomIdPool.empty()){ 234 atomIdPool_t::iterator iter=atomIdPool.begin(); 235 atomId_t id = iter->first; 236 pair<atomId_t,atomId_t> newRange = make_pair(id+1,iter->second); 237 // we wont use this iterator anymore, so we don't care about invalidating 238 atomIdPool.erase(iter); 239 if(newRange.first<newRange.second){ 240 atomIdPool.insert(newRange); 241 } 231 242 return id; 232 243 } 244 // Nothing in the pool... we are out of luck 245 return currAtomId++; 233 246 } 234 247 235 248 void World::releaseAtomId(atomId_t id){ 236 atomIdPool.insert(id); 237 // defragmentation of the pool 238 set<atomId_t>::reverse_iterator iter; 239 // go through all Ids in the pool that lie immediately below the border 240 while(!atomIdPool.empty() && *(atomIdPool.rbegin())==(currAtomId-1)){ 241 atomIdPool.erase(--currAtomId); 242 } 249 atomIdPool.insert(make_pair(id,id+1)); 250 defragAtomIdPool(); 243 251 } 244 252 245 253 bool World::reserveAtomId(atomId_t id){ 246 254 if(id>=currAtomId ){ 247 // add all ids between the new one and current border as available248 for(atomId_t pos=currAtomId; pos<id; ++pos){249 atomIdPool.insert( pos);255 pair<atomId_t,atomId_t> newRange = make_pair(currAtomId,id); 256 if(newRange.first<newRange.second){ 257 atomIdPool.insert(newRange); 250 258 } 251 259 currAtomId=id+1; 260 defragAtomIdPool(); 252 261 return true; 253 262 } 254 else if(atomIdPool.count(id)){ 255 atomIdPool.erase(id); 263 // look for a range that matches the request 264 for(atomIdPool_t::iterator iter=atomIdPool.begin();iter!=atomIdPool.end();++iter){ 265 if(iter->first>id){ 266 // we have coverd all available ranges... nothing to be found here 267 break; 268 } 269 // no need to check first, since it has to be <=id, since otherwise we would have broken out 270 if(iter->second > id){ 271 // we found a matching range... get the id from this range 272 273 // split up this range at the point of id 274 pair<atomId_t,atomId_t> bottomRange = make_pair(iter->first,id); 275 pair<atomId_t,atomId_t> topRange = make_pair(id+1,iter->second); 276 // remove this range 277 atomIdPool.erase(iter); 278 if(bottomRange.first<bottomRange.second){ 279 atomIdPool.insert(bottomRange); 280 } 281 if(topRange.first<topRange.second){ 282 atomIdPool.insert(topRange); 283 } 284 defragAtomIdPool(); 285 return true; 286 } 287 } 288 // this ID could not be reserved 289 return false; 290 } 291 292 void World::defragAtomIdPool(){ 293 // check if the situation is bad enough to make defragging neccessary 294 if((numAtomDefragSkips<MAX_FRAGMENTATION_SKIPS) && 295 (atomIdPool.size()<lastAtomPoolSize+MAX_POOL_FRAGMENTATION)){ 296 ++numAtomDefragSkips; 297 return; 298 } 299 for(atomIdPool_t::iterator iter = atomIdPool.begin();iter!=atomIdPool.end();){ 300 // see if this range is adjacent to the next one 301 atomIdPool_t::iterator next = iter; 302 next++; 303 if(next!=atomIdPool.end() && (next->first==iter->second)){ 304 // merge the two ranges 305 pair<atomId_t,atomId_t> newRange = make_pair(iter->first,next->second); 306 atomIdPool.erase(iter); 307 atomIdPool.erase(next); 308 pair<atomIdPool_t::iterator,bool> res = atomIdPool.insert(newRange); 309 ASSERT(res.second,"Id-Pool was confused"); 310 iter=res.first; 311 continue; 312 } 313 ++iter; 314 } 315 if(!atomIdPool.empty()){ 316 // check if the last range is at the border 317 atomIdPool_t::iterator iter = atomIdPool.end(); 318 iter--; 319 if(iter->second==currAtomId){ 320 currAtomId=iter->first; 321 atomIdPool.erase(iter); 322 } 323 } 324 lastAtomPoolSize=atomIdPool.size(); 325 numAtomDefragSkips=0; 326 } 327 328 // Molecules 329 330 moleculeId_t World::getNextMoleculeId(){ 331 // try to find an Id in the pool; 332 if(!moleculeIdPool.empty()){ 333 moleculeIdPool_t::iterator iter=moleculeIdPool.begin(); 334 moleculeId_t id = iter->first; 335 pair<moleculeId_t,moleculeId_t> newRange = make_pair(id+1,iter->second); 336 // we wont use this iterator anymore, so we don't care about invalidating 337 moleculeIdPool.erase(iter); 338 if(newRange.first<newRange.second){ 339 moleculeIdPool.insert(newRange); 340 } 341 return id; 342 } 343 // Nothing in the pool... we are out of luck 344 return currMoleculeId++; 345 } 346 347 void World::releaseMoleculeId(moleculeId_t id){ 348 moleculeIdPool.insert(make_pair(id,id+1)); 349 defragMoleculeIdPool(); 350 } 351 352 bool World::reserveMoleculeId(moleculeId_t id){ 353 if(id>=currMoleculeId ){ 354 pair<moleculeId_t,moleculeId_t> newRange = make_pair(currMoleculeId,id); 355 if(newRange.first<newRange.second){ 356 moleculeIdPool.insert(newRange); 357 } 358 currMoleculeId=id+1; 359 defragMoleculeIdPool(); 256 360 return true; 257 361 } 258 else{ 259 // this ID could not be reserved 260 return false; 261 } 362 // look for a range that matches the request 363 for(moleculeIdPool_t::iterator iter=moleculeIdPool.begin();iter!=moleculeIdPool.end();++iter){ 364 if(iter->first>id){ 365 // we have coverd all available ranges... nothing to be found here 366 break; 367 } 368 // no need to check first, since it has to be <=id, since otherwise we would have broken out 369 if(iter->second > id){ 370 // we found a matching range... get the id from this range 371 372 // split up this range at the point of id 373 pair<moleculeId_t,moleculeId_t> bottomRange = make_pair(iter->first,id); 374 pair<moleculeId_t,moleculeId_t> topRange = make_pair(id+1,iter->second); 375 // remove this range 376 moleculeIdPool.erase(iter); 377 if(bottomRange.first<bottomRange.second){ 378 moleculeIdPool.insert(bottomRange); 379 } 380 if(topRange.first<topRange.second){ 381 moleculeIdPool.insert(topRange); 382 } 383 defragMoleculeIdPool(); 384 return true; 385 } 386 } 387 // this ID could not be reserved 388 return false; 389 } 390 391 void World::defragMoleculeIdPool(){ 392 // check if the situation is bad enough to make defragging neccessary 393 if((numMoleculeDefragSkips<MAX_FRAGMENTATION_SKIPS) && 394 (moleculeIdPool.size()<lastMoleculePoolSize+MAX_POOL_FRAGMENTATION)){ 395 ++numMoleculeDefragSkips; 396 return; 397 } 398 for(moleculeIdPool_t::iterator iter = moleculeIdPool.begin();iter!=moleculeIdPool.end();){ 399 // see if this range is adjacent to the next one 400 moleculeIdPool_t::iterator next = iter; 401 next++; 402 if(next!=moleculeIdPool.end() && (next->first==iter->second)){ 403 // merge the two ranges 404 pair<moleculeId_t,moleculeId_t> newRange = make_pair(iter->first,next->second); 405 moleculeIdPool.erase(iter); 406 moleculeIdPool.erase(next); 407 pair<moleculeIdPool_t::iterator,bool> res = moleculeIdPool.insert(newRange); 408 ASSERT(res.second,"Id-Pool was confused"); 409 iter=res.first; 410 continue; 411 } 412 ++iter; 413 } 414 if(!moleculeIdPool.empty()){ 415 // check if the last range is at the border 416 moleculeIdPool_t::iterator iter = moleculeIdPool.end(); 417 iter--; 418 if(iter->second==currMoleculeId){ 419 currMoleculeId=iter->first; 420 moleculeIdPool.erase(iter); 421 } 422 } 423 lastMoleculePoolSize=moleculeIdPool.size(); 424 numMoleculeDefragSkips=0; 425 } 426 427 /******************************* Iterators ********************************/ 428 429 // external parts with observers 430 431 CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor); 432 433 World::AtomIterator 434 World::getAtomIter(AtomDescriptor descr){ 435 return AtomIterator(descr,atoms); 436 } 437 438 World::AtomIterator 439 World::getAtomIter(){ 440 return AtomIterator(AllAtoms(),atoms); 441 } 442 443 World::AtomIterator 444 World::atomEnd(){ 445 return AtomIterator(AllAtoms(),atoms,atoms.end()); 446 } 447 448 CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor); 449 450 World::MoleculeIterator 451 World::getMoleculeIter(MoleculeDescriptor descr){ 452 return MoleculeIterator(descr,molecules); 453 } 454 455 World::MoleculeIterator 456 World::getMoleculeIter(){ 457 return MoleculeIterator(AllMolecules(),molecules); 458 } 459 460 World::MoleculeIterator 461 World::moleculeEnd(){ 462 return MoleculeIterator(AllMolecules(),molecules,molecules.end()); 463 } 464 465 // Internal parts, without observers 466 467 // Build the AtomIterator from template 468 CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet::set_t,AtomDescriptor); 469 470 471 World::internal_AtomIterator 472 World::getAtomIter_internal(AtomDescriptor descr){ 473 return internal_AtomIterator(descr,atoms.getContent()); 474 } 475 476 World::internal_AtomIterator 477 World::atomEnd_internal(){ 478 return internal_AtomIterator(AllAtoms(),atoms.getContent(),atoms.end_internal()); 479 } 480 481 // build the MoleculeIterator from template 482 CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet::set_t,MoleculeDescriptor); 483 484 World::internal_MoleculeIterator World::getMoleculeIter_internal(MoleculeDescriptor descr){ 485 return internal_MoleculeIterator(descr,molecules.getContent()); 486 } 487 488 World::internal_MoleculeIterator World::moleculeEnd_internal(){ 489 return internal_MoleculeIterator(AllMolecules(),molecules.getContent(),molecules.end_internal()); 490 } 491 492 /************************** Selection of Atoms and molecules ******************/ 493 494 // Atoms 495 496 void World::clearAtomSelection(){ 497 selectedAtoms.clear(); 498 } 499 500 void World::selectAtom(atom *atom){ 501 ASSERT(atom,"Invalid pointer in selection of atom"); 502 selectedAtoms[atom->getId()]=atom; 503 } 504 505 void World::selectAtom(atomId_t id){ 506 ASSERT(atoms.count(id),"Atom Id selected that was not in the world"); 507 selectedAtoms[id]=atoms[id]; 508 } 509 510 void World::selectAllAtoms(AtomDescriptor descr){ 511 internal_AtomIterator begin = getAtomIter_internal(descr); 512 internal_AtomIterator end = atomEnd_internal(); 513 void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function 514 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above 515 } 516 517 void World::selectAtomsOfMolecule(molecule *_mol){ 518 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule"); 519 // need to make it const to get the fast iterators 520 const molecule *mol = _mol; 521 void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function 522 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above 523 } 524 525 void World::selectAtomsOfMolecule(moleculeId_t id){ 526 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule"); 527 selectAtomsOfMolecule(molecules[id]); 528 } 529 530 void World::unselectAtom(atom *atom){ 531 ASSERT(atom,"Invalid pointer in unselection of atom"); 532 unselectAtom(atom->getId()); 533 } 534 535 void World::unselectAtom(atomId_t id){ 536 ASSERT(atoms.count(id),"Atom Id unselected that was not in the world"); 537 selectedAtoms.erase(id); 538 } 539 540 void World::unselectAllAtoms(AtomDescriptor descr){ 541 internal_AtomIterator begin = getAtomIter_internal(descr); 542 internal_AtomIterator end = atomEnd_internal(); 543 void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function 544 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above 545 } 546 547 void World::unselectAtomsOfMolecule(molecule *_mol){ 548 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule"); 549 // need to make it const to get the fast iterators 550 const molecule *mol = _mol; 551 void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function 552 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above 553 } 554 555 void World::unselectAtomsOfMolecule(moleculeId_t id){ 556 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule"); 557 unselectAtomsOfMolecule(molecules[id]); 262 558 } 263 559 264 560 // Molecules 265 561 266 /******************************* Iterators ********************************/ 267 268 // Build the AtomIterator from template 269 CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor); 270 271 272 World::AtomIterator World::getAtomIter(AtomDescriptor descr){ 273 return AtomIterator(descr,atoms); 274 } 275 276 World::AtomIterator World::atomEnd(){ 277 return AtomIterator(AllAtoms(),atoms,atoms.end()); 278 } 279 280 // build the MoleculeIterator from template 281 CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor); 282 283 World::MoleculeIterator World::getMoleculeIter(MoleculeDescriptor descr){ 284 return MoleculeIterator(descr,molecules); 285 } 286 287 World::MoleculeIterator World::moleculeEnd(){ 288 return MoleculeIterator(AllMolecules(),molecules,molecules.end()); 562 void World::clearMoleculeSelection(){ 563 selectedMolecules.clear(); 564 } 565 566 void World::selectMolecule(molecule *mol){ 567 ASSERT(mol,"Invalid pointer to molecule in selection"); 568 selectedMolecules[mol->getId()]=mol; 569 } 570 571 void World::selectMolecule(moleculeId_t id){ 572 ASSERT(molecules.count(id),"Molecule Id selected that was not in the world"); 573 selectedMolecules[id]=molecules[id]; 574 } 575 576 void World::selectAllMoleculess(MoleculeDescriptor descr){ 577 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 578 internal_MoleculeIterator end = moleculeEnd_internal(); 579 void (World::*func)(molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function 580 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above 581 } 582 583 void World::selectMoleculeOfAtom(atom *atom){ 584 ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom"); 585 molecule *mol=atom->getMolecule(); 586 // the atom might not be part of a molecule 587 if(mol){ 588 selectMolecule(mol); 589 } 590 } 591 592 void World::selectMoleculeOfAtom(atomId_t id){ 593 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\ 594 selectMoleculeOfAtom(atoms[id]); 595 } 596 597 void World::unselectMolecule(molecule *mol){ 598 ASSERT(mol,"invalid pointer in unselection of molecule"); 599 unselectMolecule(mol->getId()); 600 } 601 602 void World::unselectMolecule(moleculeId_t id){ 603 ASSERT(molecules.count(id),"No such molecule with ID in unselection"); 604 selectedMolecules.erase(id); 605 } 606 607 void World::unselectAllMoleculess(MoleculeDescriptor descr){ 608 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 609 internal_MoleculeIterator end = moleculeEnd_internal(); 610 void (World::*func)(molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function 611 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above 612 } 613 614 void World::unselectMoleculeOfAtom(atom *atom){ 615 ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom"); 616 molecule *mol=atom->getMolecule(); 617 // the atom might not be part of a molecule 618 if(mol){ 619 unselectMolecule(mol); 620 } 621 } 622 623 void World::unselectMoleculeOfAtom(atomId_t id){ 624 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\ 625 unselectMoleculeOfAtom(atoms[id]); 626 } 627 628 /******************* Iterators over Selection *****************************/ 629 World::AtomSelectionIterator World::beginAtomSelection(){ 630 return selectedAtoms.begin(); 631 } 632 633 World::AtomSelectionIterator World::endAtomSelection(){ 634 return selectedAtoms.end(); 635 } 636 637 638 World::MoleculeSelectionIterator World::beginMoleculeSelection(){ 639 return selectedMolecules.begin(); 640 } 641 642 World::MoleculeSelectionIterator World::endMoleculeSelection(){ 643 return selectedMolecules.end(); 289 644 } 290 645 … … 297 652 Thermostats(new ThermoStatContainer), 298 653 ExitFlag(0), 299 atoms(), 654 atoms(this), 655 selectedAtoms(this), 300 656 currAtomId(0), 301 molecules(), 657 lastAtomPoolSize(0), 658 numAtomDefragSkips(0), 659 molecules(this), 660 selectedMolecules(this), 302 661 currMoleculeId(0), 303 662 molecules_deprecated(new MoleculeListClass(this)) 304 663 { 305 cell_size = new double[6]; 306 cell_size[0] = 20.; 307 cell_size[1] = 0.; 308 cell_size[2] = 20.; 309 cell_size[3] = 0.; 310 cell_size[4] = 0.; 311 cell_size[5] = 20.; 664 cell_size = new Box; 665 Matrix domain; 666 domain.at(0,0) = 20; 667 domain.at(1,1) = 20; 668 domain.at(2,2) = 20; 669 cell_size->setM(domain); 312 670 defaultName = "none"; 313 671 molecules_deprecated->signOn(this); … … 317 675 { 318 676 molecules_deprecated->signOff(this); 319 delete []cell_size;677 delete cell_size; 320 678 delete molecules_deprecated; 321 679 delete periode; -
src/World.hpp
rba9f5b rbe97a8 23 23 #include "Patterns/Cacheable.hpp" 24 24 #include "Patterns/Singleton.hpp" 25 #include "Patterns/ObservedContainer.hpp" 25 26 26 27 // include config.h … … 34 35 class AtomDescriptor_impl; 35 36 template<typename T> class AtomsCalculation; 37 class Box; 36 38 class config; 37 39 class ManipulateAtomsProcess; 40 class Matrix; 38 41 class molecule; 39 42 class MoleculeDescriptor; … … 43 46 class ThermoStatContainer; 44 47 48 45 49 /****************************************** forward declarations *****************************/ 46 50 … … 58 62 friend class MoleculeDescriptor_impl; 59 63 friend class MoleculeDescriptor; 64 // coupling with descriptors over selection 65 friend class AtomSelectionDescriptor_impl; 66 friend class MoleculeSelectionDescriptor_impl; 60 67 61 68 // Actions, calculations etc associated with the World … … 65 72 66 73 // Types for Atom and Molecule structures 67 typedef std::map<atomId_t,atom*> AtomSet;68 typedef std::map<moleculeId_t,molecule*> MoleculeSet;74 typedef ObservedContainer<std::map<atomId_t,atom*> > AtomSet; 75 typedef ObservedContainer<std::map<moleculeId_t,molecule*> > MoleculeSet; 69 76 70 77 /***** getter and setter *****/ … … 125 132 * get the domain size as a symmetric matrix (6 components) 126 133 */ 127 double * getDomain(); 134 Box& getDomain(); 135 136 /** 137 * Set the domain size from a matrix object 138 * 139 * Matrix needs to be symmetric 140 */ 141 void setDomain(const Matrix &mat); 128 142 129 143 /** … … 207 221 ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string); 208 222 223 /**** 224 * Iterators to use internal data structures 225 * All these iterators are observed to track changes. 226 * There is a corresponding protected section with unobserved iterators, 227 * which can be used internally when the extra speed is needed 228 */ 229 230 typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator; 231 232 /** 233 * returns an iterator over all Atoms matching a given descriptor. 234 * This iterator is observed, so don't keep it around unnecessary to 235 * avoid unintended blocking. 236 */ 237 AtomIterator getAtomIter(AtomDescriptor descr); 238 AtomIterator getAtomIter(); 239 240 AtomIterator atomEnd(); 241 242 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator; 243 244 /** 245 * returns an iterator over all Molecules matching a given descriptor. 246 * This iterator is observed, so don't keep it around unnecessary to 247 * avoid unintended blocking. 248 */ 249 MoleculeIterator getMoleculeIter(MoleculeDescriptor descr); 250 MoleculeIterator getMoleculeIter(); 251 252 MoleculeIterator moleculeEnd(); 253 254 /******** Selections of molecules and Atoms *************/ 255 void clearAtomSelection(); 256 void selectAtom(atom*); 257 void selectAtom(atomId_t); 258 void selectAllAtoms(AtomDescriptor); 259 void selectAtomsOfMolecule(molecule*); 260 void selectAtomsOfMolecule(moleculeId_t); 261 void unselectAtom(atom*); 262 void unselectAtom(atomId_t); 263 void unselectAllAtoms(AtomDescriptor); 264 void unselectAtomsOfMolecule(molecule*); 265 void unselectAtomsOfMolecule(moleculeId_t); 266 267 void clearMoleculeSelection(); 268 void selectMolecule(molecule*); 269 void selectMolecule(moleculeId_t); 270 void selectAllMoleculess(MoleculeDescriptor); 271 void selectMoleculeOfAtom(atom*); 272 void selectMoleculeOfAtom(atomId_t); 273 void unselectMolecule(molecule*); 274 void unselectMolecule(moleculeId_t); 275 void unselectAllMoleculess(MoleculeDescriptor); 276 void unselectMoleculeOfAtom(atom*); 277 void unselectMoleculeOfAtom(atomId_t); 278 279 /******************** Iterators to selections *****************/ 280 typedef AtomSet::iterator AtomSelectionIterator; 281 AtomSelectionIterator beginAtomSelection(); 282 AtomSelectionIterator endAtomSelection(); 283 284 typedef MoleculeSet::iterator MoleculeSelectionIterator; 285 MoleculeSelectionIterator beginMoleculeSelection(); 286 MoleculeSelectionIterator endMoleculeSelection(); 287 209 288 protected: 210 /**** Iterators to use internal data structures */ 289 /**** 290 * Iterators to use internal data structures 291 * All these iterators are unobserved for speed reasons. 292 * There is a corresponding public section to these methods, 293 * which produce observed iterators.*/ 211 294 212 295 // Atoms 213 typedef SelectiveIterator<atom*,AtomSet ,AtomDescriptor>AtomIterator;296 typedef SelectiveIterator<atom*,AtomSet::set_t,AtomDescriptor> internal_AtomIterator; 214 297 215 298 /** … … 217 300 * used for internal purposes, like AtomProcesses and AtomCalculations. 218 301 */ 219 AtomIterator getAtomIter(AtomDescriptor descr);302 internal_AtomIterator getAtomIter_internal(AtomDescriptor descr); 220 303 221 304 /** … … 225 308 * used for internal purposes, like AtomProcesses and AtomCalculations. 226 309 */ 227 AtomIterator atomEnd();310 internal_AtomIterator atomEnd_internal(); 228 311 229 312 // Molecules 230 231 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator; 313 typedef SelectiveIterator<molecule*,MoleculeSet::set_t,MoleculeDescriptor> internal_MoleculeIterator; 314 232 315 233 316 /** … … 235 318 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. 236 319 */ 237 MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);320 internal_MoleculeIterator getMoleculeIter_internal(MoleculeDescriptor descr); 238 321 239 322 /** … … 243 326 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. 244 327 */ 245 MoleculeIterator moleculeEnd();328 internal_MoleculeIterator moleculeEnd_internal(); 246 329 247 330 … … 254 337 void releaseAtomId(atomId_t); 255 338 bool reserveAtomId(atomId_t); 339 void defragAtomIdPool(); 340 341 moleculeId_t getNextMoleculeId(); 342 void releaseMoleculeId(moleculeId_t); 343 bool reserveMoleculeId(moleculeId_t); 344 void defragMoleculeIdPool(); 256 345 257 346 periodentafel *periode; 258 347 config *configuration; 259 static double*cell_size;348 Box *cell_size; 260 349 std::string defaultName; 261 350 class ThermoStatContainer *Thermostats; 262 351 int ExitFlag; 263 public: 352 private: 353 264 354 AtomSet atoms; 265 private: 266 std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId 355 AtomSet selectedAtoms; 356 typedef std::set<std::pair<atomId_t, atomId_t> > atomIdPool_t; 357 /** 358 * stores the pool for all available AtomIds below currAtomId 359 * 360 * The pool contains ranges of free ids in the form [bottom,top). 361 */ 362 atomIdPool_t atomIdPool; 267 363 atomId_t currAtomId; //!< stores the next available Id for atoms 364 size_t lastAtomPoolSize; //!< size of the pool after last defrag, to skip some defrags 365 unsigned int numAtomDefragSkips; 366 268 367 MoleculeSet molecules; 368 MoleculeSet selectedMolecules; 369 typedef std::set<std::pair<moleculeId_t, moleculeId_t> > moleculeIdPool_t; 370 /** 371 * stores the pool for all available AtomIds below currAtomId 372 * 373 * The pool contains ranges of free ids in the form [bottom,top). 374 */ 375 moleculeIdPool_t moleculeIdPool; 269 376 moleculeId_t currMoleculeId; 377 size_t lastMoleculePoolSize; //!< size of the pool after last defrag, to skip some defrags 378 unsigned int numMoleculeDefragSkips; 270 379 private: 271 380 /** -
src/analysis_bonds.cpp
rba9f5b rbe97a8 13 13 #include "element.hpp" 14 14 #include "info.hpp" 15 #include "verbose.hpp" 15 16 #include "log.hpp" 16 17 #include "molecule.hpp" -
src/analysis_correlation.cpp
rba9f5b rbe97a8 9 9 10 10 #include <iostream> 11 #include <iomanip> 11 12 12 13 #include "analysis_correlation.hpp" … … 19 20 #include "triangleintersectionlist.hpp" 20 21 #include "vector.hpp" 22 #include "Matrix.hpp" 21 23 #include "verbose.hpp" 22 24 #include "World.hpp" 25 #include "Box.hpp" 23 26 24 27 … … 34 37 PairCorrelationMap *outmap = NULL; 35 38 double distance = 0.; 36 double *domain = World::getInstance().getDomain();39 Box &domain = World::getInstance().getDomain(); 37 40 38 41 if (molecules->ListOfMolecules.empty()) { … … 75 78 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 79 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 77 distance = (*iter)->node->PeriodicDistance(*(*runner)->node, domain);80 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node); 78 81 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 79 82 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); … … 135 138 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 136 139 if ((*MolWalker)->ActiveFlag) { 137 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());138 double * FullInverseMatrix = InverseMatrix(FullMatrix);140 Matrix FullMatrix = World::getInstance().getDomain().getM(); 141 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 139 142 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 140 143 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 141 144 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 142 145 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 143 periodicX = *(*iter)->node; 144 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 146 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 145 147 // go through every range in xyz and get distance 146 148 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 147 149 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 148 150 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 149 checkX = Vector(n[0], n[1], n[2]) + periodicX; 150 checkX.MatrixMultiplication(FullMatrix); 151 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 151 152 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 152 153 if ((*MolOtherWalker)->ActiveFlag) { … … 157 158 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 158 159 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 159 periodicOtherX = *(*runner)->node; 160 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 160 periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3 161 161 // go through every range in xyz and get distance 162 162 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) 163 163 for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++) 164 164 for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) { 165 checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX; 166 checkOtherX.MatrixMultiplication(FullMatrix); 165 checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX); 167 166 distance = checkX.distance(checkOtherX); 168 167 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; … … 176 175 } 177 176 } 178 delete[](FullMatrix);179 delete[](FullInverseMatrix);180 177 } 181 178 } … … 195 192 CorrelationToPointMap *outmap = NULL; 196 193 double distance = 0.; 197 double *cell_size= World::getInstance().getDomain();194 Box &domain = World::getInstance().getDomain(); 198 195 199 196 if (molecules->ListOfMolecules.empty()) { … … 211 208 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 212 209 if ((*type == NULL) || ((*iter)->type == *type)) { 213 distance = (*iter)->node->PeriodicDistance(*point, cell_size);210 distance = domain.periodicDistance(*(*iter)->node,*point); 214 211 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 215 212 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); … … 246 243 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 247 244 if ((*MolWalker)->ActiveFlag) { 248 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());249 double * FullInverseMatrix = InverseMatrix(FullMatrix);245 Matrix FullMatrix = World::getInstance().getDomain().getM(); 246 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 250 247 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 251 248 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 253 250 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 254 251 if ((*type == NULL) || ((*iter)->type == *type)) { 255 periodicX = *(*iter)->node; 256 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 252 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 257 253 // go through every range in xyz and get distance 258 254 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 259 255 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 260 256 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 261 checkX = Vector(n[0], n[1], n[2]) + periodicX; 262 checkX.MatrixMultiplication(FullMatrix); 257 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 263 258 distance = checkX.distance(*point); 264 259 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); … … 267 262 } 268 263 } 269 delete[](FullMatrix);270 delete[](FullInverseMatrix);271 264 } 272 265 … … 352 345 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 353 346 if ((*MolWalker)->ActiveFlag) { 354 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());355 double * FullInverseMatrix = InverseMatrix(FullMatrix);347 Matrix FullMatrix = World::getInstance().getDomain().getM(); 348 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 356 349 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 357 350 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 359 352 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 360 353 if ((*type == NULL) || ((*iter)->type == *type)) { 361 periodicX = *(*iter)->node; 362 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 354 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 363 355 // go through every range in xyz and get distance 364 356 ShortestDistance = -1.; … … 366 358 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 367 359 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 368 checkX = Vector(n[0], n[1], n[2]) + periodicX; 369 checkX.MatrixMultiplication(FullMatrix); 360 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 370 361 TriangleIntersectionList Intersections(&checkX,Surface,LC); 371 362 distance = Intersections.GetSmallestDistance(); … … 381 372 } 382 373 } 383 delete[](FullMatrix);384 delete[](FullInverseMatrix);385 374 } 386 375 -
src/analysis_correlation.hpp
rba9f5b rbe97a8 26 26 27 27 #include "atom.hpp" 28 #include "verbose.hpp" 28 29 29 30 /****************************************** forward declarations *****************************/ -
src/analyzer.cpp
rba9f5b rbe97a8 14 14 #include "datacreator.hpp" 15 15 #include "helpers.hpp" 16 #include "memoryallocator.hpp"17 16 #include "parser.hpp" 18 17 #include "periodentafel.hpp" 18 #include "verbose.hpp" 19 19 20 20 // include config.h -
src/atom.cpp
rba9f5b rbe97a8 12 12 #include "element.hpp" 13 13 #include "lists.hpp" 14 #include "memoryallocator.hpp"15 14 #include "parser.hpp" 16 15 #include "vector.hpp" 17 16 #include "World.hpp" 18 17 #include "molecule.hpp" 18 #include "Shapes/Shape.hpp" 19 20 #include <iomanip> 19 21 20 22 /************************************* Functions for class atom *************************************/ … … 112 114 * \return true - is inside, false - is not 113 115 */ 114 bool atom::IsIn Parallelepiped(const Vector offset, const double *parallelepiped) const115 { 116 return (node->IsInParallelepiped(offset, parallelepiped));116 bool atom::IsInShape(const Shape& shape) const 117 { 118 return shape.isInside(*node); 117 119 }; 118 120 … … 328 330 } 329 331 332 molecule* atom::getMolecule(){ 333 return mol; 334 } 335 330 336 void atom::removeFromMolecule(){ 331 337 if(mol){ -
src/atom.hpp
rba9f5b rbe97a8 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 #include <list> 22 22 #include <vector> … … 35 35 class World; 36 36 class molecule; 37 class Shape; 37 38 38 39 /********************************************** declarations *******************************/ … … 66 67 double DistanceToVector(const Vector &origin) const; 67 68 double DistanceSquaredToVector(const Vector &origin) const; 68 bool IsIn Parallelepiped(const Vector offset, const double *parallelepiped) const;69 bool IsInShape(const Shape&) const; 69 70 70 71 // getter and setter … … 89 90 90 91 void setMolecule(molecule*); 92 molecule* getMolecule(); 91 93 void removeFromMolecule(); 92 94 -
src/atom_graphnodeinfo.cpp
rba9f5b rbe97a8 9 9 10 10 #include "atom_graphnodeinfo.hpp" 11 #include "memoryallocator.hpp"12 11 13 12 /** Constructor of class GraphNodeInfo. 14 13 */ 15 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr( NULL), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(NULL) {};14 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(0), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(0) {}; 16 15 17 16 /** Destructor of class GraphNodeInfo. -
src/atom_particleinfo.cpp
rba9f5b rbe97a8 9 9 10 10 #include "atom_particleinfo.hpp" 11 #include "memoryallocator.hpp" 11 12 #include <iostream> 12 13 13 14 /** Constructor of ParticleInfo. -
src/atom_particleinfo.hpp
rba9f5b rbe97a8 18 18 #endif 19 19 20 #include <iostream> 20 #include <iosfwd> 21 #include <string> 21 22 22 23 /****************************************** forward declarations *****************************/ -
src/atom_trajectoryparticle.hpp
rba9f5b rbe97a8 20 20 #include <fstream> 21 21 22 #include <gsl/gsl_inline.h> 22 23 #include <gsl/gsl_randist.h> 23 24 -
src/bond.cpp
rba9f5b rbe97a8 7 7 #include "Helpers/MemDebug.hpp" 8 8 9 #include "verbose.hpp" 9 10 #include "atom.hpp" 10 11 #include "bond.hpp" -
src/bondgraph.cpp
rba9f5b rbe97a8 15 15 #include "element.hpp" 16 16 #include "info.hpp" 17 #include "verbose.hpp" 17 18 #include "log.hpp" 18 19 #include "molecule.hpp" -
src/bondgraph.hpp
rba9f5b rbe97a8 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 22 22 /*********************************************** defines ***********************************/ -
src/boundary.cpp
rba9f5b rbe97a8 15 15 #include "info.hpp" 16 16 #include "linkedcell.hpp" 17 #include "verbose.hpp" 17 18 #include "log.hpp" 18 #include "memoryallocator.hpp"19 19 #include "molecule.hpp" 20 20 #include "tesselation.hpp" … … 22 22 #include "World.hpp" 23 23 #include "Plane.hpp" 24 #include "Matrix.hpp" 25 #include "Box.hpp" 26 27 #include <iostream> 28 #include <iomanip> 24 29 25 30 #include<gsl/gsl_poly.h> … … 769 774 int N[NDIM]; 770 775 int n[NDIM]; 771 double *M = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());772 double Rotations[NDIM*NDIM];773 double *MInverse = InverseMatrix(M);776 const Matrix &M = World::getInstance().getDomain().getM(); 777 Matrix Rotations; 778 const Matrix &MInverse = World::getInstance().getDomain().getMinv(); 774 779 Vector AtomTranslations; 775 780 Vector FillerTranslations; … … 804 809 805 810 // calculate filler grid in [0,1]^3 806 FillerDistance = Vector(distance[0], distance[1], distance[2]); 807 FillerDistance.InverseMatrixMultiplication(M); 811 FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]); 808 812 for(int i=0;i<NDIM;i++) 809 813 N[i] = (int) ceil(1./FillerDistance[i]); … … 818 822 for (n[2] = 0; n[2] < N[2]; n[2]++) { 819 823 // calculate position of current grid vector in untransformed box 820 CurrentPosition = Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 821 CurrentPosition.MatrixMultiplication(M); 824 CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 822 825 // create molecule random translation vector ... 823 826 for (int i=0;i<NDIM;i++) … … 840 843 } 841 844 842 Rotations [0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));843 Rotations [3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));844 Rotations [6] = cos(phi[1])*sin(phi[2]);845 Rotations [1] = - sin(phi[0])*cos(phi[1]);846 Rotations [4] = cos(phi[0])*cos(phi[1]);847 Rotations [7] = sin(phi[1]);848 Rotations [3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));849 Rotations [5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));850 Rotations [8] = cos(phi[1])*cos(phi[2]);845 Rotations.set(0,0, cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]))); 846 Rotations.set(0,1, sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]))); 847 Rotations.set(0,2, cos(phi[1])*sin(phi[2]) ); 848 Rotations.set(1,0, -sin(phi[0])*cos(phi[1]) ); 849 Rotations.set(1,1, cos(phi[0])*cos(phi[1]) ); 850 Rotations.set(1,2, sin(phi[1]) ); 851 Rotations.set(2,0, -cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]))); 852 Rotations.set(2,1, -sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]))); 853 Rotations.set(2,2, cos(phi[1])*cos(phi[2]) ); 851 854 } 852 855 … … 854 857 Inserter = (*iter)->x; 855 858 if (DoRandomRotation) 856 Inserter .MatrixMultiplication(Rotations);859 Inserter *= Rotations; 857 860 Inserter += AtomTranslations + FillerTranslations + CurrentPosition; 858 861 859 862 // check whether inserter is inside box 860 Inserter .MatrixMultiplication(MInverse);863 Inserter *= MInverse; 861 864 FillIt = true; 862 865 for (int i=0;i<NDIM;i++) 863 866 FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON); 864 Inserter .MatrixMultiplication(M);867 Inserter *= M; 865 868 866 869 // Check whether point is in- or outside … … 901 904 delete TesselStruct[(*ListRunner)]; 902 905 } 903 delete[](M);904 delete[](MInverse);905 906 906 907 return Filling; -
src/boundary.hpp
rba9f5b rbe97a8 12 12 13 13 #include <fstream> 14 #include <ios tream>14 #include <iosfwd> 15 15 16 16 // STL headers -
src/builder.cpp
rba9f5b rbe97a8 60 60 #include "config.hpp" 61 61 #include "log.hpp" 62 #include "memoryusageobserver.hpp"63 62 #include "molecule.hpp" 64 63 #include "periodentafel.hpp" -
src/config.cpp
rba9f5b rbe97a8 19 19 #include "info.hpp" 20 20 #include "lists.hpp" 21 #include "verbose.hpp" 21 22 #include "log.hpp" 22 23 #include "molecule.hpp" 23 #include "memoryallocator.hpp"24 24 #include "molecule.hpp" 25 25 #include "periodentafel.hpp" 26 26 #include "ThermoStatContainer.hpp" 27 27 #include "World.hpp" 28 #include "Matrix.hpp" 29 #include "Box.hpp" 28 30 29 31 /************************************* Functions for class config ***************************/ … … 679 681 // Unit cell and magnetic field 680 682 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 681 double * c onst cell_size = World::getInstance().getDomain();683 double * cell_size = new double[6]; 682 684 cell_size[0] = BoxLength[0]; 683 685 cell_size[1] = BoxLength[3]; … … 686 688 cell_size[4] = BoxLength[7]; 687 689 cell_size[5] = BoxLength[8]; 690 World::getInstance().setDomain(cell_size); 691 delete cell_size; 688 692 //if (1) fprintf(stderr,"\n"); 689 693 … … 883 887 884 888 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 885 double * c onst cell_size = World::getInstance().getDomain();889 double * cell_size = new double[6]; 886 890 cell_size[0] = BoxLength[0]; 887 891 cell_size[1] = BoxLength[3]; … … 890 894 cell_size[4] = BoxLength[7]; 891 895 cell_size[5] = BoxLength[8]; 896 World::getInstance().setDomain(cell_size); 897 delete[] cell_size; 892 898 if (1) fprintf(stderr,"\n"); 893 899 config::DoPerturbation = 0; … … 1027 1033 // bring MaxTypes up to date 1028 1034 mol->CountElements(); 1029 const double * const cell_size = World::getInstance().getDomain();1035 const Matrix &domain = World::getInstance().getDomain().getM(); 1030 1036 ofstream * const output = new ofstream(filename, ios::out); 1031 1037 if (output != NULL) { … … 1098 1104 *output << endl; 1099 1105 *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl; 1100 *output << cell_size[0]<< "\t" << endl;1101 *output << cell_size[1] << "\t" << cell_size[2]<< "\t" << endl;1102 *output << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5]<< "\t" << endl;1106 *output << domain.at(0,0) << "\t" << endl; 1107 *output << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl; 1108 *output << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl; 1103 1109 // FIXME 1104 1110 *output << endl; -
src/datacreator.cpp
rba9f5b rbe97a8 12 12 #include "helpers.hpp" 13 13 #include "parser.hpp" 14 #include "verbose.hpp" 15 16 #include <iomanip> 14 17 15 18 //=========================== FUNCTIONS============================ -
src/datacreator.hpp
rba9f5b rbe97a8 10 10 using namespace std; 11 11 12 #include <ios tream>12 #include <iosfwd> 13 13 14 14 /****************************************** forward declarations *****************************/ -
src/defs.hpp
rba9f5b rbe97a8 84 84 #define MOLECUILDER_NAME "Molecuilder" 85 85 86 const unsigned int MAX_POOL_FRAGMENTATION=20; 87 const unsigned int MAX_FRAGMENTATION_SKIPS=100; 88 86 89 #endif /*DEFS_HPP_*/ -
src/element.hpp
rba9f5b rbe97a8 16 16 #endif 17 17 18 #include <ios tream>18 #include <iosfwd> 19 19 #include <string> 20 20 -
src/ellipsoid.cpp
rba9f5b rbe97a8 21 21 #include "tesselation.hpp" 22 22 #include "vector.hpp" 23 #include "Matrix.hpp" 23 24 #include "verbose.hpp" 24 25 … … 34 35 Vector helper, RefPoint; 35 36 double distance = -1.; 36 double Matrix[NDIM*NDIM];37 Matrix Matrix; 37 38 double InverseLength[3]; 38 39 double psi,theta,phi; // euler angles in ZX'Z'' convention … … 51 52 theta = EllipsoidAngle[1]; 52 53 phi = EllipsoidAngle[2]; 53 Matrix [0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);54 Matrix [1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);55 Matrix [2] = sin(psi)*sin(theta);56 Matrix [3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);57 Matrix [4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);58 Matrix [5] = -cos(psi)*sin(theta);59 Matrix [6] = sin(theta)*sin(phi);60 Matrix [7] = sin(theta)*cos(phi);61 Matrix [8] = cos(theta);62 helper .MatrixMultiplication(Matrix);54 Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi)); 55 Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi)); 56 Matrix.set(2,0, sin(psi)*sin(theta)); 57 Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi)); 58 Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi)); 59 Matrix.set(2,1, -cos(psi)*sin(theta)); 60 Matrix.set(0,2, sin(theta)*sin(phi)); 61 Matrix.set(1,2, sin(theta)*cos(phi)); 62 Matrix.set(2,2, cos(theta)); 63 helper *= Matrix; 63 64 helper.ScaleAll(InverseLength); 64 65 //Log() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl; … … 73 74 phi = -EllipsoidAngle[2]; 74 75 helper.ScaleAll(EllipsoidLength); 75 Matrix [0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);76 Matrix [1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);77 Matrix [2] = sin(psi)*sin(theta);78 Matrix [3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);79 Matrix [4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);80 Matrix [5] = -cos(psi)*sin(theta);81 Matrix [6] = sin(theta)*sin(phi);82 Matrix [7] = sin(theta)*cos(phi);83 Matrix [8] = cos(theta);84 helper .MatrixMultiplication(Matrix);76 Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi)); 77 Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi)); 78 Matrix.set(2,0, sin(psi)*sin(theta)); 79 Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi)); 80 Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi)); 81 Matrix.set(2,1, -cos(psi)*sin(theta)); 82 Matrix.set(0,2, sin(theta)*sin(phi)); 83 Matrix.set(1,2, sin(theta)*cos(phi)); 84 Matrix.set(2,2, cos(theta)); 85 helper *= Matrix; 85 86 //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl; 86 87 -
src/errorlogger.cpp
rba9f5b rbe97a8 9 9 10 10 #include <fstream> 11 #include <iostream> 11 12 #include "errorlogger.hpp" 12 13 #include "verbose.hpp" -
src/errorlogger.hpp
rba9f5b rbe97a8 9 9 #define ERRORLOGGER_HPP_ 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 13 13 #include "Patterns/Singleton.hpp" -
src/graph.cpp
rba9f5b rbe97a8 13 13 #include "config.hpp" 14 14 #include "graph.hpp" 15 #include "verbose.hpp" 15 16 #include "log.hpp" 16 17 #include "molecule.hpp" -
src/graph.hpp
rba9f5b rbe97a8 27 27 class molecule; 28 28 29 class Graph;30 29 class SubGraph; 31 30 class Node; … … 34 33 /********************************************** definitions *********************************/ 35 34 36 #define NodeMap pair < int, class Node* > 37 #define EdgeMap multimap < class Node*, class Edge* > 35 typedef std::pair < int, class Node* > NodeMap; 36 typedef std::multimap < class Node*, class Edge* > EdgeMap; 38 37 39 #define KeyStack deque<int> 40 #define KeySet set<int> 41 #define NumberValuePair pair<int, double> 42 #define Graph map <KeySet, NumberValuePair, KeyCompare > 43 #define GraphPair pair <KeySet, NumberValuePair > 44 #define KeySetTestPair pair<KeySet::iterator, bool> 45 #define GraphTestPair pair<Graph::iterator, bool> 38 typedef std::deque<int> KeyStack; 39 typedef std::set<int> KeySet; 40 typedef std::pair<int, double> NumberValuePair; 46 41 47 48 /******************************** Some small functions and/or structures **********************************/ 49 42 // needed for definition of Graph and GraphTestPair 50 43 struct KeyCompare 51 44 { 52 45 bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const; 53 46 }; 47 48 typedef std::map <KeySet, NumberValuePair, KeyCompare > Graph; 49 typedef std::pair <KeySet, NumberValuePair > GraphPair; 50 typedef std::pair<KeySet::iterator, bool> KeySetTestPair; 51 typedef std::pair<Graph::iterator, bool> GraphTestPair; 52 53 54 /******************************** Some small functions and/or structures **********************************/ 54 55 55 56 //bool operator < (KeySet SubgraphA, KeySet SubgraphB); //note: this declaration is important, otherwise normal < is used (producing wrong order) -
src/gslvector.cpp
rba9f5b rbe97a8 10 10 #include <cassert> 11 11 #include <cmath> 12 #include <iostream> 12 13 13 14 #include "gslvector.hpp" 14 15 #include "defs.hpp" 15 16 #include "vector.hpp" 17 #include "VectorContent.hpp" 16 18 17 19 /** Constructor of class GSLVector. … … 69 71 */ 70 72 void GSLVector::SetFromVector(Vector &v){ 71 gsl_vector_memcpy (vector, v.get() );73 gsl_vector_memcpy (vector, v.get()->content); 72 74 } 73 75 -
src/gslvector.hpp
rba9f5b rbe97a8 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 #include <gsl/gsl_vector.h> 22 22 -
src/helpers.cpp
rba9f5b rbe97a8 8 8 #include "helpers.hpp" 9 9 #include "Helpers/fast_functions.hpp" 10 #include "verbose.hpp" 10 11 #include "log.hpp" 11 #include "memoryusageobserver.hpp" 12 13 #include <iostream> 12 14 13 15 /********************************************** helpful functions *********************************/ … … 117 119 }; 118 120 119 /** Blows the 6-dimensional \a cell_size array up to a full NDIM by NDIM matrix.120 * \param *symm 6-dim array of unique symmetric matrix components121 * \return allocated NDIM*NDIM array with the symmetric matrix122 */123 double * ReturnFullMatrixforSymmetric(const double * const symm)124 {125 double *matrix = new double[NDIM * NDIM];126 matrix[0] = symm[0];127 matrix[1] = symm[1];128 matrix[2] = symm[3];129 matrix[3] = symm[1];130 matrix[4] = symm[2];131 matrix[5] = symm[4];132 matrix[6] = symm[3];133 matrix[7] = symm[4];134 matrix[8] = symm[5];135 return matrix;136 };137 138 /** Calculate the inverse of a 3x3 matrix.139 * \param *matrix NDIM_NDIM array140 */141 double * InverseMatrix( const double * const A)142 {143 double *B = new double[NDIM * NDIM];144 double detA = RDET3(A);145 double detAReci;146 147 for (int i=0;i<NDIM*NDIM;++i)148 B[i] = 0.;149 // calculate the inverse B150 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular151 detAReci = 1./detA;152 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11153 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12154 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13155 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21156 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22157 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23158 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31159 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32160 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33161 }162 return B;163 };164 165 166 167 121 /** Comparison function for GSL heapsort on distances in two molecules. 168 122 * \param *a -
src/helpers.hpp
rba9f5b rbe97a8 20 20 #include "defs.hpp" 21 21 #include "log.hpp" 22 #include "memoryallocator.hpp"23 22 24 23 /********************************************** definitions *********************************/ … … 52 51 bool IsValidNumber( const char *string); 53 52 int CompareDoubles (const void * a, const void * b); 54 double * ReturnFullMatrixforSymmetric(const double * const cell_size);55 double * InverseMatrix(const double * const A);56 53 void performCriticalExit(); 57 54 -
src/joiner.cpp
rba9f5b rbe97a8 14 14 #include "datacreator.hpp" 15 15 #include "helpers.hpp" 16 #include "memoryallocator.hpp"17 16 #include "parser.hpp" 18 17 #include "periodentafel.hpp" 18 #include "verbose.hpp" 19 19 20 20 //============================== MAIN ============================= -
src/linkedcell.cpp
rba9f5b rbe97a8 10 10 #include "helpers.hpp" 11 11 #include "linkedcell.hpp" 12 #include "verbose.hpp" 12 13 #include "log.hpp" 13 14 #include "molecule.hpp" -
src/logger.cpp
rba9f5b rbe97a8 9 9 10 10 #include <fstream> 11 #include <iostream> 11 12 #include "logger.hpp" 12 13 #include "verbose.hpp" -
src/logger.hpp
rba9f5b rbe97a8 9 9 #define LOGGER_HPP_ 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 13 13 #include "Patterns/Singleton.hpp" -
src/molecule.cpp
rba9f5b rbe97a8 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H 8 #include <config.h> 9 #endif 10 7 11 #include "Helpers/MemDebug.hpp" 8 12 9 13 #include <cstring> 10 14 #include <boost/bind.hpp> 15 #include <boost/foreach.hpp> 16 17 #include <gsl/gsl_inline.h> 18 #include <gsl/gsl_heapsort.h> 11 19 12 20 #include "World.hpp" … … 22 30 #include "log.hpp" 23 31 #include "molecule.hpp" 24 #include "memoryallocator.hpp" 32 25 33 #include "periodentafel.hpp" 26 34 #include "stackclass.hpp" 27 35 #include "tesselation.hpp" 28 36 #include "vector.hpp" 37 #include "Matrix.hpp" 29 38 #include "World.hpp" 39 #include "Box.hpp" 30 40 #include "Plane.hpp" 31 41 #include "Exceptions/LinearDependenceException.hpp" … … 284 294 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 285 295 Vector InBondvector; // vector in direction of *Bond 286 double *matrix = NULL;296 const Matrix &matrix = World::getInstance().getDomain().getM(); 287 297 bond *Binder = NULL; 288 double * const cell_size = World::getInstance().getDomain();289 298 290 299 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 307 316 } // (signs are correct, was tested!) 308 317 } 309 matrix = ReturnFullMatrixforSymmetric(cell_size); 310 Orthovector1.MatrixMultiplication(matrix); 318 Orthovector1 *= matrix; 311 319 InBondvector -= Orthovector1; // subtract just the additional translation 312 delete[](matrix);313 320 bondlength = InBondvector.Norm(); 314 321 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 541 548 break; 542 549 } 543 delete[](matrix);544 550 545 551 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 660 666 * @param three vectors forming the matrix that defines the shape of the parallelpiped 661 667 */ 662 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {668 molecule* molecule::CopyMoleculeFromSubRegion(const Shape ®ion) const { 663 669 molecule *copy = World::getInstance().createMolecule(); 664 670 665 ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped ); 671 BOOST_FOREACH(atom *iter,atoms){ 672 if(iter->IsInShape(region)){ 673 copy->AddCopyAtom(iter); 674 } 675 } 666 676 667 677 //TODO: copy->BuildInducedSubgraph(this); … … 750 760 void molecule::SetBoxDimension(Vector *dim) 751 761 { 752 double * const cell_size = World::getInstance().getDomain(); 753 cell_size[0] = dim->at(0); 754 cell_size[1] = 0.; 755 cell_size[2] = dim->at(1); 756 cell_size[3] = 0.; 757 cell_size[4] = 0.; 758 cell_size[5] = dim->at(2); 762 Matrix domain; 763 for(int i =0; i<NDIM;++i) 764 domain.at(i,i) = dim->at(i); 765 World::getInstance().setDomain(domain); 759 766 }; 760 767 … … 849 856 bool molecule::CheckBounds(const Vector *x) const 850 857 { 851 double * const cell_size = World::getInstance().getDomain();858 const Matrix &domain = World::getInstance().getDomain().getM(); 852 859 bool result = true; 853 int j =-1;854 860 for (int i=0;i<NDIM;i++) { 855 j += i+1; 856 result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j])); 861 result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i))); 857 862 } 858 863 //return result; -
src/molecule.hpp
rba9f5b rbe97a8 7 7 #define MOLECULES_HPP_ 8 8 9 using namespace std;10 11 9 /*********************************************** includes ***********************************/ 12 10 13 // GSL headers 14 #include <gsl/gsl_eigen.h> 15 #include <gsl/gsl_heapsort.h> 16 #include <gsl/gsl_linalg.h> 17 #include <gsl/gsl_matrix.h> 18 #include <gsl/gsl_multimin.h> 19 #include <gsl/gsl_vector.h> 20 #include <gsl/gsl_randist.h> 11 #ifdef HAVE_CONFIG_H 12 #include <config.h> 13 #endif 21 14 22 15 //// STL headers … … 31 24 #include "types.hpp" 32 25 #include "graph.hpp" 33 #include "stackclass.hpp"34 26 #include "tesselation.hpp" 35 27 #include "Patterns/Observer.hpp" … … 53 45 class periodentafel; 54 46 class Vector; 47 class Shape; 48 template <class> class StackClass; 55 49 56 50 /******************************** Some definitions for easier reading **********************************/ … … 316 310 317 311 molecule *CopyMolecule(); 318 molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const;312 molecule* CopyMoleculeFromSubRegion(const Shape&) const; 319 313 320 314 /// Fragment molecule by two different approaches: -
src/molecule_dynamics.cpp
rba9f5b rbe97a8 13 13 #include "element.hpp" 14 14 #include "info.hpp" 15 #include "verbose.hpp" 15 16 #include "log.hpp" 16 #include "memoryallocator.hpp"17 17 #include "molecule.hpp" 18 18 #include "parser.hpp" 19 19 #include "Plane.hpp" 20 20 #include "ThermoStatContainer.hpp" 21 22 #include <gsl/gsl_matrix.h> 23 #include <gsl/gsl_vector.h> 24 #include <gsl/gsl_linalg.h> 21 25 22 26 /************************************* Functions for class molecule *********************************/ -
src/molecule_fragmentation.cpp
rba9f5b rbe97a8 17 17 #include "helpers.hpp" 18 18 #include "lists.hpp" 19 #include "verbose.hpp" 19 20 #include "log.hpp" 20 #include "memoryallocator.hpp"21 21 #include "molecule.hpp" 22 22 #include "periodentafel.hpp" 23 23 #include "World.hpp" 24 #include "Matrix.hpp" 25 #include "Box.hpp" 26 #include "stackclass.hpp" 24 27 25 28 /************************************* Functions for class molecule *********************************/ … … 1716 1719 atom *Walker = NULL; 1717 1720 atom *OtherWalker = NULL; 1718 double * const cell_size = World::getInstance().getDomain(); 1719 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1721 Matrix matrix = World::getInstance().getDomain().getM(); 1720 1722 enum Shading *ColorList = NULL; 1721 1723 double tmp; … … 1757 1759 Translationvector[i] = (tmp < 0) ? +1. : -1.; 1758 1760 } 1759 Translationvector .MatrixMultiplication(matrix);1761 Translationvector *= matrix; 1760 1762 //Log() << Verbose(3) << "Translation vector is "; 1761 1763 Log() << Verbose(0) << Translationvector << endl; … … 1788 1790 delete(AtomStack); 1789 1791 delete[](ColorList); 1790 delete[](matrix);1791 1792 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1792 1793 }; -
src/molecule_geometry.cpp
rba9f5b rbe97a8 5 5 * Author: heber 6 6 */ 7 8 #ifdef HAVE_CONFIG_H 9 #include <config.h> 10 #endif 7 11 8 12 #include "Helpers/MemDebug.hpp" … … 14 18 #include "helpers.hpp" 15 19 #include "leastsquaremin.hpp" 20 #include "verbose.hpp" 16 21 #include "log.hpp" 17 #include "memoryallocator.hpp"18 22 #include "molecule.hpp" 19 23 #include "World.hpp" 20 24 #include "Plane.hpp" 25 #include "Matrix.hpp" 26 #include "Box.hpp" 21 27 #include <boost/foreach.hpp> 28 29 #include <gsl/gsl_eigen.h> 30 #include <gsl/gsl_multimin.h> 22 31 23 32 … … 33 42 const Vector *Center = DetermineCenterOfAll(); 34 43 const Vector *CenterBox = DetermineCenterOfBox(); 35 double * const cell_size = World::getInstance().getDomain(); 36 double *M = ReturnFullMatrixforSymmetric(cell_size); 37 double *Minv = InverseMatrix(M); 44 Box &domain = World::getInstance().getDomain(); 38 45 39 46 // go through all atoms 40 47 ActOnAllVectors( &Vector::SubtractVector, *Center); 41 48 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 42 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);43 44 delete[](M);45 delete[](Minv); 49 BOOST_FOREACH(atom* iter, atoms){ 50 *iter->node = domain.WrapPeriodically(*iter->node); 51 } 52 46 53 delete(Center); 47 54 delete(CenterBox); … … 56 63 { 57 64 bool status = true; 58 double * const cell_size = World::getInstance().getDomain(); 59 double *M = ReturnFullMatrixforSymmetric(cell_size); 60 double *Minv = InverseMatrix(M); 65 Box &domain = World::getInstance().getDomain(); 61 66 62 67 // go through all atoms 63 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);64 65 delete[](M);66 delete[](Minv); 68 BOOST_FOREACH(atom* iter, atoms){ 69 *iter->node = domain.WrapPeriodically(*iter->node); 70 } 71 67 72 return status; 68 73 }; … … 153 158 { 154 159 Vector *a = new Vector(0.5,0.5,0.5); 155 156 const double *cell_size = World::getInstance().getDomain(); 157 double *M = ReturnFullMatrixforSymmetric(cell_size); 158 a->MatrixMultiplication(M); 159 delete[](M); 160 160 const Matrix &M = World::getInstance().getDomain().getM(); 161 (*a) *= M; 161 162 return a; 162 163 }; … … 244 245 void molecule::TranslatePeriodically(const Vector *trans) 245 246 { 246 double * const cell_size = World::getInstance().getDomain(); 247 double *M = ReturnFullMatrixforSymmetric(cell_size); 248 double *Minv = InverseMatrix(M); 247 Box &domain = World::getInstance().getDomain(); 249 248 250 249 // go through all atoms 251 250 ActOnAllVectors( &Vector::AddVector, *trans); 252 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);253 254 delete[](M);255 delete[](Minv); 251 BOOST_FOREACH(atom* iter, atoms){ 252 *iter->node = domain.WrapPeriodically(*iter->node); 253 } 254 256 255 }; 257 256 … … 264 263 OBSERVE; 265 264 Plane p(*n,0); 266 BOOST_FOREACH( 265 BOOST_FOREACH(atom* iter, atoms ){ 267 266 (*iter->node) = p.mirrorVector(*iter->node); 268 267 } … … 274 273 void molecule::DeterminePeriodicCenter(Vector ¢er) 275 274 { 276 double * const cell_size = World::getInstance().getDomain(); 277 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 278 double *inversematrix = InverseMatrix(matrix); 275 const Matrix &matrix = World::getInstance().getDomain().getM(); 276 const Matrix &inversematrix = World::getInstance().getDomain().getM(); 279 277 double tmp; 280 278 bool flag; … … 288 286 if ((*iter)->type->Z != 1) { 289 287 #endif 290 Testvector = (*iter)->x; 291 Testvector.MatrixMultiplication(inversematrix); 288 Testvector = inversematrix * (*iter)->x; 292 289 Translationvector.Zero(); 293 290 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { … … 306 303 } 307 304 Testvector += Translationvector; 308 Testvector .MatrixMultiplication(matrix);305 Testvector *= matrix; 309 306 Center += Testvector; 310 307 Log() << Verbose(1) << "vector is: " << Testvector << endl; … … 313 310 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 314 311 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 315 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 316 Testvector.MatrixMultiplication(inversematrix); 312 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x; 317 313 Testvector += Translationvector; 318 Testvector .MatrixMultiplication(matrix);314 Testvector *= matrix; 319 315 Center += Testvector; 320 316 Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl; … … 325 321 } 326 322 } while (!flag); 327 delete[](matrix);328 delete[](inversematrix);329 323 330 324 Center.Scale(1./static_cast<double>(getAtomCount())); … … 388 382 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 389 383 // the eigenvectors specify the transformation matrix 390 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 384 Matrix M = Matrix(evec->data); 385 BOOST_FOREACH(atom* iter, atoms){ 386 (*iter->node) *= M; 387 } 391 388 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 392 389 -
src/molecule_graph.cpp
rba9f5b rbe97a8 5 5 * Author: heber 6 6 */ 7 8 #ifdef HAVE_CONFIG_H 9 #include <config.h> 10 #endif 7 11 8 12 #include "Helpers/MemDebug.hpp" … … 18 22 #include "linkedcell.hpp" 19 23 #include "lists.hpp" 24 #include "verbose.hpp" 20 25 #include "log.hpp" 21 #include "memoryallocator.hpp"22 26 #include "molecule.hpp" 23 27 #include "World.hpp" 24 28 #include "Helpers/fast_functions.hpp" 25 29 #include "Helpers/Assert.hpp" 26 30 #include "Matrix.hpp" 31 #include "Box.hpp" 32 #include "stackclass.hpp" 27 33 28 34 struct BFSAccounting … … 121 127 LinkedCell *LC = NULL; 122 128 bool free_BG = false; 123 double * const cell_size= World::getInstance().getDomain();129 Box &domain = World::getInstance().getDomain(); 124 130 125 131 if (BG == NULL) { … … 178 184 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 179 185 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 180 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);186 const double distance = domain.periodicDistanceSquared(OtherWalker->x,Walker->x); 181 187 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 182 188 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 579 585 // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph 580 586 DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl); 581 LeafWalker->Leaf->Output((ofstream *)& cout);587 LeafWalker->Leaf->Output((ofstream *)&(Log() << Verbose(0))); 582 588 DoLog(0) && (Log() << Verbose(0) << endl); 583 589 -
src/molecule_pointcloud.cpp
rba9f5b rbe97a8 11 11 #include "config.hpp" 12 12 #include "info.hpp" 13 #include "memoryallocator.hpp"14 13 #include "molecule.hpp" 15 14 -
src/moleculelist.cpp
rba9f5b rbe97a8 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H 8 #include <config.h> 9 #endif 10 7 11 #include "Helpers/MemDebug.hpp" 8 12 9 13 #include <cstring> 14 15 #include <gsl/gsl_inline.h> 16 #include <gsl/gsl_heapsort.h> 10 17 11 18 #include "World.hpp" … … 19 26 #include "linkedcell.hpp" 20 27 #include "lists.hpp" 28 #include "verbose.hpp" 21 29 #include "log.hpp" 22 30 #include "molecule.hpp" 23 #include "memoryallocator.hpp"24 31 #include "periodentafel.hpp" 25 32 #include "Helpers/Assert.hpp" 33 #include "Matrix.hpp" 34 #include "Box.hpp" 35 #include "stackclass.hpp" 26 36 27 37 #include "Helpers/Assert.hpp" … … 631 641 int FragmentCounter = 0; 632 642 ofstream output; 633 double cell_size_backup[6]; 634 double * const cell_size = World::getInstance().getDomain(); 635 636 // backup cell_size 637 for (int i=0;i<6;i++) 638 cell_size_backup[i] = cell_size[i]; 643 Matrix cell_size = World::getInstance().getDomain().getM(); 644 Matrix cell_size_backup = cell_size; 645 639 646 // store the fragments as config and as xyz 640 647 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { … … 674 681 (*ListRunner)->CenterEdge(&BoxDimension); 675 682 (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary 676 int j = -1;677 683 for (int k = 0; k < NDIM; k++) { 678 j += k + 1;679 684 BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem); 680 cell_size[j] = BoxDimension[k] * 2.; 681 } 685 cell_size.at(k,k) = BoxDimension[k] * 2.; 686 } 687 World::getInstance().setDomain(cell_size); 682 688 (*ListRunner)->Translate(&BoxDimension); 683 689 … … 725 731 726 732 // restore cell_size 727 for (int i=0;i<6;i++) 728 cell_size[i] = cell_size_backup[i]; 733 World::getInstance().setDomain(cell_size_backup); 729 734 730 735 return result; … … 887 892 // center at set box dimensions 888 893 mol->CenterEdge(¢er); 889 World::getInstance().getDomain()[0] = center[0]; 890 World::getInstance().getDomain()[1] = 0; 891 World::getInstance().getDomain()[2] = center[1]; 892 World::getInstance().getDomain()[3] = 0; 893 World::getInstance().getDomain()[4] = 0; 894 World::getInstance().getDomain()[5] = center[2]; 894 Matrix domain; 895 for(int i =0;i<NDIM;++i) 896 domain.at(i,i) = center[i]; 897 World::getInstance().setDomain(domain); 895 898 insert(mol); 896 899 } -
src/parser.cpp
rba9f5b rbe97a8 12 12 13 13 #include "helpers.hpp" 14 #include "memoryallocator.hpp"15 14 #include "parser.hpp" 15 #include "verbose.hpp" 16 16 17 17 // include config.h -
src/periodentafel.hpp
rba9f5b rbe97a8 9 9 #endif 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 #include <map> 13 #include <iterator>14 13 15 14 #include "unittests/periodentafelTest.hpp" -
src/stackclass.hpp
rba9f5b rbe97a8 12 12 13 13 #include "verbose.hpp" 14 #include " memoryallocator.hpp"14 #include "log.hpp" 15 15 16 16 /****************************************** forward declarations *****************************/ -
src/tesselation.cpp
rba9f5b rbe97a8 9 9 10 10 #include <fstream> 11 #include <iomanip> 11 12 12 13 #include "helpers.hpp" -
src/tesselationhelpers.cpp
rba9f5b rbe97a8 21 21 #include "verbose.hpp" 22 22 #include "Plane.hpp" 23 24 double DetGet(gsl_matrix * const A, const int inPlace) 25 { 26 Info FunctionInfo(__func__); 27 /* 28 inPlace = 1 => A is replaced with the LU decomposed copy. 29 inPlace = 0 => A is retained, and a copy is used for LU. 30 */ 31 32 double det; 33 int signum; 34 gsl_permutation *p = gsl_permutation_alloc(A->size1); 35 gsl_matrix *tmpA=0; 36 37 if (inPlace) 38 tmpA = A; 39 else { 40 gsl_matrix *tmpA = gsl_matrix_alloc(A->size1, A->size2); 41 gsl_matrix_memcpy(tmpA , A); 42 } 43 44 45 gsl_linalg_LU_decomp(tmpA , p , &signum); 46 det = gsl_linalg_LU_det(tmpA , signum); 47 gsl_permutation_free(p); 48 if (! inPlace) 49 gsl_matrix_free(tmpA); 50 51 return det; 52 }; 23 #include "Matrix.hpp" 53 24 54 25 void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS) 55 26 { 56 27 Info FunctionInfo(__func__); 57 gsl_matrix *A = gsl_matrix_calloc(3,3);28 Matrix mat; 58 29 double m11, m12, m13, m14; 59 30 60 31 for(int i=0;i<3;i++) { 61 gsl_matrix_set(A,i, 0, a[i]);62 gsl_matrix_set(A,i, 1, b[i]);63 gsl_matrix_set(A,i, 2, c[i]);64 } 65 m11 = DetGet(A, 1);32 mat.set(i, 0, a[i]); 33 mat.set(i, 1, b[i]); 34 mat.set(i, 2, c[i]); 35 } 36 m11 = mat.determinant(); 66 37 67 38 for(int i=0;i<3;i++) { 68 gsl_matrix_set(A,i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);69 gsl_matrix_set(A,i, 1, b[i]);70 gsl_matrix_set(A,i, 2, c[i]);71 } 72 m12 = DetGet(A, 1);39 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]); 40 mat.set(i, 1, b[i]); 41 mat.set(i, 2, c[i]); 42 } 43 m12 = mat.determinant(); 73 44 74 45 for(int i=0;i<3;i++) { 75 gsl_matrix_set(A,i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);76 gsl_matrix_set(A,i, 1, a[i]);77 gsl_matrix_set(A,i, 2, c[i]);78 } 79 m13 = DetGet(A, 1);46 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]); 47 mat.set(i, 1, a[i]); 48 mat.set(i, 2, c[i]); 49 } 50 m13 = mat.determinant(); 80 51 81 52 for(int i=0;i<3;i++) { 82 gsl_matrix_set(A,i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);83 gsl_matrix_set(A,i, 1, a[i]);84 gsl_matrix_set(A,i, 2, b[i]);85 } 86 m14 = DetGet(A, 1);53 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]); 54 mat.set(i, 1, a[i]); 55 mat.set(i, 2, b[i]); 56 } 57 m14 = mat.determinant(); 87 58 88 59 if (fabs(m11) < MYEPSILON) … … 95 66 if (fabs(a.distance(*center) - RADIUS) > MYEPSILON) 96 67 DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.distance(*center) - RADIUS) << " from a than RADIUS." << endl); 97 98 gsl_matrix_free(A);99 68 }; 100 69 … … 248 217 Vector x3; 249 218 Vector x4; 250 };251 252 /**253 * Intersection calculation function.254 *255 * @param x to find the result for256 * @param function parameter257 */258 double MinIntersectDistance(const gsl_vector * x, void *params)259 {260 Info FunctionInfo(__func__);261 double retval = 0;262 struct Intersection *I = (struct Intersection *)params;263 Vector intersection;264 for (int i=0;i<NDIM;i++)265 intersection[i] = gsl_vector_get(x, i);266 267 Vector SideA = I->x1 -I->x2 ;268 Vector HeightA = intersection - I->x1;269 HeightA.ProjectOntoPlane(SideA);270 271 Vector SideB = I->x3 - I->x4;272 Vector HeightB = intersection - I->x3;273 HeightB.ProjectOntoPlane(SideB);274 275 retval = HeightA.ScalarProduct(HeightA) + HeightB.ScalarProduct(HeightB);276 //Log() << Verbose(1) << "MinIntersectDistance called, result: " << retval << endl;277 278 return retval;279 };280 281 282 /**283 * Calculates whether there is an intersection between two lines. The first line284 * always goes through point 1 and point 2 and the second line is given by the285 * connection between point 4 and point 5.286 *287 * @param point 1 of line 1288 * @param point 2 of line 1289 * @param point 1 of line 2290 * @param point 2 of line 2291 *292 * @return true if there is an intersection between the given lines, false otherwise293 */294 bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4)295 {296 Info FunctionInfo(__func__);297 bool result;298 299 struct Intersection par;300 par.x1 = point1;301 par.x2 = point2;302 par.x3 = point3;303 par.x4 = point4;304 305 const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;306 gsl_multimin_fminimizer *s = NULL;307 gsl_vector *ss, *x;308 gsl_multimin_function minexFunction;309 310 size_t iter = 0;311 int status;312 double size;313 314 /* Starting point */315 x = gsl_vector_alloc(NDIM);316 gsl_vector_set(x, 0, point1[0]);317 gsl_vector_set(x, 1, point1[1]);318 gsl_vector_set(x, 2, point1[2]);319 320 /* Set initial step sizes to 1 */321 ss = gsl_vector_alloc(NDIM);322 gsl_vector_set_all(ss, 1.0);323 324 /* Initialize method and iterate */325 minexFunction.n = NDIM;326 minexFunction.f = &MinIntersectDistance;327 minexFunction.params = (void *)∥328 329 s = gsl_multimin_fminimizer_alloc(T, NDIM);330 gsl_multimin_fminimizer_set(s, &minexFunction, x, ss);331 332 do {333 iter++;334 status = gsl_multimin_fminimizer_iterate(s);335 336 if (status) {337 break;338 }339 340 size = gsl_multimin_fminimizer_size(s);341 status = gsl_multimin_test_size(size, 1e-2);342 343 if (status == GSL_SUCCESS) {344 DoLog(1) && (Log() << Verbose(1) << "converged to minimum" << endl);345 }346 } while (status == GSL_CONTINUE && iter < 100);347 348 // check whether intersection is in between or not349 Vector intersection;350 double t1, t2;351 for (int i = 0; i < NDIM; i++) {352 intersection[i] = gsl_vector_get(s->x, i);353 }354 355 Vector SideA = par.x2 - par.x1;356 Vector HeightA = intersection - par.x1;357 358 t1 = HeightA.ScalarProduct(SideA)/SideA.ScalarProduct(SideA);359 360 Vector SideB = par.x4 - par.x3;361 Vector HeightB = intersection - par.x3;362 363 t2 = HeightB.ScalarProduct(SideB)/SideB.ScalarProduct(SideB);364 365 Log() << Verbose(1) << "Intersection " << intersection << " is at "366 << t1 << " for (" << point1 << "," << point2 << ") and at "367 << t2 << " for (" << point3 << "," << point4 << "): ";368 369 if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) {370 DoLog(1) && (Log() << Verbose(1) << "true intersection." << endl);371 result = true;372 } else {373 DoLog(1) && (Log() << Verbose(1) << "intersection out of region of interest." << endl);374 result = false;375 }376 377 // free minimizer stuff378 gsl_vector_free(x);379 gsl_vector_free(ss);380 gsl_multimin_fminimizer_free(s);381 382 return result;383 219 }; 384 220 -
src/tesselationhelpers.hpp
rba9f5b rbe97a8 20 20 #endif 21 21 22 #include <gsl/gsl_linalg.h> 23 #include <gsl/gsl_matrix.h> 24 #include <gsl/gsl_multimin.h> 25 #include <gsl/gsl_permutation.h> 26 #include <gsl/gsl_vector.h> 27 28 #include <iostream> 22 #include <iosfwd> 29 23 30 24 #include "defs.hpp" … … 47 41 /********************************************** declarations *******************************/ 48 42 49 double DetGet(gsl_matrix * const A, const int inPlace);50 43 void GetSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS); 51 44 void GetCenterOfSphere(Vector* const Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* const 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); 52 45 void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c); 53 46 double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection); 54 double MinIntersectDistance(const gsl_vector * x, void *params);55 bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4);56 47 double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d); 57 48 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C); -
src/triangleintersectionlist.cpp
rba9f5b rbe97a8 18 18 #include "tesselation.hpp" 19 19 #include "vector.hpp" 20 #include "verbose.hpp" 20 21 21 22 /** Constructor for class TriangleIntersectionList. -
src/unittests/ActOnAllUnitTest.cpp
rba9f5b rbe97a8 14 14 #include "../test/ActOnAlltest.hpp" 15 15 #include "ActOnAllUnitTest.hpp" 16 #include "memoryallocator.hpp"17 16 #include "vector.hpp" 18 17 -
src/unittests/LineUnittest.cpp
rba9f5b rbe97a8 17 17 18 18 #include <iostream> 19 #include <cmath> 19 20 20 21 using namespace std; … … 352 353 CPPUNIT_ASSERT_EQUAL(fixture,zeroVec); 353 354 } 355 356 void LineUnittest::sphereIntersectionTest(){ 357 { 358 std::vector<Vector> res = la1->getSphereIntersections(); 359 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 360 CPPUNIT_ASSERT(testDirection(res[0],e1)); 361 CPPUNIT_ASSERT(testDirection(res[1],e1)); 362 CPPUNIT_ASSERT(res[0]!=res[1]); 363 } 364 365 { 366 std::vector<Vector> res = la2->getSphereIntersections(); 367 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 368 CPPUNIT_ASSERT(testDirection(res[0],e2)); 369 CPPUNIT_ASSERT(testDirection(res[1],e2)); 370 CPPUNIT_ASSERT(res[0]!=res[1]); 371 } 372 373 { 374 std::vector<Vector> res = la3->getSphereIntersections(); 375 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 376 CPPUNIT_ASSERT(testDirection(res[0],e3)); 377 CPPUNIT_ASSERT(testDirection(res[1],e3)); 378 CPPUNIT_ASSERT(res[0]!=res[1]); 379 } 380 381 { 382 std::vector<Vector> res = lp1->getSphereIntersections(); 383 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 384 CPPUNIT_ASSERT((res[0]==e1) || (res[0]==e2)); 385 CPPUNIT_ASSERT((res[1]==e1) || (res[1]==e2)); 386 CPPUNIT_ASSERT(res[0]!=res[1]); 387 } 388 389 { 390 std::vector<Vector> res = lp2->getSphereIntersections(); 391 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 392 CPPUNIT_ASSERT((res[0]==e2) || (res[0]==e3)); 393 CPPUNIT_ASSERT((res[1]==e2) || (res[1]==e3)); 394 CPPUNIT_ASSERT(res[0]!=res[1]); 395 } 396 397 { 398 std::vector<Vector> res = lp3->getSphereIntersections(); 399 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 400 CPPUNIT_ASSERT((res[0]==e3) || (res[0]==e1)); 401 CPPUNIT_ASSERT((res[1]==e3) || (res[1]==e1)); 402 CPPUNIT_ASSERT(res[0]!=res[1]); 403 } 404 } -
src/unittests/LineUnittest.hpp
rba9f5b rbe97a8 22 22 CPPUNIT_TEST ( intersectionTest ); 23 23 CPPUNIT_TEST ( rotationTest ); 24 CPPUNIT_TEST ( sphereIntersectionTest ); 24 25 CPPUNIT_TEST_SUITE_END(); 25 26 … … 33 34 void intersectionTest(); 34 35 void rotationTest(); 36 void sphereIntersectionTest(); 35 37 36 38 private: -
src/unittests/Makefile.am
rba9f5b rbe97a8 31 31 LogUnitTest \ 32 32 manipulateAtomsTest \ 33 MemoryUsageObserverUnitTest \ 34 MemoryAllocatorUnitTest \ 33 MatrixUnittest \ 35 34 MoleculeDescriptorTest \ 36 35 ObserverTest \ … … 38 37 periodentafelTest \ 39 38 PlaneUnittest \ 39 ShapeUnittest \ 40 40 SingletonTest \ 41 41 StackClassUnitTest \ … … 75 75 listofbondsunittest.cpp \ 76 76 logunittest.cpp \ 77 MatrixUnittest.cpp \ 77 78 manipulateAtomsTest.cpp \ 78 memoryallocatorunittest.cpp \79 memoryusageobserverunittest.cpp \80 79 MoleculeDescriptorTest.cpp \ 81 80 ObserverTest.cpp \ … … 83 82 periodentafelTest.cpp \ 84 83 PlaneUnittest.cpp \ 84 ShapeUnittest.cpp \ 85 85 SingletonTest.cpp \ 86 86 stackclassunittest.cpp \ … … 112 112 logunittest.hpp \ 113 113 manipulateAtomsTest.hpp \ 114 memoryallocatorunittest.hpp \ 115 memoryusageobserverunittest.hpp \ 114 MatrixUnittest.hpp \ 116 115 MoleculeDescriptorTest.hpp \ 117 116 periodentafelTest.hpp \ … … 189 188 manipulateAtomsTest_LDADD = ${ALLLIBS} 190 189 191 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 192 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS} 193 194 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 195 MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS} 190 MatrixUnittest_SOURCES = UnitTestMain.cpp MatrixUnittest.cpp MatrixUnittest.hpp 191 MatrixUnittest_LDADD = ${ALLLIBS} 196 192 197 193 MoleculeDescriptorTest_SOURCES = UnitTestMain.cpp MoleculeDescriptorTest.cpp MoleculeDescriptorTest.hpp … … 210 206 PlaneUnittest_LDADD = ${ALLLIBS} 211 207 208 ShapeUnittest_SOURCES = UnitTestMain.cpp ShapeUnittest.cpp ShapeUnittest.hpp 209 ShapeUnittest_LDADD = ${ALLLIBS} 210 212 211 SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp 213 212 SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB} … … 225 224 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 226 225 227 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp$(TESTSOURCES) $(TESTHEADERS)226 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS) 228 227 TestRunner_LDADD = ${ALLLIBS} 229 228 -
src/unittests/ObserverTest.cpp
rba9f5b rbe97a8 182 182 }; 183 183 184 class Observable Collection: public Observable {184 class ObservableSet : public Observable { 185 185 public: 186 186 typedef std::set<SimpleObservable*> set; … … 188 188 typedef set::const_iterator const_iterator; 189 189 190 Observable Collection(int _num) :190 ObservableSet(int _num) : 191 191 Observable("ObservableCollection"), 192 192 num(_num) … … 199 199 } 200 200 201 ~Observable Collection(){201 ~ObservableSet(){ 202 202 set::iterator iter; 203 203 for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){ 204 204 delete (*iter); 205 } 206 } 207 208 iterator begin(){ 209 return iterator(theSet.begin(),this); 210 } 211 212 iterator end(){ 213 return iterator(theSet.end(),this); 214 } 215 216 const int num; 217 218 private: 219 set theSet; 220 }; 221 222 class ObservableMap : public Observable { 223 public: 224 typedef std::map<int,SimpleObservable*> set; 225 typedef ObservedIterator<set> iterator; 226 typedef set::const_iterator const_iterator; 227 228 ObservableMap(int _num) : 229 Observable("ObservableCollection"), 230 num(_num) 231 { 232 for(int i=0; i<num; ++i){ 233 SimpleObservable *content = new SimpleObservable(); 234 content->signOn(this); 235 theSet.insert(make_pair(i,content)); 236 } 237 } 238 239 ~ObservableMap(){ 240 set::iterator iter; 241 for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){ 242 delete iter->second; 205 243 } 206 244 } … … 231 269 blockObservable = new BlockObservable(); 232 270 notificationObservable = new NotificationObservable(); 233 collection = new ObservableCollection(5); 271 obsset = new ObservableSet(5); 272 obsmap = new ObservableMap(5); 234 273 235 274 observer1 = new UpdateCountObserver(); … … 249 288 delete blockObservable; 250 289 delete notificationObservable; 251 delete collection; 290 delete obsset; 291 delete obsmap; 252 292 253 293 delete observer1; … … 268 308 simpleObservable2->signOn(observer4); 269 309 310 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 311 CPPUNIT_ASSERT_EQUAL( 0, observer2->updates ); 312 CPPUNIT_ASSERT_EQUAL( 0, observer3->updates ); 313 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 314 315 270 316 simpleObservable1->changeMethod(); 271 317 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates ); … … 292 338 void ObserverTest::doesBlockUpdateTest() { 293 339 callObservable->signOn(observer1); 340 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 294 341 295 342 callObservable->changeMethod1(); … … 311 358 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 312 359 CPPUNIT_ASSERT_EQUAL( 2, observer2->updates ); 360 } 361 362 void ObserverTest::outsideLockTest(){ 363 callObservable->signOn(observer1); 364 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 365 366 { 367 LOCK_OBSERVABLE(*callObservable); 368 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 369 } 370 // lock is gone now, observer should have notified 371 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates ); 313 372 } 314 373 … … 341 400 int i = 0; 342 401 // test the general iterator methods 343 for(Observable Collection::iterator iter=collection->begin(); iter!=collection->end();++iter){344 CPPUNIT_ASSERT(i< collection->num);402 for(ObservableSet::iterator iter=obsset->begin(); iter!=obsset->end();++iter){ 403 CPPUNIT_ASSERT(i< obsset->num); 345 404 i++; 346 405 } 347 406 348 407 i=0; 349 for(Observable Collection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){350 CPPUNIT_ASSERT(i< collection->num);351 i++; 352 } 353 354 collection->signOn(observer1);408 for(ObservableSet::const_iterator iter=obsset->begin(); iter!=obsset->end();++iter){ 409 CPPUNIT_ASSERT(i<obsset->num); 410 i++; 411 } 412 413 obsset->signOn(observer1); 355 414 { 356 415 // we construct this out of the loop, so the iterator dies at the end of 357 416 // the scope and not the end of the loop (allows more testing) 358 Observable Collection::iterator iter;359 for(iter= collection->begin(); iter!=collection->end(); ++iter){417 ObservableSet::iterator iter; 418 for(iter=obsset->begin(); iter!=obsset->end(); ++iter){ 360 419 (*iter)->changeMethod(); 361 420 } … … 367 426 368 427 // when using a const_iterator no changes should be propagated 369 for(Observable Collection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);428 for(ObservableSet::const_iterator iter = obsset->begin(); iter!=obsset->end();++iter); 370 429 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates); 371 collection->signOff(observer1); 430 431 // we need to test the operator-> as well 432 obsmap->signOn(observer2); 433 { 434 // we construct this out of the loop, so the iterator dies at the end of 435 // the scope and not the end of the loop (allows more testing) 436 ObservableMap::iterator iter; 437 for(iter=obsmap->begin(); iter!=obsmap->end(); ++iter){ 438 iter->second->changeMethod(); 439 } 440 // At this point no change should have been propagated 441 CPPUNIT_ASSERT_EQUAL( 0, observer2->updates); 442 } 443 // After the Iterator has died the propagation should take place 444 CPPUNIT_ASSERT_EQUAL( 1, observer2->updates); 445 446 447 obsset->signOff(observer1); 448 obsmap->signOff(observer2); 372 449 } 373 450 -
src/unittests/ObserverTest.hpp
rba9f5b rbe97a8 17 17 class CallObservable; 18 18 class SuperObservable; 19 class ObservableCollection; 19 class ObservableSet; 20 class ObservableMap; 20 21 class BlockObservable; 21 22 class NotificationObservable; … … 27 28 CPPUNIT_TEST ( doesBlockUpdateTest ); 28 29 CPPUNIT_TEST ( doesSubObservableTest ); 30 CPPUNIT_TEST ( outsideLockTest ); 29 31 CPPUNIT_TEST ( doesNotifyTest ); 30 32 CPPUNIT_TEST ( doesReportTest ); … … 40 42 void doesBlockUpdateTest(); 41 43 void doesSubObservableTest(); 44 void outsideLockTest(); 42 45 void doesNotifyTest(); 43 46 void doesReportTest(); … … 60 63 SuperObservable *superObservable; 61 64 NotificationObservable *notificationObservable; 62 ObservableCollection *collection; 65 ObservableSet *obsset; 66 ObservableMap *obsmap; 63 67 64 68 }; -
src/unittests/PlaneUnittest.cpp
rba9f5b rbe97a8 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <cmath> 13 15 14 16 #ifdef HAVE_TESTRUNNER -
src/unittests/linearsystemofequationsunittest.cpp
rba9f5b rbe97a8 12 12 #include <cppunit/extensions/TestFactoryRegistry.h> 13 13 #include <cppunit/ui/text/TestRunner.h> 14 #include <cmath> 14 15 15 16 #include "linearsystemofequationsunittest.hpp" -
src/unittests/tesselation_insideoutsideunittest.cpp
rba9f5b rbe97a8 17 17 #include "tesselation.hpp" 18 18 #include "tesselation_insideoutsideunittest.hpp" 19 #include "verbose.hpp" 19 20 20 21 #ifdef HAVE_TESTRUNNER -
src/unittests/vectorunittest.cpp
rba9f5b rbe97a8 15 15 #include "defs.hpp" 16 16 #include "log.hpp" 17 #include "memoryusageobserver.hpp"18 17 #include "vector.hpp" 19 18 #include "vector_ops.hpp" … … 21 20 #include "Plane.hpp" 22 21 #include "Exceptions/LinearDependenceException.hpp" 22 #include "Matrix.hpp" 23 23 24 24 #ifdef HAVE_TESTRUNNER … … 214 214 CPPUNIT_ASSERT(testVector.ScalarProduct(three) < MYEPSILON); 215 215 } 216 217 218 /**219 * UnitTest for Vector::IsInParallelepiped().220 */221 void VectorTest::IsInParallelepipedTest()222 {223 double parallelepiped[NDIM*NDIM];224 parallelepiped[0] = 1;225 parallelepiped[1] = 0;226 parallelepiped[2] = 0;227 parallelepiped[3] = 0;228 parallelepiped[4] = 1;229 parallelepiped[5] = 0;230 parallelepiped[6] = 0;231 parallelepiped[7] = 0;232 parallelepiped[8] = 1;233 234 fixture = zero;235 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );236 fixture = Vector(2.5,2.5,2.5);237 CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );238 fixture = Vector(1.,1.,1.);239 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );240 fixture = Vector(3.5,3.5,3.5);241 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );242 fixture = Vector(2.,2.,2.);243 CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );244 fixture = Vector(2.,3.,2.);245 CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );246 fixture = Vector(-2.,2.,-1.);247 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );248 }249 -
src/unittests/vectorunittest.hpp
rba9f5b rbe97a8 27 27 CPPUNIT_TEST ( ProjectionTest ); 28 28 CPPUNIT_TEST ( NormalsTest ); 29 CPPUNIT_TEST ( IsInParallelepipedTest );30 29 CPPUNIT_TEST_SUITE_END(); 31 30 … … 45 44 void LineIntersectionTest(); 46 45 void VectorRotationTest(); 47 void IsInParallelepipedTest();48 46 49 47 private: -
src/vector.cpp
rba9f5b rbe97a8 8 8 9 9 #include "vector.hpp" 10 #include "VectorContent.hpp" 10 11 #include "verbose.hpp" 11 12 #include "World.hpp" 12 13 #include "Helpers/Assert.hpp" 13 14 #include "Helpers/fast_functions.hpp" 15 #include "Exceptions/MathException.hpp" 14 16 15 17 #include <iostream> 18 #include <gsl/gsl_blas.h> 19 16 20 17 21 using namespace std; … … 24 28 Vector::Vector() 25 29 { 26 content = gsl_vector_calloc (NDIM);30 content = new VectorContent(); 27 31 }; 28 32 … … 33 37 Vector::Vector(const Vector& src) 34 38 { 35 content = gsl_vector_alloc(NDIM); 36 gsl_vector_set(content,0,src[0]); 37 gsl_vector_set(content,1,src[1]); 38 gsl_vector_set(content,2,src[2]); 39 content = new VectorContent(); 40 gsl_vector_memcpy(content->content, src.content->content); 39 41 } 40 42 … … 43 45 Vector::Vector(const double x1, const double x2, const double x3) 44 46 { 45 content = gsl_vector_alloc(NDIM); 46 gsl_vector_set(content,0,x1); 47 gsl_vector_set(content,1,x2); 48 gsl_vector_set(content,2,x3); 49 }; 47 content = new VectorContent(); 48 gsl_vector_set(content->content,0,x1); 49 gsl_vector_set(content->content,1,x2); 50 gsl_vector_set(content->content,2,x3); 51 }; 52 53 Vector::Vector(VectorContent *_content) : 54 content(_content) 55 {} 50 56 51 57 /** … … 55 61 // check for self assignment 56 62 if(&src!=this){ 57 gsl_vector_set(content,0,src[0]); 58 gsl_vector_set(content,1,src[1]); 59 gsl_vector_set(content,2,src[2]); 63 gsl_vector_memcpy(content->content, src.content->content); 60 64 } 61 65 return *this; … … 65 69 */ 66 70 Vector::~Vector() { 67 gsl_vector_free(content);71 delete content; 68 72 }; 69 73 … … 94 98 } 95 99 96 /** Calculates distance between this and another vector in a periodic cell.97 * \param *y array to second vector98 * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell99 * \return \f$| x - y |\f$100 */101 double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const102 {103 double res = distance(y), tmp, matrix[NDIM*NDIM];104 Vector Shiftedy, TranslationVector;105 int N[NDIM];106 matrix[0] = cell_size[0];107 matrix[1] = cell_size[1];108 matrix[2] = cell_size[3];109 matrix[3] = cell_size[1];110 matrix[4] = cell_size[2];111 matrix[5] = cell_size[4];112 matrix[6] = cell_size[3];113 matrix[7] = cell_size[4];114 matrix[8] = cell_size[5];115 // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells116 for (N[0]=-1;N[0]<=1;N[0]++)117 for (N[1]=-1;N[1]<=1;N[1]++)118 for (N[2]=-1;N[2]<=1;N[2]++) {119 // create the translation vector120 TranslationVector.Zero();121 for (int i=NDIM;i--;)122 TranslationVector[i] = (double)N[i];123 TranslationVector.MatrixMultiplication(matrix);124 // add onto the original vector to compare with125 Shiftedy = y + TranslationVector;126 // get distance and compare with minimum so far127 tmp = distance(Shiftedy);128 if (tmp < res) res = tmp;129 }130 return (res);131 };132 133 /** Calculates distance between this and another vector in a periodic cell.134 * \param *y array to second vector135 * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell136 * \return \f$| x - y |^2\f$137 */138 double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const139 {140 double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];141 Vector Shiftedy, TranslationVector;142 int N[NDIM];143 matrix[0] = cell_size[0];144 matrix[1] = cell_size[1];145 matrix[2] = cell_size[3];146 matrix[3] = cell_size[1];147 matrix[4] = cell_size[2];148 matrix[5] = cell_size[4];149 matrix[6] = cell_size[3];150 matrix[7] = cell_size[4];151 matrix[8] = cell_size[5];152 // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells153 for (N[0]=-1;N[0]<=1;N[0]++)154 for (N[1]=-1;N[1]<=1;N[1]++)155 for (N[2]=-1;N[2]<=1;N[2]++) {156 // create the translation vector157 TranslationVector.Zero();158 for (int i=NDIM;i--;)159 TranslationVector[i] = (double)N[i];160 TranslationVector.MatrixMultiplication(matrix);161 // add onto the original vector to compare with162 Shiftedy = y + TranslationVector;163 // get distance and compare with minimum so far164 tmp = DistanceSquared(Shiftedy);165 if (tmp < res) res = tmp;166 }167 return (res);168 };169 170 /** Keeps the vector in a periodic cell, defined by the symmetric \a *matrix.171 * \param *out ofstream for debugging messages172 * Tries to translate a vector into each adjacent neighbouring cell.173 */174 void Vector::KeepPeriodic(const double * const matrix)175 {176 // int N[NDIM];177 // bool flag = false;178 //vector Shifted, TranslationVector;179 // Log() << Verbose(1) << "Begin of KeepPeriodic." << endl;180 // Log() << Verbose(2) << "Vector is: ";181 // Output(out);182 // Log() << Verbose(0) << endl;183 InverseMatrixMultiplication(matrix);184 for(int i=NDIM;i--;) { // correct periodically185 if (at(i) < 0) { // get every coefficient into the interval [0,1)186 at(i) += ceil(at(i));187 } else {188 at(i) -= floor(at(i));189 }190 }191 MatrixMultiplication(matrix);192 // Log() << Verbose(2) << "New corrected vector is: ";193 // Output(out);194 // Log() << Verbose(0) << endl;195 // Log() << Verbose(1) << "End of KeepPeriodic." << endl;196 };197 198 100 /** Calculates scalar product between this and another vector. 199 101 * \param *y array to second vector … … 203 105 { 204 106 double res = 0.; 205 for (int i=NDIM;i--;) 206 res += at(i)*y[i]; 107 gsl_blas_ddot(content->content, y.content->content, &res); 207 108 return (res); 208 109 }; … … 369 270 double& Vector::operator[](size_t i){ 370 271 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 371 return *gsl_vector_ptr (content , i);272 return *gsl_vector_ptr (content->content, i); 372 273 } 373 274 374 275 const double& Vector::operator[](size_t i) const{ 375 276 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 376 return *gsl_vector_ptr (content , i);277 return *gsl_vector_ptr (content->content, i); 377 278 } 378 279 … … 385 286 } 386 287 387 gsl_vector* Vector::get(){288 VectorContent* Vector::get(){ 388 289 return content; 389 290 } … … 504 405 }; 505 406 407 void Vector::ScaleAll(const Vector &factor){ 408 gsl_vector_mul(content->content, factor.content->content); 409 } 506 410 507 411 508 412 void Vector::Scale(const double factor) 509 413 { 510 for (int i=NDIM;i--;) 511 at(i) *= factor; 512 }; 513 514 /** Given a box by its matrix \a *M and its inverse *Minv the vector is made to point within that box. 515 * \param *M matrix of box 516 * \param *Minv inverse matrix 517 */ 518 void Vector::WrapPeriodically(const double * const M, const double * const Minv) 519 { 520 MatrixMultiplication(Minv); 521 // truncate to [0,1] for each axis 522 for (int i=0;i<NDIM;i++) { 523 //at(i) += 0.5; // set to center of box 524 while (at(i) >= 1.) 525 at(i) -= 1.; 526 while (at(i) < 0.) 527 at(i) += 1.; 528 } 529 MatrixMultiplication(M); 414 gsl_vector_scale(content->content,factor); 530 415 }; 531 416 … … 546 431 return make_pair(res,helper); 547 432 } 548 549 /** Do a matrix multiplication.550 * \param *matrix NDIM_NDIM array551 */552 void Vector::MatrixMultiplication(const double * const M)553 {554 Vector tmp;555 // do the matrix multiplication556 for(int i=NDIM;i--;)557 tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2);558 559 (*this) = tmp;560 };561 562 /** Do a matrix multiplication with the \a *A' inverse.563 * \param *matrix NDIM_NDIM array564 */565 bool Vector::InverseMatrixMultiplication(const double * const A)566 {567 double B[NDIM*NDIM];568 double detA = RDET3(A);569 double detAReci;570 571 // calculate the inverse B572 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular573 detAReci = 1./detA;574 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11575 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12576 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13577 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21578 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22579 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23580 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31581 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32582 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33583 584 MatrixMultiplication(B);585 586 return true;587 } else {588 return false;589 }590 };591 592 433 593 434 /** Creates this vector as the b y *factors' components scaled linear combination of the given three. … … 679 520 void Vector::AddVector(const Vector &y) 680 521 { 681 for(int i=NDIM;i--;) 682 at(i) += y[i]; 522 gsl_vector_add(content->content, y.content->content); 683 523 } 684 524 … … 688 528 void Vector::SubtractVector(const Vector &y) 689 529 { 690 for(int i=NDIM;i--;) 691 at(i) -= y[i]; 692 } 693 694 /** 695 * Checks whether this vector is within the parallelepiped defined by the given three vectors and 696 * their offset. 697 * 698 * @param offest for the origin of the parallelepiped 699 * @param three vectors forming the matrix that defines the shape of the parallelpiped 700 */ 701 bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const 702 { 703 Vector a = (*this)-offset; 704 a.InverseMatrixMultiplication(parallelepiped); 705 bool isInside = true; 706 707 for (int i=NDIM;i--;) 708 isInside = isInside && ((a[i] <= 1) && (a[i] >= 0)); 709 710 return isInside; 530 gsl_vector_sub(content->content, y.content->content); 711 531 } 712 532 -
src/vector.hpp
rba9f5b rbe97a8 11 11 #endif 12 12 13 #include <iostream> 14 #include <gsl/gsl_vector.h> 15 #include <gsl/gsl_multimin.h> 13 #include <iosfwd> 16 14 17 15 #include <memory> … … 24 22 25 23 class Vector; 24 class Matrix; 25 struct VectorContent; 26 26 27 27 typedef std::vector<Vector> pointset; … … 31 31 */ 32 32 class Vector : public Space{ 33 friend Vector operator*(const Matrix&,const Vector&); 34 friend class Matrix; 33 35 public: 34 35 36 Vector(); 36 37 Vector(const double x1, const double x2, const double x3); … … 42 43 double DistanceSquared(const Vector &y) const; 43 44 double DistanceToSpace(const Space& space) const; 44 double PeriodicDistance(const Vector &y, const double * const cell_size) const;45 double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const;46 45 double ScalarProduct(const Vector &y) const; 47 46 double Angle(const Vector &y) const; … … 58 57 Vector Projection(const Vector &y) const; 59 58 void ScaleAll(const double *factor); 59 void ScaleAll(const Vector &factor); 60 60 void Scale(const double factor); 61 void MatrixMultiplication(const double * const M);62 bool InverseMatrixMultiplication(const double * const M);63 void KeepPeriodic(const double * const matrix);64 61 bool GetOneNormalVector(const Vector &x1); 65 62 bool MakeNormalTo(const Vector &y1); 66 bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const;67 void WrapPeriodically(const double * const M, const double * const Minv);68 63 std::pair<Vector,Vector> partition(const Vector&) const; 69 64 std::pair<pointset,Vector> partition(const pointset&) const; … … 79 74 80 75 // Access to internal structure 81 gsl_vector* get();76 VectorContent* get(); 82 77 83 78 // Methods that are derived directly from other methods … … 104 99 105 100 private: 106 gsl_vector *content; 101 Vector(VectorContent *); 102 VectorContent *content; 107 103 108 104 }; -
src/vector_ops.cpp
rba9f5b rbe97a8 23 23 #include <gsl/gsl_permutation.h> 24 24 #include <gsl/gsl_vector.h> 25 #include <gsl/gsl_multimin.h> 25 26 26 27 /** -
src/verbose.cpp
rba9f5b rbe97a8 5 5 #include "info.hpp" 6 6 #include "verbose.hpp" 7 #include <iostream> 7 8 8 9 /** Prints the tabs according to verbosity stored in the temporary constructed class. -
src/verbose.hpp
rba9f5b rbe97a8 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 22 22 /************************************* Class Verbose & Binary *******************************/ -
test_all.sh
rba9f5b rbe97a8 23 23 docheck=0; 24 24 docheck_mem=0; 25 if [ -n "$TMPDIR" ] 26 then 27 tmpdir="$TMPDIR"; 28 else 29 tmpdir="/tmp"; 30 fi 31 tmppattern="MolecuilderTest"; 25 32 26 33 function usage(){ … … 36 43 echo " -c Only configure and compile (implies -s)"; 37 44 echo " -O <opt-level> Only compile this optimization level"; 38 } 39 40 while getopts âho:f:scO:â OPTION 45 echo " -t <tmpDir> Use tmpDir as temporary directory"; 46 echo " -p <prefix> Prefix to use for directory names (standart MolecuilderTest)"; 47 } 48 49 while getopts âho:f:scO:t:p:â OPTION 41 50 do 42 51 case $OPTION in … … 46 55 ;; 47 56 o) 48 outfile= $OPTARG;57 outfile="$OPTARG"; 49 58 ;; 50 59 f) 51 logfile= $OPTARG;60 logfile="$OPTARG"; 52 61 ;; 53 62 s) … … 61 70 optimizations=("-O$OPTARG"); 62 71 ;; 72 t) 73 tmpdir="$OPTARG"; 74 ;; 75 p) 76 tmppattern="$OPTARG"; 77 ;; 63 78 ?) 64 79 usage; … … 68 83 done 69 84 70 if [[ -z $outfile ]] || [[ -z $logfile ]] 85 # test if all arguments were provided 86 if [[ -z "$outfile" ]] || [[ -z "$logfile" ]] || [[ -z "$tmpdir" ]] || [[ -z "$tmppattern" ]] 71 87 then 72 88 usage; … … 74 90 fi 75 91 92 # turn all relative paths into absolutes 76 93 outfile=`realpath -s $outfile`; 77 94 logfile=`realpath -s $logfile`; 95 tmpdir=`realpath -s $tmpdir`; 78 96 79 97 … … 167 185 function run(){ 168 186 echo "Testing with \"$1\":" >> $outfile; 169 testdir=`mktemp -d --tmpdir MolecuilderTest.XXXXXXXXXX`;187 testdir=`mktemp -d --tmpdir=$tmpdir $tmppattern.XXXXXXXXXX`; 170 188 basedir=$PWD; 171 189 cd $testdir; -
tests/Tesselations/defs.in
rba9f5b rbe97a8 59 59 fi 60 60 #echo "Molecuilder done with exitcode $exitcode." 61 cd ../.. 61 62 #cat stderr 62 63 #cat stdout 63 grep -E "^[0-9]* [0-9]* [0-9]*$" ../../@srcdir@/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat64 grep -E "^[0-9]* [0-9]* [0-9]*$" $ {FILENAME}.dat | sort -n >new-triangles.dat65 diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$?64 grep -E "^[0-9]* [0-9]* [0-9]*$" @srcdir@/$mol/$2/${FILENAME}-$mol.dat | sort -n >$testdir/$RADIUS/reference-triangles.dat 65 grep -E "^[0-9]* [0-9]* [0-9]*$" $testdir/$RADIUS/${FILENAME}.dat | sort -n >$testdir/$RADIUS/new-triangles.dat 66 diff $testdir/$RADIUS/reference-triangles.dat $testdir/$RADIUS/new-triangles.dat 2>$testdir/$RADIUS/diffstderr >$testdir/$RADIUS/diffstdout || exitcode=$? 66 67 #echo "Diff done with exitcode $exitcode." 67 68 #cat diffstderr 68 69 #cat diffstdout 69 cd ../..70 70 test $exitcode = $expected_exitcode || exit 1 71 71 } -
tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat
rba9f5b rbe97a8 1 1 TITLE = "3D CONVEX SHELL" 2 2 VARIABLES = "X" "Y" "Z" "U" 3 ZONE T=" heptan", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE3 ZONE T="none", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 4 -7.27e-07 -1.22006 0.930455 18.7229 5 5 -7.27e-07 -1.22006 -0.849545 18.7229 … … 7 7 -1.2492 0.921941 -0.849545 18.7227 8 8 1.2492 0.921941 -0.849545 18.7222 9 1.2492 0.921941 0.930455 27.064110 -2.4985 -1.22006 -0.849545 19.976911 -2.4985 -1.22006 0.930455 27.472712 2.4985 -1.22006 0.930455 19.976913 2.4985 -1.22006 -0.849545 27.47279 1.2492 0.921941 0.930455 18.7222 10 -2.4985 -1.22006 -0.849545 27.4727 11 -2.4985 -1.22006 0.930455 19.9769 12 2.4985 -1.22006 0.930455 27.4727 13 2.4985 -1.22006 -0.849545 19.9769 14 14 -4.6377 -0.336759 0.0404545 21.541 15 15 -3.7477 0.921941 0.930455 18.8853 … … 17 17 4.6377 -0.336759 0.0404545 10.6618 18 18 3.7477 0.921941 -0.849545 18.5406 19 3.7477 0.921941 0.930455 1 2.198819 3.7477 0.921941 0.930455 18.5406 20 20 -7.27e-07 -0.590759 0.0404545 23.0174 21 21 -1.2492 0.292641 0.0404545 23.0167 22 1.2492 0.292641 0.0404545 2 0.163222 1.2492 0.292641 0.0404545 23.0172 23 23 -2.4985 -0.590759 0.0404545 18.9798 24 24 2.4985 -0.590759 0.0404545 18.9798 25 25 -3.7477 0.292641 0.0404545 39.5267 26 3.7477 0.292641 0.0404545 2 3.251226 3.7477 0.292641 0.0404545 20.5497 27 27 28 28 14 15 23 … … 34 34 15 19 23 35 35 5 15 19 36 16 19 23 37 6 16 19 36 38 5 6 19 37 39 5 6 19 … … 42 44 3 4 18 43 45 3 4 18 46 3 18 22 47 3 12 22 44 48 4 18 22 45 49 4 13 22 46 3 18 2247 3 12 2248 50 12 13 22 49 51 12 13 22 50 6 19 23 51 6 16 23 52 11 12 22 53 11 12 22 54 8 11 22 55 8 12 22 52 56 11 13 22 53 57 11 13 22 54 58 7 11 22 55 59 7 13 22 56 11 12 2257 11 12 2258 8 11 2259 8 12 2260 60 14 16 23 61 61 14 16 23 … … 76 76 9 10 21 77 77 9 14 21 78 1017 2179 2 101778 9 17 21 79 1 9 17 80 80 1 2 17 81 81 1 2 17 82 117 2183 1 92184 217 2085 2 72082 2 17 21 83 2 10 21 84 1 17 20 85 1 8 20 86 86 7 8 20 87 87 7 8 20 88 8 11 20 88 89 7 11 20 89 8 11 20 90 8 17 20 91 1 8 17 90 7 17 20 91 2 7 17 -
tests/regression/Domain/4/post/test.conf
rba9f5b rbe97a8 47 47 BoxLength # (Length of a unit cell) 48 48 1 49 0 049 0 1 50 50 0 0 2 51 51 -
tests/regression/testsuite-analysis.at
rba9f5b rbe97a8 39 39 AT_KEYWORDS([analysis]) 40 40 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/pre/test.conf .], 0) 41 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I -C S --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 20 8], 0, [stdout], [stderr])41 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I -C S --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 207], 0, [stdout], [stderr]) 42 42 AT_CHECK([fgrep "Begin of CorrelationToSurface" stdout], 0, [ignore], [ignore]) 43 43 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/post/$file], 0, [ignore], [ignore])
Note:
See TracChangeset
for help on using the changeset viewer.