source: src/World.cpp@ 794bc8

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 794bc8 was 6f0841, checked in by Frederik Heber <heber@…>, 13 years ago

Shifted all modules related to atoms into own subfolder src/Atom/

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