Changeset b3d687 for src/Filling/Filler.cpp
- Timestamp:
- Apr 5, 2012, 3:57:16 PM (13 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:
- 5cdd83
- Parents:
- 259887
- git-author:
- Frederik Heber <heber@…> (04/05/12 08:14:13)
- git-committer:
- Frederik Heber <heber@…> (04/05/12 15:57:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Filling/Filler.cpp
r259887 rb3d687 39 39 #include "LinearAlgebra/RealSpaceMatrix.hpp" 40 40 #include "LinearAlgebra/Vector.hpp" 41 #include "molecule.hpp" 41 42 #include "NodeTypes.hpp" 42 43 #include "Predicates/FillPredicate.hpp" … … 86 87 NodeSet FillNodes(nodes.size(), zeroVec); 87 88 88 // move filler cluster's atoms out of domain such that it does not disturb the predicate. 89 // we only move the atoms as otherwise two translate ShapeOps will be on top of the Shape 90 // which is subsequently copied to all other cloned Clusters ... 91 Vector BoxDiagonal; 89 // evaluate predicates at each FillNode 92 90 { 93 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 94 BoxDiagonal = (M * Vector(1.,1.,1.)); 95 BoxDiagonal -= cluster->getShape().getCenter(); 96 BoxDiagonal *= 1. + 2.*cluster->getShape().getRadius()/BoxDiagonal.Norm(); // extend it a little further 97 AtomIdSet atoms = cluster->getAtoms(); 98 for (AtomIdSet::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) 99 (*iter)->setPosition( (*iter)->getPosition() + BoxDiagonal ); 100 LOG(1, "INFO: Translating original cluster's atoms by " << BoxDiagonal << "."); 101 } 91 // move filler cluster's atoms out of domain such that it does not disturb the predicate. 92 // we only move the atoms as otherwise two translate ShapeOps will be on top of the Shape 93 // which is subsequently copied to all other cloned Clusters ... 94 Vector BoxDiagonal; 95 { 96 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 97 BoxDiagonal = (M * Vector(1.,1.,1.)); 98 BoxDiagonal -= cluster->getShape().getCenter(); 99 BoxDiagonal *= 1. + 2.*cluster->getShape().getRadius()/BoxDiagonal.Norm(); // extend it a little further 100 AtomIdSet atoms = cluster->getAtoms(); 101 for (AtomIdSet::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) 102 (*iter)->setPosition( (*iter)->getPosition() + BoxDiagonal ); 103 LOG(1, "INFO: Translating original cluster's atoms by " << BoxDiagonal << "."); 104 } 102 105 103 // evaluate predicate and gather into new set104 NodeSet::iterator transform_end =105 std::remove_copy_if(nodes.begin(), nodes.end(), FillNodes.begin(), predicate );106 FillNodes.erase(transform_end, FillNodes.end());106 // evaluate predicate and gather into new set 107 NodeSet::iterator transform_end = 108 std::remove_copy_if(nodes.begin(), nodes.end(), FillNodes.begin(), predicate ); 109 FillNodes.erase(transform_end, FillNodes.end()); 107 110 108 // shift cluster back to original place 109 { 110 AtomIdSet atoms = cluster->getAtoms(); 111 for (AtomIdSet::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) 112 (*iter)->setPosition( (*iter)->getPosition() - BoxDiagonal ); 113 LOG(1, "INFO: Translating original cluster's atoms back."); 111 // shift cluster back to original place 112 { 113 AtomIdSet atoms = cluster->getAtoms(); 114 for (AtomIdSet::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) 115 (*iter)->setPosition( (*iter)->getPosition() - BoxDiagonal ); 116 LOG(1, "INFO: Translating original cluster's atoms back."); 117 } 114 118 } 115 119 … … 123 127 // clone clusters 124 128 std::vector<ClusterInterface::Cluster_impl> clusters(FillNodes.size()); 125 std::vector<ClusterInterface::Cluster_impl>::iterator clusteriter = clusters.begin(); 126 *clusteriter = cluster; 127 clusteriter++; 128 std::generate_n(clusteriter, FillNodes.size()-1, 129 boost::bind(&ClusterInterface::clone, boost::cref(cluster), boost::ref(copyMethod), zeroVec) ); 129 { 130 std::vector<ClusterInterface::Cluster_impl>::iterator clusteriter = clusters.begin(); 131 *clusteriter = cluster; 132 clusteriter++; 133 std::generate_n(clusteriter, FillNodes.size()-1, 134 boost::bind(&ClusterInterface::clone, boost::cref(cluster), boost::ref(copyMethod), zeroVec) ); 135 } 130 136 131 137 // insert each cluster by abusing std::search a bit: 132 // we look for the subsequence of FillNodes inside clusters. If Inserter always 133 // returns true, we'll have the iterator pointing at first cluster 134 std::vector<ClusterInterface::Cluster_impl>::const_iterator inserteriter = 135 std::search(clusters.begin(), clusters.end(), FillNodes.begin(), FillNodes.end(), 136 boost::bind(&Inserter::operator(), boost::cref(inserter), _1, _2)); 137 if( inserteriter != clusters.begin()) { 138 ELOG(1, "Not all cloned clusters could be successfully inserted."); 139 return false; 138 { 139 // we look for the subsequence of FillNodes inside clusters. If Inserter always 140 // returns true, we'll have the iterator pointing at first cluster 141 std::vector<ClusterInterface::Cluster_impl>::const_iterator inserteriter = 142 std::search(clusters.begin(), clusters.end(), FillNodes.begin(), FillNodes.end(), 143 boost::bind(&Inserter::operator(), boost::cref(inserter), _1, _2)); 144 if( inserteriter != clusters.begin()) { 145 ELOG(1, "Not all cloned clusters could be successfully inserted."); 146 return false; 147 } 148 } 149 150 // create molecules for each cluster and fill in atoms 151 { 152 std::vector<molecule *> molecules(clusters.size()-1, NULL); 153 std::generate_n(molecules.begin(), FillNodes.size()-1, 154 boost::bind(&World::createMolecule, World::getPointer()) ); 155 std::vector<ClusterInterface::Cluster_impl>::const_iterator clusteriter = clusters.begin(); 156 ++clusteriter; 157 std::vector<molecule *>::iterator moliter = molecules.begin(); 158 for (;moliter != molecules.end(); ++clusteriter, ++moliter) { 159 AtomIdSet atoms = (*clusteriter)->getAtoms(); 160 for (AtomIdSet::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) 161 (*moliter)->AddAtom(*iter); 162 } 140 163 } 141 164
Note:
See TracChangeset
for help on using the changeset viewer.