- Timestamp:
- Sep 14, 2016, 6:42:53 PM (8 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, 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:
- ca4b372
- Parents:
- c1948c
- git-author:
- Frederik Heber <heber@…> (06/01/16 08:51:01)
- git-committer:
- Frederik Heber <heber@…> (09/14/16 18:42:53)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Jobs/WindowGrid_converter.cpp
rc1948c r336da8 59 59 { 60 60 #ifndef NDEBUG 61 for(size_t index=0;index< 3;++index) {61 for(size_t index=0;index<NDIM;++index) { 62 62 ASSERT( window.begin[index] >= window.begin_window[index], 63 63 "InterfaceVMGJob::addGridOntoWindow() - given grid starts earlier than window in component " … … 69 69 #endif 70 70 // the only issue are indices 71 const size_t gridpoints_axis = window.getGridPointsPerAxis(); 72 size_t pre_offset[3]; 73 size_t post_offset[3]; 74 size_t length[3]; 75 size_t total[3]; 76 const double round_offset = 77 (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ? 78 0.5 : 0.; // need offset to get to round_toward_nearest behavior 79 for(size_t index=0;index<3;++index) { 80 const double delta = (double)gridpoints_axis/(window.end[index] - window.begin[index]); 81 // delta is conversion factor from box length to discrete length, i.e. number of points 82 pre_offset[index] = delta*(window.begin[index] - window.begin_window[index])+round_offset; 83 length[index] = delta*(window.end[index] - window.begin[index])+round_offset; 84 post_offset[index] = delta*(window.end_window[index] - window.end[index])+round_offset; 85 total[index] = delta*(window.end_window[index] - window.begin_window[index])+round_offset; 86 // total is used as safe-guard against loss due to discrete conversion 87 ASSERT( pre_offset[index]+post_offset[index]+length[index] == total[index], 88 "InterfaceVMGJob::addGridOntoWindow() - pre, post, and length don't sum up to total for " 89 +toString(index)+"th component."); 90 } 71 size_t pre_offset[NDIM]; 72 size_t post_offset[NDIM]; 73 size_t length[NDIM]; 74 size_t total[NDIM]; 75 window.getDiscreteWindowOffsets(pre_offset, post_offset, length, total); 91 76 #ifndef NDEBUG 92 77 const size_t calculated_size = length[0]*length[1]*length[2]; 93 // const size_t given_size = std::distance(grid_begin, grid_end);94 // ASSERT( calculated_size == given_size,95 // "InterfaceVMGJob::addGridOntoWindow() - not enough sampled values given: "96 // +toString(calculated_size)+" != "+toString(given_size)+".");97 78 ASSERT( calculated_size <= window.sampled_grid.size(), 98 79 "InterfaceVMGJob::addGridOntoWindow() - not enough sampled values available: " … … 103 84 +toString(total_size)+" != "+toString(window.sampled_grid.size())+"."); 104 85 #endif 105 size_t N[ 3];86 size_t N[NDIM]; 106 87 SamplingGrid::sampledvalues_t::iterator griditer = window.sampled_grid.begin(); 107 88 std::advance(griditer, pre_offset[0]*total[1]*total[2]); … … 183 164 { 184 165 #ifndef NDEBUG 185 for(size_t index=0;index< 3;++index) {166 for(size_t index=0;index<NDIM;++index) { 186 167 ASSERT( grid.begin_window[index] >= grid.begin[index], 187 168 "InterfaceVMGJob::addWindowOntoGrid() - given window starts earlier than grid in component " … … 193 174 #endif 194 175 // the only issue are indices 195 const size_t gridpoints_axis = grid.getGridPointsPerAxis(); 196 size_t pre_offset[3]; 197 size_t post_offset[3]; 198 size_t length[3]; 199 size_t total[3]; 200 const double round_offset = 201 (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ? 202 0.5 : 0.; // need offset to get to round_toward_nearest behavior 203 for(size_t index=0;index<3;++index) { 204 const double delta = (double)gridpoints_axis/(grid.end[index] - grid.begin[index]); 205 // delta is conversion factor from box length to discrete length, i.e. number of points 206 pre_offset[index] = delta*(grid.begin_window[index] - grid.begin[index])+round_offset; 207 length[index] = delta*(grid.end_window[index] - grid.begin_window[index])+round_offset; 208 post_offset[index] = delta*(grid.end[index] - grid.end_window[index])+round_offset; 209 total[index] = delta*(grid.end[index] - grid.begin[index])+round_offset; 210 // total is used as safe-guard against loss due to discrete conversion 211 ASSERT( pre_offset[index]+post_offset[index]+length[index] == total[index], 212 "InterfaceVMGJob::addWindowOntoGrid() - pre, post, and length don't sum up to total for " 213 +toString(index)+"th component."); 214 } 176 size_t pre_offset[NDIM]; 177 size_t post_offset[NDIM]; 178 size_t length[NDIM]; 179 size_t total[NDIM]; 180 grid.getDiscreteWindowOffsets(pre_offset, post_offset, length, total); 215 181 #ifndef NDEBUG 216 182 const size_t calculated_size = length[0]*length[1]*length[2]; … … 218 184 "InterfaceVMGJob::addWindowOntoGrid() - not enough sampled values given: " 219 185 +toString(calculated_size)+" != "+toString(grid.sampled_grid.size())+"."); 220 // ASSERT( calculated_size <= given_size, 221 // "InterfaceVMGJob::addWindowOntoGrid() - not enough sampled values available: " 222 // +toString(calculated_size)+" <= "+toString(given_size)+"."); 223 // const size_t total_size = total[0]*total[1]*total[2]; 224 // ASSERT( total_size == given_size, 225 // "InterfaceVMGJob::addWindowOntoGrid() - total size is not equal to number of present points: " 226 // +toString(total_size)+" != "+toString(given_size)+"."); 227 #endif 228 size_t N[3]; 186 #endif 187 size_t N[NDIM]; 229 188 // in open boundary case grid.Local() contains more than just the inner area. The grid 230 189 // is actually twice as large to allow for the FV discretization to work. Hence, we first … … 238 197 // this mimicks VMG::GridIndexTranslations::EndOffset() 239 198 const size_t off = OpenBoundaryConditions ? 1 : 0; 240 for (size_t i=0;i< 3;++i)199 for (size_t i=0;i<NDIM;++i) 241 200 pre_offset[i] += ((size_t)size[i] - off) / 4; 242 for (size_t i=0;i< 3;++i)201 for (size_t i=0;i<NDIM;++i) 243 202 total[i] = ((size_t)size[i]); 244 for (size_t i=0;i< 3;++i)203 for (size_t i=0;i<NDIM;++i) 245 204 post_offset[i] = ((size_t)size[i]) - pre_offset[i] - length[i]; 246 205 }
Note:
See TracChangeset
for help on using the changeset viewer.