Changeset c6355f for src/Jobs/Grid/SamplingGrid.cpp
- Timestamp:
- Feb 15, 2013, 9:51:49 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:
- 64bafe0
- Parents:
- de6dfb
- git-author:
- Frederik Heber <heber@…> (12/15/12 08:33:06)
- git-committer:
- Frederik Heber <heber@…> (02/15/13 09:51:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Jobs/Grid/SamplingGrid.cpp
rde6dfb rc6355f 60 60 SamplingGrid::SamplingGrid(const double _begin[3], 61 61 const double _end[3], 62 const int _level) : 63 SamplingGridProperties(_begin, _end, _level) 64 { 65 setWindowSize(zeroOffset, zeroOffset); 66 ASSERT( getWindowGridPoints() == (size_t)0, 67 "SamplingGrid::SamplingGrid() - incorrect number of samples given for the window."); 68 } 69 70 SamplingGrid::SamplingGrid(const double _begin[3], 71 const double _end[3], 62 72 const int _level, 63 73 const sampledvalues_t &_sampled_grid) : … … 74 84 sampled_grid(_grid.sampled_grid) 75 85 { 76 setWindowSize(_grid.begin, _grid.end); 86 setWindowSize(_grid.begin_window, _grid.end_window); 87 ASSERT( getWindowGridPoints() == _grid.getWindowGridPoints(), 88 "SamplingGrid::SamplingGrid() - incorrect number of samples given for the window."); 77 89 } 78 90 … … 80 92 SamplingGridProperties(_props) 81 93 { 82 setWindowSize(_props.begin, _props.end); 94 setWindowSize(zeroOffset, zeroOffset); 95 ASSERT( getWindowGridPoints() == (size_t)0, 96 "SamplingGrid::SamplingGrid() - incorrect number of samples given for the window."); 83 97 } 84 98 … … 241 255 setWindowSize(_begin_window, _end_window); 242 256 const size_t gridpoints_window = getWindowGridPoints(); 257 sampled_grid.clear(); 243 258 sampled_grid.resize(gridpoints_window, 0.); 244 259 } … … 268 283 const double _end_window[3]) 269 284 { 270 // check that we truly have to extend the window271 285 #ifndef NDEBUG 272 286 for(size_t index=0;index < 3; ++index) { 287 // check that we truly have to extend the window 273 288 ASSERT ( begin_window[index] >= _begin_window[index], 274 289 "SamplingGrid::extendWindow() - component "+toString(index)+ … … 277 292 "SamplingGrid::extendWindow() - component "+toString(index)+ 278 293 " of window end is less than old value."); 294 295 // check that we are still less than domain 296 ASSERT ( _begin_window[index] >= begin[index], 297 "SamplingGrid::extendWindow() - component "+toString(index)+ 298 " of window start is less than domain start."); 299 ASSERT ( _end_window[index] <= end[index], 300 "SamplingGrid::extendWindow() - component "+toString(index)+ 301 " of window end is greater than domain end."); 279 302 } 280 303 #endif … … 311 334 #endif 312 335 // the only issue are indices 313 const size_t gridpoints_axis = pow(2, level);336 const size_t gridpoints_axis = getGridPointsPerAxis(); 314 337 size_t pre_offset[3]; 315 338 size_t post_offset[3]; … … 318 341 for(size_t index=0;index<3;++index) { 319 342 pre_offset[index] = (_begin_window[index] - begin_window[index])*gridpoints_axis; 343 length[index] = (_end_window[index] - _begin_window[index])*gridpoints_axis; 320 344 post_offset[index] = (end_window[index] - _end_window[index])*gridpoints_axis; 321 length[index] = (_end_window[index] - _begin_window[index])*gridpoints_axis;322 345 total[index] = (end_window[index] - begin_window[index])*gridpoints_axis; 323 346 ASSERT( pre_offset[index]+post_offset[index]+length[index] == total[index], 324 "SamplingGrid::addOntoWindow() - pre, p ast, and length don't sum up to total for "347 "SamplingGrid::addOntoWindow() - pre, post, and length don't sum up to total for " 325 348 +toString(index)+"th component."); 326 349 } 327 ASSERT( length[0]*length[1]*length[2] == _sampled_grid.size(), 328 "SamplingGrid::addOntoWindow() - not enough sampled values given."); 329 ASSERT( length[0]*length[1]*length[2] <= sampled_grid.size(), 330 "SamplingGrid::addOntoWindow() - not enough sampled values available."); 350 #ifndef NDEBUG 351 const size_t calculated_size = length[0]*length[1]*length[2]; 352 ASSERT( calculated_size == _sampled_grid.size(), 353 "SamplingGrid::addOntoWindow() - not enough sampled values given: " 354 +toString(calculated_size)+" != "+toString(_sampled_grid.size())+"."); 355 ASSERT( calculated_size <= sampled_grid.size(), 356 "SamplingGrid::addOntoWindow() - not enough sampled values available: " 357 +toString(calculated_size)+" <= "+toString(sampled_grid.size())+"."); 358 const size_t total_size = total[0]*total[1]*total[2]; 359 ASSERT( total_size == sampled_grid.size(), 360 "SamplingGrid::addOntoWindow() - total size is not equal to number of present points: " 361 +toString(total_size)+" != "+toString(sampled_grid.size())+"."); 362 #endif 331 363 size_t N[3]; 364 size_t counter = 0; 332 365 sampledvalues_t::iterator griditer = sampled_grid.begin(); 333 366 std::advance(griditer, pre_offset[0]*total[1]*total[2]); … … 338 371 std::advance(griditer, pre_offset[2]); 339 372 for(N[2]=0; N[2] < length[2]; ++N[2]) { 373 ASSERT( griditer != sampled_grid.end(), 374 "SamplingGrid::addOntoWindow() - griditer is already at end of window."); 375 ASSERT( copyiter != _sampled_grid.end(), 376 "SamplingGrid::addOntoWindow() - griditer is already at end of window."); 340 377 *griditer++ += prefactor*(*copyiter++); 341 378 } … … 344 381 std::advance(griditer, post_offset[1]*total[2]); 345 382 } 346 //std::advance(griditer, post_offset[0]*total[1]*total[2]); 383 #ifndef NDEBUG 384 std::advance(griditer, post_offset[0]*total[1]*total[2]); 385 ASSERT( griditer == sampled_grid.end(), 386 "SamplingGrid::addOntoWindow() - griditer is not at end of window."); 387 ASSERT( copyiter == _sampled_grid.end(), 388 "SamplingGrid::addOntoWindow() - copyiter is not at end of window."); 389 #endif 347 390 LOG(2, "DEBUG: Grid after adding other is " << sampled_grid << "."); 348 391 }
Note:
See TracChangeset
for help on using the changeset viewer.