Changeset fb3485
- Timestamp:
- Feb 15, 2013, 5:09:58 PM (12 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:
- 313f83
- Parents:
- c0e8fb
- git-author:
- Frederik Heber <heber@…> (01/31/13 13:25:31)
- git-committer:
- Frederik Heber <heber@…> (02/15/13 17:09:58)
- Location:
- src/Jobs/Grid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Jobs/Grid/SamplingGrid.cpp ¶
rc0e8fb rfb3485 42 42 #include "Jobs/Grid/SamplingGrid.hpp" 43 43 44 #include <boost/bind.hpp> 44 45 #include <limits> 45 46 … … 333 334 } 334 335 336 static void addElements( 337 double &dest, 338 const double &source, 339 const double prefactor) 340 { 341 dest += prefactor*(source); 342 } 343 335 344 void SamplingGrid::addOntoWindow( 336 345 const double _begin_window[3], … … 339 348 const double prefactor) 340 349 { 350 addWindowOntoWindow( 351 begin_window, 352 end_window, 353 _begin_window, 354 _end_window, 355 sampled_grid, 356 _sampled_grid, 357 boost::bind(addElements, _1, _2, boost::cref(prefactor)), 358 thiswindow); 359 } 360 361 void SamplingGrid::addWindowOntoWindow( 362 const double wbegin[3], 363 const double wend[3], 364 const double other_wbegin[3], 365 const double other_wend[3], 366 sampledvalues_t &sampled_grid, 367 const sampledvalues_t &other_sampled_grid, 368 boost::function<void (double &, const double &)> op, 369 enum LargerWindow choice) 370 { 341 371 #ifndef NDEBUG 342 372 for(size_t index=0;index<3;++index) { 343 ASSERT( _begin_window[index] >= begin_window[index],344 "SamplingGrid::add OntoWindow() - given window starts earlierin component "373 ASSERT( other_wbegin[index] >= wbegin[index], 374 "SamplingGrid::addWindowOntoWindow() - given smaller window starts earlier than larger window in component " 345 375 +toString(index)+"."); 346 ASSERT( _end_window[index] <= end_window[index],347 "SamplingGrid::add OntoWindow() - given window ends laterin component "376 ASSERT( other_wend[index] <= wend[index], 377 "SamplingGrid::addWindowOntoWindow() - given smaller window ends later than larger window in component " 348 378 +toString(index)+"."); 349 379 } … … 364 394 const double delta = (double)gridpoints_axis/(end[index] - begin[index]); 365 395 // delta is conversion factor from box length to discrete length, i.e. number of points 366 pre_offset[index] = delta*( _begin_window[index] - begin_window[index])+round_offset;367 length[index] = delta*( _end_window[index] - _begin_window[index])+round_offset;368 post_offset[index] = delta*( end_window[index] - _end_window[index])+round_offset;369 total[index] = delta*( end_window[index] - begin_window[index])+round_offset;396 pre_offset[index] = delta*(other_wbegin[index] - wbegin[index])+round_offset; 397 length[index] = delta*(other_wend[index] - other_wbegin[index])+round_offset; 398 post_offset[index] = delta*(wend[index] - other_wend[index])+round_offset; 399 total[index] = delta*(wend[index] - wbegin[index])+round_offset; 370 400 // total is used as safe-guard against loss due to discrete conversion 371 401 ASSERT( pre_offset[index]+post_offset[index]+length[index] == total[index], 372 "SamplingGrid::add OntoWindow() - pre, post, and length don't sum up to total for "402 "SamplingGrid::addWindowOntoWindow() - pre, post, and length don't sum up to total for " 373 403 +toString(index)+"th component."); 374 404 } … … 376 406 #ifndef NDEBUG 377 407 const size_t calculated_size = length[0]*length[1]*length[2]; 378 ASSERT( calculated_size == _sampled_grid.size(),379 "SamplingGrid::add OntoWindow() - not enough sampled values given: "380 +toString(calculated_size)+" != "+toString( _sampled_grid.size())+".");408 ASSERT( calculated_size == other_sampled_grid.size(), 409 "SamplingGrid::addWindowOntoWindow() - not enough sampled values given: " 410 +toString(calculated_size)+" != "+toString(other_sampled_grid.size())+"."); 381 411 ASSERT( calculated_size <= sampled_grid.size(), 382 "SamplingGrid::add OntoWindow() - not enough sampled values available: "412 "SamplingGrid::addWindowOntoWindow() - not enough sampled values available: " 383 413 +toString(calculated_size)+" <= "+toString(sampled_grid.size())+"."); 384 414 const size_t total_size = total[0]*total[1]*total[2]; 385 415 ASSERT( total_size == sampled_grid.size(), 386 "SamplingGrid::add OntoWindow() - total size is not equal to number of present points: "416 "SamplingGrid::addWindowOntoWindow() - total size is not equal to number of present points: " 387 417 +toString(total_size)+" != "+toString(sampled_grid.size())+"."); 388 418 #endif … … 390 420 // size_t counter = 0; 391 421 sampledvalues_t::iterator griditer = sampled_grid.begin(); 392 std::advance(griditer, pre_offset[0]*total[1]*total[2]); 393 sampledvalues_t::const_iterator copyiter = _sampled_grid.begin(); 422 sampledvalues_t::const_iterator copyiter = other_sampled_grid.begin(); 423 if (choice == thiswindow) 424 std::advance(griditer, pre_offset[0]*total[1]*total[2]); 425 else 426 std::advance(copyiter, pre_offset[0]*total[1]*total[2]); 394 427 for(N[0]=0; N[0] < length[0]; ++N[0]) { 395 std::advance(griditer, pre_offset[1]*total[2]); 428 if (choice == thiswindow) 429 std::advance(griditer, pre_offset[1]*total[2]); 430 else 431 std::advance(copyiter, pre_offset[1]*total[2]); 396 432 for(N[1]=0; N[1] < length[1]; ++N[1]) { 397 std::advance(griditer, pre_offset[2]); 433 if (choice == thiswindow) 434 std::advance(griditer, pre_offset[2]); 435 else 436 std::advance(copyiter, pre_offset[2]); 398 437 for(N[2]=0; N[2] < length[2]; ++N[2]) { 399 438 ASSERT( griditer != sampled_grid.end(), 400 "SamplingGrid::addOntoWindow() - griditer is already at end of window."); 401 ASSERT( copyiter != _sampled_grid.end(), 402 "SamplingGrid::addOntoWindow() - griditer is already at end of window."); 403 *griditer++ += prefactor*(*copyiter++); 439 "SamplingGrid::addWindowOntoWindow() - griditer is already at end of window."); 440 ASSERT( copyiter != other_sampled_grid.end(), 441 "SamplingGrid::addWindowOntoWindow() - griditer is already at end of window."); 442 op(*griditer, *copyiter); 443 ++griditer; 444 ++copyiter; 404 445 } 405 std::advance(griditer, post_offset[2]); 446 if (choice == thiswindow) 447 std::advance(griditer, post_offset[2]); 448 else 449 std::advance(copyiter, post_offset[2]); 406 450 } 407 std::advance(griditer, post_offset[1]*total[2]); 451 if (choice == thiswindow) 452 std::advance(griditer, post_offset[1]*total[2]); 453 else 454 std::advance(copyiter, post_offset[1]*total[2]); 408 455 } 409 456 #ifndef NDEBUG 410 std::advance(griditer, post_offset[0]*total[1]*total[2]); 457 if (choice == thiswindow) 458 std::advance(griditer, post_offset[0]*total[1]*total[2]); 459 else 460 std::advance(copyiter, post_offset[0]*total[1]*total[2]); 411 461 ASSERT( griditer == sampled_grid.end(), 412 "SamplingGrid::add OntoWindow() - griditer is not at end of window.");413 ASSERT( copyiter == _sampled_grid.end(),414 "SamplingGrid::add OntoWindow() - copyiter is not at end of window.");462 "SamplingGrid::addWindowOntoWindow() - griditer is not at end of window."); 463 ASSERT( copyiter == other_sampled_grid.end(), 464 "SamplingGrid::addWindowOntoWindow() - copyiter is not at end of window."); 415 465 #endif 416 466 LOG(2, "DEBUG: Grid after adding other is " << sampled_grid << "."); -
TabularUnified src/Jobs/Grid/SamplingGrid.hpp ¶
rc0e8fb rfb3485 14 14 #endif 15 15 16 #include <boost/function.hpp> 16 17 #include <iosfwd> 17 18 #include <vector> … … 265 266 const double prefactor); 266 267 268 /** Enum to help in addWindowOntoWindow() decide which iterator needs to be 269 * advanced. 270 */ 271 enum LargerWindow { 272 thiswindow, 273 otherwindow 274 }; 275 276 /** Helper function to copy one (larger) window into a (smaller) window. 277 * 278 * \note Why do we need the extra \a choice? We need to know which window 279 * tuples is associated with which sampled values that are constrained by 280 * one of them being constant, hence the source values 281 * 282 * \param wbegin start of larger window 283 * \param wend end of larger window 284 * \param other_wbegin start of smaller window 285 * \param other_wend end of smaller window 286 * \param sampled_grid larger set of sampled values 287 * \param other_sampled_grid smaller set of sampled values 288 * \param op operation to perform with the two elements 289 * \param choice indicates which is the larger window 290 */ 291 void addWindowOntoWindow( 292 const double wbegin[3], 293 const double wend[3], 294 const double other_wbegin[3], 295 const double other_wend[3], 296 sampledvalues_t &sampled_grid, 297 const sampledvalues_t &other_sampled_grid, 298 boost::function<void (double &, const double &)> op, 299 enum LargerWindow choice); 300 267 301 /** Helper function that contains all the logic of how to superpose two 268 302 * grids.
Note:
See TracChangeset
for help on using the changeset viewer.