source: src/World.hpp@ 0e01b4

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 0e01b4 was 5f612ee, checked in by Frederik Heber <heber@…>, 15 years ago

Merge branch 'Analysis_PairCorrelation' into StructureRefactoring

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/World.cpp
molecuilder/src/World.hpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/log.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/periodentafel.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/Makefile.am
molecuilder/src/unittests/bondgraphunittest.cpp
molecuilder/src/unittests/gslvectorunittest.cpp
molecuilder/src/unittests/logunittest.cpp
molecuilder/src/unittests/tesselation_boundarytriangleunittest.hpp
molecuilder/src/vector.cpp
molecuilder/tests/Tesselations/defs.in

Conflicts have been many and too numerous to listen here, just the few general cases

  • new molecule() replaced by World::getInstance().createMolecule()
  • new atom() replaced by World::getInstance().createAtom() where appropriate.
  • Some DoLog()s added interfered with changes to the message produced by Log() << Verbose(.) << ...
  • DoLog() has been erroneously added to TestRunner.cpp as well, there cout is appropriate
  • ...

Additionally, there was a bug in atom::clone(), sort was set to atom::nr of the atom to clone not of the clone itself. This caused a failure of the fragmentation.

This merge has been fully checked from a clean build directory with subsequent configure,make all install and make check.
It configures, compiles and runs all test cases and the test suite without errors.

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 8.0 KB
RevLine 
[5d1611]1/*
2 * World.hpp
3 *
4 * Created on: Feb 3, 2010
5 * Author: crueger
6 */
7
8#ifndef WORLD_HPP_
9#define WORLD_HPP_
10
[b34306]11/*********************************************** includes ***********************************/
12
[7c4e29]13#include <string>
[d346b6]14#include <map>
[fc1b24]15#include <vector>
[354859]16#include <set>
[7c4e29]17#include <boost/thread.hpp>
[865a945]18#include <boost/shared_ptr.hpp>
[5d1611]19
[ead4e6]20#include "types.hpp"
[6e97e5]21#include "Descriptors/SelectiveIterator.hpp"
[5d1611]22#include "Patterns/Observer.hpp"
23#include "Patterns/Cacheable.hpp"
[23b547]24#include "Patterns/Singleton.hpp"
25
[b34306]26// include config.h
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
[5d1611]30
31// forward declarations
32class periodentafel;
33class MoleculeListClass;
[4d9c01]34class atom;
[354859]35class molecule;
[fc1b24]36class AtomDescriptor;
[7a1ce5]37class AtomDescriptor_impl;
[1c51c8]38class MoleculeDescriptor;
39class MoleculeDescriptor_impl;
[7c4e29]40class ManipulateAtomsProcess;
[b54ac8]41template<typename T>
42class AtomsCalculation;
[5d1611]43
[b34306]44/****************************************** forward declarations *****************************/
[23b547]45
[b34306]46/********************************************** Class World *******************************/
[23b547]47
48class World : public Singleton<World>, public Observable
[5d1611]49{
[23b547]50
51// Make access to constructor and destructor possible from inside the singleton
52friend class Singleton<World>;
53
[b54ac8]54// necessary for coupling with descriptors
[7a1ce5]55friend class AtomDescriptor_impl;
[865a945]56friend class AtomDescriptor;
[1c51c8]57friend class MoleculeDescriptor_impl;
58friend class MoleculeDescriptor;
[865a945]59
[b54ac8]60// Actions, calculations etc associated with the World
[7c4e29]61friend class ManipulateAtomsProcess;
[b54ac8]62template<typename> friend class AtomsCalculation;
[5d1611]63public:
[23b547]64
65 // Types for Atom and Molecule structures
[7042f45]66 typedef std::map<atomId_t,atom*> AtomSet;
67 typedef std::map<moleculeId_t,molecule*> MoleculeSet;
[5d1611]68
69 /***** getter and setter *****/
[354859]70 // reference to pointer is used for legacy reason... reference will be removed latter to keep encapsulation of World object
[02ee15]71 /**
72 * returns the periodentafel for the world.
73 */
[354859]74 periodentafel *&getPeriode();
[02ee15]75
76 /**
77 * returns the first atom that matches a given descriptor.
78 * Do not rely on ordering for descriptors that match more than one atom.
79 */
[7a1ce5]80 atom* getAtom(AtomDescriptor descriptor);
[02ee15]81
82 /**
83 * returns a vector containing all atoms that match a given descriptor
84 */
[7a1ce5]85 std::vector<atom*> getAllAtoms(AtomDescriptor descriptor);
[0e2a47]86 std::vector<atom*> getAllAtoms();
[b54ac8]87
[02ee15]88 /**
89 * returns a calculation that calls a given function on all atoms matching a descriptor.
90 * the calculation is not called at this point and can be used as an action, i.e. be stored in
91 * menus, be kept around for later use etc.
92 */
[0e2a47]93 template<typename T> AtomsCalculation<T>* calcOnAtoms(boost::function<T(atom*)>,std::string,AtomDescriptor);
94 template<typename T> AtomsCalculation<T>* calcOnAtoms(boost::function<T(atom*)>,std::string);
[b54ac8]95
[02ee15]96 /**
97 * get the number of atoms in the World
98 */
[354859]99 int numAtoms();
[02ee15]100
[1c51c8]101 /**
102 * returns the first molecule that matches a given descriptor.
103 * Do not rely on ordering for descriptors that match more than one molecule.
104 */
105 molecule *getMolecule(MoleculeDescriptor descriptor);
106
107 /**
108 * returns a vector containing all molecules that match a given descriptor
109 */
110 std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor);
111
[02ee15]112 /**
113 * get the number of molecules in the World
114 */
[354859]115 int numMolecules();
116
[5f612ee]117 /**
118 * get the domain size as a symmetric matrix (6 components)
119 */
120 double * getDomain();
121
122 /**
123 * set the domain size as a symmetric matrix (6 components)
124 */
125 void setDomain(double * matrix);
126
127 /**
128 * get the default name
129 */
130 char * getDefaultName();
131
132 /**
133 * set the default name
134 */
135 void setDefaultName(char * name);
136
[354859]137 /***** Methods to work with the World *****/
[02ee15]138
139 /**
140 * create a new molecule. This method should be used whenever any kind of molecule is needed. Assigns a unique
141 * ID to the molecule and stores it in the World for later retrieval. Do not create molecules directly.
142 */
[354859]143 molecule *createMolecule();
[02ee15]144
[cbc5fb]145 void destroyMolecule(molecule*);
146 void destroyMolecule(moleculeId_t);
147
[02ee15]148 /**
149 * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores
150 * the atom in the World. If the atom is not destroyed it will automatically be destroyed when the world ends.
151 */
[46d958]152 atom *createAtom();
[02ee15]153
154 /**
155 * Registers a Atom unknown to world. Needed in some rare cases, e.g. when cloning atoms, or in some unittests.
156 * Do not re-register Atoms already known to the world since this will cause double-frees.
157 */
[46d958]158 int registerAtom(atom*);
[02ee15]159
160 /**
161 * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on
162 * atom directly since this will leave the pointer inside the world.
163 */
[46d958]164 void destroyAtom(atom*);
[02ee15]165
166 /**
167 * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on
168 * atom directly since this will leave the pointer inside the world.
169 */
[cbc5fb]170 void destroyAtom(atomId_t);
[865a945]171
[88d586]172 /**
173 * used when changing an atom Id.
174 * Unless you are calling this method from inside an atom don't fiddle with the third parameter.
175 *
176 * Return value indicates wether the change could be done or not.
177 */
178 bool changeAtomId(atomId_t oldId, atomId_t newId, atom* target=0);
179
[02ee15]180 /**
181 * Produces a process that calls a function on all Atoms matching a given descriptor. The process is not
182 * called at this time, so it can be passed around, stored inside menuItems etc.
183 */
[7c4e29]184 ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string,AtomDescriptor);
[0e2a47]185 ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string);
[7c4e29]186
[865a945]187protected:
188 /**** Iterators to use internal data structures */
[1c51c8]189
190 // Atoms
[6e97e5]191 typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator;
[865a945]192
[02ee15]193 /**
194 * returns an iterator over all Atoms matching a given descriptor.
195 * used for internal purposes, like AtomProcesses and AtomCalculations.
196 */
[865a945]197 AtomIterator getAtomIter(AtomDescriptor descr);
[02ee15]198
199 /**
[d2dbac0]200 * returns an iterator to the end of the AtomSet. Due to overloading this iterator
[02ee15]201 * can be compared to iterators produced by getAtomIter (see the mis-matching types).
202 * Thus it can be used to detect when such an iterator is at the end of the list.
203 * used for internal purposes, like AtomProcesses and AtomCalculations.
204 */
[6e97e5]205 AtomIterator atomEnd();
[865a945]206
[1c51c8]207 // Molecules
208
[6e97e5]209 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator;
[1c51c8]210
211 /**
212 * returns an iterator over all Molecules matching a given descriptor.
213 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
214 */
215 MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
216
217 /**
218 * returns an iterator to the end of the MoleculeSet. Due to overloading this iterator
219 * can be compared to iterators produced by getMoleculeIter (see the mis-matching types).
220 * Thus it can be used to detect when such an iterator is at the end of the list.
221 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
222 */
[6e97e5]223 MoleculeIterator moleculeEnd();
[1c51c8]224
225
[afb47f]226 /******* Internal manipulation routines for double callback and Observer mechanism ******/
227 void doManipulate(ManipulateAtomsProcess *);
228
[5d1611]229private:
[88d586]230
231 atomId_t getNextAtomId();
232 void releaseAtomId(atomId_t);
233 bool reserveAtomId(atomId_t);
234
[5d1611]235 periodentafel *periode;
[5f612ee]236 static double *cell_size;
237 static char *defaultName;
[6e97e5]238public:
[d2dbac0]239 AtomSet atoms;
[6e97e5]240private:
[88d586]241 std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId
[cbc5fb]242 atomId_t currAtomId; //!< stores the next available Id for atoms
[d2dbac0]243 MoleculeSet molecules;
[cbc5fb]244 moleculeId_t currMoleculeId;
[5d1611]245private:
[02ee15]246 /**
247 * private constructor to ensure creation of the world using
248 * the singleton pattern.
249 */
[5d1611]250 World();
[02ee15]251
252 /**
253 * private destructor to ensure destruction of the world using the
254 * singleton pattern.
255 */
[5d1611]256 virtual ~World();
257
258 /*****
259 * some legacy stuff that is include for now but will be removed later
260 *****/
261public:
[354859]262 MoleculeListClass *&getMolecules();
[4d9c01]263
[5d1611]264private:
[354859]265 MoleculeListClass *molecules_deprecated;
[5d1611]266};
267
268#endif /* WORLD_HPP_ */
Note: See TracBrowser for help on using the repository browser.