Changeset 5b1e5e
- Timestamp:
- Sep 14, 2016, 6:42:52 PM (8 years ago)
- 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)
- Location:
- src/Fragmentation/Summation/SetValues
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Summation/SetValues/SamplingGrid.cpp
r028790 r5b1e5e 51 51 52 52 // static instances 53 const double SamplingGrid::zeroOffset[ 3] = { 0., 0., 0. };53 const double SamplingGrid::zeroOffset[NDIM] = { 0., 0., 0. }; 54 54 55 55 SamplingGrid::SamplingGrid() : … … 61 61 } 62 62 63 SamplingGrid::SamplingGrid(const double _begin[ 3],64 const double _end[ 3],63 SamplingGrid::SamplingGrid(const double _begin[NDIM], 64 const double _end[NDIM], 65 65 const int _level) : 66 66 SamplingGridProperties(_begin, _end, _level) … … 71 71 } 72 72 73 SamplingGrid::SamplingGrid(const double _begin[ 3],74 const double _end[ 3],73 SamplingGrid::SamplingGrid(const double _begin[NDIM], 74 const double _end[NDIM], 75 75 const int _level, 76 76 const sampledvalues_t &_sampled_grid) : … … 119 119 status &= (static_cast<const SamplingGridProperties &>(*this) == 120 120 static_cast<const SamplingGridProperties &>(_props)); 121 for(size_t i = 0; i< 3; ++i) {121 for(size_t i = 0; i<NDIM; ++i) { 122 122 status &= begin_window[i] == _props.begin_window[i]; 123 123 status &= end_window[i] == _props.end_window[i]; … … 160 160 if (isCompatible(other)) { 161 161 /// 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]; 164 164 bool doShrink = false; 165 for (size_t index=0; index< 3;++index) {165 for (size_t index=0; index<NDIM;++index) { 166 166 if (begin_window[index] <= other.begin_window[index]) { 167 167 min_begin_window[index] = other.begin_window[index]; … … 201 201 if (isCompatible(other)) { 202 202 /// 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]; 205 205 bool doExtend = false; 206 for (size_t index=0; index< 3;++index) {206 for (size_t index=0; index<NDIM;++index) { 207 207 if (begin_window[index] >= other.begin_window[index]) { 208 208 max_begin_window[index] = other.begin_window[index]; … … 273 273 } 274 274 void 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) { 279 279 begin_window[index] = getNearestLowerGridPoint(_begin_window[index], index); 280 280 ASSERT( begin_window[index] >= begin[index], … … 289 289 290 290 void 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]) 293 293 { 294 294 setWindowSize(_begin_window, _end_window); … … 299 299 300 300 void SamplingGrid::setDomain( 301 const double _begin[ 3],302 const double _end[ 3])301 const double _begin[NDIM], 302 const double _end[NDIM]) 303 303 { 304 304 setDomainSize(_begin, _end); … … 309 309 310 310 void 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]) 313 313 { 314 314 #ifndef NDEBUG 315 for(size_t index=0;index < 3; ++index) {315 for(size_t index=0;index < NDIM; ++index) { 316 316 // check that we truly have to extend the window 317 317 ASSERT ( begin_window[index] >= _begin_window[index], … … 332 332 #endif 333 333 // 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) { 337 337 old_begin_window[index] = begin_window[index]; 338 338 old_end_window[index] = end_window[index]; … … 347 347 348 348 void 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]) 351 351 { 352 352 #ifndef NDEBUG 353 for(size_t index=0;index < 3; ++index) {353 for(size_t index=0;index < NDIM; ++index) { 354 354 // check that we truly have to shrink the window 355 355 ASSERT ( begin_window[index] <= _begin_window[index], … … 370 370 #endif 371 371 // 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) { 375 375 old_begin_window[index] = begin_window[index]; 376 376 old_end_window[index] = end_window[index]; … … 393 393 394 394 void 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], 397 397 const sampledvalues_t &_sampled_grid, 398 398 const double prefactor) … … 410 410 411 411 void 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], 414 414 const sampledvalues_t &_sampled_grid, 415 415 const double prefactor) … … 440 440 (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ? 441 441 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) { 443 443 if (fabs(end[index] - begin[index]) > std::numeric_limits<double>::epsilon()*1e4) { 444 444 // we refrain from using floor/ceil as the window's starts and ends, … … 465 465 466 466 void 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], 471 471 sampledvalues_t &dest_sampled_grid, 472 472 const sampledvalues_t &source_sampled_grid, … … 475 475 { 476 476 #ifndef NDEBUG 477 for(size_t index=0;index< 3;++index) {477 for(size_t index=0;index<NDIM;++index) { 478 478 ASSERT( smaller_wbegin[index] >= larger_wbegin[index], 479 479 "SamplingGrid::addWindowOntoWindow() - given smaller window starts earlier than larger window in component " … … 485 485 #endif 486 486 // 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]; 491 491 getDiscreteWindowIndices( 492 492 larger_wbegin, larger_wend, … … 526 526 } 527 527 #endif 528 size_t N[ 3];528 size_t N[NDIM]; 529 529 // size_t counter = 0; 530 530 sampledvalues_t::iterator destiter = dest_sampled_grid.begin(); … … 585 585 if (status) { 586 586 // compare windows 587 for (size_t i=0; i< 3; ++i) {587 for (size_t i=0; i<NDIM; ++i) { 588 588 status &= begin_window[i] == other.begin_window[i]; 589 589 status &= end_window[i] == other.end_window[i]; -
src/Fragmentation/Summation/SetValues/SamplingGrid.hpp
r028790 r5b1e5e 20 20 #include "boost/serialization/export.hpp" 21 21 #include "boost/serialization/vector.hpp" 22 23 #include "LinearAlgebra/defs.hpp" 22 24 23 25 #include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp" … … 51 53 * \param _sampled_grid sample points 52 54 */ 53 SamplingGrid(const double _begin[ 3],54 const double _end[ 3],55 SamplingGrid(const double _begin[NDIM], 56 const double _end[NDIM], 55 57 const int _level, 56 58 const sampledvalues_t &_sampled_grid); … … 64 66 * \param _level number of grid points in \f$2^{\mathrm{level}}\f$ 65 67 */ 66 SamplingGrid(const double _begin[ 3],67 const double _end[ 3],68 SamplingGrid(const double _begin[NDIM], 69 const double _end[NDIM], 68 70 const int _level); 69 71 … … 211 213 * \param _end_window end of window 212 214 */ 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]); 214 216 215 217 /** Helper function to convert begin_window and end_window that are w.r.t. … … 255 257 * \param _end end of window 256 258 */ 257 void setDomain(const double _begin[ 3], const double _end[3]);259 void setDomain(const double _begin[NDIM], const double _end[NDIM]); 258 260 259 261 /** Sets the size of the domain. … … 264 266 * \param _end end of domain 265 267 */ 266 void setDomainSize(const double _begin[ 3], const double _end[3]);268 void setDomainSize(const double _begin[NDIM], const double _end[NDIM]); 267 269 268 270 /** Extends the window while keeping the values. … … 271 273 * \param _end_window new end of window 272 274 */ 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]); 274 276 275 277 /** Shrinks the window while keeping the values. … … 278 280 * \param _end_window new end of window 279 281 */ 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]); 281 283 282 284 /** Adds another (smaller) window onto the one in this instance. … … 290 292 */ 291 293 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], 294 296 const sampledvalues_t &_sampled_grid, 295 297 const double prefactor); … … 305 307 */ 306 308 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], 309 311 const sampledvalues_t &_sampled_grid, 310 312 const double prefactor); … … 334 336 */ 335 337 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], 340 342 sampledvalues_t &dest_sampled_grid, 341 343 const sampledvalues_t &source_sampled_grid, … … 360 362 * \param _end_window end of window 361 363 */ 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]); 363 365 364 366 public: … … 370 372 371 373 //!> start of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size 372 double begin_window[ 3];374 double begin_window[NDIM]; 373 375 //!> end of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size 374 double end_window[ 3];376 double end_window[NDIM]; 375 377 376 378 private: … … 384 386 ar & boost::serialization::base_object<SamplingGridProperties>(*this); 385 387 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) { 387 389 ar & begin_window[i]; 388 390 ar & end_window[i]; … … 391 393 392 394 //!> static typedef to use in cstor when no initial values are given 393 static const double zeroOffset[ 3];395 static const double zeroOffset[NDIM]; 394 396 }; 395 397 -
src/Fragmentation/Summation/SetValues/SamplingGridProperties.cpp
r028790 r5b1e5e 44 44 45 45 SamplingGridProperties::SamplingGridProperties( 46 const double _begin[ 3],47 const double _end[ 3],46 const double _begin[NDIM], 47 const double _end[NDIM], 48 48 const int _level) : 49 49 level(_level) 50 50 { 51 for(size_t i=0; i< 3; ++i) {51 for(size_t i=0; i<NDIM; ++i) { 52 52 begin[i] = _begin[i]; 53 53 end[i] = _end[i]; … … 58 58 level(_props.level) 59 59 { 60 for(size_t i=0; i< 3; ++i) {60 for(size_t i=0; i<NDIM; ++i) { 61 61 begin[i] = _props.begin[i]; 62 62 end[i] = _props.end[i]; … … 67 67 level(0) 68 68 { 69 for(size_t i=0; i< 3; ++i) {69 for(size_t i=0; i<NDIM; ++i) { 70 70 begin[i] = 0.; 71 71 end[i] = 0.; … … 80 80 // check for self-assignment 81 81 if (this != &other) { 82 for(size_t index=0; index< 3; ++index) {82 for(size_t index=0; index<NDIM; ++index) { 83 83 begin[index] = other.begin[index]; 84 84 end[index] = other.end[index]; … … 92 92 { 93 93 bool status = true; 94 for (size_t i=0; i< 3; ++i) {94 for (size_t i=0; i<NDIM; ++i) { 95 95 status &= begin[i] == _props.begin[i]; 96 96 status &= end[i] == _props.end[i]; -
src/Fragmentation/Summation/SetValues/SamplingGridProperties.hpp
r028790 r5b1e5e 17 17 #include "boost/serialization/array.hpp" 18 18 19 #include "LinearAlgebra/defs.hpp" 20 19 21 #include "Fragmentation/Summation/ZeroInstance.hpp" 20 22 … … 31 33 */ 32 34 SamplingGridProperties( 33 const double _begin[ 3],34 const double _end[ 3],35 const double _begin[NDIM], 36 const double _end[NDIM], 35 37 const int _level); 36 38 … … 132 134 public: 133 135 //!> offset of grid 134 double begin[ 3];136 double begin[NDIM]; 135 137 //!> size of grid, i.e. edge length per axis of domain 136 double end[ 3];138 double end[NDIM]; 137 139 //!> level, i.e. \f$2^{\mathrm{level}}\f$ grid points per axis per unit(!) length 138 140 int level; … … 146 148 { 147 149 int i; 148 for (i=0; i< 3; ++i)150 for (i=0; i<NDIM; ++i) 149 151 ar & begin[i]; 150 for (i=0; i< 3; ++i)152 for (i=0; i<NDIM; ++i) 151 153 ar & end[i]; 152 154 ar & level; -
src/Fragmentation/Summation/SetValues/SamplingGridProperties_inline.hpp
r028790 r5b1e5e 24 24 { 25 25 double volume = 1.; 26 for (size_t i=0;i< 3;++i)26 for (size_t i=0;i<NDIM;++i) 27 27 volume *= end[i]-begin[i]; 28 28 return volume; … … 34 34 const size_t SamplingGridProperties::getTotalGridPoints() const 35 35 { 36 return pow(getGridPointsPerAxis(), 3);36 return pow(getGridPointsPerAxis(),(int)NDIM); 37 37 } 38 38 -
src/Fragmentation/Summation/SetValues/SamplingGrid_inline.hpp
r028790 r5b1e5e 22 22 { 23 23 double volume = 1.; 24 for (size_t i=0;i< 3;++i)24 for (size_t i=0;i<NDIM;++i) 25 25 volume *= end_window[i]-begin_window[i]; 26 26 return volume; … … 49 49 #endif 50 50 void SamplingGrid::setDomainSize( 51 const double _begin[ 3],52 const double _end[ 3])51 const double _begin[NDIM], 52 const double _end[NDIM]) 53 53 { 54 for (size_t index=0;index< 3;++index) {54 for (size_t index=0;index<NDIM;++index) { 55 55 begin[index] = _begin[index]; 56 56 end[index] = _end[index]; -
src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp
r028790 r5b1e5e 62 62 const double grid_value=1.; 63 63 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) 66 66 67 67 // Registers the fixture into the 'registry' … … 75 75 76 76 // 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. }; 79 79 for (size_t i=0; i< DOMAINVOLUME(1)*NUMBEROFSAMPLES(2); ++i) 80 80 values += grid_value; … … 94 94 { 95 95 // 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. }; 98 98 SamplingGridProperties illegal_props(begin, end, 5); 99 99 SamplingGridProperties legal_props(begin, end, 2); … … 125 125 void SamplingGridTest::isCongruent_Test() 126 126 { 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. }; 131 131 SamplingGridProperties illegal_begin_props(otherbegin, end, 5); 132 132 SamplingGridProperties illegal_end_props(begin, otherend, 5); … … 135 135 136 136 // 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 }; 141 141 142 142 // check that incompatible grid are also incongruent … … 238 238 239 239 // 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. }; 242 242 for (size_t level = 3; level<=6; ++level) { 243 243 values.clear(); … … 257 257 { 258 258 // 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. }; 260 260 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]; 263 263 for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5) 264 264 for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5) 265 265 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]}; 268 268 SamplingGrid newgrid(begin, end, 2); 269 269 newgrid.setWindowSize(window_begin, window_end); … … 292 292 { 293 293 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]; 297 297 for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5) 298 298 for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5) 299 299 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]}; 302 302 SamplingGrid newgrid(begin, end, 2); 303 303 CPPUNIT_ASSERT_EQUAL( (size_t)0, newgrid.getWindowGridPoints() ); 304 304 newgrid.setWindowSize(window_begin, window_end); 305 305 // 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); 307 307 for (size_t i=0; i< max_samples; ++i) 308 308 newgrid.sampled_grid += grid_value*i; … … 326 326 // create values for half-sized window 327 327 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) 329 329 values += grid_value; 330 330 331 331 // check that too large a window throws 332 332 #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 }; 335 335 std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl; 336 336 CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values, +1.), Assert::AssertionFailure ); … … 338 338 339 339 // create another window from (.5,.5,.5) to (1., 1., 1.) 340 double offset[ 3];340 double offset[NDIM]; 341 341 for (offset[0] = 0.; offset[0] <= .5; offset[0] += .5) 342 342 for (offset[1] = 0.; offset[1] <= .5; offset[1] += .5) 343 343 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]}; 346 346 347 347 SamplingGrid newgrid(*grid); … … 350 350 351 351 // 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() ); 353 353 } 354 354 } … … 383 383 { 384 384 // 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. }; 387 387 SamplingGrid::sampledvalues_t othervalues; 388 388 const double othergrid_value = 1.5; … … 407 407 { 408 408 // 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. }; 411 411 SamplingGrid::sampledvalues_t othervalues; 412 412 const double othergrid_value = 1.5; … … 431 431 void SamplingGridTest::equality_Test() 432 432 { 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 }; 441 441 442 442 // create other grid … … 515 515 delete samegrid; 516 516 } 517
Note:
See TracChangeset
for help on using the changeset viewer.