source: src/World.cpp@ fea945

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 fea945 was 02ce36, checked in by Frederik Heber <heber@…>, 13 years ago

We now require CodePatterns 1.2.0.

  • this is due to the updated Observer structure and multi_array MemDebug bugfix.
  • Property mode set to 100644
File size: 19.0 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2011 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * World.cpp
10 *
11 * Created on: Feb 3, 2010
12 * Author: crueger
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include "World.hpp"
23
24#include <functional>
25
26#include "Actions/ActionTrait.hpp"
27#include "Actions/ManipulateAtomsProcess.hpp"
28#include "Atom/atom.hpp"
29#include "Box.hpp"
30#include "CodePatterns/Assert.hpp"
31#include "config.hpp"
32#include "Descriptors/AtomDescriptor.hpp"
33#include "Descriptors/AtomDescriptor_impl.hpp"
34#include "Descriptors/MoleculeDescriptor.hpp"
35#include "Descriptors/MoleculeDescriptor_impl.hpp"
36#include "Descriptors/SelectiveIterator_impl.hpp"
37#include "Element/periodentafel.hpp"
38#include "Graph/BondGraph.hpp"
39#include "Graph/DepthFirstSearchAnalysis.hpp"
40#include "Helpers/defs.hpp"
41#include "LinearAlgebra/RealSpaceMatrix.hpp"
42#include "molecule.hpp"
43#include "MoleculeListClass.hpp"
44#include "Thermostats/ThermoStatContainer.hpp"
45#include "WorldTime.hpp"
46
47#include "IdPool_impl.hpp"
48
49#include "CodePatterns/Singleton_impl.hpp"
50#include "CodePatterns/Observer/Channels.hpp"
51#include "CodePatterns/Observer/ObservedContainer_impl.hpp"
52
53using namespace MoleCuilder;
54
55/******************************* Notifications ************************/
56
57
58atom* World::_lastchangedatom = NULL;
59molecule* World::_lastchangedmol = NULL;
60
61/******************************* getter and setter ************************/
62periodentafel *&World::getPeriode()
63{
64 return periode;
65}
66
67BondGraph *&World::getBondGraph()
68{
69 return BG;
70}
71
72void World::setBondGraph(BondGraph *_BG){
73 delete (BG);
74 BG = _BG;
75}
76
77config *&World::getConfig(){
78 return configuration;
79}
80
81// Atoms
82
83atom* World::getAtom(AtomDescriptor descriptor){
84 return descriptor.find();
85}
86
87World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor){
88 return descriptor.findAll();
89}
90
91World::AtomComposite World::getAllAtoms(){
92 return getAllAtoms(AllAtoms());
93}
94
95int World::numAtoms(){
96 return atoms.size();
97}
98
99// Molecules
100
101molecule *World::getMolecule(MoleculeDescriptor descriptor){
102 return descriptor.find();
103}
104
105std::vector<molecule*> World::getAllMolecules(MoleculeDescriptor descriptor){
106 return descriptor.findAll();
107}
108
109std::vector<molecule*> World::getAllMolecules(){
110 return getAllMolecules(AllMolecules());
111}
112
113int World::numMolecules(){
114 return molecules_deprecated->ListOfMolecules.size();
115}
116
117// system
118
119Box& World::getDomain() {
120 return *cell_size;
121}
122
123void World::setDomain(const RealSpaceMatrix &mat){
124 OBSERVE;
125 *cell_size = mat;
126}
127
128void World::setDomain(double * matrix)
129{
130 OBSERVE;
131 RealSpaceMatrix M = ReturnFullMatrixforSymmetric(matrix);
132 cell_size->setM(M);
133}
134
135void World::setTime(const unsigned int _step)
136{
137 if (_step != WorldTime::getTime()) {
138 // set new time
139 WorldTime::setTime(_step);
140 // TODO: removed when BondGraph creates the adjacency
141 // 1. remove all of World's molecules
142 for (MoleculeIterator iter = getMoleculeIter();
143 getMoleculeIter() != moleculeEnd();
144 iter = getMoleculeIter()) {
145 getMolecules()->erase(*iter);
146 destroyMolecule(*iter);
147 }
148 // 2. (re-)create bondgraph
149 AtomComposite Set = getAllAtoms();
150 BG->CreateAdjacency(Set);
151
152 // 3. scan for connected subgraphs => molecules
153 DepthFirstSearchAnalysis DFS;
154 DFS();
155 DFS.UpdateMoleculeStructure();
156 }
157}
158
159std::string World::getDefaultName() {
160 return defaultName;
161}
162
163void World::setDefaultName(std::string name)
164{
165 OBSERVE;
166 defaultName = name;
167};
168
169class ThermoStatContainer * World::getThermostats()
170{
171 return Thermostats;
172}
173
174
175int World::getExitFlag() {
176 return ExitFlag;
177}
178
179void World::setExitFlag(int flag) {
180 if (ExitFlag < flag)
181 ExitFlag = flag;
182}
183
184/******************** Methods to change World state *********************/
185
186molecule* World::createMolecule(){
187 OBSERVE;
188 molecule *mol = NULL;
189 mol = NewMolecule();
190 moleculeId_t id = moleculeIdPool.getNextId();
191 ASSERT(!molecules.count(id),"proposed id did not specify an unused ID");
192 mol->setId(id);
193 // store the molecule by ID
194 molecules[mol->getId()] = mol;
195 mol->signOn(this);
196 _lastchangedmol = mol;
197 NOTIFY(MoleculeInserted);
198 return mol;
199}
200
201void World::destroyMolecule(molecule* mol){
202 OBSERVE;
203 ASSERT(mol,"Molecule that was meant to be destroyed did not exist");
204 destroyMolecule(mol->getId());
205}
206
207void World::destroyMolecule(moleculeId_t id){
208 molecule *mol = molecules[id];
209 ASSERT(mol,"Molecule id that was meant to be destroyed did not exist");
210 // give notice about immediate removal
211 {
212 OBSERVE;
213 _lastchangedmol = mol;
214 NOTIFY(MoleculeRemoved);
215 }
216 DeleteMolecule(mol);
217 if (isMoleculeSelected(id))
218 selectedMolecules.erase(id);
219 molecules.erase(id);
220 moleculeIdPool.releaseId(id);
221}
222
223atom *World::createAtom(){
224 OBSERVE;
225 atomId_t id = atomIdPool.getNextId();
226 ASSERT(!atoms.count(id),"proposed id did not specify an unused ID");
227 atom *res = NewAtom(id);
228 res->setWorld(this);
229 // store the atom by ID
230 atoms[res->getId()] = res;
231 _lastchangedatom = res;
232 NOTIFY(AtomInserted);
233 return res;
234}
235
236
237int World::registerAtom(atom *atom){
238 OBSERVE;
239 atomId_t id = atomIdPool.getNextId();
240 atom->setId(id);
241 atom->setWorld(this);
242 atoms[atom->getId()] = atom;
243 return atom->getId();
244}
245
246void World::destroyAtom(atom* atom){
247 int id = atom->getId();
248 destroyAtom(id);
249}
250
251void World::destroyAtom(atomId_t id) {
252 atom *atom = atoms[id];
253 ASSERT(atom,"Atom ID that was meant to be destroyed did not exist");
254 // give notice about immediate removal
255 {
256 OBSERVE;
257 _lastchangedatom = atom;
258 NOTIFY(AtomRemoved);
259 }
260 DeleteAtom(atom);
261 if (isAtomSelected(id))
262 selectedAtoms.erase(id);
263 atoms.erase(id);
264 atomIdPool.releaseId(id);
265}
266
267bool World::changeAtomId(atomId_t oldId, atomId_t newId, atom* target){
268 OBSERVE;
269 // in case this call did not originate from inside the atom, we redirect it,
270 // to also let it know that it has changed
271 if(!target){
272 target = atoms[oldId];
273 ASSERT(target,"Atom with that ID not found");
274 return target->changeId(newId);
275 }
276 else{
277 if(atomIdPool.reserveId(newId)){
278 atoms.erase(oldId);
279 atoms.insert(pair<atomId_t,atom*>(newId,target));
280 return true;
281 }
282 else{
283 return false;
284 }
285 }
286}
287
288bool World::changeMoleculeId(moleculeId_t oldId, moleculeId_t newId, molecule* target){
289 OBSERVE;
290 // in case this call did not originate from inside the atom, we redirect it,
291 // to also let it know that it has changed
292 if(!target){
293 target = molecules[oldId];
294 ASSERT(target,"Molecule with that ID not found");
295 return target->changeId(newId);
296 }
297 else{
298 if(moleculeIdPool.reserveId(newId)){
299 molecules.erase(oldId);
300 molecules.insert(pair<moleculeId_t,molecule*>(newId,target));
301 return true;
302 }
303 else{
304 return false;
305 }
306 }
307}
308
309ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name,AtomDescriptor descr){
310 ActionTrait manipulateTrait(name);
311 return new ManipulateAtomsProcess(op, descr,manipulateTrait,false);
312}
313
314ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name){
315 return manipulateAtoms(op,name,AllAtoms());
316}
317
318/********************* Internal Change methods for double Callback and Observer mechanism ********/
319
320void World::doManipulate(ManipulateAtomsProcess *proc){
321 proc->signOn(this);
322 {
323 OBSERVE;
324 proc->doManipulate(this);
325 }
326 proc->signOff(this);
327}
328/******************************* Iterators ********************************/
329
330// external parts with observers
331
332CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor);
333
334World::AtomIterator
335World::getAtomIter(AtomDescriptor descr){
336 return AtomIterator(descr,atoms);
337}
338
339World::AtomIterator
340World::getAtomIter(){
341 return AtomIterator(AllAtoms(),atoms);
342}
343
344World::AtomIterator
345World::atomEnd(){
346 return AtomIterator(AllAtoms(),atoms,atoms.end());
347}
348
349CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor);
350
351World::MoleculeIterator
352World::getMoleculeIter(MoleculeDescriptor descr){
353 return MoleculeIterator(descr,molecules);
354}
355
356World::MoleculeIterator
357World::getMoleculeIter(){
358 return MoleculeIterator(AllMolecules(),molecules);
359}
360
361World::MoleculeIterator
362World::moleculeEnd(){
363 return MoleculeIterator(AllMolecules(),molecules,molecules.end());
364}
365
366// Internal parts, without observers
367
368// Build the AtomIterator from template
369CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet::set_t,AtomDescriptor);
370
371
372World::internal_AtomIterator
373World::getAtomIter_internal(AtomDescriptor descr){
374 return internal_AtomIterator(descr,atoms.getContent());
375}
376
377World::internal_AtomIterator
378World::atomEnd_internal(){
379 return internal_AtomIterator(AllAtoms(),atoms.getContent(),atoms.end_internal());
380}
381
382// build the MoleculeIterator from template
383CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet::set_t,MoleculeDescriptor);
384
385World::internal_MoleculeIterator World::getMoleculeIter_internal(MoleculeDescriptor descr){
386 return internal_MoleculeIterator(descr,molecules.getContent());
387}
388
389World::internal_MoleculeIterator World::moleculeEnd_internal(){
390 return internal_MoleculeIterator(AllMolecules(),molecules.getContent(),molecules.end_internal());
391}
392
393/************************** Selection of Atoms and molecules ******************/
394
395// Atoms
396
397void World::clearAtomSelection(){
398 selectedAtoms.clear();
399}
400
401void World::selectAtom(const atom *_atom){
402 // atom * is unchanged in this function, but we do store entity as changeable
403 ASSERT(_atom,"Invalid pointer in selection of atom");
404 selectedAtoms[_atom->getId()]=const_cast<atom *>(_atom);
405}
406
407void World::selectAtom(const atomId_t id){
408 ASSERT(atoms.count(id),"Atom Id selected that was not in the world");
409 selectedAtoms[id]=atoms[id];
410}
411
412void World::selectAllAtoms(AtomDescriptor descr){
413 internal_AtomIterator begin = getAtomIter_internal(descr);
414 internal_AtomIterator end = atomEnd_internal();
415 void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
416 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
417}
418
419void World::selectAtomsOfMolecule(const molecule *_mol){
420 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
421 // need to make it const to get the fast iterators
422 const molecule *mol = _mol;
423 void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
424 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above
425}
426
427void World::selectAtomsOfMolecule(const moleculeId_t id){
428 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
429 selectAtomsOfMolecule(molecules[id]);
430}
431
432void World::unselectAtom(const atom *_atom){
433 ASSERT(_atom,"Invalid pointer in unselection of atom");
434 unselectAtom(_atom->getId());
435}
436
437void World::unselectAtom(const atomId_t id){
438 ASSERT(atoms.count(id),"Atom Id unselected that was not in the world");
439 selectedAtoms.erase(id);
440}
441
442void World::unselectAllAtoms(AtomDescriptor descr){
443 internal_AtomIterator begin = getAtomIter_internal(descr);
444 internal_AtomIterator end = atomEnd_internal();
445 void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
446 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
447}
448
449void World::unselectAtomsOfMolecule(const molecule *_mol){
450 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
451 // need to make it const to get the fast iterators
452 const molecule *mol = _mol;
453 void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
454 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above
455}
456
457void World::unselectAtomsOfMolecule(const moleculeId_t id){
458 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
459 unselectAtomsOfMolecule(molecules[id]);
460}
461
462size_t World::countSelectedAtoms() const {
463 size_t count = 0;
464 for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
465 count++;
466 return count;
467}
468
469bool World::isSelected(const atom *_atom) const {
470 return isAtomSelected(_atom->getId());
471}
472
473bool World::isAtomSelected(const atomId_t no) const {
474 return selectedAtoms.find(no) != selectedAtoms.end();
475}
476
477const std::vector<atom *> World::getSelectedAtoms() const {
478 std::vector<atom *> returnAtoms;
479 returnAtoms.resize(countSelectedAtoms());
480 int count = 0;
481 for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
482 returnAtoms[count++] = iter->second;
483 return returnAtoms;
484}
485
486
487// Molecules
488
489void World::clearMoleculeSelection(){
490 selectedMolecules.clear();
491}
492
493void World::selectMolecule(const molecule *_mol){
494 // molecule * is unchanged in this function, but we do store entity as changeable
495 ASSERT(_mol,"Invalid pointer to molecule in selection");
496 selectedMolecules[_mol->getId()]=const_cast<molecule *>(_mol);
497}
498
499void World::selectMolecule(const moleculeId_t id){
500 ASSERT(molecules.count(id),"Molecule Id selected that was not in the world");
501 selectedMolecules[id]=molecules[id];
502}
503
504void World::selectAllMolecules(MoleculeDescriptor descr){
505 internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
506 internal_MoleculeIterator end = moleculeEnd_internal();
507 void (World::*func)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
508 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
509}
510
511void World::selectMoleculeOfAtom(const atom *_atom){
512 ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
513 molecule *mol=_atom->getMolecule();
514 // the atom might not be part of a molecule
515 if(mol){
516 selectMolecule(mol);
517 }
518}
519
520void World::selectMoleculeOfAtom(const atomId_t id){
521 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
522 selectMoleculeOfAtom(atoms[id]);
523}
524
525void World::unselectMolecule(const molecule *_mol){
526 ASSERT(_mol,"invalid pointer in unselection of molecule");
527 unselectMolecule(_mol->getId());
528}
529
530void World::unselectMolecule(const moleculeId_t id){
531 ASSERT(molecules.count(id),"No such molecule with ID in unselection");
532 selectedMolecules.erase(id);
533}
534
535void World::unselectAllMolecules(MoleculeDescriptor descr){
536 internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
537 internal_MoleculeIterator end = moleculeEnd_internal();
538 void (World::*func)(const molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
539 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
540}
541
542void World::unselectMoleculeOfAtom(const atom *_atom){
543 ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
544 molecule *mol=_atom->getMolecule();
545 // the atom might not be part of a molecule
546 if(mol){
547 unselectMolecule(mol);
548 }
549}
550
551void World::unselectMoleculeOfAtom(const atomId_t id){
552 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
553 unselectMoleculeOfAtom(atoms[id]);
554}
555
556size_t World::countSelectedMolecules() const {
557 size_t count = 0;
558 for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
559 count++;
560 return count;
561}
562
563bool World::isSelected(const molecule *_mol) const {
564 return isMoleculeSelected(_mol->getId());
565}
566
567bool World::isMoleculeSelected(const moleculeId_t no) const {
568 return selectedMolecules.find(no) != selectedMolecules.end();
569}
570
571const std::vector<molecule *> World::getSelectedMolecules() const {
572 std::vector<molecule *> returnMolecules;
573 returnMolecules.resize(countSelectedMolecules());
574 int count = 0;
575 for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
576 returnMolecules[count++] = iter->second;
577 return returnMolecules;
578}
579
580/******************* Iterators over Selection *****************************/
581World::AtomSelectionIterator World::beginAtomSelection(){
582 return selectedAtoms.begin();
583}
584
585World::AtomSelectionIterator World::endAtomSelection(){
586 return selectedAtoms.end();
587}
588
589World::AtomSelectionConstIterator World::beginAtomSelection() const{
590 return selectedAtoms.begin();
591}
592
593World::AtomSelectionConstIterator World::endAtomSelection() const{
594 return selectedAtoms.end();
595}
596
597
598World::MoleculeSelectionIterator World::beginMoleculeSelection(){
599 return selectedMolecules.begin();
600}
601
602World::MoleculeSelectionIterator World::endMoleculeSelection(){
603 return selectedMolecules.end();
604}
605
606World::MoleculeSelectionConstIterator World::beginMoleculeSelection() const{
607 return selectedMolecules.begin();
608}
609
610World::MoleculeSelectionConstIterator World::endMoleculeSelection() const{
611 return selectedMolecules.end();
612}
613
614/******************************* Singleton Stuff **************************/
615
616World::World() :
617 Observable("World"),
618 BG(new BondGraph(true)), // assume Angstroem for the moment
619 periode(new periodentafel(true)),
620 configuration(new config),
621 Thermostats(new ThermoStatContainer),
622 ExitFlag(0),
623 atoms(this),
624 selectedAtoms(this),
625 atomIdPool(0, 20, 100),
626 molecules(this),
627 selectedMolecules(this),
628 moleculeIdPool(0, 20,100),
629 molecules_deprecated(new MoleculeListClass(this))
630{
631 cell_size = new Box;
632 RealSpaceMatrix domain;
633 domain.at(0,0) = 20;
634 domain.at(1,1) = 20;
635 domain.at(2,2) = 20;
636 cell_size->setM(domain);
637 defaultName = "none";
638 Channels *OurChannel = new Channels;
639 NotificationChannels.insert( std::make_pair( this, OurChannel) );
640 for (size_t type = 0; type < (size_t)NotificationType_MAX; ++type)
641 OurChannel->addChannel(type);
642 molecules_deprecated->signOn(this);
643}
644
645World::~World()
646{
647 molecules_deprecated->signOff(this);
648 delete cell_size;
649 delete molecules_deprecated;
650 MoleculeSet::iterator molIter;
651 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
652 DeleteMolecule((*molIter).second);
653 }
654 molecules.clear();
655 AtomSet::iterator atIter;
656 for(atIter=atoms.begin();atIter!=atoms.end();++atIter){
657 DeleteAtom((*atIter).second);
658 }
659 atoms.clear();
660
661 // empty notifications
662 std::map<Observable *, Channels*>::iterator iter = NotificationChannels.find(this);
663 ASSERT(iter != NotificationChannels.end(),
664 "World::~World() - cannot find our Channels in NotificationChannels.");
665 delete iter->second;
666 NotificationChannels.erase(iter);
667
668 delete BG;
669 delete periode;
670 delete configuration;
671 delete Thermostats;
672}
673
674// Explicit instantiation of the singleton mechanism at this point
675
676// moleculeId_t und atomId_t sind gleicher Basistyp, deswegen nur einen von beiden konstruieren
677CONSTRUCT_IDPOOL(moleculeId_t)
678
679CONSTRUCT_SINGLETON(World)
680
681CONSTRUCT_OBSERVEDCONTAINER(World::AtomSTLSet)
682
683CONSTRUCT_OBSERVEDCONTAINER(World::MoleculeSTLSet)
684
685/******************************* deprecated Legacy Stuff ***********************/
686
687MoleculeListClass *&World::getMolecules() {
688 return molecules_deprecated;
689}
Note: See TracBrowser for help on using the repository browser.