Changes in / [4e10f5:192f6e]
- Files:
-
- 4 added
- 22 deleted
- 108 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionRegistry.hpp
r4e10f5 r192f6e 9 9 #define ACTIONREGISTRY_HPP_ 10 10 11 #include <ios fwd>11 #include <iostream> 12 12 #include <string> 13 13 #include <map> -
src/Actions/AnalysisAction/PairCorrelationAction.cpp
r4e10f5 r192f6e 12 12 #include "boundary.hpp" 13 13 #include "linkedcell.hpp" 14 #include "verbose.hpp"15 14 #include "log.hpp" 16 15 #include "element.hpp" … … 68 67 dialog = UIFactory::getInstance().makeDialog(); 69 68 if (type == "P") 70 dialog->queryVector("position", &Point, false, MapOfActions::getInstance().getDescription("position"));69 dialog->queryVector("position", &Point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position")); 71 70 if (type == "S") 72 71 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id")); -
src/Actions/AtomAction/AddAction.cpp
r4e10f5 r192f6e 41 41 42 42 dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME)); 43 dialog->queryVector("position", &position, true, MapOfActions::getInstance().getDescription("position"));43 dialog->queryVector("position", &position, World::getInstance().getDomain(), true, MapOfActions::getInstance().getDescription("position")); 44 44 cout << "pre-dialog" << endl; 45 45 -
src/Actions/AtomsCalculation_impl.hpp
r4e10f5 r192f6e 11 11 #include "Actions/AtomsCalculation.hpp" 12 12 #include "Actions/Calculation_impl.hpp" 13 14 #include <iostream> 13 15 14 16 using namespace std; -
src/Actions/MapOfActions.cpp
r4e10f5 r192f6e 17 17 #include <boost/optional.hpp> 18 18 #include <boost/program_options.hpp> 19 20 #include <iostream>21 19 22 20 #include "CommandLineParser.hpp" -
src/Actions/MoleculeAction/BondFileAction.cpp
r4e10f5 r192f6e 24 24 #include "config.hpp" 25 25 #include "defs.hpp" 26 #include "verbose.hpp"27 26 #include "log.hpp" 28 27 #include "molecule.hpp" -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
r4e10f5 r192f6e 62 62 63 63 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 64 dialog->queryVector("distances", &distances, false, MapOfActions::getInstance().getDescription("distances"));65 dialog->queryVector("lengths", &lengths, false, MapOfActions::getInstance().getDescription("lengths"));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")); 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
r4e10f5 r192f6e 22 22 #include "boundary.hpp" 23 23 #include "config.hpp" 24 #include "verbose.hpp"25 24 #include "log.hpp" 26 25 #include "config.hpp" -
src/Actions/MoleculeAction/TranslateAction.cpp
r4e10f5 r192f6e 55 55 bool periodic = false; 56 56 57 dialog->queryVector(NAME, &x, false, MapOfActions::getInstance().getDescription(NAME));57 dialog->queryVector(NAME, &x, World::getInstance().getDomain(), 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
r4e10f5 r192f6e 41 41 int j=0; 42 42 43 dialog->queryVector(NAME, &boundary, false, MapOfActions::getInstance().getDescription(NAME));43 dialog->queryVector(NAME, &boundary, World::getInstance().getDomain(), 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 = new double[6];61 double * const cell_size = World::getInstance().getDomain(); 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;71 69 // translate all atoms, such that Min is aty (0,0,0) 72 70 AtomRunner = AllAtoms.begin(); -
src/Actions/WorldAction/CenterInBoxAction.cpp
r4e10f5 r192f6e 34 34 Dialog *dialog = UIFactory::getInstance().makeDialog(); 35 35 36 Box&cell_size = World::getInstance().getDomain();36 double * 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); 40 41 // center 41 42 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); -
src/Actions/WorldAction/CenterOnEdgeAction.cpp
r4e10f5 r192f6e 13 13 #include "vector.hpp" 14 14 #include "World.hpp" 15 #include "Matrix.hpp"16 15 17 16 #include <iostream> … … 38 37 Vector Min; 39 38 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 Matrix domain; 59 double * const cell_size = World::getInstance().getDomain(); 60 for (j=0;j<6;j++) 61 cell_size[j] = 0.; 62 j=-1; 60 63 for (int i=0;i<NDIM;i++) { 61 double tmp = Max[i]-Min[i]; 62 tmp = fabs(tmp)>=1. ? tmp : 1.0; 63 domain.at(i,i) = tmp; 64 j += i+1; 65 cell_size[j] = (Max[i]-Min[i]); 64 66 } 65 World::getInstance().setDomain( domain);67 World::getInstance().setDomain(cell_size); 66 68 // translate all atoms, such that Min is aty (0,0,0) 67 69 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) -
src/Actions/WorldAction/ChangeBoxAction.cpp
r4e10f5 r192f6e 12 12 #include "verbose.hpp" 13 13 #include "World.hpp" 14 #include "Box.hpp"15 #include "Matrix.hpp"16 14 17 15 #include <iostream> … … 36 34 Dialog *dialog = UIFactory::getInstance().makeDialog(); 37 35 38 Box&cell_size = World::getInstance().getDomain();36 double * cell_size = World::getInstance().getDomain(); 39 37 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 40 38 41 39 if(dialog->display()) { 42 DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size.getM() << endl); 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); 43 42 delete dialog; 44 43 return Action::success; -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
r4e10f5 r192f6e 41 41 42 42 dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME)); 43 dialog->queryVector("position", &point, false, MapOfActions::getInstance().getDescription("position"));43 dialog->queryVector("position", &point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position")); 44 44 45 45 if(dialog->display()) { -
src/Actions/WorldAction/RepeatBoxAction.cpp
r4e10f5 r192f6e 13 13 #include "molecule.hpp" 14 14 #include "vector.hpp" 15 #include "Matrix.hpp"16 15 #include "verbose.hpp" 17 16 #include "World.hpp" 18 #include "Box.hpp"19 17 20 18 #include <iostream> … … 48 46 MoleculeListClass *molecules = World::getInstance().getMolecules(); 49 47 50 dialog->queryVector(NAME, &Repeater, false, MapOfActions::getInstance().getDescription(NAME));48 dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME)); 51 49 //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id")); 52 50 vector<molecule *> AllMolecules; … … 61 59 if(dialog->display()) { 62 60 (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl); 63 Matrix M = World::getInstance().getDomain().getM();64 Matrix newM = M;61 double * const cell_size = World::getInstance().getDomain(); 62 double *M = ReturnFullMatrixforSymmetric(cell_size); 65 63 Vector x,y; 66 64 int n[NDIM]; 67 Matrix repMat;68 65 for (int axis = 0; axis < NDIM; axis++) { 69 66 Repeater[axis] = floor(Repeater[axis]); … … 72 69 Repeater[axis] = 1; 73 70 } 74 repMat.at(axis,axis)= Repeater[axis];71 cell_size[ ((axis == 1) ? 2 : (axis == 2) ? 5 : 0) ] *= Repeater[axis]; 75 72 } 76 newM *= repMat;77 World::getInstance().setDomain(newM);78 73 74 World::getInstance().setDomain(cell_size); 79 75 molecule *newmol = NULL; 80 76 Vector ** vectors = NULL; … … 103 99 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 104 100 x = y; 105 x *= M;101 x.MatrixMultiplication(M); 106 102 newmol = World::getInstance().createMolecule(); 107 103 molecules->insert(newmol); … … 123 119 } 124 120 } 121 delete(M); 125 122 delete dialog; 126 123 return Action::success; -
src/Actions/WorldAction/ScaleBoxAction.cpp
r4e10f5 r192f6e 14 14 #include "verbose.hpp" 15 15 #include "World.hpp" 16 #include "Box.hpp"17 #include "Matrix.hpp"18 16 19 17 #include <iostream> … … 39 37 Vector Scaler; 40 38 double x[NDIM]; 39 int j=0; 41 40 42 dialog->queryVector(NAME, &Scaler, false, MapOfActions::getInstance().getDescription(NAME));41 dialog->queryVector(NAME, &Scaler, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME)); 43 42 44 43 if(dialog->display()) { … … 50 49 (*AtomRunner)->x.ScaleAll(x); 51 50 } 52 53 Matrix M = World::getInstance().getDomain().getM(); 54 Matrix scale; 55 51 j = -1; 52 double * const cell_size = World::getInstance().getDomain(); 56 53 for (int i=0;i<NDIM;i++) { 57 scale.at(i,i) = x[i]; 54 j += i+1; 55 cell_size[j]*=x[i]; 58 56 } 59 M *= scale; 60 World::getInstance().setDomain(M); 57 World::getInstance().setDomain(cell_size); 61 58 62 59 delete dialog; -
src/ConfigFileBuffer.cpp
r4e10f5 r192f6e 9 9 #include "helpers.hpp" 10 10 #include "lists.hpp" 11 #include "verbose.hpp"12 11 #include "log.hpp" 13 12 #include "World.hpp" -
src/ConfigFileBuffer.hpp
r4e10f5 r192f6e 17 17 #endif 18 18 19 #include <ios fwd>19 #include <iostream> 20 20 21 21 /****************************************** forward declarations *****************************/ -
src/Exceptions/CustomException.cpp
r4e10f5 r192f6e 9 9 10 10 #include "CustomException.hpp" 11 #include <iostream>12 11 13 12 using namespace std; -
src/Exceptions/CustomException.hpp
r4e10f5 r192f6e 10 10 11 11 #include <exception> 12 #include <iosfwd> 13 #include <string> 12 #include <iostream> 14 13 15 14 /** -
src/Helpers/Assert.hpp
r4e10f5 r192f6e 11 11 #include<sstream> 12 12 #include<string> 13 #include<ios fwd>13 #include<iostream> 14 14 #include<vector> 15 15 #include<map> -
src/Helpers/MemDebug.cpp
r4e10f5 r192f6e 6 6 */ 7 7 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 8 #ifndef NDEBUG 9 #ifndef NO_MEMDEBUG 27 10 28 11 #include <iostream> … … 506 489 } 507 490 #endif 491 #endif -
src/Helpers/MemDebug.hpp
r4e10f5 r192f6e 21 21 * your sourcefiles. 22 22 */ 23 #ifndef NDEBUG 24 #ifndef NO_MEMDEBUG 23 25 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 26 #ifndef MEMDEBUG 27 #define MEMDEBUG 31 28 #endif 32 33 // NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set34 #ifdef NO_MEMDEBUG35 # ifdef MEMDEBUG36 # undef MEMDEBUG37 # endif38 #else39 # ifndef MEMDEBUG40 # define MEMDEBUG41 # endif42 #endif43 44 #ifdef MEMDEBUG45 29 46 30 #include <new> … … 99 83 #endif 100 84 101 #else 85 #endif 86 #endif 87 88 89 #ifdef NDEBUG 90 #undef MEMDEBUG 91 #endif 92 93 #ifndef MEMDEBUG 102 94 // memory debugging was disabled 103 95 … … 112 104 113 105 #endif 114 115 116 106 #endif /* MEMDEBUG_HPP_ */ -
src/Line.cpp
r4e10f5 r192f6e 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 calculations221 double discriminant = 1-origin->NormSquared();222 // we might have 2, 1 or 0 solutions, depending on discriminant223 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 236 217 Line makeLineThrough(const Vector &x1, const Vector &x2){ 237 218 if(x1==x2){ -
src/Line.hpp
r4e10f5 r192f6e 38 38 Plane getOrthogonalPlane(const Vector &origin) const; 39 39 40 std::vector<Vector> getSphereIntersections() const;41 42 40 private: 43 41 std::auto_ptr<Vector> origin; -
src/Makefile.am
r4e10f5 r192f6e 38 38 vector.cpp 39 39 40 LINALGHEADER = \ 41 gslmatrix.hpp \ 40 LINALGHEADER = gslmatrix.hpp \ 42 41 gslvector.hpp \ 43 42 linearsystemofequations.hpp \ … … 76 75 Actions/MethodAction.hpp \ 77 76 Actions/Process.hpp 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 77 92 78 93 79 PARSERSOURCE = \ … … 115 101 Patterns/Observer.hpp \ 116 102 Patterns/Singleton.hpp 117 118 SHAPESOURCE = \119 Shapes/BaseShapes.cpp \120 Shapes/Shape.cpp \121 Shapes/ShapeOps.cpp122 SHAPEHEADER = \123 Shapes/BaseShapes.hpp \124 Shapes/Shape.hpp \125 Shapes/ShapeOps.hpp126 127 103 128 104 QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \ … … 158 134 Descriptors/MoleculeNameDescriptor.hpp \ 159 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 160 148 161 149 QTUISOURCE = ${QTUIMOC_TARGETS} \ … … 177 165 ${ACTIONSSOURCE} \ 178 166 ${ATOMSOURCE} \ 179 ${EXCEPTIONSOURCE} \180 167 ${PATTERNSOURCE} \ 181 168 ${PARSERSOURCE} \ 182 ${SHAPESOURCE} \183 169 ${DESCRIPTORSOURCE} \ 184 170 ${HELPERSOURCE} \ 171 ${EXCEPTIONSOURCE} \ 185 172 bond.cpp \ 186 173 bondgraph.cpp \ 187 174 boundary.cpp \ 188 Box.cpp \189 175 CommandLineParser.cpp \ 190 176 config.cpp \ … … 202 188 log.cpp \ 203 189 logger.cpp \ 204 Matrix.cpp \205 190 moleculelist.cpp \ 206 191 molecule.cpp \ … … 227 212 ${ACTIONSHEADER} \ 228 213 ${ATOMHEADER} \ 229 ${EXCEPTIONHEADER} \230 214 ${PARSERHEADER} \ 231 215 ${PATTERNHEADER} \ 232 ${SHAPEHEADER} \233 216 ${DESCRIPTORHEADER} \ 217 ${EXCEPTIONHEADER} \ 234 218 bond.hpp \ 235 219 bondgraph.hpp \ 236 220 boundary.hpp \ 237 Box.hpp \238 221 CommandLineParser.hpp \ 239 222 config.hpp \ … … 253 236 log.hpp \ 254 237 logger.hpp \ 255 Matrix.hpp \256 238 molecule.hpp \ 257 239 molecule_template.hpp \ -
src/Parser/MpqcParser.hpp
r4e10f5 r192f6e 11 11 #include "FormatParser.hpp" 12 12 13 #include <ios fwd>13 #include <iostream> 14 14 15 15 /** -
src/Parser/PcpParser.cpp
r4e10f5 r192f6e 7 7 8 8 #include <iostream> 9 #include <iomanip>10 9 11 10 #include "atom.hpp" … … 21 20 #include "verbose.hpp" 22 21 #include "World.hpp" 23 #include "Matrix.hpp"24 #include "Box.hpp"25 22 26 23 /** Constructor of PcpParser. … … 213 210 // Unit cell and magnetic field 214 211 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 215 double * cell_size = new double[6];212 double * const cell_size = World::getInstance().getDomain(); 216 213 cell_size[0] = BoxLength[0]; 217 214 cell_size[1] = BoxLength[3]; … … 220 217 cell_size[4] = BoxLength[7]; 221 218 cell_size[5] = BoxLength[8]; 222 World::getInstance().setDomain(cell_size);223 delete[] cell_size;224 219 //if (1) fprintf(stderr,"\n"); 225 220 … … 332 327 void PcpParser::save(std::ostream* file) 333 328 { 334 const Matrix &domain = World::getInstance().getDomain().getM();329 const double * const cell_size = World::getInstance().getDomain(); 335 330 class ThermoStatContainer *Thermostats = World::getInstance().getThermostats(); 336 331 if (!file->fail()) { … … 417 412 *file << endl; 418 413 *file << "BoxLength\t\t\t# (Length of a unit cell)" << 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;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; 422 417 // FIXME 423 418 *file << endl; -
src/Parser/PcpParser.hpp
r4e10f5 r192f6e 9 9 #define PCPPARSER_HPP_ 10 10 11 #include <ios fwd>11 #include <iostream> 12 12 #include "Parser/FormatParser.hpp" 13 13 -
src/Patterns/Cacheable.hpp
r4e10f5 r192f6e 12 12 #include <boost/function.hpp> 13 13 #include <boost/shared_ptr.hpp> 14 #include <iostream> 14 15 15 16 #include "Helpers/Assert.hpp" -
src/Plane.hpp
r4e10f5 r192f6e 11 11 #include <memory> 12 12 #include <vector> 13 #include <ios fwd>13 #include <iostream> 14 14 #include "Space.hpp" 15 15 #include "Exceptions/LinearDependenceException.hpp" -
src/UIElements/CommandLineUI/CommandLineDialog.cpp
r4e10f5 r192f6e 27 27 #include "verbose.hpp" 28 28 #include "World.hpp" 29 #include "Box.hpp"30 29 31 30 #include "atom.hpp" … … 78 77 } 79 78 80 void CommandLineDialog::queryVector(const char* title, Vector *target, bool check, string _description) {81 registerQuery(new VectorCommandLineQuery(title,target,c heck, _description));82 } 83 84 void CommandLineDialog::queryBox(const char* title, Box*cellSize, string _description) {79 void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) { 80 registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description)); 81 } 82 83 void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) { 85 84 registerQuery(new BoxCommandLineQuery(title,cellSize,_description)); 86 85 } … … 223 222 } 224 223 225 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, bool _check, string _description) :226 Dialog::VectorQuery(title,_target,_c heck, _description)224 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) : 225 Dialog::VectorQuery(title,_target,_cellSize,_check, _description) 227 226 {} 228 227 … … 245 244 246 245 247 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, Box*_cellSize, string _description) :246 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) : 248 247 Dialog::BoxQuery(title,_cellSize, _description) 249 248 {} -
src/UIElements/CommandLineUI/CommandLineDialog.hpp
r4e10f5 r192f6e 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 *, bool, std::string = "");38 virtual void queryBox(const char*, Box *, 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 = ""); 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, bool _check, std::string _description = "");101 VectorCommandLineQuery(std::string title,Vector *_target,const double *const _cellSize,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, Box*_cellSize, std::string _description = "");108 BoxCommandLineQuery(std::string title,double ** const _cellSize, std::string _description = ""); 109 109 virtual ~BoxCommandLineQuery(); 110 110 virtual bool handle(); -
src/UIElements/Dialog.cpp
r4e10f5 r192f6e 10 10 #include "Dialog.hpp" 11 11 12 #include "verbose.hpp"13 12 #include "atom.hpp" 14 13 #include "element.hpp" 15 14 #include "molecule.hpp" 16 15 #include "vector.hpp" 17 #include "Matrix.hpp"18 #include "Box.hpp"19 16 20 17 using namespace std; … … 188 185 // Vector Queries 189 186 190 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target, bool _check, std::string _description) :187 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) : 191 188 Query(title, _description), 189 cellSize(_cellSize), 192 190 check(_check), 193 191 target(_target) … … 207 205 // Box Queries 208 206 209 Dialog::BoxQuery::BoxQuery(std::string title, Box*_cellSize, std::string _description) :207 Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) : 210 208 Query(title, _description), 211 209 target(_cellSize) … … 220 218 221 219 void Dialog::BoxQuery::setResult() { 222 (*target)= ReturnFullMatrixforSymmetric(tmp); 220 for (int i=0;i<6;i++) { 221 (*target)[i] = tmp[i]; 222 } 223 223 } 224 224 -
src/UIElements/Dialog.hpp
r4e10f5 r192f6e 14 14 15 15 class atom; 16 class Box;17 16 class element; 18 17 class molecule; … … 44 43 virtual void queryAtom(const char*,atom**,std::string = "")=0; 45 44 virtual void queryMolecule(const char*,molecule**, std::string = "")=0; 46 virtual void queryVector(const char*,Vector *, bool, std::string = "")=0;47 virtual void queryBox(const char*, Box*, 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; 48 47 virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0; 49 48 … … 177 176 class VectorQuery : public Query { 178 177 public: 179 VectorQuery(std::string title,Vector *_target, bool _check, std::string _description = "");178 VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = ""); 180 179 virtual ~VectorQuery(); 181 180 virtual bool handle()=0; … … 183 182 protected: 184 183 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, Box *_cellSize, std::string _description = "");192 BoxQuery(std::string title,double ** const _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 Box*target;199 double **target; 200 200 }; 201 201 -
src/UIElements/QT4/QTDialog.cpp
r4e10f5 r192f6e 29 29 #include "molecule.hpp" 30 30 #include "Descriptors/MoleculeIdDescriptor.hpp" 31 #include "Matrix.hpp"32 #include "Box.hpp"33 31 34 32 … … 95 93 } 96 94 97 void QTDialog::queryBox(char const*, Box*, string){95 void QTDialog::queryBox(char const*, double**, string){ 98 96 // TODO 99 97 ASSERT(false, "Not implemented yet"); … … 125 123 } 126 124 127 void QTDialog::queryVector(const char* title, Vector *target, bool check,string) {128 registerQuery(new VectorQTQuery(title,target,c heck,inputLayout,this));125 void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check,string) { 126 registerQuery(new VectorQTQuery(title,target,cellSize,check,inputLayout,this)); 129 127 } 130 128 … … 293 291 } 294 292 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(); 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; 300 299 const char *coords[3] = {"x:","y:","z:"}; 301 300 mainLayout= new QHBoxLayout(); … … 305 304 mainLayout->addLayout(subLayout); 306 305 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, M.at(i,i));312 coordInput[i]->setRange(0,cellSize[j]); 313 313 coordInput[i]->setDecimals(3); 314 314 coordLayout[i]->addWidget(coordInput[i]); -
src/UIElements/QT4/QTDialog.hpp
r4e10f5 r192f6e 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 *, bool,std::string = "");46 virtual void queryBox(const char*, Box*, 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 = ""); 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, bool _check,QBoxLayout *,QTDialog *);126 VectorQTQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check,QBoxLayout *,QTDialog *); 127 127 virtual ~VectorQTQuery(); 128 128 virtual bool handle(); -
src/UIElements/QT4/QTMainWindow.cpp
r4e10f5 r192f6e 21 21 #include "atom.hpp" 22 22 #include "molecule.hpp" 23 #include "verbose.hpp"24 23 #include "Actions/Action.hpp" 25 24 #include "Actions/ActionRegistry.hpp" -
src/UIElements/TextUI/TextDialog.cpp
r4e10f5 r192f6e 25 25 #include "molecule.hpp" 26 26 #include "vector.hpp" 27 #include "Matrix.hpp"28 #include "Box.hpp"29 27 30 28 using namespace std; … … 72 70 } 73 71 74 void TextDialog::queryVector(const char* title, Vector *target, bool check, string description) {75 registerQuery(new VectorTextQuery(title,target,c heck,description));76 } 77 78 void TextDialog::queryBox(const char* title, Box*cellSize, string description) {72 void TextDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string description) { 73 registerQuery(new VectorTextQuery(title,target,cellSize,check,description)); 74 } 75 76 void TextDialog::queryBox(const char* title,double ** const cellSize, string description) { 79 77 registerQuery(new BoxTextQuery(title,cellSize,description)); 80 78 } … … 272 270 } 273 271 274 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, bool _check, std::string _description) :275 Dialog::VectorQuery(title,_target,_c heck,_description)272 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check, std::string _description) : 273 Dialog::VectorQuery(title,_target,_cellSize,_check,_description) 276 274 {} 277 275 … … 282 280 Log() << Verbose(0) << getTitle(); 283 281 284 const Matrix &M = World::getInstance().getDomain().getM();285 282 char coords[3] = {'x','y','z'}; 283 int j = -1; 286 284 for (int i=0;i<3;i++) { 285 j += i+1; 287 286 do { 288 Log() << Verbose(0) << coords[i] << "[0.." << M.at(i,i)<< "]: ";287 Log() << Verbose(0) << coords[i] << "[0.." << cellSize[j] << "]: "; 289 288 cin >> (*tmp)[i]; 290 } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= M.at(i,i))) && (check));289 } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= cellSize[j])) && (check)); 291 290 } 292 291 return true; 293 292 } 294 293 295 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, Box*_cellSize, std::string _description) :294 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, double ** const _cellSize, std::string _description) : 296 295 Dialog::BoxQuery(title,_cellSize,_description) 297 296 {} -
src/UIElements/TextUI/TextDialog.hpp
r4e10f5 r192f6e 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 *, bool, std::string = "");35 virtual void queryBox(const char*, Box*, 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 = ""); 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, bool _check, std::string _description = NULL);98 VectorTextQuery(std::string title,Vector *_target,const double *const _cellSize,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, Box*_cellSize, std::string _description = NULL);105 BoxTextQuery(std::string title,double ** const _cellSize, std::string _description = NULL); 106 106 virtual ~BoxTextQuery(); 107 107 virtual bool handle(); -
src/UIElements/TextUI/TextWindow.hpp
r4e10f5 r192f6e 11 11 #include "MainWindow.hpp" 12 12 13 #include <string>14 13 #include <set> 15 14 -
src/UIElements/Views/StreamStringView.hpp
r4e10f5 r192f6e 10 10 11 11 #include <boost/function.hpp> 12 #include <ios fwd>12 #include <iostream> 13 13 14 14 #include "Views/StringView.hpp" -
src/VectorSet.hpp
r4e10f5 r192f6e 12 12 #include <functional> 13 13 #include <algorithm> 14 #include <limits>15 14 16 15 /** … … 20 19 */ 21 20 22 #include "vector.hpp" 23 #include <list> 21 class Vector; 24 22 25 23 // this tests, whether we actually have a Vector … … 50 48 void translate(const Vector &translater){ 51 49 // this is needed to allow template lookup 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()); 50 transform(this->begin(),this->end(),this->begin(),bind1st(plus<Vector>(),translater)); 64 51 } 65 52 }; 66 53 67 // allows simpler definition of VectorSets68 #define VECTORSET(container_type) VectorSet<container_type<Vector> >69 70 54 #endif /* VECTORSET_HPP_ */ -
src/World.cpp
r4e10f5 r192f6e 22 22 #include "Actions/ManipulateAtomsProcess.hpp" 23 23 #include "Helpers/Assert.hpp" 24 #include "Box.hpp"25 #include "Matrix.hpp"26 24 27 25 #include "Patterns/Singleton_impl.hpp" … … 76 74 // system 77 75 78 Box& World::getDomain() { 79 return *cell_size; 80 } 81 82 void World::setDomain(const Matrix &mat){ 83 *cell_size = mat; 76 double * World::getDomain() { 77 return cell_size; 84 78 } 85 79 86 80 void World::setDomain(double * matrix) 87 81 { 88 Matrix M = ReturnFullMatrixforSymmetric(matrix); 89 cell_size->setM(M); 82 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]; 90 89 } 91 90 … … 140 139 molecules.erase(id); 141 140 } 141 142 double *World::cell_size = NULL; 142 143 143 144 atom *World::createAtom(){ … … 302 303 molecules_deprecated(new MoleculeListClass(this)) 303 304 { 304 cell_size = new Box; 305 Matrix domain; 306 domain.at(0,0) = 20; 307 domain.at(1,1) = 20; 308 domain.at(2,2) = 20; 309 cell_size->setM(domain); 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.; 310 312 defaultName = "none"; 311 313 molecules_deprecated->signOn(this); … … 315 317 { 316 318 molecules_deprecated->signOff(this); 317 delete cell_size;319 delete[] cell_size; 318 320 delete molecules_deprecated; 319 321 delete periode; -
src/World.hpp
r4e10f5 r192f6e 34 34 class AtomDescriptor_impl; 35 35 template<typename T> class AtomsCalculation; 36 class Box;37 36 class config; 38 37 class ManipulateAtomsProcess; 39 class Matrix;40 38 class molecule; 41 39 class MoleculeDescriptor; … … 127 125 * get the domain size as a symmetric matrix (6 components) 128 126 */ 129 Box& getDomain(); 130 131 /** 132 * Set the domain size from a matrix object 133 * 134 * Matrix needs to be symmetric 135 */ 136 void setDomain(const Matrix &mat); 127 double * getDomain(); 137 128 138 129 /** … … 266 257 periodentafel *periode; 267 258 config *configuration; 268 Box*cell_size;259 static double *cell_size; 269 260 std::string defaultName; 270 261 class ThermoStatContainer *Thermostats; -
src/analysis_bonds.cpp
r4e10f5 r192f6e 13 13 #include "element.hpp" 14 14 #include "info.hpp" 15 #include "verbose.hpp"16 15 #include "log.hpp" 17 16 #include "molecule.hpp" -
src/analysis_correlation.cpp
r4e10f5 r192f6e 9 9 10 10 #include <iostream> 11 #include <iomanip>12 11 13 12 #include "analysis_correlation.hpp" … … 20 19 #include "triangleintersectionlist.hpp" 21 20 #include "vector.hpp" 22 #include "Matrix.hpp"23 21 #include "verbose.hpp" 24 22 #include "World.hpp" 25 #include "Box.hpp"26 23 27 24 … … 37 34 PairCorrelationMap *outmap = NULL; 38 35 double distance = 0.; 39 Box &domain = World::getInstance().getDomain();36 double *domain = World::getInstance().getDomain(); 40 37 41 38 if (molecules->ListOfMolecules.empty()) { … … 78 75 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 79 76 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 80 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);77 distance = (*iter)->node->PeriodicDistance(*(*runner)->node, domain); 81 78 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 82 79 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); … … 138 135 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 139 136 if ((*MolWalker)->ActiveFlag) { 140 Matrix FullMatrix = World::getInstance().getDomain().getM();141 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();137 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 138 double * FullInverseMatrix = InverseMatrix(FullMatrix); 142 139 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 143 140 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 144 141 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 145 142 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 146 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 143 periodicX = *(*iter)->node; 144 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 147 145 // go through every range in xyz and get distance 148 146 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 149 147 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 150 148 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 151 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 149 checkX = Vector(n[0], n[1], n[2]) + periodicX; 150 checkX.MatrixMultiplication(FullMatrix); 152 151 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 153 152 if ((*MolOtherWalker)->ActiveFlag) { … … 158 157 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 159 158 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 160 periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3 159 periodicOtherX = *(*runner)->node; 160 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // 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 = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX); 165 checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX; 166 checkOtherX.MatrixMultiplication(FullMatrix); 166 167 distance = checkX.distance(checkOtherX); 167 168 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; … … 175 176 } 176 177 } 178 delete[](FullMatrix); 179 delete[](FullInverseMatrix); 177 180 } 178 181 } … … 192 195 CorrelationToPointMap *outmap = NULL; 193 196 double distance = 0.; 194 Box &domain= World::getInstance().getDomain();197 double *cell_size = World::getInstance().getDomain(); 195 198 196 199 if (molecules->ListOfMolecules.empty()) { … … 208 211 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 209 212 if ((*type == NULL) || ((*iter)->type == *type)) { 210 distance = domain.periodicDistance(*(*iter)->node,*point);213 distance = (*iter)->node->PeriodicDistance(*point, cell_size); 211 214 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 212 215 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); … … 243 246 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 244 247 if ((*MolWalker)->ActiveFlag) { 245 Matrix FullMatrix = World::getInstance().getDomain().getM();246 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();248 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 249 double * FullInverseMatrix = InverseMatrix(FullMatrix); 247 250 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 248 251 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 250 253 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 251 254 if ((*type == NULL) || ((*iter)->type == *type)) { 252 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 255 periodicX = *(*iter)->node; 256 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 253 257 // go through every range in xyz and get distance 254 258 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 255 259 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 256 260 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 257 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 261 checkX = Vector(n[0], n[1], n[2]) + periodicX; 262 checkX.MatrixMultiplication(FullMatrix); 258 263 distance = checkX.distance(*point); 259 264 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); … … 262 267 } 263 268 } 269 delete[](FullMatrix); 270 delete[](FullInverseMatrix); 264 271 } 265 272 … … 345 352 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 346 353 if ((*MolWalker)->ActiveFlag) { 347 Matrix FullMatrix = World::getInstance().getDomain().getM();348 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();354 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 355 double * FullInverseMatrix = InverseMatrix(FullMatrix); 349 356 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 350 357 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 352 359 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 353 360 if ((*type == NULL) || ((*iter)->type == *type)) { 354 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 361 periodicX = *(*iter)->node; 362 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 355 363 // go through every range in xyz and get distance 356 364 ShortestDistance = -1.; … … 358 366 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 359 367 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 360 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 368 checkX = Vector(n[0], n[1], n[2]) + periodicX; 369 checkX.MatrixMultiplication(FullMatrix); 361 370 TriangleIntersectionList Intersections(&checkX,Surface,LC); 362 371 distance = Intersections.GetSmallestDistance(); … … 372 381 } 373 382 } 383 delete[](FullMatrix); 384 delete[](FullInverseMatrix); 374 385 } 375 386 -
src/analysis_correlation.hpp
r4e10f5 r192f6e 26 26 27 27 #include "atom.hpp" 28 #include "verbose.hpp"29 28 30 29 /****************************************** forward declarations *****************************/ -
src/analyzer.cpp
r4e10f5 r192f6e 14 14 #include "datacreator.hpp" 15 15 #include "helpers.hpp" 16 #include "memoryallocator.hpp" 16 17 #include "parser.hpp" 17 18 #include "periodentafel.hpp" 18 #include "verbose.hpp"19 19 20 20 // include config.h -
src/atom.cpp
r4e10f5 r192f6e 12 12 #include "element.hpp" 13 13 #include "lists.hpp" 14 #include "memoryallocator.hpp" 14 15 #include "parser.hpp" 15 16 #include "vector.hpp" 16 17 #include "World.hpp" 17 18 #include "molecule.hpp" 18 #include "Shapes/Shape.hpp"19 20 #include <iomanip>21 19 22 20 /************************************* Functions for class atom *************************************/ … … 114 112 * \return true - is inside, false - is not 115 113 */ 116 bool atom::IsIn Shape(const Shape& shape) const117 { 118 return shape.isInside(*node);114 bool atom::IsInParallelepiped(const Vector offset, const double *parallelepiped) const 115 { 116 return (node->IsInParallelepiped(offset, parallelepiped)); 119 117 }; 120 118 -
src/atom.hpp
r4e10f5 r192f6e 18 18 #endif 19 19 20 #include <ios fwd>20 #include <iostream> 21 21 #include <list> 22 22 #include <vector> … … 35 35 class World; 36 36 class molecule; 37 class Shape;38 37 39 38 /********************************************** declarations *******************************/ … … 67 66 double DistanceToVector(const Vector &origin) const; 68 67 double DistanceSquaredToVector(const Vector &origin) const; 69 bool IsIn Shape(const Shape&) const;68 bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const; 70 69 71 70 // getter and setter -
src/atom_graphnodeinfo.cpp
r4e10f5 r192f6e 9 9 10 10 #include "atom_graphnodeinfo.hpp" 11 #include "memoryallocator.hpp" 11 12 12 13 /** Constructor of class GraphNodeInfo. 13 14 */ 14 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr( 0), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(0) {};15 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(NULL), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(NULL) {}; 15 16 16 17 /** Destructor of class GraphNodeInfo. -
src/atom_particleinfo.cpp
r4e10f5 r192f6e 9 9 10 10 #include "atom_particleinfo.hpp" 11 12 #include <iostream> 11 #include "memoryallocator.hpp" 13 12 14 13 /** Constructor of ParticleInfo. -
src/atom_particleinfo.hpp
r4e10f5 r192f6e 18 18 #endif 19 19 20 #include <iosfwd> 21 #include <string> 20 #include <iostream> 22 21 23 22 /****************************************** forward declarations *****************************/ -
src/atom_trajectoryparticle.hpp
r4e10f5 r192f6e 20 20 #include <fstream> 21 21 22 #include <gsl/gsl_inline.h>23 22 #include <gsl/gsl_randist.h> 24 23 -
src/bond.cpp
r4e10f5 r192f6e 7 7 #include "Helpers/MemDebug.hpp" 8 8 9 #include "verbose.hpp"10 9 #include "atom.hpp" 11 10 #include "bond.hpp" -
src/bondgraph.cpp
r4e10f5 r192f6e 15 15 #include "element.hpp" 16 16 #include "info.hpp" 17 #include "verbose.hpp"18 17 #include "log.hpp" 19 18 #include "molecule.hpp" -
src/bondgraph.hpp
r4e10f5 r192f6e 18 18 #endif 19 19 20 #include <ios fwd>20 #include <iostream> 21 21 22 22 /*********************************************** defines ***********************************/ -
src/boundary.cpp
r4e10f5 r192f6e 15 15 #include "info.hpp" 16 16 #include "linkedcell.hpp" 17 #include "verbose.hpp"18 17 #include "log.hpp" 18 #include "memoryallocator.hpp" 19 19 #include "molecule.hpp" 20 20 #include "tesselation.hpp" … … 22 22 #include "World.hpp" 23 23 #include "Plane.hpp" 24 #include "Matrix.hpp"25 #include "Box.hpp"26 27 #include <iostream>28 #include <iomanip>29 24 30 25 #include<gsl/gsl_poly.h> … … 774 769 int N[NDIM]; 775 770 int n[NDIM]; 776 const Matrix &M = World::getInstance().getDomain().getM();777 Matrix Rotations;778 const Matrix &MInverse = World::getInstance().getDomain().getMinv();771 double *M = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 772 double Rotations[NDIM*NDIM]; 773 double *MInverse = InverseMatrix(M); 779 774 Vector AtomTranslations; 780 775 Vector FillerTranslations; … … 809 804 810 805 // calculate filler grid in [0,1]^3 811 FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]); 806 FillerDistance = Vector(distance[0], distance[1], distance[2]); 807 FillerDistance.InverseMatrixMultiplication(M); 812 808 for(int i=0;i<NDIM;i++) 813 809 N[i] = (int) ceil(1./FillerDistance[i]); … … 822 818 for (n[2] = 0; n[2] < N[2]; n[2]++) { 823 819 // calculate position of current grid vector in untransformed box 824 CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 820 CurrentPosition = Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 821 CurrentPosition.MatrixMultiplication(M); 825 822 // create molecule random translation vector ... 826 823 for (int i=0;i<NDIM;i++) … … 843 840 } 844 841 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]) );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]) ; 854 851 } 855 852 … … 857 854 Inserter = (*iter)->x; 858 855 if (DoRandomRotation) 859 Inserter *= Rotations;856 Inserter.MatrixMultiplication(Rotations); 860 857 Inserter += AtomTranslations + FillerTranslations + CurrentPosition; 861 858 862 859 // check whether inserter is inside box 863 Inserter *= MInverse;860 Inserter.MatrixMultiplication(MInverse); 864 861 FillIt = true; 865 862 for (int i=0;i<NDIM;i++) 866 863 FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON); 867 Inserter *= M;864 Inserter.MatrixMultiplication(M); 868 865 869 866 // Check whether point is in- or outside … … 904 901 delete TesselStruct[(*ListRunner)]; 905 902 } 903 delete[](M); 904 delete[](MInverse); 906 905 907 906 return Filling; -
src/boundary.hpp
r4e10f5 r192f6e 12 12 13 13 #include <fstream> 14 #include <ios fwd>14 #include <iostream> 15 15 16 16 // STL headers -
src/builder.cpp
r4e10f5 r192f6e 60 60 #include "config.hpp" 61 61 #include "log.hpp" 62 #include "memoryusageobserver.hpp" 62 63 #include "molecule.hpp" 63 64 #include "periodentafel.hpp" -
src/config.cpp
r4e10f5 r192f6e 19 19 #include "info.hpp" 20 20 #include "lists.hpp" 21 #include "verbose.hpp"22 21 #include "log.hpp" 23 22 #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"30 28 31 29 /************************************* Functions for class config ***************************/ … … 681 679 // Unit cell and magnetic field 682 680 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 683 double * c ell_size = new double[6];681 double * const cell_size = World::getInstance().getDomain(); 684 682 cell_size[0] = BoxLength[0]; 685 683 cell_size[1] = BoxLength[3]; … … 688 686 cell_size[4] = BoxLength[7]; 689 687 cell_size[5] = BoxLength[8]; 690 World::getInstance().setDomain(cell_size);691 delete cell_size;692 688 //if (1) fprintf(stderr,"\n"); 693 689 … … 887 883 888 884 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 889 double * c ell_size = new double[6];885 double * const cell_size = World::getInstance().getDomain(); 890 886 cell_size[0] = BoxLength[0]; 891 887 cell_size[1] = BoxLength[3]; … … 894 890 cell_size[4] = BoxLength[7]; 895 891 cell_size[5] = BoxLength[8]; 896 World::getInstance().setDomain(cell_size);897 delete[] cell_size;898 892 if (1) fprintf(stderr,"\n"); 899 893 config::DoPerturbation = 0; … … 1033 1027 // bring MaxTypes up to date 1034 1028 mol->CountElements(); 1035 const Matrix &domain = World::getInstance().getDomain().getM();1029 const double * const cell_size = World::getInstance().getDomain(); 1036 1030 ofstream * const output = new ofstream(filename, ios::out); 1037 1031 if (output != NULL) { … … 1104 1098 *output << endl; 1105 1099 *output << "BoxLength\t\t\t# (Length of a unit cell)" << 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;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; 1109 1103 // FIXME 1110 1104 *output << endl; -
src/datacreator.cpp
r4e10f5 r192f6e 12 12 #include "helpers.hpp" 13 13 #include "parser.hpp" 14 #include "verbose.hpp"15 16 #include <iomanip>17 14 18 15 //=========================== FUNCTIONS============================ -
src/datacreator.hpp
r4e10f5 r192f6e 10 10 using namespace std; 11 11 12 #include <ios fwd>12 #include <iostream> 13 13 14 14 /****************************************** forward declarations *****************************/ -
src/element.hpp
r4e10f5 r192f6e 16 16 #endif 17 17 18 #include <ios fwd>18 #include <iostream> 19 19 #include <string> 20 20 -
src/ellipsoid.cpp
r4e10f5 r192f6e 21 21 #include "tesselation.hpp" 22 22 #include "vector.hpp" 23 #include "Matrix.hpp"24 23 #include "verbose.hpp" 25 24 … … 35 34 Vector helper, RefPoint; 36 35 double distance = -1.; 37 Matrix Matrix;36 double Matrix[NDIM*NDIM]; 38 37 double InverseLength[3]; 39 38 double psi,theta,phi; // euler angles in ZX'Z'' convention … … 52 51 theta = EllipsoidAngle[1]; 53 52 phi = EllipsoidAngle[2]; 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;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); 64 63 helper.ScaleAll(InverseLength); 65 64 //Log() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl; … … 74 73 phi = -EllipsoidAngle[2]; 75 74 helper.ScaleAll(EllipsoidLength); 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;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); 86 85 //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl; 87 86 -
src/errorlogger.cpp
r4e10f5 r192f6e 9 9 10 10 #include <fstream> 11 #include <iostream>12 11 #include "errorlogger.hpp" 13 12 #include "verbose.hpp" -
src/errorlogger.hpp
r4e10f5 r192f6e 9 9 #define ERRORLOGGER_HPP_ 10 10 11 #include <ios fwd>11 #include <iostream> 12 12 13 13 #include "Patterns/Singleton.hpp" -
src/graph.cpp
r4e10f5 r192f6e 13 13 #include "config.hpp" 14 14 #include "graph.hpp" 15 #include "verbose.hpp"16 15 #include "log.hpp" 17 16 #include "molecule.hpp" -
src/graph.hpp
r4e10f5 r192f6e 27 27 class molecule; 28 28 29 class Graph; 29 30 class SubGraph; 30 31 class Node; … … 33 34 /********************************************** definitions *********************************/ 34 35 35 typedef std::pair < int, class Node* > NodeMap; 36 typedef std::multimap < class Node*, class Edge* > EdgeMap; 36 #define NodeMap pair < int, class Node* > 37 #define EdgeMap multimap < class Node*, class Edge* > 37 38 38 typedef std::deque<int> KeyStack; 39 typedef std::set<int> KeySet; 40 typedef std::pair<int, double> NumberValuePair; 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> 41 46 42 // needed for definition of Graph and GraphTestPair 47 48 /******************************** Some small functions and/or structures **********************************/ 49 43 50 struct KeyCompare 44 51 { 45 52 bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const; 46 53 }; 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 **********************************/55 54 56 55 //bool operator < (KeySet SubgraphA, KeySet SubgraphB); //note: this declaration is important, otherwise normal < is used (producing wrong order) -
src/gslvector.cpp
r4e10f5 r192f6e 10 10 #include <cassert> 11 11 #include <cmath> 12 #include <iostream>13 12 14 13 #include "gslvector.hpp" 15 14 #include "defs.hpp" 16 15 #include "vector.hpp" 17 #include "VectorContent.hpp"18 16 19 17 /** Constructor of class GSLVector. … … 71 69 */ 72 70 void GSLVector::SetFromVector(Vector &v){ 73 gsl_vector_memcpy (vector, v.get() ->content);71 gsl_vector_memcpy (vector, v.get()); 74 72 } 75 73 -
src/gslvector.hpp
r4e10f5 r192f6e 18 18 #endif 19 19 20 #include <ios fwd>20 #include <iostream> 21 21 #include <gsl/gsl_vector.h> 22 22 -
src/helpers.cpp
r4e10f5 r192f6e 8 8 #include "helpers.hpp" 9 9 #include "Helpers/fast_functions.hpp" 10 #include "verbose.hpp"11 10 #include "log.hpp" 12 13 #include <iostream> 11 #include "memoryusageobserver.hpp" 14 12 15 13 /********************************************** helpful functions *********************************/ … … 119 117 }; 120 118 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 components 121 * \return allocated NDIM*NDIM array with the symmetric matrix 122 */ 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 array 140 */ 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 B 150 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular 151 detAReci = 1./detA; 152 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11 153 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12 154 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13 155 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21 156 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22 157 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23 158 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31 159 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32 160 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33 161 } 162 return B; 163 }; 164 165 166 121 167 /** Comparison function for GSL heapsort on distances in two molecules. 122 168 * \param *a -
src/helpers.hpp
r4e10f5 r192f6e 20 20 #include "defs.hpp" 21 21 #include "log.hpp" 22 #include "memoryallocator.hpp" 22 23 23 24 /********************************************** definitions *********************************/ … … 51 52 bool IsValidNumber( const char *string); 52 53 int CompareDoubles (const void * a, const void * b); 54 double * ReturnFullMatrixforSymmetric(const double * const cell_size); 55 double * InverseMatrix(const double * const A); 53 56 void performCriticalExit(); 54 57 -
src/joiner.cpp
r4e10f5 r192f6e 14 14 #include "datacreator.hpp" 15 15 #include "helpers.hpp" 16 #include "memoryallocator.hpp" 16 17 #include "parser.hpp" 17 18 #include "periodentafel.hpp" 18 #include "verbose.hpp"19 19 20 20 //============================== MAIN ============================= -
src/linkedcell.cpp
r4e10f5 r192f6e 10 10 #include "helpers.hpp" 11 11 #include "linkedcell.hpp" 12 #include "verbose.hpp"13 12 #include "log.hpp" 14 13 #include "molecule.hpp" -
src/logger.cpp
r4e10f5 r192f6e 9 9 10 10 #include <fstream> 11 #include <iostream>12 11 #include "logger.hpp" 13 12 #include "verbose.hpp" -
src/logger.hpp
r4e10f5 r192f6e 9 9 #define LOGGER_HPP_ 10 10 11 #include <ios fwd>11 #include <iostream> 12 12 13 13 #include "Patterns/Singleton.hpp" -
src/molecule.cpp
r4e10f5 r192f6e 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H8 #include <config.h>9 #endif10 11 7 #include "Helpers/MemDebug.hpp" 12 8 13 9 #include <cstring> 14 10 #include <boost/bind.hpp> 15 #include <boost/foreach.hpp>16 17 #include <gsl/gsl_inline.h>18 #include <gsl/gsl_heapsort.h>19 11 20 12 #include "World.hpp" … … 30 22 #include "log.hpp" 31 23 #include "molecule.hpp" 32 24 #include "memoryallocator.hpp" 33 25 #include "periodentafel.hpp" 34 26 #include "stackclass.hpp" 35 27 #include "tesselation.hpp" 36 28 #include "vector.hpp" 37 #include "Matrix.hpp"38 29 #include "World.hpp" 39 #include "Box.hpp"40 30 #include "Plane.hpp" 41 31 #include "Exceptions/LinearDependenceException.hpp" … … 294 284 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 295 285 Vector InBondvector; // vector in direction of *Bond 296 const Matrix &matrix = World::getInstance().getDomain().getM();286 double *matrix = NULL; 297 287 bond *Binder = NULL; 288 double * const cell_size = World::getInstance().getDomain(); 298 289 299 290 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 316 307 } // (signs are correct, was tested!) 317 308 } 318 Orthovector1 *= matrix; 309 matrix = ReturnFullMatrixforSymmetric(cell_size); 310 Orthovector1.MatrixMultiplication(matrix); 319 311 InBondvector -= Orthovector1; // subtract just the additional translation 312 delete[](matrix); 320 313 bondlength = InBondvector.Norm(); 321 314 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 548 541 break; 549 542 } 543 delete[](matrix); 550 544 551 545 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 666 660 * @param three vectors forming the matrix that defines the shape of the parallelpiped 667 661 */ 668 molecule* molecule::CopyMoleculeFromSubRegion(const Shape ®ion) const {662 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const { 669 663 molecule *copy = World::getInstance().createMolecule(); 670 664 671 BOOST_FOREACH(atom *iter,atoms){ 672 if(iter->IsInShape(region)){ 673 copy->AddCopyAtom(iter); 674 } 675 } 665 ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped ); 676 666 677 667 //TODO: copy->BuildInducedSubgraph(this); … … 760 750 void molecule::SetBoxDimension(Vector *dim) 761 751 { 762 Matrix domain; 763 for(int i =0; i<NDIM;++i) 764 domain.at(i,i) = dim->at(i); 765 World::getInstance().setDomain(domain); 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); 766 759 }; 767 760 … … 856 849 bool molecule::CheckBounds(const Vector *x) const 857 850 { 858 const Matrix &domain = World::getInstance().getDomain().getM();851 double * const cell_size = World::getInstance().getDomain(); 859 852 bool result = true; 853 int j =-1; 860 854 for (int i=0;i<NDIM;i++) { 861 result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i))); 855 j += i+1; 856 result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j])); 862 857 } 863 858 //return result; -
src/molecule.hpp
r4e10f5 r192f6e 7 7 #define MOLECULES_HPP_ 8 8 9 using namespace std; 10 9 11 /*********************************************** includes ***********************************/ 10 12 11 #ifdef HAVE_CONFIG_H 12 #include <config.h> 13 #endif 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> 14 21 15 22 //// STL headers … … 24 31 #include "types.hpp" 25 32 #include "graph.hpp" 33 #include "stackclass.hpp" 26 34 #include "tesselation.hpp" 27 35 #include "Patterns/Observer.hpp" … … 45 53 class periodentafel; 46 54 class Vector; 47 class Shape;48 template <class> class StackClass;49 55 50 56 /******************************** Some definitions for easier reading **********************************/ … … 310 316 311 317 molecule *CopyMolecule(); 312 molecule* CopyMoleculeFromSubRegion(const Shape&) const;318 molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const; 313 319 314 320 /// Fragment molecule by two different approaches: -
src/molecule_dynamics.cpp
r4e10f5 r192f6e 13 13 #include "element.hpp" 14 14 #include "info.hpp" 15 #include "verbose.hpp"16 15 #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>25 21 26 22 /************************************* Functions for class molecule *********************************/ -
src/molecule_fragmentation.cpp
r4e10f5 r192f6e 17 17 #include "helpers.hpp" 18 18 #include "lists.hpp" 19 #include "verbose.hpp"20 19 #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"27 24 28 25 /************************************* Functions for class molecule *********************************/ … … 1719 1716 atom *Walker = NULL; 1720 1717 atom *OtherWalker = NULL; 1721 Matrix matrix = World::getInstance().getDomain().getM(); 1718 double * const cell_size = World::getInstance().getDomain(); 1719 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1722 1720 enum Shading *ColorList = NULL; 1723 1721 double tmp; … … 1759 1757 Translationvector[i] = (tmp < 0) ? +1. : -1.; 1760 1758 } 1761 Translationvector *= matrix;1759 Translationvector.MatrixMultiplication(matrix); 1762 1760 //Log() << Verbose(3) << "Translation vector is "; 1763 1761 Log() << Verbose(0) << Translationvector << endl; … … 1790 1788 delete(AtomStack); 1791 1789 delete[](ColorList); 1790 delete[](matrix); 1792 1791 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1793 1792 }; -
src/molecule_geometry.cpp
r4e10f5 r192f6e 5 5 * Author: heber 6 6 */ 7 8 #ifdef HAVE_CONFIG_H9 #include <config.h>10 #endif11 7 12 8 #include "Helpers/MemDebug.hpp" … … 18 14 #include "helpers.hpp" 19 15 #include "leastsquaremin.hpp" 20 #include "verbose.hpp"21 16 #include "log.hpp" 17 #include "memoryallocator.hpp" 22 18 #include "molecule.hpp" 23 19 #include "World.hpp" 24 20 #include "Plane.hpp" 25 #include "Matrix.hpp"26 #include "Box.hpp"27 21 #include <boost/foreach.hpp> 28 29 #include <gsl/gsl_eigen.h>30 #include <gsl/gsl_multimin.h>31 22 32 23 … … 42 33 const Vector *Center = DetermineCenterOfAll(); 43 34 const Vector *CenterBox = DetermineCenterOfBox(); 44 Box &domain = World::getInstance().getDomain(); 35 double * const cell_size = World::getInstance().getDomain(); 36 double *M = ReturnFullMatrixforSymmetric(cell_size); 37 double *Minv = InverseMatrix(M); 45 38 46 39 // go through all atoms 47 40 ActOnAllVectors( &Vector::SubtractVector, *Center); 48 41 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 49 BOOST_FOREACH(atom* iter, atoms){50 *iter->node = domain.WrapPeriodically(*iter->node); 51 }52 42 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 43 44 delete[](M); 45 delete[](Minv); 53 46 delete(Center); 54 47 delete(CenterBox); … … 63 56 { 64 57 bool status = true; 65 Box &domain = World::getInstance().getDomain(); 58 double * const cell_size = World::getInstance().getDomain(); 59 double *M = ReturnFullMatrixforSymmetric(cell_size); 60 double *Minv = InverseMatrix(M); 66 61 67 62 // go through all atoms 68 BOOST_FOREACH(atom* iter, atoms){69 *iter->node = domain.WrapPeriodically(*iter->node); 70 }71 63 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 64 65 delete[](M); 66 delete[](Minv); 72 67 return status; 73 68 }; … … 158 153 { 159 154 Vector *a = new Vector(0.5,0.5,0.5); 160 const Matrix &M = World::getInstance().getDomain().getM(); 161 (*a) *= M; 155 156 const double *cell_size = World::getInstance().getDomain(); 157 double *M = ReturnFullMatrixforSymmetric(cell_size); 158 a->MatrixMultiplication(M); 159 delete[](M); 160 162 161 return a; 163 162 }; … … 245 244 void molecule::TranslatePeriodically(const Vector *trans) 246 245 { 247 Box &domain = World::getInstance().getDomain(); 246 double * const cell_size = World::getInstance().getDomain(); 247 double *M = ReturnFullMatrixforSymmetric(cell_size); 248 double *Minv = InverseMatrix(M); 248 249 249 250 // go through all atoms 250 251 ActOnAllVectors( &Vector::AddVector, *trans); 251 BOOST_FOREACH(atom* iter, atoms){252 *iter->node = domain.WrapPeriodically(*iter->node); 253 }254 252 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 253 254 delete[](M); 255 delete[](Minv); 255 256 }; 256 257 … … 263 264 OBSERVE; 264 265 Plane p(*n,0); 265 BOOST_FOREACH( atom* iter, atoms ){266 BOOST_FOREACH( atom* iter, atoms ){ 266 267 (*iter->node) = p.mirrorVector(*iter->node); 267 268 } … … 273 274 void molecule::DeterminePeriodicCenter(Vector ¢er) 274 275 { 275 const Matrix &matrix = World::getInstance().getDomain().getM(); 276 const Matrix &inversematrix = World::getInstance().getDomain().getM(); 276 double * const cell_size = World::getInstance().getDomain(); 277 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 278 double *inversematrix = InverseMatrix(matrix); 277 279 double tmp; 278 280 bool flag; … … 286 288 if ((*iter)->type->Z != 1) { 287 289 #endif 288 Testvector = inversematrix * (*iter)->x; 290 Testvector = (*iter)->x; 291 Testvector.MatrixMultiplication(inversematrix); 289 292 Translationvector.Zero(); 290 293 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { … … 303 306 } 304 307 Testvector += Translationvector; 305 Testvector *= matrix;308 Testvector.MatrixMultiplication(matrix); 306 309 Center += Testvector; 307 310 Log() << Verbose(1) << "vector is: " << Testvector << endl; … … 310 313 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 311 314 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 312 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x; 315 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 316 Testvector.MatrixMultiplication(inversematrix); 313 317 Testvector += Translationvector; 314 Testvector *= matrix;318 Testvector.MatrixMultiplication(matrix); 315 319 Center += Testvector; 316 320 Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl; … … 321 325 } 322 326 } while (!flag); 327 delete[](matrix); 328 delete[](inversematrix); 323 329 324 330 Center.Scale(1./static_cast<double>(getAtomCount())); … … 382 388 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 383 389 // the eigenvectors specify the transformation matrix 384 Matrix M = Matrix(evec->data); 385 BOOST_FOREACH(atom* iter, atoms){ 386 (*iter->node) *= M; 387 } 390 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 388 391 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 389 392 -
src/molecule_graph.cpp
r4e10f5 r192f6e 5 5 * Author: heber 6 6 */ 7 8 #ifdef HAVE_CONFIG_H9 #include <config.h>10 #endif11 7 12 8 #include "Helpers/MemDebug.hpp" … … 22 18 #include "linkedcell.hpp" 23 19 #include "lists.hpp" 24 #include "verbose.hpp"25 20 #include "log.hpp" 21 #include "memoryallocator.hpp" 26 22 #include "molecule.hpp" 27 23 #include "World.hpp" 28 24 #include "Helpers/fast_functions.hpp" 29 25 #include "Helpers/Assert.hpp" 30 #include "Matrix.hpp" 31 #include "Box.hpp" 32 #include "stackclass.hpp" 26 33 27 34 28 struct BFSAccounting … … 127 121 LinkedCell *LC = NULL; 128 122 bool free_BG = false; 129 Box &domain= World::getInstance().getDomain();123 double * const cell_size = World::getInstance().getDomain(); 130 124 131 125 if (BG == NULL) { … … 184 178 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 185 179 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 186 const double distance = domain.periodicDistanceSquared(OtherWalker->x,Walker->x);180 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size); 187 181 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 188 182 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 585 579 // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph 586 580 DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl); 587 LeafWalker->Leaf->Output((ofstream *)& (Log() << Verbose(0)));581 LeafWalker->Leaf->Output((ofstream *)&cout); 588 582 DoLog(0) && (Log() << Verbose(0) << endl); 589 583 -
src/molecule_pointcloud.cpp
r4e10f5 r192f6e 11 11 #include "config.hpp" 12 12 #include "info.hpp" 13 #include "memoryallocator.hpp" 13 14 #include "molecule.hpp" 14 15 -
src/moleculelist.cpp
r4e10f5 r192f6e 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H8 #include <config.h>9 #endif10 11 7 #include "Helpers/MemDebug.hpp" 12 8 13 9 #include <cstring> 14 15 #include <gsl/gsl_inline.h>16 #include <gsl/gsl_heapsort.h>17 10 18 11 #include "World.hpp" … … 26 19 #include "linkedcell.hpp" 27 20 #include "lists.hpp" 28 #include "verbose.hpp"29 21 #include "log.hpp" 30 22 #include "molecule.hpp" 23 #include "memoryallocator.hpp" 31 24 #include "periodentafel.hpp" 32 25 #include "Helpers/Assert.hpp" 33 #include "Matrix.hpp"34 #include "Box.hpp"35 #include "stackclass.hpp"36 26 37 27 #include "Helpers/Assert.hpp" … … 641 631 int FragmentCounter = 0; 642 632 ofstream output; 643 Matrix cell_size = World::getInstance().getDomain().getM(); 644 Matrix cell_size_backup = cell_size; 645 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]; 646 639 // store the fragments as config and as xyz 647 640 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { … … 681 674 (*ListRunner)->CenterEdge(&BoxDimension); 682 675 (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary 676 int j = -1; 683 677 for (int k = 0; k < NDIM; k++) { 678 j += k + 1; 684 679 BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem); 685 cell_size.at(k,k) = BoxDimension[k] * 2.; 686 } 687 World::getInstance().setDomain(cell_size); 680 cell_size[j] = BoxDimension[k] * 2.; 681 } 688 682 (*ListRunner)->Translate(&BoxDimension); 689 683 … … 731 725 732 726 // restore cell_size 733 World::getInstance().setDomain(cell_size_backup); 727 for (int i=0;i<6;i++) 728 cell_size[i] = cell_size_backup[i]; 734 729 735 730 return result; … … 892 887 // center at set box dimensions 893 888 mol->CenterEdge(¢er); 894 Matrix domain; 895 for(int i =0;i<NDIM;++i) 896 domain.at(i,i) = center[i]; 897 World::getInstance().setDomain(domain); 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]; 898 895 insert(mol); 899 896 } -
src/parser.cpp
r4e10f5 r192f6e 12 12 13 13 #include "helpers.hpp" 14 #include "memoryallocator.hpp" 14 15 #include "parser.hpp" 15 #include "verbose.hpp"16 16 17 17 // include config.h -
src/periodentafel.hpp
r4e10f5 r192f6e 9 9 #endif 10 10 11 #include <ios fwd>11 #include <iostream> 12 12 #include <map> 13 #include <iterator> 13 14 14 15 #include "unittests/periodentafelTest.hpp" -
src/stackclass.hpp
r4e10f5 r192f6e 12 12 13 13 #include "verbose.hpp" 14 #include " log.hpp"14 #include "memoryallocator.hpp" 15 15 16 16 /****************************************** forward declarations *****************************/ -
src/tesselation.cpp
r4e10f5 r192f6e 9 9 10 10 #include <fstream> 11 #include <iomanip>12 11 13 12 #include "helpers.hpp" -
src/tesselationhelpers.cpp
r4e10f5 r192f6e 21 21 #include "verbose.hpp" 22 22 #include "Plane.hpp" 23 #include "Matrix.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 }; 24 53 25 54 void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS) 26 55 { 27 56 Info FunctionInfo(__func__); 28 Matrix mat;57 gsl_matrix *A = gsl_matrix_calloc(3,3); 29 58 double m11, m12, m13, m14; 30 59 31 60 for(int i=0;i<3;i++) { 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();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); 37 66 38 67 for(int i=0;i<3;i++) { 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();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); 44 73 45 74 for(int i=0;i<3;i++) { 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();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); 51 80 52 81 for(int i=0;i<3;i++) { 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();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); 58 87 59 88 if (fabs(m11) < MYEPSILON) … … 66 95 if (fabs(a.distance(*center) - RADIUS) > MYEPSILON) 67 96 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); 68 99 }; 69 100 … … 217 248 Vector x3; 218 249 Vector x4; 250 }; 251 252 /** 253 * Intersection calculation function. 254 * 255 * @param x to find the result for 256 * @param function parameter 257 */ 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 line 284 * always goes through point 1 and point 2 and the second line is given by the 285 * connection between point 4 and point 5. 286 * 287 * @param point 1 of line 1 288 * @param point 2 of line 1 289 * @param point 1 of line 2 290 * @param point 2 of line 2 291 * 292 * @return true if there is an intersection between the given lines, false otherwise 293 */ 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 not 349 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 stuff 378 gsl_vector_free(x); 379 gsl_vector_free(ss); 380 gsl_multimin_fminimizer_free(s); 381 382 return result; 219 383 }; 220 384 -
src/tesselationhelpers.hpp
r4e10f5 r192f6e 20 20 #endif 21 21 22 #include <iosfwd> 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> 23 29 24 30 #include "defs.hpp" … … 41 47 /********************************************** declarations *******************************/ 42 48 49 double DetGet(gsl_matrix * const A, const int inPlace); 43 50 void GetSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS); 44 51 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); 45 52 void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c); 46 53 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); 47 56 double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d); 48 57 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C); -
src/triangleintersectionlist.cpp
r4e10f5 r192f6e 18 18 #include "tesselation.hpp" 19 19 #include "vector.hpp" 20 #include "verbose.hpp"21 20 22 21 /** Constructor for class TriangleIntersectionList. -
src/unittests/ActOnAllUnitTest.cpp
r4e10f5 r192f6e 14 14 #include "../test/ActOnAlltest.hpp" 15 15 #include "ActOnAllUnitTest.hpp" 16 #include "memoryallocator.hpp" 16 17 #include "vector.hpp" 17 18 -
src/unittests/LineUnittest.cpp
r4e10f5 r192f6e 17 17 18 18 #include <iostream> 19 #include <cmath>20 19 21 20 using namespace std; … … 353 352 CPPUNIT_ASSERT_EQUAL(fixture,zeroVec); 354 353 } 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
r4e10f5 r192f6e 22 22 CPPUNIT_TEST ( intersectionTest ); 23 23 CPPUNIT_TEST ( rotationTest ); 24 CPPUNIT_TEST ( sphereIntersectionTest );25 24 CPPUNIT_TEST_SUITE_END(); 26 25 … … 34 33 void intersectionTest(); 35 34 void rotationTest(); 36 void sphereIntersectionTest();37 35 38 36 private: -
src/unittests/Makefile.am
r4e10f5 r192f6e 31 31 LogUnitTest \ 32 32 manipulateAtomsTest \ 33 MatrixUnittest \ 33 MemoryUsageObserverUnitTest \ 34 MemoryAllocatorUnitTest \ 34 35 MoleculeDescriptorTest \ 35 36 ObserverTest \ … … 37 38 periodentafelTest \ 38 39 PlaneUnittest \ 39 ShapeUnittest \40 40 SingletonTest \ 41 41 StackClassUnitTest \ … … 75 75 listofbondsunittest.cpp \ 76 76 logunittest.cpp \ 77 MatrixUnittest.cpp \78 77 manipulateAtomsTest.cpp \ 78 memoryallocatorunittest.cpp \ 79 memoryusageobserverunittest.cpp \ 79 80 MoleculeDescriptorTest.cpp \ 80 81 ObserverTest.cpp \ … … 82 83 periodentafelTest.cpp \ 83 84 PlaneUnittest.cpp \ 84 ShapeUnittest.cpp \85 85 SingletonTest.cpp \ 86 86 stackclassunittest.cpp \ … … 112 112 logunittest.hpp \ 113 113 manipulateAtomsTest.hpp \ 114 MatrixUnittest.hpp \ 114 memoryallocatorunittest.hpp \ 115 memoryusageobserverunittest.hpp \ 115 116 MoleculeDescriptorTest.hpp \ 116 117 periodentafelTest.hpp \ … … 188 189 manipulateAtomsTest_LDADD = ${ALLLIBS} 189 190 190 MatrixUnittest_SOURCES = UnitTestMain.cpp MatrixUnittest.cpp MatrixUnittest.hpp 191 MatrixUnittest_LDADD = ${ALLLIBS} 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} 192 196 193 197 MoleculeDescriptorTest_SOURCES = UnitTestMain.cpp MoleculeDescriptorTest.cpp MoleculeDescriptorTest.hpp … … 206 210 PlaneUnittest_LDADD = ${ALLLIBS} 207 211 208 ShapeUnittest_SOURCES = UnitTestMain.cpp ShapeUnittest.cpp ShapeUnittest.hpp209 ShapeUnittest_LDADD = ${ALLLIBS}210 211 212 SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp 212 213 SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB} … … 224 225 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 225 226 226 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)227 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS) 227 228 TestRunner_LDADD = ${ALLLIBS} 228 229 -
src/unittests/PlaneUnittest.cpp
r4e10f5 r192f6e 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <cmath>15 13 16 14 #ifdef HAVE_TESTRUNNER -
src/unittests/linearsystemofequationsunittest.cpp
r4e10f5 r192f6e 12 12 #include <cppunit/extensions/TestFactoryRegistry.h> 13 13 #include <cppunit/ui/text/TestRunner.h> 14 #include <cmath>15 14 16 15 #include "linearsystemofequationsunittest.hpp" -
src/unittests/tesselation_insideoutsideunittest.cpp
r4e10f5 r192f6e 17 17 #include "tesselation.hpp" 18 18 #include "tesselation_insideoutsideunittest.hpp" 19 #include "verbose.hpp"20 19 21 20 #ifdef HAVE_TESTRUNNER -
src/unittests/vectorunittest.cpp
r4e10f5 r192f6e 15 15 #include "defs.hpp" 16 16 #include "log.hpp" 17 #include "memoryusageobserver.hpp" 17 18 #include "vector.hpp" 18 19 #include "vector_ops.hpp" … … 20 21 #include "Plane.hpp" 21 22 #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
r4e10f5 r192f6e 27 27 CPPUNIT_TEST ( ProjectionTest ); 28 28 CPPUNIT_TEST ( NormalsTest ); 29 CPPUNIT_TEST ( IsInParallelepipedTest ); 29 30 CPPUNIT_TEST_SUITE_END(); 30 31 … … 44 45 void LineIntersectionTest(); 45 46 void VectorRotationTest(); 47 void IsInParallelepipedTest(); 46 48 47 49 private: -
src/vector.cpp
r4e10f5 r192f6e 8 8 9 9 #include "vector.hpp" 10 #include "VectorContent.hpp"11 10 #include "verbose.hpp" 12 11 #include "World.hpp" 13 12 #include "Helpers/Assert.hpp" 14 13 #include "Helpers/fast_functions.hpp" 15 #include "Exceptions/MathException.hpp"16 14 17 15 #include <iostream> 18 #include <gsl/gsl_blas.h>19 20 16 21 17 using namespace std; … … 28 24 Vector::Vector() 29 25 { 30 content = new VectorContent();26 content = gsl_vector_calloc (NDIM); 31 27 }; 32 28 … … 37 33 Vector::Vector(const Vector& src) 38 34 { 39 content = new VectorContent(); 40 gsl_vector_memcpy(content->content, src.content->content); 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]); 41 39 } 42 40 … … 45 43 Vector::Vector(const double x1, const double x2, const double x3) 46 44 { 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 {} 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 }; 56 50 57 51 /** … … 61 55 // check for self assignment 62 56 if(&src!=this){ 63 gsl_vector_memcpy(content->content, src.content->content); 57 gsl_vector_set(content,0,src[0]); 58 gsl_vector_set(content,1,src[1]); 59 gsl_vector_set(content,2,src[2]); 64 60 } 65 61 return *this; … … 69 65 */ 70 66 Vector::~Vector() { 71 delete content;67 gsl_vector_free(content); 72 68 }; 73 69 … … 98 94 } 99 95 96 /** Calculates distance between this and another vector in a periodic cell. 97 * \param *y array to second vector 98 * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell 99 * \return \f$| x - y |\f$ 100 */ 101 double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const 102 { 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 cells 116 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 vector 120 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 with 125 Shiftedy = y + TranslationVector; 126 // get distance and compare with minimum so far 127 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 vector 135 * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell 136 * \return \f$| x - y |^2\f$ 137 */ 138 double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const 139 { 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 cells 153 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 vector 157 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 with 162 Shiftedy = y + TranslationVector; 163 // get distance and compare with minimum so far 164 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 messages 172 * 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 periodically 185 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 100 198 /** Calculates scalar product between this and another vector. 101 199 * \param *y array to second vector … … 105 203 { 106 204 double res = 0.; 107 gsl_blas_ddot(content->content, y.content->content, &res); 205 for (int i=NDIM;i--;) 206 res += at(i)*y[i]; 108 207 return (res); 109 208 }; … … 270 369 double& Vector::operator[](size_t i){ 271 370 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 272 return *gsl_vector_ptr (content ->content, i);371 return *gsl_vector_ptr (content, i); 273 372 } 274 373 275 374 const double& Vector::operator[](size_t i) const{ 276 375 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 277 return *gsl_vector_ptr (content ->content, i);376 return *gsl_vector_ptr (content, i); 278 377 } 279 378 … … 286 385 } 287 386 288 VectorContent* Vector::get(){387 gsl_vector* Vector::get(){ 289 388 return content; 290 389 } … … 405 504 }; 406 505 407 void Vector::ScaleAll(const Vector &factor){408 gsl_vector_mul(content->content, factor.content->content);409 }410 506 411 507 412 508 void Vector::Scale(const double factor) 413 509 { 414 gsl_vector_scale(content->content,factor); 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); 415 530 }; 416 531 … … 431 546 return make_pair(res,helper); 432 547 } 548 549 /** Do a matrix multiplication. 550 * \param *matrix NDIM_NDIM array 551 */ 552 void Vector::MatrixMultiplication(const double * const M) 553 { 554 Vector tmp; 555 // do the matrix multiplication 556 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 array 564 */ 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 B 572 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular 573 detAReci = 1./detA; 574 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11 575 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12 576 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13 577 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21 578 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22 579 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23 580 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31 581 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32 582 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33 583 584 MatrixMultiplication(B); 585 586 return true; 587 } else { 588 return false; 589 } 590 }; 591 433 592 434 593 /** Creates this vector as the b y *factors' components scaled linear combination of the given three. … … 520 679 void Vector::AddVector(const Vector &y) 521 680 { 522 gsl_vector_add(content->content, y.content->content); 681 for(int i=NDIM;i--;) 682 at(i) += y[i]; 523 683 } 524 684 … … 528 688 void Vector::SubtractVector(const Vector &y) 529 689 { 530 gsl_vector_sub(content->content, y.content->content); 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; 531 711 } 532 712 -
src/vector.hpp
r4e10f5 r192f6e 11 11 #endif 12 12 13 #include <iosfwd> 13 #include <iostream> 14 #include <gsl/gsl_vector.h> 15 #include <gsl/gsl_multimin.h> 14 16 15 17 #include <memory> … … 22 24 23 25 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;35 33 public: 34 36 35 Vector(); 37 36 Vector(const double x1, const double x2, const double x3); … … 43 42 double DistanceSquared(const Vector &y) const; 44 43 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; 45 46 double ScalarProduct(const Vector &y) const; 46 47 double Angle(const Vector &y) const; … … 57 58 Vector Projection(const Vector &y) const; 58 59 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); 61 64 bool GetOneNormalVector(const Vector &x1); 62 65 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); 63 68 std::pair<Vector,Vector> partition(const Vector&) const; 64 69 std::pair<pointset,Vector> partition(const pointset&) const; … … 74 79 75 80 // Access to internal structure 76 VectorContent* get();81 gsl_vector* get(); 77 82 78 83 // Methods that are derived directly from other methods … … 99 104 100 105 private: 101 Vector(VectorContent *); 102 VectorContent *content; 106 gsl_vector *content; 103 107 104 108 }; -
src/vector_ops.cpp
r4e10f5 r192f6e 23 23 #include <gsl/gsl_permutation.h> 24 24 #include <gsl/gsl_vector.h> 25 #include <gsl/gsl_multimin.h>26 25 27 26 /** -
src/verbose.cpp
r4e10f5 r192f6e 5 5 #include "info.hpp" 6 6 #include "verbose.hpp" 7 #include <iostream>8 7 9 8 /** Prints the tabs according to verbosity stored in the temporary constructed class. -
src/verbose.hpp
r4e10f5 r192f6e 18 18 #endif 19 19 20 #include <ios fwd>20 #include <iostream> 21 21 22 22 /************************************* Class Verbose & Binary *******************************/ -
tests/regression/Domain/4/post/test.conf
r4e10f5 r192f6e 47 47 BoxLength # (Length of a unit cell) 48 48 1 49 0 149 0 0 50 50 0 0 2 51 51
Note:
See TracChangeset
for help on using the changeset viewer.