Ignore:
Timestamp:
Dec 10, 2012, 10:10:58 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
19c50e
Parents:
27594e
git-author:
Frederik Heber <heber@…> (09/04/12 08:13:21)
git-committer:
Frederik Heber <heber@…> (12/10/12 10:10:58)
Message:

Refactored controller usage in FragmentationAutomationAction: Made three distinct parts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/FragmentationAutomationAction.cpp

    r27594e r4f056e  
    372372Action::state_ptr FragmentationFragmentationAutomationAction::performCall() {
    373373  boost::asio::io_service io_service;
    374   MPQCFragmentController mpqccontroller(io_service);
    375   mpqccontroller.setHost(params.host.get());
    376   mpqccontroller.setPort(params.port.get());
    377   mpqccontroller.setLevel(params.level.get());
    378   VMGFragmentController vmgcontroller(io_service);
    379   vmgcontroller.setHost(params.host.get());
    380   vmgcontroller.setPort(params.port.get());
    381   VMGDebugGridFragmentController debugcontroller(io_service);
    382   debugcontroller.setHost(params.host.get());
    383   debugcontroller.setPort(params.port.get());
    384374
    385375  // TODO: Have io_service run in second thread and merge with current again eventually
    386376
    387   // Phase One: obtain ids
    388   std::vector< boost::filesystem::path > jobfiles = params.jobfiles.get();
    389   mpqccontroller.requestIds(jobfiles.size());
    390 
    391   // Phase Two: create and add MPQCJobs
    392   if (!mpqccontroller.addJobsFromFiles(params.executable.get().string(), jobfiles))
    393     return Action::failure;
    394 
    395   // Phase Three: calculate result
    396   mpqccontroller.waitforResults(jobfiles.size());
     377  size_t Exitflag = 0;
    397378  std::map<JobId_t, MPQCData> fragmentData;
    398   mpqccontroller.getResults(fragmentData);
     379  {
     380    MPQCFragmentController mpqccontroller(io_service);
     381    mpqccontroller.setHost(params.host.get());
     382    mpqccontroller.setPort(params.port.get());
     383    mpqccontroller.setLevel(params.level.get());
     384    // Phase One: obtain ids
     385    std::vector< boost::filesystem::path > jobfiles = params.jobfiles.get();
     386    mpqccontroller.requestIds(jobfiles.size());
     387
     388    // Phase Two: create and add MPQCJobs
     389    if (!mpqccontroller.addJobsFromFiles(params.executable.get().string(), jobfiles))
     390      return Action::failure;
     391
     392    // Phase Three: calculate result
     393    mpqccontroller.waitforResults(jobfiles.size());
     394    mpqccontroller.getResults(fragmentData);
     395
     396    Exitflag += mpqccontroller.getExitflag();
     397  }
    399398
    400399#ifdef HAVE_VMG
     
    404403
    405404  // obtain combined charge density
    406   LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
    407405  FragmentationChargeDensity summedChargeDensity(
    408406      fragmentData,
     
    410408  const std::vector<SamplingGrid> full_sample = summedChargeDensity.getFullSampledGrid();
    411409
     410  LOG(1, "INFO: There are " << fragmentData.size() << " short-range and "
     411      << full_sample.size() << " level-wise long-range jobs.");
     412
    412413  // Phase Four: obtain more ids
    413   const size_t NoJobs = fragmentData.size()+full_sample.size();
    414   vmgcontroller.requestIds(NoJobs);
    415 
    416   // Phase Five: create VMGJobs
    417   const size_t near_field_cells = params.near_field_cells.get();
    418   if (!vmgcontroller.createLongRangeJobs(
    419       fragmentData,
    420       full_sample,
    421       summedChargeDensity.getFragment(), near_field_cells))
    422     return Action::failure;
    423 
    424   // Phase Six: calculate result
    425   vmgcontroller.waitforResults(NoJobs);
    426414  std::map<JobId_t, VMGData> longrangeData;
    427   vmgcontroller.getResults(longrangeData);
    428   ASSERT( NoJobs == longrangeData.size(),
    429       "FragmentationFragmentationAutomationAction::performCall() - number of MPQCresults+"
    430       +toString(full_sample)+" "
    431       +toString(NoJobs)
    432       +" and VMGresults "+toString(longrangeData.size())+" don't match.");
     415  {
     416    VMGFragmentController vmgcontroller(io_service);
     417    vmgcontroller.setHost(params.host.get());
     418    vmgcontroller.setPort(params.port.get());
     419    const size_t NoJobs = fragmentData.size()+full_sample.size();
     420    vmgcontroller.requestIds(NoJobs);
     421
     422    // Phase Five: create VMGJobs
     423    const size_t near_field_cells = params.near_field_cells.get();
     424    if (!vmgcontroller.createLongRangeJobs(
     425        fragmentData,
     426        full_sample,
     427        summedChargeDensity.getFragment(), near_field_cells))
     428      return Action::failure;
     429
     430    // Phase Six: calculate result
     431    vmgcontroller.waitforResults(NoJobs);
     432    vmgcontroller.getResults(longrangeData);
     433    ASSERT( NoJobs == longrangeData.size(),
     434        "FragmentationFragmentationAutomationAction::performCall() - number of MPQCresults+"
     435        +toString(full_sample.size())+"="+toString(NoJobs)
     436        +" and VMGresults "+toString(longrangeData.size())+" don't match.");
     437    Exitflag += vmgcontroller.getExitflag();
     438  }
    433439
    434440  // remove full solution corresponding to full_sample from map (must be highest ids), has to be treated extra
     
    454460    LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
    455461    printReceivedFullResults(results);
    456 
     462  }
     463
     464  std::map<JobId_t, std::string> debugData;
     465  {
    457466    if (!full_sample.empty()) {
    458467      // create debug jobs for each level to print the summed-up potential to vtk files
     468      VMGDebugGridFragmentController debugcontroller(io_service);
     469      debugcontroller.setHost(params.host.get());
     470      debugcontroller.setPort(params.port.get());
    459471      debugcontroller.requestIds(full_sample.size());
    460472      if (!debugcontroller.createDebugJobs(full_sample))
    461473        return Action::failure;
    462474      debugcontroller.waitforResults(full_sample.size());
    463       std::map<JobId_t, std::string> debugData;
    464475      debugcontroller.getResults(debugData);
     476      Exitflag += debugcontroller.getExitflag();
    465477    }
    466478  }
     
    476488  }
    477489#endif
    478   size_t Exitflag = vmgcontroller.getExitflag() + mpqccontroller.getExitflag();
    479490
    480491  return (Exitflag == 0) ? Action::success : Action::failure;
Note: See TracChangeset for help on using the changeset viewer.