Changeset 64bafe0 for src/Jobs/Grid
- Timestamp:
- Feb 15, 2013, 9:52:02 AM (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:
- 8f3cdd
- Parents:
- c6355f
- git-author:
- Frederik Heber <heber@…> (12/19/12 12:46:23)
- git-committer:
- Frederik Heber <heber@…> (02/15/13 09:52:02)
- Location:
- src/Jobs/Grid
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Jobs/Grid/SamplingGrid.cpp
rc6355f r64bafe0 233 233 } 234 234 235 double SamplingGrid::getNearestLowerGridPoint( 236 const double value, const size_t axis) const 237 { 238 const double length = end[axis] - begin[axis]; 239 if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0)) { 240 return 0.; 241 } else { 242 const double offset = value - begin[axis]; 243 const double factor = floor((double)getGridPointsPerAxis()*(offset/length)); 244 return factor*(length/(double)getGridPointsPerAxis()); 245 } 246 } 247 248 double SamplingGrid::getNearestHigherGridPoint( 249 const double value, const size_t axis) const 250 { 251 const double length = end[axis] - begin[axis]; 252 if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0)) { 253 return 0.; 254 } else { 255 const double offset = value - begin[axis]; 256 const double factor = ceil((double)getGridPointsPerAxis()*(offset/length)); 257 return factor*(length/(double)getGridPointsPerAxis()); 258 } 259 } 260 235 261 void SamplingGrid::setWindowSize( 236 262 const double _begin_window[3], … … 238 264 { 239 265 for (size_t index=0;index<3;++index) { 240 ASSERT( _begin_window[index] >= begin[index], 266 begin_window[index] = getNearestLowerGridPoint(_begin_window[index], index); 267 ASSERT( begin_window[index] >= begin[index], 241 268 "SamplingGrid::setWindowSize() - window starts earlier than domain on " 242 269 +toString(index)+"th component."); 243 begin_window[index] = _begin_window[index];244 ASSERT( _end_window[index] <= end[index],270 end_window[index] = getNearestHigherGridPoint(_end_window[index], index); 271 ASSERT( end_window[index] <= end[index], 245 272 "SamplingGrid::setWindowSize() - window ends later than domain on " 246 273 +toString(index)+"th component."); 247 end_window[index] = _end_window[index];248 274 } 249 275 } … … 339 365 size_t length[3]; 340 366 size_t total[3]; 367 const double round_offset = 368 (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ? 369 0.5 : 0.; // need offset to get to round_toward_nearest behavior 341 370 for(size_t index=0;index<3;++index) { 342 pre_offset[index] = (_begin_window[index] - begin_window[index])*gridpoints_axis; 343 length[index] = (_end_window[index] - _begin_window[index])*gridpoints_axis; 344 post_offset[index] = (end_window[index] - _end_window[index])*gridpoints_axis; 345 total[index] = (end_window[index] - begin_window[index])*gridpoints_axis; 371 // we refrain from using floor/ceil as the window's starts and ends, 372 // the grids have to be compatible (equal level), should always be on 373 // discrete grid point locations. 374 const double delta = (double)gridpoints_axis/(end[index] - begin[index]); 375 // delta is conversion factor from box length to discrete length, i.e. number of points 376 pre_offset[index] = delta*(_begin_window[index] - begin_window[index])+round_offset; 377 length[index] = delta*(_end_window[index] - _begin_window[index])+round_offset; 378 post_offset[index] = delta*(end_window[index] - _end_window[index])+round_offset; 379 total[index] = delta*(end_window[index] - begin_window[index])+round_offset; 380 // total is used as safe-guard against loss due to discrete conversion 346 381 ASSERT( pre_offset[index]+post_offset[index]+length[index] == total[index], 347 382 "SamplingGrid::addOntoWindow() - pre, post, and length don't sum up to total for " 348 383 +toString(index)+"th component."); 349 384 } 385 // assert that calculated lengths match with given vector sizes 350 386 #ifndef NDEBUG 351 387 const size_t calculated_size = length[0]*length[1]*length[2]; … … 362 398 #endif 363 399 size_t N[3]; 364 size_t counter = 0;400 // size_t counter = 0; 365 401 sampledvalues_t::iterator griditer = sampled_grid.begin(); 366 402 std::advance(griditer, pre_offset[0]*total[1]*total[2]); -
src/Jobs/Grid/SamplingGrid.hpp
rc6355f r64bafe0 246 246 void setWindowSize(const double _begin_window[3], const double _end_window[3]); 247 247 248 /** Helper function to get point at grid point for given \a axis and less than value. 249 * 250 * @param value value to find nearest grid point to 251 * @param axis axis of the value 252 * @return nearest lower grid point 253 */ 254 double getNearestLowerGridPoint( 255 const double value, const size_t axis) const; 256 257 /** Helper function to get point at grid point for given \a axis and greater than value. 258 * 259 * @param value value to find nearest grid point to 260 * @param axis axis of the value 261 * @return nearest lower grid point 262 */ 263 double getNearestHigherGridPoint( 264 const double value, const size_t axis) const; 265 248 266 public: 249 267 /// We do not store the whole grid if many entries are actually zero -
src/Jobs/Grid/unittests/Makefile.am
rc6355f r64bafe0 14 14 SamplingGridUnitTest 15 15 16 XFAIL_TESTS += SamplingGridUnitTest17 16 TESTS += $(JOBSGRIDTESTS) 18 17 check_PROGRAMS += $(JOBSGRIDTESTS)
Note:
See TracChangeset
for help on using the changeset viewer.