- Timestamp:
- Sep 14, 2016, 7:02:33 AM (9 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, 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_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, 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, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, 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, SaturateAtoms_findBestMatching, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- 1af2ae
- Parents:
- 36bd59
- git-author:
- Frederik Heber <heber@…> (07/12/14 19:07:44)
- git-committer:
- Frederik Heber <heber@…> (09/14/16 07:02:33)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
r36bd59 rfe90ab 480 480 for (IndexList_t::iterator iter = _indices.begin(); 481 481 (iter != _indices.end()) && (!_MCS.foundflag);) { 482 482 483 // check whether we can stay in the current bin or have to move on to next one 483 484 if (*_remainiter == 0) { … … 490 491 } 491 492 } 492 // advance in matching to same position 493 494 // advance in matching to current bin to fill in 493 495 const size_t OldIndex = std::distance(_remainingweights.begin(), _remainiter); 494 496 while (_matching.size() <= OldIndex) { // add empty lists of new bin is opened … … 498 500 IndexTupleList_t::iterator filliniter = _matching.begin(); 499 501 std::advance(filliniter, OldIndex); 502 503 // check whether connection between bins' indices and candidate is satisfied 504 { 505 adjacency_t::const_iterator finder = _MCS.adjacency.find(*iter); 506 ASSERT( finder != _MCS.adjacency.end(), 507 "recurseMatchings() - "+toString(*iter)+" is not in adjacency list."); 508 if ((!filliniter->empty()) 509 && (finder->second.find(*filliniter->begin()) == finder->second.end())) { 510 LOG(5, "DEBUG; Skipping index " << *iter 511 << " as is not connected to current set." << *filliniter << "."); 512 ++iter; // note that for loop does not contain incrementor 513 continue; 514 } 515 } 516 500 517 // add index to matching 501 518 filliniter->push_back(*iter); … … 532 549 } 533 550 551 SphericalPointDistribution::MatchingControlStructure::MatchingControlStructure( 552 const adjacency_t &_adjacency, 553 const VectorArray_t &_oldpoints, 554 const VectorArray_t &_newpoints, 555 const WeightsArray_t &_weights 556 ) : 557 foundflag(false), 558 bestL2(std::numeric_limits<double>::max()), 559 adjacency(_adjacency), 560 oldpoints(_oldpoints), 561 newpoints(_newpoints), 562 weights(_weights) 563 {} 564 534 565 /** Finds combinatorially the best matching between points in \a _polygon 535 566 * and \a _newpolygon. … … 551 582 */ 552 583 SphericalPointDistribution::IndexList_t SphericalPointDistribution::findBestMatching( 553 const WeightedPolygon_t &_polygon, 554 Polygon_t &_newpolygon 584 const WeightedPolygon_t &_polygon 555 585 ) 556 586 { 557 MatchingControlStructure MCS;558 MCS.foundflag = false;559 MCS.bestL2 = std::numeric_limits<double>::max();560 587 // transform lists into arrays 588 VectorArray_t oldpoints; 589 VectorArray_t newpoints; 590 WeightsArray_t weights; 561 591 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 562 592 iter != _polygon.end(); ++iter) { 563 MCS.oldpoints.push_back(iter->first); 564 MCS.weights.push_back(iter->second); 565 } 566 MCS.newpoints.insert(MCS.newpoints.begin(), _newpolygon.begin(),_newpolygon.end() ); 593 oldpoints.push_back(iter->first); 594 weights.push_back(iter->second); 595 } 596 newpoints.insert(newpoints.begin(), points.begin(), points.end() ); 597 MatchingControlStructure MCS(adjacency, oldpoints, newpoints, weights); 567 598 568 599 // search for bestmatching combinatorially 569 600 { 570 601 // translate polygon into vector to enable index addressing 571 IndexList_t indices( _newpolygon.size());602 IndexList_t indices(points.size()); 572 603 std::generate(indices.begin(), indices.end(), UniqueNumber); 573 604 IndexTupleList_t matching; … … 594 625 // combine multiple points and create simple IndexList from IndexTupleList 595 626 const SphericalPointDistribution::IndexList_t IndexList = 596 joinPoints( _newpolygon, MCS.newpoints, MCS.bestmatching);627 joinPoints(points, MCS.newpoints, MCS.bestmatching); 597 628 598 629 return IndexList; … … 781 812 } 782 813 814 void SphericalPointDistribution::initSelf(const int _NumberOfPoints) 815 { 816 switch (_NumberOfPoints) 817 { 818 case 0: 819 points = get<0>(); 820 adjacency = getConnections<0>(); 821 break; 822 case 1: 823 points = get<1>(); 824 adjacency = getConnections<1>(); 825 break; 826 case 2: 827 points = get<2>(); 828 adjacency = getConnections<2>(); 829 break; 830 case 3: 831 points = get<3>(); 832 adjacency = getConnections<3>(); 833 break; 834 case 4: 835 points = get<4>(); 836 adjacency = getConnections<4>(); 837 break; 838 case 5: 839 points = get<5>(); 840 adjacency = getConnections<5>(); 841 break; 842 case 6: 843 points = get<6>(); 844 adjacency = getConnections<6>(); 845 break; 846 case 7: 847 points = get<7>(); 848 adjacency = getConnections<7>(); 849 break; 850 case 8: 851 points = get<8>(); 852 adjacency = getConnections<8>(); 853 break; 854 case 9: 855 points = get<9>(); 856 adjacency = getConnections<9>(); 857 break; 858 case 10: 859 points = get<10>(); 860 adjacency = getConnections<10>(); 861 break; 862 case 11: 863 points = get<11>(); 864 adjacency = getConnections<11>(); 865 break; 866 case 12: 867 points = get<12>(); 868 adjacency = getConnections<12>(); 869 break; 870 case 14: 871 points = get<14>(); 872 adjacency = getConnections<14>(); 873 break; 874 default: 875 ASSERT(0, "SphericalPointDistribution::initSelf() - cannot deal with the case " 876 +toString(_NumberOfPoints)+"."); 877 } 878 LOG(3, "DEBUG: Ideal polygon is " << points); 879 } 783 880 784 881 SphericalPointDistribution::Polygon_t 785 SphericalPointDistribution::matchSphericalPointDistributions( 786 const SphericalPointDistribution::WeightedPolygon_t &_polygon, 787 SphericalPointDistribution::Polygon_t &_newpolygon 788 ) 882 SphericalPointDistribution::getRemainingPoints( 883 const WeightedPolygon_t &_polygon, 884 const int _N) 789 885 { 790 886 SphericalPointDistribution::Polygon_t remainingpoints; 791 887 888 // initialze to given number of points 889 initSelf(_N); 792 890 LOG(2, "INFO: Matching old polygon " << _polygon 793 << " with new polygon " << _newpolygon); 794 795 if (_polygon.size() == _newpolygon.size()) { 796 // same number of points desired as are present? Do nothing 797 LOG(2, "INFO: There are no vacant points to return."); 891 << " with new polygon " << points); 892 893 // check whether any points will remain vacant 894 int RemainingPoints = _N; 895 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 896 iter != _polygon.end(); ++iter) 897 RemainingPoints -= iter->second; 898 if (RemainingPoints == 0) 798 899 return remainingpoints; 799 } 800 801 if (_polygon.size() > 0) { 802 IndexList_t bestmatching = findBestMatching(_polygon, _newpolygon); 900 901 if (_N > 0) { 902 IndexList_t bestmatching = findBestMatching(_polygon); 803 903 LOG(2, "INFO: Best matching is " << bestmatching); 804 904 … … 819 919 newSet.indices.resize(NumberIds, -1); 820 920 std::copy(beginiter, enditer, newSet.indices.begin()); 821 std::copy( _newpolygon.begin(),_newpolygon.end(), std::back_inserter(newSet.polygon));921 std::copy(points.begin(),points.end(), std::back_inserter(newSet.polygon)); 822 922 823 923 // determine rotation angles to align the two point distributions with … … 927 1027 return remainingpoints; 928 1028 } else 929 return _newpolygon;930 } 1029 return points; 1030 }
Note:
See TracChangeset
for help on using the changeset viewer.