Changeset f6abb1 for src/Potentials
- Timestamp:
- May 7, 2016, 7:03:56 AM (9 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_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:
- fde8e7
- Parents:
- 086e30
- git-author:
- Frederik Heber <heber@…> (02/27/16 13:09:08)
- git-committer:
- Frederik Heber <heber@…> (05/07/16 07:03:56)
- Location:
- src/Potentials
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/Makefile.am
r086e30 rf6abb1 29 29 Potentials/Specifics/PairPotential_Morse.cpp \ 30 30 Potentials/Specifics/PotentialTypes.cpp \ 31 Potentials/Specifics/ThreeBodyPotential_Angle.cpp 31 Potentials/Specifics/ThreeBodyPotential_Angle.cpp \ 32 Potentials/StreamFactory_EmpiricalPotential.cpp 32 33 33 34 POTENTIALSHEADER = \ … … 57 58 Potentials/Specifics/PotentialTypes.def \ 58 59 Potentials/Specifics/PotentialTypes.undef \ 59 Potentials/StreamFactory.hpp 60 Potentials/StreamFactory.hpp \ 61 Potentials/StreamFactory_EmpiricalPotential.hpp 60 62 61 63 if CONDLEVMAR -
src/Potentials/PotentialDeserializer.cpp
r086e30 rf6abb1 62 62 // instantiate type 63 63 EmpiricalPotential *potential = 64 PotentialFactory::getInstance().createInstance(65 token, potentialstream);64 static_cast<StreamFactory<EmpiricalPotential>&>(PotentialFactory::getInstance()). 65 createInstance(token, potentialstream); 66 66 67 67 // and register -
src/Potentials/PotentialFactory.cpp
r086e30 rf6abb1 96 96 #include "Potentials/Specifics/PotentialTypes.undef" 97 97 98 enum PotentialTypes PotentialFactory::getTypeForName(const std::string &_name) 99 { 100 ASSERT (NameToType.count(_name), 101 "PotentialFactory::getTypeForName() - cannot find potential of name "+_name); 102 return NameToType[_name]; 103 } 104 105 const std::string & PotentialFactory::getNameForType(enum PotentialTypes _type) 106 { 107 ASSERT (TypeToName.count(_type), 108 "PotentialFactory::getNameForType() - cannot find potential of name "+_type); 109 return TypeToName[_type]; 110 } 111 98 112 EmpiricalPotential *PotentialFactory::createInstance( 99 113 const std::string &potentialtype, 100 114 const SerializablePotential::ParticleTypes_t &types) const 101 115 { 102 ASSERT (NameToType.count(potentialtype), 103 "PotentialFactory::createInstance() - cannot find potential of name "+potentialtype); 104 switch (NameToType[potentialtype]) { 116 switch (getTypeForName(potentialtype)) { 105 117 case constant: 106 118 return new ConstantPotential(types); … … 125 137 } 126 138 127 EmpiricalPotential *PotentialFactory::createInstance( 128 const std::string &potentialtype, 129 std::istream &serialized) const 139 EmpiricalPotential* PotentialFactory::getDefaultPotential(const std::string &_name) const 130 140 { 131 141 EmpiricalPotential *potential = NULL; 132 ASSERT (NameToType.count(potentialtype), 133 "PotentialFactory::createInstance() - cannot find potential of name "+potentialtype); 134 switch (NameToType[potentialtype]) { 142 switch (getTypeForName(_name)) { 135 143 case constant: 136 144 potential = new ConstantPotential(); … … 161 169 break; 162 170 } 163 // now stream in types and parameters164 potential->stream_from(serialized);165 166 171 return potential; 167 172 } -
src/Potentials/PotentialFactory.hpp
r086e30 rf6abb1 21 21 #include "Potentials/EmpiricalPotential.hpp" 22 22 #include "Potentials/Specifics/PotentialTypes.hpp" 23 #include "Potentials/StreamFactory_EmpiricalPotential.hpp" 23 24 24 25 /** Class that creates instances of potentials. … … 27 28 * 28 29 */ 29 class PotentialFactory : public Singleton<PotentialFactory> 30 class PotentialFactory : 31 public Singleton<PotentialFactory>, 32 public StreamFactory<EmpiricalPotential> 30 33 { 31 34 //!> make Singleton template friend 32 35 friend class Singleton<PotentialFactory>; 33 36 37 protected: 38 39 /** Returns a default potential to which only we have access. 40 * 41 */ 42 EmpiricalPotential* getDefaultPotential(const std::string &_name) const; 43 34 44 public: 45 35 46 /** Creates an instance of the requested potential. 36 47 * … … 41 52 const std::string &potentialtype, 42 53 const SerializablePotential::ParticleTypes_t &charges) const; 43 44 /** Creates an instance of the requested potential.45 *46 * \param potentialtype key of potential to create47 * \param serialized stream to parser SerializablePotential from48 */49 EmpiricalPotential *createInstance(50 const std::string &potentialtype,51 std::istream &serialized) const;52 54 53 55 //!> typedef for map to lookup type for a given name … … 63 65 static TypeToName_t TypeToName; 64 66 67 static enum PotentialTypes getTypeForName(const std::string &_name); 68 69 static const std::string & getNameForType(enum PotentialTypes _type); 70 65 71 private: 66 72 PotentialFactory() {}
Note:
See TracChangeset
for help on using the changeset viewer.