Changeset 5b1e5e


Ignore:
Timestamp:
Sep 14, 2016, 6:42:52 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:
e51f2c
Parents:
028790
git-author:
Frederik Heber <heber@…> (05/26/16 09:51:07)
git-committer:
Frederik Heber <heber@…> (09/14/16 18:42:52)
Message:

FIX: Replaced 3 by NDIM in SamplingGrid which avoids some confusion with numeric grid levels.

Location:
src/Fragmentation/Summation/SetValues
Files:
7 edited

Legend:

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

    r028790 r5b1e5e  
    5151
    5252// static instances
    53 const double SamplingGrid::zeroOffset[3] = { 0., 0., 0. };
     53const double SamplingGrid::zeroOffset[NDIM] = { 0., 0., 0. };
    5454
    5555SamplingGrid::SamplingGrid() :
     
    6161}
    6262
    63 SamplingGrid::SamplingGrid(const double _begin[3],
    64     const double _end[3],
     63SamplingGrid::SamplingGrid(const double _begin[NDIM],
     64    const double _end[NDIM],
    6565    const int _level) :
    6666  SamplingGridProperties(_begin, _end, _level)
     
    7171}
    7272
    73 SamplingGrid::SamplingGrid(const double _begin[3],
    74     const double _end[3],
     73SamplingGrid::SamplingGrid(const double _begin[NDIM],
     74    const double _end[NDIM],
    7575    const int _level,
    7676    const sampledvalues_t &_sampled_grid) :
     
    119119  status &= (static_cast<const SamplingGridProperties &>(*this) ==
    120120      static_cast<const SamplingGridProperties &>(_props));
    121   for(size_t i = 0; i<3; ++i) {
     121  for(size_t i = 0; i<NDIM; ++i) {
    122122    status &= begin_window[i] == _props.begin_window[i];
    123123    status &= end_window[i] == _props.end_window[i];
     
    160160  if (isCompatible(other)) {
    161161    /// get minimum of window
    162     double min_begin_window[3];
    163     double min_end_window[3];
     162    double min_begin_window[NDIM];
     163    double min_end_window[NDIM];
    164164    bool doShrink = false;
    165     for (size_t index=0; index<3;++index) {
     165    for (size_t index=0; index<NDIM;++index) {
    166166      if (begin_window[index] <= other.begin_window[index]) {
    167167        min_begin_window[index] = other.begin_window[index];
     
    201201  if (isCompatible(other)) {
    202202    /// get maximum of window
    203     double max_begin_window[3];
    204     double max_end_window[3];
     203    double max_begin_window[NDIM];
     204    double max_end_window[NDIM];
    205205    bool doExtend = false;
    206     for (size_t index=0; index<3;++index) {
     206    for (size_t index=0; index<NDIM;++index) {
    207207      if (begin_window[index] >= other.begin_window[index]) {
    208208        max_begin_window[index] = other.begin_window[index];
     
    273273}
    274274void SamplingGrid::setWindowSize(
    275     const double _begin_window[3],
    276     const double _end_window[3])
    277 {
    278   for (size_t index=0;index<3;++index) {
     275    const double _begin_window[NDIM],
     276    const double _end_window[NDIM])
     277{
     278  for (size_t index=0;index<NDIM;++index) {
    279279    begin_window[index] = getNearestLowerGridPoint(_begin_window[index], index);
    280280    ASSERT( begin_window[index] >= begin[index],
     
    289289
    290290void SamplingGrid::setWindow(
    291     const double _begin_window[3],
    292     const double _end_window[3])
     291    const double _begin_window[NDIM],
     292    const double _end_window[NDIM])
    293293{
    294294  setWindowSize(_begin_window, _end_window);
     
    299299
    300300void SamplingGrid::setDomain(
    301     const double _begin[3],
    302     const double _end[3])
     301    const double _begin[NDIM],
     302    const double _end[NDIM])
    303303{
    304304  setDomainSize(_begin, _end);
     
    309309
    310310void SamplingGrid::extendWindow(
    311     const double _begin_window[3],
    312     const double _end_window[3])
     311    const double _begin_window[NDIM],
     312    const double _end_window[NDIM])
    313313{
    314314#ifndef NDEBUG
    315   for(size_t index=0;index < 3; ++index) {
     315  for(size_t index=0;index < NDIM; ++index) {
    316316    // check that we truly have to extend the window
    317317    ASSERT ( begin_window[index] >= _begin_window[index],
     
    332332#endif
    333333  // copy old window size and values
    334   double old_begin_window[3];
    335   double old_end_window[3];
    336   for(size_t index=0;index<3;++index) {
     334  double old_begin_window[NDIM];
     335  double old_end_window[NDIM];
     336  for(size_t index=0;index<NDIM;++index) {
    337337    old_begin_window[index] = begin_window[index];
    338338    old_end_window[index] = end_window[index];
     
    347347
    348348void SamplingGrid::shrinkWindow(
    349     const double _begin_window[3],
    350     const double _end_window[3])
     349    const double _begin_window[NDIM],
     350    const double _end_window[NDIM])
    351351{
    352352#ifndef NDEBUG
    353   for(size_t index=0;index < 3; ++index) {
     353  for(size_t index=0;index < NDIM; ++index) {
    354354    // check that we truly have to shrink the window
    355355    ASSERT ( begin_window[index] <= _begin_window[index],
     
    370370#endif
    371371  // copy old window size and values
    372   double old_begin_window[3];
    373   double old_end_window[3];
    374   for(size_t index=0;index<3;++index) {
     372  double old_begin_window[NDIM];
     373  double old_end_window[NDIM];
     374  for(size_t index=0;index<NDIM;++index) {
    375375    old_begin_window[index] = begin_window[index];
    376376    old_end_window[index] = end_window[index];
     
    393393
    394394void SamplingGrid::addOntoWindow(
    395     const double _begin_window[3],
    396     const double _end_window[3],
     395    const double _begin_window[NDIM],
     396    const double _end_window[NDIM],
    397397    const sampledvalues_t &_sampled_grid,
    398398    const double prefactor)
     
    410410
    411411void SamplingGrid::addIntoWindow(
    412     const double _begin_window[3],
    413     const double _end_window[3],
     412    const double _begin_window[NDIM],
     413    const double _end_window[NDIM],
    414414    const sampledvalues_t &_sampled_grid,
    415415    const double prefactor)
     
    440440      (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ?
    441441          0.5 : 0.; // need offset to get to round_toward_nearest behavior
    442   for(size_t index=0;index<3;++index) {
     442  for(size_t index=0;index<NDIM;++index) {
    443443    if (fabs(end[index] - begin[index]) > std::numeric_limits<double>::epsilon()*1e4) {
    444444      // we refrain from using floor/ceil as the window's starts and ends,
     
    465465
    466466void SamplingGrid::addWindowOntoWindow(
    467     const double larger_wbegin[3],
    468     const double larger_wend[3],
    469     const double smaller_wbegin[3],
    470     const double smaller_wend[3],
     467    const double larger_wbegin[NDIM],
     468    const double larger_wend[NDIM],
     469    const double smaller_wbegin[NDIM],
     470    const double smaller_wend[NDIM],
    471471    sampledvalues_t &dest_sampled_grid,
    472472    const sampledvalues_t &source_sampled_grid,
     
    475475{
    476476#ifndef NDEBUG
    477   for(size_t index=0;index<3;++index) {
     477  for(size_t index=0;index<NDIM;++index) {
    478478    ASSERT( smaller_wbegin[index] >= larger_wbegin[index],
    479479        "SamplingGrid::addWindowOntoWindow() - given smaller window starts earlier than larger window in component "
     
    485485#endif
    486486  // the only issue are indices
    487   size_t pre_offset[3];
    488   size_t post_offset[3];
    489   size_t length[3];
    490   size_t total[3];
     487  size_t pre_offset[NDIM];
     488  size_t post_offset[NDIM];
     489  size_t length[NDIM];
     490  size_t total[NDIM];
    491491  getDiscreteWindowIndices(
    492492      larger_wbegin, larger_wend,
     
    526526  }
    527527#endif
    528   size_t N[3];
     528  size_t N[NDIM];
    529529//  size_t counter = 0;
    530530  sampledvalues_t::iterator destiter = dest_sampled_grid.begin();
     
    585585  if (status) {
    586586    // compare windows
    587     for (size_t i=0; i<3; ++i) {
     587    for (size_t i=0; i<NDIM; ++i) {
    588588      status &= begin_window[i] == other.begin_window[i];
    589589      status &= end_window[i] == other.end_window[i];
  • src/Fragmentation/Summation/SetValues/SamplingGrid.hpp

    r028790 r5b1e5e  
    2020#include "boost/serialization/export.hpp"
    2121#include "boost/serialization/vector.hpp"
     22
     23#include "LinearAlgebra/defs.hpp"
    2224
    2325#include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp"
     
    5153   * \param _sampled_grid sample points
    5254   */
    53   SamplingGrid(const double _begin[3],
    54       const double _end[3],
     55  SamplingGrid(const double _begin[NDIM],
     56      const double _end[NDIM],
    5557      const int _level,
    5658      const sampledvalues_t &_sampled_grid);
     
    6466   * \param _level number of grid points in \f$2^{\mathrm{level}}\f$
    6567   */
    66   SamplingGrid(const double _begin[3],
    67       const double _end[3],
     68  SamplingGrid(const double _begin[NDIM],
     69      const double _end[NDIM],
    6870      const int _level);
    6971
     
    211213   * \param _end_window end of window
    212214   */
    213   void setWindow(const double _begin_window[3], const double _end_window[3]);
     215  void setWindow(const double _begin_window[NDIM], const double _end_window[NDIM]);
    214216
    215217  /** Helper function to convert begin_window and end_window that are w.r.t.
     
    255257   * \param _end end of window
    256258   */
    257   void setDomain(const double _begin[3], const double _end[3]);
     259  void setDomain(const double _begin[NDIM], const double _end[NDIM]);
    258260
    259261  /** Sets the size of the domain.
     
    264266   * \param _end end of domain
    265267   */
    266   void setDomainSize(const double _begin[3], const double _end[3]);
     268  void setDomainSize(const double _begin[NDIM], const double _end[NDIM]);
    267269
    268270  /** Extends the window while keeping the values.
     
    271273   * \param _end_window new end of window
    272274   */
    273   void extendWindow(const double _begin_window[3], const double _end_window[3]);
     275  void extendWindow(const double _begin_window[NDIM], const double _end_window[NDIM]);
    274276
    275277  /** Shrinks the window while keeping the values.
     
    278280   * \param _end_window new end of window
    279281   */
    280   void shrinkWindow(const double _begin_window[3], const double _end_window[3]);
     282  void shrinkWindow(const double _begin_window[NDIM], const double _end_window[NDIM]);
    281283
    282284  /** Adds another (smaller) window onto the one in this instance.
     
    290292   */
    291293  void addOntoWindow(
    292       const double _begin_window[3],
    293       const double _end_window[3],
     294      const double _begin_window[NDIM],
     295      const double _end_window[NDIM],
    294296      const sampledvalues_t &_sampled_grid,
    295297      const double prefactor);
     
    305307   */
    306308  void addIntoWindow(
    307       const double _begin_window[3],
    308       const double _end_window[3],
     309      const double _begin_window[NDIM],
     310      const double _end_window[NDIM],
    309311      const sampledvalues_t &_sampled_grid,
    310312      const double prefactor);
     
    334336   */
    335337  void addWindowOntoWindow(
    336       const double larger_wbegin[3],
    337       const double larger_wend[3],
    338       const double smaller_wbegin[3],
    339       const double smaller_wend[3],
     338      const double larger_wbegin[NDIM],
     339      const double larger_wend[NDIM],
     340      const double smaller_wbegin[NDIM],
     341      const double smaller_wend[NDIM],
    340342      sampledvalues_t &dest_sampled_grid,
    341343      const sampledvalues_t &source_sampled_grid,
     
    360362   * \param _end_window end of window
    361363   */
    362   void setWindowSize(const double _begin_window[3], const double _end_window[3]);
     364  void setWindowSize(const double _begin_window[NDIM], const double _end_window[NDIM]);
    363365
    364366public:
     
    370372
    371373  //!> start of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size
    372   double begin_window[3];
     374  double begin_window[NDIM];
    373375  //!> end of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size
    374   double end_window[3];
     376  double end_window[NDIM];
    375377
    376378private:
     
    384386    ar & boost::serialization::base_object<SamplingGridProperties>(*this);
    385387    ar & const_cast< sampledvalues_t &>(sampled_grid);
    386     for(size_t i=0;i<3;++i) {
     388    for(size_t i=0;i<NDIM;++i) {
    387389      ar & begin_window[i];
    388390      ar & end_window[i];
     
    391393
    392394  //!> static typedef to use in cstor when no initial values are given
    393   static const double zeroOffset[3];
     395  static const double zeroOffset[NDIM];
    394396};
    395397
  • src/Fragmentation/Summation/SetValues/SamplingGridProperties.cpp

    r028790 r5b1e5e  
    4444
    4545SamplingGridProperties::SamplingGridProperties(
    46     const double _begin[3],
    47     const double _end[3],
     46    const double _begin[NDIM],
     47    const double _end[NDIM],
    4848    const int _level) :
    4949  level(_level)
    5050{
    51   for(size_t i=0; i<3; ++i) {
     51  for(size_t i=0; i<NDIM; ++i) {
    5252    begin[i] = _begin[i];
    5353    end[i] = _end[i];
     
    5858  level(_props.level)
    5959{
    60   for(size_t i=0; i<3; ++i) {
     60  for(size_t i=0; i<NDIM; ++i) {
    6161    begin[i] = _props.begin[i];
    6262    end[i] = _props.end[i];
     
    6767  level(0)
    6868{
    69   for(size_t i=0; i<3; ++i) {
     69  for(size_t i=0; i<NDIM; ++i) {
    7070    begin[i] = 0.;
    7171    end[i] = 0.;
     
    8080  // check for self-assignment
    8181  if (this != &other) {
    82     for(size_t index=0; index<3; ++index) {
     82    for(size_t index=0; index<NDIM; ++index) {
    8383      begin[index] = other.begin[index];
    8484      end[index] = other.end[index];
     
    9292{
    9393  bool status = true;
    94   for (size_t i=0; i<3; ++i) {
     94  for (size_t i=0; i<NDIM; ++i) {
    9595    status &= begin[i] == _props.begin[i];
    9696    status &= end[i] == _props.end[i];
  • src/Fragmentation/Summation/SetValues/SamplingGridProperties.hpp

    r028790 r5b1e5e  
    1717#include "boost/serialization/array.hpp"
    1818
     19#include "LinearAlgebra/defs.hpp"
     20
    1921#include "Fragmentation/Summation/ZeroInstance.hpp"
    2022
     
    3133   */
    3234  SamplingGridProperties(
    33       const double _begin[3],
    34       const double _end[3],
     35      const double _begin[NDIM],
     36      const double _end[NDIM],
    3537      const int _level);
    3638
     
    132134public:
    133135  //!> offset of grid
    134   double begin[3];
     136  double begin[NDIM];
    135137  //!> size of grid, i.e. edge length per axis of domain
    136   double end[3];
     138  double end[NDIM];
    137139  //!> level, i.e. \f$2^{\mathrm{level}}\f$ grid points per axis per unit(!) length
    138140  int level;
     
    146148  {
    147149    int i;
    148     for (i=0; i<3; ++i)
     150    for (i=0; i<NDIM; ++i)
    149151      ar & begin[i];
    150     for (i=0; i<3; ++i)
     152    for (i=0; i<NDIM; ++i)
    151153      ar & end[i];
    152154    ar & level;
  • src/Fragmentation/Summation/SetValues/SamplingGridProperties_inline.hpp

    r028790 r5b1e5e  
    2424{
    2525  double volume = 1.;
    26   for (size_t i=0;i<3;++i)
     26  for (size_t i=0;i<NDIM;++i)
    2727    volume *= end[i]-begin[i];
    2828  return volume;
     
    3434const size_t SamplingGridProperties::getTotalGridPoints() const
    3535{
    36   return pow(getGridPointsPerAxis(),3);
     36  return pow(getGridPointsPerAxis(),(int)NDIM);
    3737}
    3838
  • src/Fragmentation/Summation/SetValues/SamplingGrid_inline.hpp

    r028790 r5b1e5e  
    2222{
    2323  double volume = 1.;
    24   for (size_t i=0;i<3;++i)
     24  for (size_t i=0;i<NDIM;++i)
    2525    volume *= end_window[i]-begin_window[i];
    2626  return volume;
     
    4949#endif
    5050void SamplingGrid::setDomainSize(
    51     const double _begin[3],
    52     const double _end[3])
     51    const double _begin[NDIM],
     52    const double _end[NDIM])
    5353{
    54   for (size_t index=0;index<3;++index) {
     54  for (size_t index=0;index<NDIM;++index) {
    5555    begin[index] = _begin[index];
    5656    end[index] = _end[index];
  • src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp

    r028790 r5b1e5e  
    6262const double grid_value=1.;
    6363
    64 #define NUMBEROFSAMPLES(n) (size_t)(pow(pow(2,n),3))
    65 #define DOMAINVOLUME(l) (size_t)pow(l,3)
     64#define NUMBEROFSAMPLES(n) (size_t)(pow(pow(2,n),(int)NDIM))
     65#define DOMAINVOLUME(l) (size_t)pow(l,(int)NDIM)
    6666
    6767// Registers the fixture into the 'registry'
     
    7575
    7676  // create the grid
    77   const double begin[3] = { 0., 0., 0. };
    78   const double end[3] = { 1., 1., 1. };
     77  const double begin[NDIM] = { 0., 0., 0. };
     78  const double end[NDIM] = { 1., 1., 1. };
    7979  for (size_t i=0; i< DOMAINVOLUME(1)*NUMBEROFSAMPLES(2); ++i)
    8080    values += grid_value;
     
    9494{
    9595  // check illegal grid
    96   const double begin[3] = { 0., 0., 0. };
    97   const double end[3] = { 2., 2., 2. };
     96  const double begin[NDIM] = { 0., 0., 0. };
     97  const double end[NDIM] = { 2., 2., 2. };
    9898  SamplingGridProperties illegal_props(begin, end, 5);
    9999  SamplingGridProperties legal_props(begin, end, 2);
     
    125125void SamplingGridTest::isCongruent_Test()
    126126{
    127   const double begin[3] = { 0., 0., 0. };
    128   const double end[3] = { 2., 2., 2. };
    129   const double otherbegin[3] = { 0.1, 0.1, 0.1 };
    130   const double otherend[3] = { 1., 1., 1. };
     127  const double begin[NDIM] = { 0., 0., 0. };
     128  const double end[NDIM] = { 2., 2., 2. };
     129  const double otherbegin[NDIM] = { 0.1, 0.1, 0.1 };
     130  const double otherend[NDIM] = { 1., 1., 1. };
    131131  SamplingGridProperties illegal_begin_props(otherbegin, end, 5);
    132132  SamplingGridProperties illegal_end_props(begin, otherend, 5);
     
    135135
    136136  // differing windows
    137 //  const double begin_window[3] = { 0.5, 0.5, 0.5 };
    138 //  const double end_window[3] = { 1., 1., 1. };
    139   const double otherbegin_window[3] = { 0.45, 0.45, 0.45 };
    140   const double otherend_window[3] = { 1.05, 1.05, 1.05 };
     137//  const double begin_window[NDIM] = { 0.5, 0.5, 0.5 };
     138//  const double end_window[NDIM] = { 1., 1., 1. };
     139  const double otherbegin_window[NDIM] = { 0.45, 0.45, 0.45 };
     140  const double otherend_window[NDIM] = { 1.05, 1.05, 1.05 };
    141141
    142142  // check that incompatible grid are also incongruent
     
    238238
    239239  // create another one and check its size, too
    240   const double begin[3] = { 0., 0., 0. };
    241   const double end[3] = { 1., 1., 1. };
     240  const double begin[NDIM] = { 0., 0., 0. };
     241  const double end[NDIM] = { 1., 1., 1. };
    242242  for (size_t level = 3; level<=6; ++level) {
    243243    values.clear();
     
    257257{
    258258  // we have a grid with size of one, extend to twice the size and check
    259   const double begin[3] = { 0., 0., 0. };
     259  const double begin[NDIM] = { 0., 0., 0. };
    260260  const double size = 2.;
    261   const double end[3] = { size, size, size };
    262   double offset[3];
     261  const double end[NDIM] = { size, size, size };
     262  double offset[NDIM];
    263263  for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5)
    264264    for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5)
    265265      for (offset[2] = 0.; offset[2] <= 1.; offset[2] += .5) {
    266         const double window_begin[3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
    267         const double window_end[3] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
     266        const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
     267        const double window_end[NDIM] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
    268268        SamplingGrid newgrid(begin, end, 2);
    269269        newgrid.setWindowSize(window_begin, window_end);
     
    292292{
    293293  std::cout << "SamplingGridTest::extendWindow_asymmetric_Test()" << std::endl;
    294   const double begin[3] = { 0., 0., 0. };
    295   const double end[3] = { 2., 2., 2. };
    296   double offset[3];
     294  const double begin[NDIM] = { 0., 0., 0. };
     295  const double end[NDIM] = { 2., 2., 2. };
     296  double offset[NDIM];
    297297  for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5)
    298298    for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5)
    299299      for (offset[2] = 0.; offset[2] <= 1.; offset[2] += .5) {
    300         const double window_begin[3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
    301         const double window_end[3] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
     300        const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
     301        const double window_end[NDIM] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
    302302        SamplingGrid newgrid(begin, end, 2);
    303303        CPPUNIT_ASSERT_EQUAL( (size_t)0, newgrid.getWindowGridPoints() );
    304304        newgrid.setWindowSize(window_begin, window_end);
    305305        // window size is only half of domain size
    306         const size_t max_samples = NUMBEROFSAMPLES(newgrid.level)*pow(0.5,3);
     306        const size_t max_samples = NUMBEROFSAMPLES(newgrid.level)*pow(0.5,(int)NDIM);
    307307        for (size_t i=0; i< max_samples; ++i)
    308308          newgrid.sampled_grid += grid_value*i;
     
    326326  // create values for half-sized window
    327327  values.clear();
    328   for (size_t i=0; i< (size_t)pow(.5*pow(2,2),3); ++i)
     328  for (size_t i=0; i< (size_t)pow(.5*pow(2,2),(int)NDIM); ++i)
    329329    values += grid_value;
    330330
    331331  // check that too large a window throws
    332332#ifndef NDEBUG
    333   const double begin[3] = { .5, .5, .5 };
    334   const double wrongend[3] = { 1.5, 1.5, 1.5 };
     333  const double begin[NDIM] = { .5, .5, .5 };
     334  const double wrongend[NDIM] = { 1.5, 1.5, 1.5 };
    335335  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
    336336  CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values, +1.), Assert::AssertionFailure );
     
    338338
    339339  // create another window from (.5,.5,.5) to (1., 1., 1.)
    340   double offset[3];
     340  double offset[NDIM];
    341341  for (offset[0] = 0.; offset[0] <= .5; offset[0] += .5)
    342342    for (offset[1] = 0.; offset[1] <= .5; offset[1] += .5)
    343343      for (offset[2] = 0.; offset[2] <= .5; offset[2] += .5) {
    344         const double window_begin[3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
    345         const double window_end[3] = { .5+offset[0], .5+offset[1], .5+offset[2]};
     344        const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
     345        const double window_end[NDIM] = { .5+offset[0], .5+offset[1], .5+offset[2]};
    346346
    347347        SamplingGrid newgrid(*grid);
     
    350350
    351351        // check integral to be one and one eighth times the old value
    352         CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,3))*grid_value, newgrid.integral() );
     352        CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,(int)NDIM))*grid_value, newgrid.integral() );
    353353      }
    354354}
     
    383383{
    384384  // create other grid
    385   const double begin[3] = { 0., 0., 0. };
    386   const double end[3] = { 1., 1., 1. };
     385  const double begin[NDIM] = { 0., 0., 0. };
     386  const double end[NDIM] = { 1., 1., 1. };
    387387  SamplingGrid::sampledvalues_t othervalues;
    388388  const double othergrid_value = 1.5;
     
    407407{
    408408  // create other grid
    409   const double begin[3] = { 0., 0., 0. };
    410   const double end[3] = { 1., 1., 1. };
     409  const double begin[NDIM] = { 0., 0., 0. };
     410  const double end[NDIM] = { 1., 1., 1. };
    411411  SamplingGrid::sampledvalues_t othervalues;
    412412  const double othergrid_value = 1.5;
     
    431431void SamplingGridTest::equality_Test()
    432432{
    433   const double begin[3] = { 0., 0., 0. };
    434   const double otherbegin[3] = { .5, 0.1, -0.5 };
    435   const double end[3] = { 1., 1., 1. };
    436   const double otherend[3] = { 2., 2., 2. };
    437   const double begin_window[3] = { 0., 0., 0. };
    438   const double otherbegin_window[3] = { .75, 0.1, 0. };
    439   const double end_window[3] = { 1., 1., 1. };
    440   const double otherend_window[3] = { .9, .9, .9 };
     433  const double begin[NDIM] = { 0., 0., 0. };
     434  const double otherbegin[NDIM] = { .5, 0.1, -0.5 };
     435  const double end[NDIM] = { 1., 1., 1. };
     436  const double otherend[NDIM] = { 2., 2., 2. };
     437  const double begin_window[NDIM] = { 0., 0., 0. };
     438  const double otherbegin_window[NDIM] = { .75, 0.1, 0. };
     439  const double end_window[NDIM] = { 1., 1., 1. };
     440  const double otherend_window[NDIM] = { .9, .9, .9 };
    441441
    442442  // create other grid
     
    515515  delete samegrid;
    516516}
     517
Note: See TracChangeset for help on using the changeset viewer.