- Timestamp:
- Feb 25, 2010, 4:43:02 PM (15 years ago)
- Branches:
- 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
- Children:
- cf1a07
- Parents:
- 244d26
- Location:
- src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
r244d26 rcbc5fb 1093 1093 A++; 1094 1094 } 1095 delete(mol);1095 World::get()->destroyMolecule(mol); 1096 1096 }; 1097 1097 -
src/World.cpp
r244d26 rcbc5fb 47 47 OBSERVE; 48 48 molecule *mol = NULL; 49 mol = new molecule(periode); 50 molecules_deprecated->insert(mol); 49 mol = NewMolecule(); 51 50 assert(!molecules.count(currMoleculeId)); 51 mol->setId(currMoleculeId++); 52 52 // store the molecule by ID 53 molecules[ currMoleculeId++] = mol;53 molecules[mol->getId()] = mol; 54 54 mol->signOn(this); 55 55 return mol; 56 } 57 58 void World::destroyMolecule(molecule* mol){ 59 OBSERVE; 60 destroyMolecule(mol->getId()); 61 } 62 63 void World::destroyMolecule(moleculeId_t id){ 64 OBSERVE; 65 molecule *mol = molecules[id]; 66 assert(mol); 67 DeleteMolecule(mol); 68 molecules.erase(id); 56 69 } 57 70 … … 83 96 } 84 97 85 void World::destroyAtom( int id) {98 void World::destroyAtom(atomId_t id) { 86 99 OBSERVE; 87 100 atom *atom = atoms[id]; … … 134 147 currMoleculeId(0), 135 148 periode(new periodentafel), 136 molecules_deprecated(new MoleculeListClass ),149 molecules_deprecated(new MoleculeListClass(this)), 137 150 atoms(), 138 151 molecules() … … 145 158 delete molecules_deprecated; 146 159 delete periode; 147 AtomSet::iterator iter; 148 for(iter=atoms.begin();iter!=atoms.end();++iter){ 149 DeleteAtom((*iter).second); 160 MoleculeSet::iterator molIter; 161 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ 162 DeleteMolecule((*molIter).second); 163 } 164 molecules.clear(); 165 AtomSet::iterator atIter; 166 for(atIter=atoms.begin();atIter!=atoms.end();++atIter){ 167 DeleteAtom((*atIter).second); 150 168 } 151 169 atoms.clear(); -
src/World.hpp
r244d26 rcbc5fb 16 16 #include <boost/shared_ptr.hpp> 17 17 18 18 #include "defs.hpp" 19 19 #include "Patterns/Observer.hpp" 20 20 #include "Patterns/Cacheable.hpp" … … 40 40 friend class ManipulateAtomsProcess; 41 41 template<typename> friend class AtomsCalculation; 42 43 typedef std::map<int,atom*> AtomSet; 44 typedef std::map<int,molecule*> MoleculeSet; 42 typedef std::map<atomId_t,atom*> AtomSet; 43 typedef std::map<moleculeId_t,molecule*> MoleculeSet; 45 44 public: 46 45 … … 90 89 molecule *createMolecule(); 91 90 91 void destroyMolecule(molecule*); 92 void destroyMolecule(moleculeId_t); 93 92 94 /** 93 95 * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores … … 112 114 * atom directly since this will leave the pointer inside the world. 113 115 */ 114 void destroyAtom( int);116 void destroyAtom(atomId_t); 115 117 116 118 /** … … 166 168 periodentafel *periode; 167 169 AtomSet atoms; 168 int currAtomId; //!< stores the next available Id for atoms170 atomId_t currAtomId; //!< stores the next available Id for atoms 169 171 MoleculeSet molecules; 170 int currMoleculeId;172 moleculeId_t currMoleculeId; 171 173 172 174 -
src/boundary.cpp
r244d26 rcbc5fb 4 4 */ 5 5 6 #include "World.hpp" 6 7 #include "atom.hpp" 7 8 #include "bond.hpp" … … 800 801 { 801 802 Info FunctionInfo(__func__); 802 molecule *Filling = new molecule(filler->elemente);803 molecule *Filling = World::get()->createMolecule(); 803 804 Vector CurrentPosition; 804 805 int N[NDIM]; -
src/builder.cpp
r244d26 rcbc5fb 1432 1432 } 1433 1433 if (mol == NULL) { 1434 mol = new molecule(periode);1434 mol = World::get()->createMolecule(); 1435 1435 mol->ActiveFlag = true; 1436 1436 if (ConfigFileName != NULL) … … 1634 1634 Log() << Verbose(1) << "Filling Box with water molecules." << endl; 1635 1635 // construct water molecule 1636 molecule *filler = new molecule(periode);1636 molecule *filler = World::get()->createMolecule(); 1637 1637 molecule *Filling = NULL; 1638 1638 atom *second = NULL, *third = NULL; … … 1664 1664 molecules->insert(Filling); 1665 1665 } 1666 delete(filler);1666 World::get()->destroyMolecule(filler); 1667 1667 argptr+=6; 1668 1668 } … … 2203 2203 if(World::get()->numMolecules() == 0){ 2204 2204 mol = World::get()->createMolecule(); 2205 World::get()->getMolecules()->insert(mol); 2206 cout << "Molecule created" << endl; 2205 2207 if(mol->cell_size[0] == 0.){ 2206 2208 Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl; -
src/config.cpp
r244d26 rcbc5fb 851 851 void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList) 852 852 { 853 molecule *mol = new molecule(periode);853 molecule *mol = World::get()->createMolecule(); 854 854 ifstream *file = new ifstream(filename); 855 855 if (file == NULL) { … … 1089 1089 void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList) 1090 1090 { 1091 molecule *mol = new molecule(periode);1091 molecule *mol = World::get()->createMolecule(); 1092 1092 ifstream *file = new ifstream(filename); 1093 1093 if (file == NULL) { … … 1788 1788 char filename[MAXSTRINGSIZE]; 1789 1789 ofstream output; 1790 molecule *mol = new molecule(periode);1790 molecule *mol = World::get()->createMolecule(); 1791 1791 mol->SetNameFromFilename(ConfigFileName); 1792 1792 … … 1899 1899 } 1900 1900 1901 delete(mol);1901 World::get()->destroyMolecule(mol); 1902 1902 }; 1903 1903 -
src/defs.hpp
r244d26 rcbc5fb 32 32 33 33 enum Shading { white, lightgray, darkgray, black }; //!< color in Breadth-First-Search analysis 34 35 // some types that can stay abstract 36 typedef unsigned int moleculeId_t; 37 typedef int atomId_t; 34 38 35 39 //enum CutCyclicBond { KeepBond, SaturateBond }; //!< Saturation scheme either atom- or bondwise -
src/molecule.cpp
r244d26 rcbc5fb 53 53 }; 54 54 55 molecule *NewMolecule(){ 56 return new molecule(World::get()->getPeriode()); 57 } 58 55 59 /** Destructor of class molecule. 56 60 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. … … 66 70 67 71 72 void DeleteMolecule(molecule *mol){ 73 delete mol; 74 } 75 68 76 // getter and setter 69 77 const std::string molecule::getName(){ … … 74 82 OBSERVE; 75 83 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 84 } 85 86 moleculeId_t molecule::getId(){ 87 return id; 88 } 89 90 void molecule::setId(moleculeId_t _id){ 91 id =_id; 76 92 } 77 93 -
src/molecule.hpp
r244d26 rcbc5fb 29 29 #include <string> 30 30 31 #include "defs.hpp" 31 32 #include "graph.hpp" 32 33 #include "stackclass.hpp" … … 85 86 */ 86 87 class molecule : public PointCloud , public Observable { 88 friend molecule *NewMolecule(); 89 friend void DeleteMolecule(molecule *); 87 90 public: 88 91 double cell_size[6];//!< cell size … … 108 111 private: 109 112 Cacheable<string> formula; 113 moleculeId_t id; 114 protected: 115 molecule(const periodentafel * const teil); 116 virtual ~molecule(); 117 110 118 111 119 public: 112 molecule(const periodentafel * const teil);113 virtual ~molecule();114 115 120 //getter and setter 116 121 const std::string getName(); 122 moleculeId_t getId(); 123 void setId(moleculeId_t); 117 124 void setName(const std::string); 118 125 const std::string getFormula(); 119 126 std::string calcFormula(); 127 120 128 121 129 // re-definition of virtual functions from PointCloud … … 321 329 }; 322 330 331 molecule *NewMolecule(); 332 void DeleteMolecule(molecule* mol); 333 323 334 #include "molecule_template.hpp" 324 335 … … 330 341 int MaxIndex; 331 342 332 MoleculeListClass( );343 MoleculeListClass(World *world); 333 344 ~MoleculeListClass(); 334 345 … … 363 374 364 375 private: 376 World *world; //!< The world this List belongs to. Needed to avoid deadlocks in the destructor 365 377 }; 366 378 -
src/molecule_dynamics.cpp
r244d26 rcbc5fb 6 6 */ 7 7 8 #include "World.hpp" 8 9 #include "atom.hpp" 9 10 #include "config.hpp" … … 485 486 bool status = true; 486 487 int MaxSteps = configuration.MaxOuterStep; 487 MoleculeListClass *MoleculePerStep = new MoleculeListClass( );488 MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::get()); 488 489 // Get the Permutation Map by MinimiseConstrainedPotential 489 490 atom **PermutationMap = NULL; … … 505 506 Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl; 506 507 for (int step = 0; step <= MaxSteps; step++) { 507 mol = new molecule(elemente);508 mol = World::get()->createMolecule(); 508 509 MoleculePerStep->insert(mol); 509 510 Walker = start; -
src/molecule_fragmentation.cpp
r244d26 rcbc5fb 8 8 #include <cstring> 9 9 10 #include "World.hpp" 10 11 #include "atom.hpp" 11 12 #include "bond.hpp" … … 675 676 //if (FragmentationToDo) { // we should always store the fragments again as coordination might have changed slightly without changing bond structure 676 677 // allocate memory for the pointer array and transmorph graphs into full molecular fragments 677 BondFragments = new MoleculeListClass( );678 BondFragments = new MoleculeListClass(World::get()); 678 679 int k=0; 679 680 for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) { … … 926 927 { 927 928 atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList"); 928 molecule *Leaf = new molecule(elemente);929 molecule *Leaf = World::get()->createMolecule(); 929 930 930 931 // Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl; -
src/moleculelist.cpp
r244d26 rcbc5fb 7 7 #include <cstring> 8 8 9 #include "World.hpp" 9 10 #include "atom.hpp" 10 11 #include "bond.hpp" … … 24 25 /** Constructor for MoleculeListClass. 25 26 */ 26 MoleculeListClass::MoleculeListClass() 27 MoleculeListClass::MoleculeListClass(World *_world) : 28 world(_world) 27 29 { 28 30 // empty lists … … 38 40 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { 39 41 Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl; 40 delete(*ListRunner);42 world->destroyMolecule(*ListRunner); 41 43 } 42 44 Log() << Verbose(4) << "Freeing ListOfMolecules." << endl; … … 213 215 // remove src 214 216 ListOfMolecules.remove(srcmol); 215 delete(srcmol);217 World::get()->destroyMolecule(srcmol); 216 218 return true; 217 219 }; … … 748 750 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration) 749 751 { 750 molecule *mol = new molecule(periode);752 molecule *mol = World::get()->createMolecule(); 751 753 atom *Walker = NULL; 752 754 atom *Advancer = NULL; … … 773 775 } 774 776 // remove the molecule 775 delete(*MolRunner);777 World::get()->destroyMolecule(*MolRunner); 776 778 ListOfMolecules.erase(MolRunner); 777 779 } … … 795 797 molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules"); 796 798 for (int i=0;i<MolCount;i++) { 797 molecules[i] = (molecule*) new molecule(mol->elemente);799 molecules[i] = World::get()->createMolecule(); 798 800 molecules[i]->ActiveFlag = true; 799 801 strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE); … … 893 895 OBSERVE; 894 896 molecule *mol = NULL; 895 mol = new molecule(periode);897 mol = World::get()->createMolecule(); 896 898 insert(mol); 897 899 }; … … 902 904 char filename[MAXSTRINGSIZE]; 903 905 Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 904 mol = new molecule(periode);906 mol = World::get()->createMolecule(); 905 907 do { 906 908 Log() << Verbose(0) << "Enter file name: "; … … 960 962 mol = *ListRunner; 961 963 ListOfMolecules.erase(ListRunner); 962 delete(mol);964 World::get()->destroyMolecule(mol); 963 965 break; 964 966 } … … 1007 1009 // remove the leaf itself 1008 1010 if (Leaf != NULL) { 1009 delete(Leaf);1011 World::get()->destroyMolecule(Leaf); 1010 1012 Leaf = NULL; 1011 1013 } -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r244d26 rcbc5fb 52 52 53 53 // construct periodentafel 54 tafel = new periodentafel;54 tafel = World::get()->getPeriode(); 55 55 tafel->AddElement(hydrogen); 56 56 57 57 // construct molecule (tetraeder of hydrogens) 58 TestMolecule = new molecule(tafel);58 TestMolecule = World::get()->createMolecule(); 59 59 Walker = World::get()->createAtom(); 60 60 Walker->type = hydrogen; … … 77 77 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 78 78 79 TestList = new MoleculeListClass;79 TestList = World::get()->getMolecules(); 80 80 TestMolecule->ActiveFlag = true; 81 81 TestList->insert(TestMolecule); … … 98 98 delete(binmap); 99 99 100 // remove101 delete(TestList);102 // note that all the atoms are cleaned by TestMolecule103 100 delete(point); 104 delete(tafel); 105 // note that element is cleaned by periodentafel 101 World::destroy(); 106 102 }; 107 103 -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r244d26 rcbc5fb 56 56 57 57 // construct periodentafel 58 tafel = new periodentafel;58 tafel = World::get()->getPeriode(); 59 59 tafel->AddElement(hydrogen); 60 60 tafel->AddElement(carbon); 61 61 62 62 // construct molecule (tetraeder of hydrogens) base 63 TestMolecule = new molecule(tafel);63 TestMolecule = World::get()->createMolecule(); 64 64 Walker = World::get()->createAtom(); 65 65 Walker->type = hydrogen; … … 82 82 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 83 83 84 TestList = new MoleculeListClass;84 TestList = World::get()->getMolecules(); 85 85 TestMolecule->ActiveFlag = true; 86 86 TestList->insert(TestMolecule); … … 127 127 delete(binmap); 128 128 129 // remove130 delete(TestList);131 129 delete(Surface); 132 130 // note that all the atoms are cleaned by TestMolecule 133 131 delete(LC); 134 delete(tafel); 135 // note that element is cleaned by periodentafel 132 World::destroy(); 136 133 }; 137 134 -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r244d26 rcbc5fb 51 51 52 52 // construct periodentafel 53 tafel = new periodentafel;53 tafel = World::get()->getPeriode(); 54 54 tafel->AddElement(hydrogen); 55 55 56 56 // construct molecule (tetraeder of hydrogens) 57 TestMolecule = new molecule(tafel);57 TestMolecule = World::get()->createMolecule(); 58 58 Walker = World::get()->createAtom(); 59 59 Walker->type = hydrogen; … … 76 76 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 77 77 78 TestList = new MoleculeListClass;78 TestList = World::get()->getMolecules(); 79 79 TestMolecule->ActiveFlag = true; 80 80 TestList->insert(TestMolecule); … … 94 94 delete(binmap); 95 95 96 // remove97 delete(TestList);98 96 // note that all the atoms are cleaned by TestMolecule 99 delete(tafel); 100 // note that element is cleaned by periodentafel 97 World::destroy(); 101 98 }; 102 99 -
src/unittests/Makefile.am
r244d26 rcbc5fb 30 30 CacheableTest \ 31 31 DescriptorUnittest \ 32 manipulateAtomsTest \ 32 manipulateAtomsTest \ 33 33 atomsCalculationTest \ 34 34 ${MENUTESTS} -
src/unittests/analysisbondsunittest.cpp
r244d26 rcbc5fb 57 57 58 58 // construct periodentafel 59 tafel = new periodentafel;59 tafel = World::get()->getPeriode(); 60 60 tafel->AddElement(hydrogen); 61 61 tafel->AddElement(carbon); 62 62 63 63 // construct molecule (tetraeder of hydrogens) 64 TestMolecule = new molecule(tafel);64 TestMolecule = World::get()->createMolecule(); 65 65 Walker = World::get()->createAtom(); 66 66 Walker->type = hydrogen; … … 113 113 114 114 // remove molecule 115 delete(TestMolecule);115 World::get()->destroyMolecule(TestMolecule); 116 116 // note that all the atoms are cleaned by TestMolecule 117 delete(tafel); 118 // note that element is cleaned by periodentafel 117 World::destroy(); 119 118 }; 120 119 -
src/unittests/bondgraphunittest.cpp
r244d26 rcbc5fb 52 52 53 53 // construct periodentafel 54 tafel = new periodentafel;54 tafel = World::get()->getPeriode(); 55 55 tafel->AddElement(hydrogen); 56 56 tafel->AddElement(carbon); 57 57 58 58 // construct molecule (tetraeder of hydrogens) 59 TestMolecule = new molecule(tafel);59 TestMolecule = World::get()->createMolecule(); 60 60 Walker = World::get()->createAtom(); 61 61 Walker->type = hydrogen; … … 97 97 98 98 // remove molecule 99 delete(TestMolecule);99 World::get()->destroyMolecule(TestMolecule); 100 100 // note that all the atoms are cleaned by TestMolecule 101 delete(tafel); 102 // note that element is cleaned by periodentafel 101 World::destroy(); 103 102 }; 104 103 -
src/unittests/listofbondsunittest.cpp
r244d26 rcbc5fb 46 46 47 47 // construct periodentafel 48 tafel = new periodentafel;48 tafel = World::get()->getPeriode(); 49 49 tafel->AddElement(hydrogen); 50 50 51 51 // construct molecule (tetraeder of hydrogens) 52 TestMolecule = new molecule(tafel);52 TestMolecule = World::get()->createMolecule(); 53 53 Walker = World::get()->createAtom(); 54 54 Walker->type = hydrogen; … … 77 77 { 78 78 // remove 79 delete(TestMolecule);79 World::get()->destroyMolecule(TestMolecule); 80 80 // note that all the atoms are cleaned by TestMolecule 81 delete(tafel); 82 // note that element is cleaned by periodentafel 81 World::destroy(); 83 82 }; 84 83
Note:
See TracChangeset
for help on using the changeset viewer.