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:
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)
Message:

WindowGrid_converter's refactored a bit with getDiscreteWindowOffsets().

  • Added SamplingGrid::getDiscreteWindowOffsets().
  • WindowGrid_converter now also use NDIM instead of 3 to clarify the use of the spatial degrees of freedom (and not some grid level or else).
Location:
src/Fragmentation/Summation/SetValues
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/SamplingGrid.cpp

    rc1948c r336da8  
    452452    ASSERT( (_wend[index] - _wbegin[index]) == _wlength[index],
    453453        "SamplingGrid::getDiscreteWindowCopyIndices() - end - begin is not equal to length for "
     454        +toString(index)+"th component.");
     455  }
     456}
     457
     458void SamplingGrid::getDiscreteWindowOffsets(
     459    size_t _pre_offset[NDIM],
     460    size_t _post_offset[NDIM],
     461    size_t _length[NDIM],
     462    size_t _total[NDIM]) const
     463{
     464  const double round_offset =
     465      (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ?
     466          0.5 : 0.; // need offset to get to round_toward_nearest behavior
     467  for(size_t index=0;index<NDIM;++index) {
     468    if (fabs(end[index] - begin[index]) > std::numeric_limits<double>::epsilon()*1e4) {
     469      // we refrain from using floor/ceil as the window's starts and ends,
     470      // the grids have to be compatible (equal level), should always be on
     471      // discrete grid point locations.
     472      const double delta = getDeltaPerAxis(index);
     473      // delta is conversion factor from box length to discrete length, i.e. number of points
     474      _pre_offset[index] = (begin_window[index] - begin[index])/delta+round_offset;
     475      _post_offset[index] = (end[index] - end_window[index])/delta+round_offset;
     476      _length[index] = (end_window[index] - begin_window[index])/delta+round_offset;
     477      _total[index] = (end[index] - begin[index])/delta+round_offset;
     478    } else {
     479      _pre_offset[index] = 0;
     480      _post_offset[index] = 0;
     481      _length[index] = 0;
     482      _total[index] = 0;
     483    }
     484    // total is used as safe-guard against loss due to discrete conversion
     485    ASSERT( (_pre_offset[index] + _post_offset[index]) + _length[index] == _total[index],
     486        "SamplingGrid::getDiscreteWindowCopyIndices() - pre, length, post are not equal to total for "
    454487        +toString(index)+"th component.");
    455488  }
  • src/Fragmentation/Summation/SetValues/SamplingGrid.hpp

    rc1948c r336da8  
    253253      size_t _wend[NDIM]) const;
    254254
     255  /** Returns number of grid points before the window, during the window, and
     256   * after the window including the total length of the domain for check.
     257   *
     258   * \param _pre_offset grid points before start of window
     259   * \param _post_offset grid points after end of window
     260   * \param _length grid points in window
     261   * \param _total grid points in domain
     262   */
     263  void getDiscreteWindowOffsets(
     264      size_t _pre_offset[NDIM],
     265      size_t _post_offset[NDIM],
     266      size_t _length[NDIM],
     267      size_t _total[NDIM]) const;
     268
    255269  /** Equality operator.
    256270   *
Note: See TracChangeset for help on using the changeset viewer.