Changeset 95304c for src/Actions


Ignore:
Timestamp:
Nov 4, 2016, 9:37:49 AM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
6829d2
Parents:
f946b2
git-author:
Frederik Heber <heber@…> (10/02/16 11:50:53)
git-committer:
Frederik Heber <heber@…> (11/04/16 09:37:49)
Message:

REFACTOR: Extracted registerPotentialIfNotPresent out of PotentialFitPotentialAction::performCall().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/PotentialAction/FitPotentialAction.cpp

    rf946b2 r95304c  
    6969/** =========== define the function ====================== */
    7070
     71static void registerPotentialIfNotPresent(
     72    const std::string &_potentialtype,
     73    const SerializablePotential::ParticleTypes_t &_types)
     74{
     75  EmpiricalPotential *potential =
     76      PotentialFactory::getInstance().createInstance(_potentialtype,_types);
     77  // check whether such a potential already exists
     78  const std::string potential_name = potential->getName();
     79  if (PotentialRegistry::getInstance().isPresentByName(potential_name)) {
     80    delete potential;
     81    potential = PotentialRegistry::getInstance().getByName(potential_name);
     82  } else
     83    PotentialRegistry::getInstance().registerInstance(potential);
     84}
     85
     86
    7187ActionState::ptr PotentialFitPotentialAction::performCall() {
    7288  // fragment specifies the homology fragment to use
     
    87103
    88104    // register desired potential and an additional constant one
    89     {
    90       EmpiricalPotential *potential =
    91           PotentialFactory::getInstance().createInstance(
    92               params.potentialtype.get(),
    93               chargenumbers);
    94       // check whether such a potential already exists
    95       const std::string potential_name = potential->getName();
    96       if (PotentialRegistry::getInstance().isPresentByName(potential_name)) {
    97         delete potential;
    98         potential = PotentialRegistry::getInstance().getByName(potential_name);
    99       } else
    100         PotentialRegistry::getInstance().registerInstance(potential);
    101     }
    102     {
    103       EmpiricalPotential *constant =
    104           PotentialFactory::getInstance().createInstance(
    105               std::string("constant"),
    106               SerializablePotential::ParticleTypes_t());
    107       // check whether such a potential already exists
    108       const std::string constant_name = constant->getName();
    109       if (PotentialRegistry::getInstance().isPresentByName(constant_name)) {
    110         delete constant;
    111         constant = PotentialRegistry::getInstance().getByName(constant_name);
    112       } else
    113         PotentialRegistry::getInstance().registerInstance(constant);
    114     }
     105    registerPotentialIfNotPresent(params.potentialtype.get(),chargenumbers);
     106    registerPotentialIfNotPresent(
     107        std::string("constant"),
     108        SerializablePotential::ParticleTypes_t());
    115109  }
    116110
Note: See TracChangeset for help on using the changeset viewer.