- Timestamp:
- Feb 15, 2013, 5:07:49 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:
- 620517
- Parents:
- 8f3cdd
- git-author:
- Frederik Heber <heber@…> (01/19/13 13:38:57)
- git-committer:
- Frederik Heber <heber@…> (02/15/13 17:07:49)
- Location:
- src/Jobs
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Jobs/InterfaceVMGDebugGridJob.cpp ¶
r8f3cdd rb123a5 52 52 #include "CodePatterns/Log.hpp" 53 53 54 #include "Jobs/WindowGrid_converter.hpp" 54 55 55 56 using namespace VMG; … … 57 58 58 59 InterfaceVMGDebugGridJob::InterfaceVMGDebugGridJob( 59 const std::vector< double >&_sampled_input,60 const SamplingGrid &_sampled_input, 60 61 VMG::Boundary boundary, 61 62 int levelMin, … … 72 73 { 73 74 } 74 75 InterfaceVMGDebugGridJob::~InterfaceVMGDebugGridJob()76 {}77 75 78 76 void InterfaceVMGDebugGridJob::ImportRightHandSide(Multigrid& multigrid) … … 95 93 96 94 // add sampled grid points to grid 97 std::vector<double>::const_iterator sample_iter = sampled_input.begin(); 98 for (Grid::iterator iter = grid.Iterators().Local().Begin(); 99 iter != grid.Iterators().Local().End(); 100 ++iter) 101 grid(*iter) = -1. * (*sample_iter++); 102 assert( sample_iter == sampled_input.end() ); 95 WindowGrid_converter::addWindowOntoGrid( 96 grid, 97 sampled_input, 98 -1.); 103 99 104 100 // print electron grid to vtk -
TabularUnified src/Jobs/InterfaceVMGDebugGridJob.hpp ¶
r8f3cdd rb123a5 22 22 } 23 23 24 #include "Jobs/Grid/SamplingGrid.hpp" 25 24 26 namespace VMGInterfaces 25 27 { … … 34 36 public: 35 37 InterfaceVMGDebugGridJob( 36 const std::vector< double >&_sampled_input,38 const SamplingGrid &_sampled_input, 37 39 VMG::Boundary boundary, 38 40 int levelMin, … … 44 46 double alpha=1.6); 45 47 46 virtual ~InterfaceVMGDebugGridJob();48 ~InterfaceVMGDebugGridJob() {} 47 49 48 50 void ImportRightHandSide(VMG::Multigrid& multigrid); … … 51 53 private: 52 54 //!> sampled density on the grid as input 53 const std::vector< double >sampled_input;54 //!> number of grid points per axis as \f$2^{\ text{level}}\f$55 const SamplingGrid sampled_input; 56 //!> number of grid points per axis as \f$2^{\mathrm{level}}\f$ 55 57 const int level; 56 58 }; -
TabularUnified src/Jobs/InterfaceVMGJob.cpp ¶
r8f3cdd rb123a5 56 56 #include "CodePatterns/Log.hpp" 57 57 58 #include "Jobs/ Grid/SamplingGrid.hpp"58 #include "Jobs/WindowGrid_converter.hpp" 59 59 60 60 using namespace VMG; … … 97 97 } 98 98 99 InterfaceVMGJob::~InterfaceVMGJob()100 {}101 102 void InterfaceVMGJob::addGridOntoWindow(103 VMG::Grid &grid,104 SamplingGrid &window,105 const double prefactor) const106 {107 #ifndef NDEBUG108 for(size_t index=0;index<3;++index) {109 ASSERT( box_begin[index] >= window.begin_window[index],110 "InterfaceVMGJob::addGridOntoWindow() - given grid starts earlier than window in component "111 +toString(index)+".");112 ASSERT( box_end[index] <= window.end_window[index],113 "InterfaceVMGJob::addGridOntoWindow() - given grid ends later than window in component "114 +toString(index)+".");115 }116 #endif117 // the only issue are indices118 const size_t gridpoints_axis = window.getGridPointsPerAxis();119 size_t pre_offset[3];120 size_t post_offset[3];121 size_t length[3];122 size_t total[3];123 const double round_offset =124 (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ?125 0.5 : 0.; // need offset to get to round_toward_nearest behavior126 for(size_t index=0;index<3;++index) {127 const double delta = (double)gridpoints_axis/(window.end[index] - window.begin[index]);128 // delta is conversion factor from box length to discrete length, i.e. number of points129 pre_offset[index] = delta*(box_begin[index] - window.begin_window[index])+round_offset;130 length[index] = delta*(box_end[index] - box_begin[index])+round_offset;131 post_offset[index] = delta*(window.end_window[index] - box_end[index])+round_offset;132 total[index] = delta*(window.end_window[index] - window.begin_window[index])+round_offset;133 // total is used as safe-guard against loss due to discrete conversion134 ASSERT( pre_offset[index]+post_offset[index]+length[index] == total[index],135 "InterfaceVMGJob::addGridOntoWindow() - pre, post, and length don't sum up to total for "136 +toString(index)+"th component.");137 }138 #ifndef NDEBUG139 const size_t calculated_size = length[0]*length[1]*length[2];140 // const size_t given_size = std::distance(grid_begin, grid_end);141 // ASSERT( calculated_size == given_size,142 // "InterfaceVMGJob::addGridOntoWindow() - not enough sampled values given: "143 // +toString(calculated_size)+" != "+toString(given_size)+".");144 ASSERT( calculated_size <= window.sampled_grid.size(),145 "InterfaceVMGJob::addGridOntoWindow() - not enough sampled values available: "146 +toString(calculated_size)+" <= "+toString(window.sampled_grid.size())+".");147 const size_t total_size = total[0]*total[1]*total[2];148 ASSERT( total_size == window.sampled_grid.size(),149 "InterfaceVMGJob::addGridOntoWindow() - total size is not equal to number of present points: "150 +toString(total_size)+" != "+toString(window.sampled_grid.size())+".");151 #endif152 size_t N[3];153 SamplingGrid::sampledvalues_t::iterator griditer = window.sampled_grid.begin();154 std::advance(griditer, pre_offset[0]*total[1]*total[2]);155 Grid::iterator copyiter = grid.Iterators().Local().Begin();156 for(N[0]=0; N[0] < length[0]; ++N[0]) {157 std::advance(griditer, pre_offset[1]*total[2]);158 for(N[1]=0; N[1] < length[1]; ++N[1]) {159 std::advance(griditer, pre_offset[2]);160 for(N[2]=0; N[2] < length[2]; ++N[2]) {161 ASSERT( griditer != window.sampled_grid.end(),162 "InterfaceVMGJob::addGridOntoWindow() - griditer is already at end of window.");163 ASSERT( copyiter != grid.Iterators().Local().End(),164 "InterfaceVMGJob::addGridOntoWindow() - griditer is already at end of window.");165 *griditer++ += prefactor*grid(*copyiter++);166 }167 std::advance(griditer, post_offset[2]);168 }169 std::advance(griditer, post_offset[1]*total[2]);170 }171 #ifndef NDEBUG172 std::advance(griditer, post_offset[0]*total[1]*total[2]);173 ASSERT( griditer == window.sampled_grid.end(),174 "InterfaceVMGJob::addGridOntoWindow() - griditer is not at end of window.");175 ASSERT( copyiter == grid.Iterators().Local().End(),176 "InterfaceVMGJob::addGridOntoWindow() - copyiter is not at end of window.");177 #endif178 }179 180 void InterfaceVMGJob::addWindowOntoGrid(181 VMG::Grid& window,182 const SamplingGrid &grid,183 const double prefactor) const184 {185 #ifndef NDEBUG186 for(size_t index=0;index<3;++index) {187 ASSERT( grid.begin_window[index] >= box_begin[index],188 "InterfaceVMGJob::addWindowOntoGrid() - given window starts earlier than grid in component "189 +toString(index)+".");190 ASSERT( grid.end_window[index] <= box_end[index],191 "InterfaceVMGJob::addWindowOntoGrid() - given window ends later than grid in component "192 +toString(index)+".");193 }194 #endif195 // the only issue are indices196 const size_t gridpoints_axis = grid.getGridPointsPerAxis();197 size_t pre_offset[3];198 size_t post_offset[3];199 size_t length[3];200 size_t total[3];201 const double round_offset =202 (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ?203 0.5 : 0.; // need offset to get to round_toward_nearest behavior204 for(size_t index=0;index<3;++index) {205 const double delta = (double)gridpoints_axis/(grid.end[index] - grid.begin[index]);206 // delta is conversion factor from box length to discrete length, i.e. number of points207 pre_offset[index] = delta*(grid.begin_window[index] - box_begin[index])+round_offset;208 length[index] = delta*(grid.end_window[index] - grid.begin_window[index])+round_offset;209 post_offset[index] = delta*(box_end[index] - grid.end_window[index])+round_offset;210 total[index] = delta*(box_end[index] - box_begin[index])+round_offset;211 // total is used as safe-guard against loss due to discrete conversion212 ASSERT( pre_offset[index]+post_offset[index]+length[index] == total[index],213 "InterfaceVMGJob::addWindowOntoGrid() - pre, post, and length don't sum up to total for "214 +toString(index)+"th component.");215 }216 #ifndef NDEBUG217 const size_t calculated_size = length[0]*length[1]*length[2];218 ASSERT( calculated_size == grid.sampled_grid.size(),219 "InterfaceVMGJob::addWindowOntoGrid() - not enough sampled values given: "220 +toString(calculated_size)+" != "+toString(grid.sampled_grid.size())+".");221 // ASSERT( calculated_size <= given_size,222 // "InterfaceVMGJob::addWindowOntoGrid() - not enough sampled values available: "223 // +toString(calculated_size)+" <= "+toString(given_size)+".");224 // const size_t total_size = total[0]*total[1]*total[2];225 // ASSERT( total_size == given_size,226 // "InterfaceVMGJob::addWindowOntoGrid() - total size is not equal to number of present points: "227 // +toString(total_size)+" != "+toString(given_size)+".");228 #endif229 size_t N[3];230 Grid::iterator griditer = window.Iterators().Local().Begin();231 griditer += pre_offset[0]*total[1]*total[2];232 SamplingGrid::sampledvalues_t::const_iterator copyiter = grid.sampled_grid.begin();233 for(N[0]=0; N[0] < length[0]; ++N[0]) {234 griditer += pre_offset[1]*total[2];235 for(N[1]=0; N[1] < length[1]; ++N[1]) {236 griditer += pre_offset[2];237 for(N[2]=0; N[2] < length[2]; ++N[2]) {238 ASSERT( griditer != window.Iterators().Local().End(),239 "InterfaceVMGJob::addWindowOntoGrid() - griditer is already at end of window.");240 ASSERT( copyiter != grid.sampled_grid.end(),241 "InterfaceVMGJob::addWindowOntoGrid() - griditer is already at end of window.");242 window(*griditer++) += prefactor*(*copyiter++);243 }244 griditer += post_offset[2];245 }246 griditer += post_offset[1]*total[2];247 }248 #ifndef NDEBUG249 griditer += post_offset[0]*total[1]*total[2];250 ASSERT( griditer == window.Iterators().Local().End(),251 "InterfaceVMGJob::addWindowOntoGrid() - griditer is not at end of window.");252 ASSERT( copyiter == grid.sampled_grid.end(),253 "InterfaceVMGJob::addWindowOntoGrid() - copyiter is not at end of window.");254 #endif255 // LOG(2, "DEBUG: Grid after adding other is " << grid << ".");256 }257 258 99 void InterfaceVMGJob::ImportRightHandSide(Multigrid& multigrid) 259 100 { … … 307 148 308 149 // add sampled electron charge density onto grid 309 addWindowOntoGrid(150 WindowGrid_converter::addWindowOntoGrid( 310 151 grid, 311 152 sampled_input, … … 364 205 box_end 365 206 ); 366 addGridOntoWindow(207 WindowGrid_converter::addGridOntoWindow( 367 208 grid, 368 209 returndata.sampled_potential, -
TabularUnified src/Jobs/InterfaceVMGJob.hpp ¶
r8f3cdd rb123a5 21 21 22 22 #include "Jobs/VMGData.hpp" 23 24 class SamplingGrid; 23 #include "Jobs/Grid/SamplingGrid.hpp" 25 24 26 25 namespace VMG … … 50 49 double alpha=1.6); 51 50 52 virtual ~InterfaceVMGJob();51 ~InterfaceVMGJob() {} 53 52 54 53 void ImportRightHandSide(VMG::Multigrid& multigrid); … … 58 57 VMG::Particle::BSpline spl; 59 58 60 private:61 /** Helper function to copy VMG's Grid onto the non-zero window of a SamplingGrid62 *63 * The code is very similar to SamplingGrid::addOntoWindow().64 *65 * @param grid grid with non-zero window66 * @param prefactor factor for each added value, e.g. -1. makes a subtraction67 */68 void addGridOntoWindow(69 VMG::Grid& grid,70 SamplingGrid &window,71 const double prefactor) const;72 73 /** Helper function to copy non-zero window in SamplingGrid onto VMG's Grid.74 *75 * The code is very similar to SamplingGrid::addOntoWindow().76 *77 * @param grid grid with non-zero window78 * @param prefactor factor for each added value, e.g. -1. makes a subtraction79 */80 void addWindowOntoGrid(81 VMG::Grid& window,82 const SamplingGrid &grid,83 const double prefactor) const;84 59 private: 85 60 //!> sampled density on the grid as input -
TabularUnified src/Jobs/Makefile.am ¶
r8f3cdd rb123a5 12 12 Jobs/VMGData.cpp \ 13 13 Jobs/VMGDebugGridJob.cpp \ 14 Jobs/VMGJob.cpp 14 Jobs/VMGJob.cpp \ 15 Jobs/WindowGrid_converter.cpp 15 16 endif 16 17 … … 35 36 Jobs/VMGDebugGridJob_binding.hpp \ 36 37 Jobs/VMGJob.hpp \ 37 Jobs/VMGJob_binding.hpp 38 Jobs/VMGJob_binding.hpp \ 39 Jobs/WindowGrid_converter.hpp 38 40 endif 39 41 -
TabularUnified src/Jobs/VMGDebugGridJob.cpp ¶
r8f3cdd rb123a5 133 133 new DiscretizationPoissonFD(4); 134 134 new VMGInterfaces::InterfaceVMGDebugGridJob( 135 density_grid .sampled_grid,135 density_grid, 136 136 boundary, 137 137 2,
Note:
See TracChangeset
for help on using the changeset viewer.