Changeset b123a5 for src/Jobs


Ignore:
Timestamp:
Feb 15, 2013, 5:07:49 PM (12 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Shifted functions to add window onto grid into own namespace.

  • InterfaceVMG...Job now receive SamplingGrid and not the samples directly.
Location:
src/Jobs
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Jobs/InterfaceVMGDebugGridJob.cpp

    r8f3cdd rb123a5  
    5252#include "CodePatterns/Log.hpp"
    5353
     54#include "Jobs/WindowGrid_converter.hpp"
    5455
    5556using namespace VMG;
     
    5758
    5859InterfaceVMGDebugGridJob::InterfaceVMGDebugGridJob(
    59     const std::vector< double > &_sampled_input,
     60    const SamplingGrid &_sampled_input,
    6061    VMG::Boundary boundary,
    6162    int levelMin,
     
    7273{
    7374}
    74 
    75 InterfaceVMGDebugGridJob::~InterfaceVMGDebugGridJob()
    76 {}
    7775
    7876void InterfaceVMGDebugGridJob::ImportRightHandSide(Multigrid& multigrid)
     
    9593
    9694  // 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.);
    10399
    104100  // print electron grid to vtk
  • TabularUnified src/Jobs/InterfaceVMGDebugGridJob.hpp

    r8f3cdd rb123a5  
    2222}
    2323
     24#include "Jobs/Grid/SamplingGrid.hpp"
     25
    2426namespace VMGInterfaces
    2527{
     
    3436public:
    3537  InterfaceVMGDebugGridJob(
    36       const std::vector< double > &_sampled_input,
     38      const SamplingGrid &_sampled_input,
    3739      VMG::Boundary boundary,
    3840      int levelMin,
     
    4446      double alpha=1.6);
    4547
    46   virtual ~InterfaceVMGDebugGridJob();
     48  ~InterfaceVMGDebugGridJob() {}
    4749
    4850  void ImportRightHandSide(VMG::Multigrid& multigrid);
     
    5153private:
    5254  //!> 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$
    5557  const int level;
    5658};
  • TabularUnified src/Jobs/InterfaceVMGJob.cpp

    r8f3cdd rb123a5  
    5656#include "CodePatterns/Log.hpp"
    5757
    58 #include "Jobs/Grid/SamplingGrid.hpp"
     58#include "Jobs/WindowGrid_converter.hpp"
    5959
    6060using namespace VMG;
     
    9797}
    9898
    99 InterfaceVMGJob::~InterfaceVMGJob()
    100 {}
    101 
    102 void InterfaceVMGJob::addGridOntoWindow(
    103     VMG::Grid &grid,
    104     SamplingGrid &window,
    105     const double prefactor) const
    106 {
    107 #ifndef NDEBUG
    108   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 #endif
    117   // the only issue are indices
    118   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 behavior
    126   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 points
    129     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 conversion
    134     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 NDEBUG
    139   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 #endif
    152   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 NDEBUG
    172   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 #endif
    178 }
    179 
    180 void InterfaceVMGJob::addWindowOntoGrid(
    181     VMG::Grid& window,
    182     const SamplingGrid &grid,
    183     const double prefactor) const
    184 {
    185 #ifndef NDEBUG
    186   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 #endif
    195   // the only issue are indices
    196   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 behavior
    204   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 points
    207     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 conversion
    212     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 NDEBUG
    217   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 #endif
    229   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 NDEBUG
    249   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 #endif
    255 //  LOG(2, "DEBUG: Grid after adding other is " << grid << ".");
    256 }
    257 
    25899void InterfaceVMGJob::ImportRightHandSide(Multigrid& multigrid)
    259100{
     
    307148
    308149  // add sampled electron charge density onto grid
    309   addWindowOntoGrid(
     150  WindowGrid_converter::addWindowOntoGrid(
    310151      grid,
    311152      sampled_input,
     
    364205      box_end
    365206      );
    366   addGridOntoWindow(
     207  WindowGrid_converter::addGridOntoWindow(
    367208      grid,
    368209      returndata.sampled_potential,
  • TabularUnified src/Jobs/InterfaceVMGJob.hpp

    r8f3cdd rb123a5  
    2121
    2222#include "Jobs/VMGData.hpp"
    23 
    24 class SamplingGrid;
     23#include "Jobs/Grid/SamplingGrid.hpp"
    2524
    2625namespace VMG
     
    5049      double alpha=1.6);
    5150
    52   virtual ~InterfaceVMGJob();
     51  ~InterfaceVMGJob() {}
    5352
    5453  void ImportRightHandSide(VMG::Multigrid& multigrid);
     
    5857  VMG::Particle::BSpline spl;
    5958
    60 private:
    61   /** Helper function to copy VMG's Grid onto the non-zero window of a SamplingGrid
    62    *
    63    * The code is very similar to SamplingGrid::addOntoWindow().
    64    *
    65    * @param grid grid with non-zero window
    66    * @param prefactor factor for each added value, e.g. -1. makes a subtraction
    67    */
    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 window
    78    * @param prefactor factor for each added value, e.g. -1. makes a subtraction
    79    */
    80   void addWindowOntoGrid(
    81       VMG::Grid& window,
    82       const SamplingGrid &grid,
    83       const double prefactor) const;
    8459private:
    8560  //!> sampled density on the grid as input
  • TabularUnified src/Jobs/Makefile.am

    r8f3cdd rb123a5  
    1212        Jobs/VMGData.cpp \
    1313        Jobs/VMGDebugGridJob.cpp \
    14         Jobs/VMGJob.cpp
     14        Jobs/VMGJob.cpp \
     15        Jobs/WindowGrid_converter.cpp
    1516endif
    1617
     
    3536        Jobs/VMGDebugGridJob_binding.hpp \
    3637        Jobs/VMGJob.hpp \
    37         Jobs/VMGJob_binding.hpp
     38        Jobs/VMGJob_binding.hpp \
     39        Jobs/WindowGrid_converter.hpp
    3840endif
    3941
  • TabularUnified src/Jobs/VMGDebugGridJob.cpp

    r8f3cdd rb123a5  
    133133  new DiscretizationPoissonFD(4);
    134134  new VMGInterfaces::InterfaceVMGDebugGridJob(
    135       density_grid.sampled_grid,
     135      density_grid,
    136136      boundary,
    137137      2,
Note: See TracChangeset for help on using the changeset viewer.