Ignore:
Timestamp:
Sep 14, 2016, 6:42:53 PM (8 years ago)
Author:
Frederik Heber <heber@…>
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:
57fda0
Parents:
d56e21
git-author:
Frederik Heber <heber@…> (05/26/16 18:15:19)
git-committer:
Frederik Heber <heber@…> (09/14/16 18:42:53)
Message:

SamplingGrid::downsample() uses padWithZerosForEvenNumberedSamples().

  • in the end this requires copying the original grid as we might need to pad it with zeros but should not change the given one.
  • Added some debugging information to downsample().
Location:
src/Fragmentation/Summation/SetValues
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/Makefile.am

    rd56e21 r6a5eb2  
    2727libMolecuilderFragmentationSetValues_la_LDFLAGS = -ldl ${BOOST_LDFLAGS}
    2828libMolecuilderFragmentationSetValues_la_LIBADD = \
     29        $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
    2930        ${CodePatterns_LIBS}
    3031
  • src/Fragmentation/Summation/SetValues/SamplingGrid.cpp

    rd56e21 r6a5eb2  
    5050#include "CodePatterns/Assert.hpp"
    5151#include "CodePatterns/Log.hpp"
     52
     53#include "LinearAlgebra/Vector.hpp"
    5254
    5355// static instances
     
    792794  size_t wnewend_index[NDIM];
    793795  for(size_t i=0;i<NDIM;++i) {
     796    LOG(2, "INFO: window[" << i << "] starts at " << wbegin_index[i] << " and ends at "
     797        << wend_index[i] << " with length " << wlength_index[i]);
    794798    // We require begin and end of window on even indices (and inside grid).
    795799    wnewbegin_index[i] = wbegin_index[i];
     
    822826      end_newwindow[i] = begin[i]+delta*wnewend_index[i];
    823827    }
     828    LOG(2, "INFO: Original window is " << Vector(begin_window) << " <-> "  << Vector(end_window));
     829    LOG(2, "INFO: Padded window is " << Vector(begin_newwindow) << " <-> "  << Vector(end_newwindow));
    824830    // extend window
    825831    extendWindow(begin_newwindow, end_newwindow);
     
    836842{
    837843  if (&instance != &other) {
     844    LOG(2, "INFO: other's window is " << Vector(other.begin_window)
     845        << " <-> " << Vector(other.end_window));
    838846    // take over properties
    839847    static_cast<SamplingGridProperties &>(instance) = other;
    840848    instance.setWindowSize(other.begin_window, other.end_window);
     849    LOG(2, "INFO: Set instance's window to " << Vector(instance.begin_window)
     850        << " <-> " << Vector(instance.end_window));
    841851    ASSERT( _level <= other.level,
    842852        "SamplingGrid::downsample() - desired level "+toString(_level)
     
    850860      // have reached the desired one
    851861
    852       // the reference such that we never have to copy the full grid but only
    853       // downsampled ones
    854       const sampledvalues_t * sourcevalues = &other.sampled_grid;
    855       int length_d[3];
    856       int length_s[3];
    857       getLengthsOfWindow(length_s, other);
     862      // we need to copy the other grid because we might need to pad it with zeros anyway
     863      SamplingGrid FinerGrid(other);
     864      int length_d[NDIM];
     865      int length_s[NDIM];
    858866      for (instance.level = other.level-1; instance.level >= _level; --instance.level) {
     867        // pad with zeros for even indices and get length of fine grid window
     868        FinerGrid.padWithZerosForEvenNumberedSamples();
     869        getLengthsOfWindow(length_s, FinerGrid);
     870        ASSERT( FinerGrid.getWindowGridPoints() % 8 == 0,
     871            "SamplingGrid::downsample() - at level "+toString( instance.level)
     872            +" given grid points "+toString(FinerGrid.getWindowGridPoints())+" are not even numbered per axis anymore.");
     873        // re-adjust the window (length), get the corresponding window length and downsample
     874        instance.setWindow(FinerGrid.begin_window, FinerGrid.end_window);
    859875        getLengthsOfWindow(length_d, instance);
    860         // we always have an eighth of the number of sample points as we stop
    861         ASSERT( sourcevalues->size() % 8 == 0,
     876        ASSERT( instance.sampled_grid.size() == FinerGrid.getWindowGridPoints()/(size_t)8,
    862877            "SamplingGrid::downsample() - at level "+toString( instance.level)
    863             +" given grid points "+toString(sourcevalues->size())+" are not even numbered per axis anymore.");
    864         sampledvalues_t downsampled(sourcevalues->size()/(size_t)8, 0.);
    865         restrictFullWeight(downsampled, length_d, *sourcevalues, length_s);
    866         // then copy the downsampled values
    867         instance.sampled_grid = downsampled;
    868         sourcevalues = &instance.sampled_grid;
    869         // and exchange lengths
    870         for (size_t i=0;i<3;++i) {
    871           length_s[i] = length_d[i];
    872         }
     878            +" points on coarser grid "+toString(instance.sampled_grid.size())
     879            +" and downsampled number on finer grid "
     880            +toString(FinerGrid.getWindowGridPoints()/(size_t)8)+" do not match.");
     881        restrictFullWeight(instance.sampled_grid, length_d, FinerGrid.sampled_grid, length_s);
     882        // then use as new finer grid for next downsampling (if it's not the last level)
     883        if (instance.level > _level)
     884          FinerGrid = instance;
    873885      }
     886      // loop stops at _level-1
    874887      instance.level = _level;
    875888
Note: See TracChangeset for help on using the changeset viewer.