Changeset 2ccdf4 for src/Fragmentation
- Timestamp:
- Sep 14, 2016, 7:02:31 AM (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, SaturateAtoms_findBestMatching, 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:
- 36bd59
- Parents:
- 2d8c4e
- git-author:
- Frederik Heber <heber@…> (05/18/16 21:47:15)
- git-committer:
- Frederik Heber <heber@…> (09/14/16 07:02:31)
- Location:
- src/Fragmentation/Exporters/unittests
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/unittests/Makefile.am
r2d8c4e r2ccdf4 21 21 SphericalPointDistributionUnitTest 22 22 23 XFAIL_TESTS += SphericalPointDistributionUnitTest24 23 TESTS += $(FRAGMENTATIONEXPORTERSTESTS) 25 24 check_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS) -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
r2d8c4e r2ccdf4 47 47 #include <algorithm> 48 48 #include <boost/assign.hpp> 49 #include <boost/math/quaternion.hpp> 49 #include <boost/bind.hpp> 50 #include <numeric> 50 51 51 52 #include "CodePatterns/Assert.hpp" … … 274 275 } 275 276 277 /** The getConnectionTest test functions are templated. We only implement 278 * special cases here where we need to override the behavior found in there. 279 */ 280 276 281 /** UnitTest for getConnections() 277 282 */ … … 339 344 // and compare the two 340 345 CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 346 } 347 348 void freeTesselPointSTLList(TesselPointSTLList &_Corners) 349 { 350 for (TesselPointSTLList::iterator iter = _Corners.begin(); 351 !_Corners.empty(); iter = _Corners.begin()) { 352 delete *iter; 353 _Corners.erase(iter); 354 } 355 } 356 357 template <int N> SphericalPointDistribution::adjacency_t getAdjacencyConnections() 358 { 359 SphericalPointDistribution SPD(1.); 360 // get the points and convert into TesselPoint list 361 SphericalPointDistribution::Polygon_t newpolygon = SPD.get<N>(); 362 TesselPointSTLList Corners; 363 SphericalPointDistribution::IndexList_t indices(N); 364 std::generate(indices.begin(), indices.end(), UniqueNumber); 365 std::transform( 366 newpolygon.begin(), newpolygon.end(), 367 indices.begin(), 368 std::back_inserter(Corners), 369 VectorToTesselPoint()); 370 371 // create the tesselation 372 const double SPHERERADIUS = 1.5; 373 Tesselation TesselStruct; 374 PointCloudAdaptor<TesselPointSTLList> cloud(&Corners, "TesselPointSTLList"); 375 TesselStruct(cloud, SPHERERADIUS); 376 377 // create a adjacency list from a tesselation of the (convex set of) points 378 SphericalPointDistribution::adjacency_t adjacency; 379 for (LineMap::const_iterator iter = TesselStruct.LinesOnBoundary.begin(); 380 iter != TesselStruct.LinesOnBoundary.end(); ++iter) { 381 const BoundaryLineSet * const line = iter->second; 382 { 383 std::pair< SphericalPointDistribution::adjacency_t::iterator, bool > inserter = 384 adjacency.insert( 385 std::make_pair( 386 line->endpoints[0]->Nr, 387 SphericalPointDistribution::IndexSet_t() )); 388 inserter.first->second.insert(line->endpoints[1]->Nr); 389 LOG(6, "DEBUG: Inserting " << line->endpoints[0]->Nr << "," << line->endpoints[1]->Nr); 390 } 391 { 392 std::pair< SphericalPointDistribution::adjacency_t::iterator, bool > inserter = 393 adjacency.insert( 394 std::make_pair( 395 line->endpoints[1]->Nr, 396 SphericalPointDistribution::IndexSet_t() )); 397 inserter.first->second.insert(line->endpoints[0]->Nr); 398 LOG(6, "DEBUG: Inserting " << line->endpoints[1]->Nr << "," << line->endpoints[0]->Nr); 399 } 400 } 401 402 // free allocated TesselPoints 403 freeTesselPointSTLList(Corners); 404 405 LOG(2, "INFO: adjacency is " << adjacency); 406 407 return adjacency; 408 } 409 410 template <int N> SphericalPointDistribution::adjacency_t getExpectedConnections() 411 { 412 SphericalPointDistribution SPD(1.); 413 414 // get the implemented connections 415 SphericalPointDistribution::adjacency_t expected = 416 SPD.getConnections<N>(); 417 418 LOG(2, "INFO: expected is " << expected); 419 420 return expected; 421 } 422 423 /** UnitTest for getConnections() 424 */ 425 template <> 426 void SphericalPointDistributionTest_assistant::getConnectionTest<8>() 427 { 428 const int N=8; 429 430 SphericalPointDistribution::adjacency_t adjacency = getAdjacencyConnections<N>(); 431 SphericalPointDistribution::adjacency_t expected = getExpectedConnections<N>(); 432 433 // and compare the two 434 // CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 435 436 // with eight points we obtain a cube. The problem is that each side 437 // is a polygon with four corners that is ambiguous in the tesselation 438 // it receives. Hence, we cannot directly test the linking but only 439 // the properties. 440 size_t NumberEdges_expected = 0; 441 for (SphericalPointDistribution::adjacency_t::const_iterator iter = expected.begin(); 442 iter != expected.begin(); ++iter) { 443 NumberEdges_expected += iter->second.size(); 444 CPPUNIT_ASSERT( iter->second.size() >= 3 ); 445 CPPUNIT_ASSERT( iter->second.size() <= 6 ); 446 } 447 size_t NumberEdges_adjacency = 0; 448 for (SphericalPointDistribution::adjacency_t::const_iterator iter = adjacency.begin(); 449 iter != adjacency.begin(); ++iter) { 450 NumberEdges_adjacency += iter->second.size(); 451 CPPUNIT_ASSERT( iter->second.size() >= 3 ); 452 CPPUNIT_ASSERT( iter->second.size() <= 6 ); 453 } 454 CPPUNIT_ASSERT_EQUAL( NumberEdges_expected, NumberEdges_adjacency); 455 } 456 457 /** UnitTest for getConnections() 458 */ 459 template <> 460 void SphericalPointDistributionTest_assistant::getConnectionTest<9>() 461 { 462 const int N=9; 463 464 SphericalPointDistribution::adjacency_t adjacency = getAdjacencyConnections<N>(); 465 SphericalPointDistribution::adjacency_t expected = getExpectedConnections<N>(); 466 467 // and compare the two 468 // CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 469 470 // with nine points we have a square on one end and an pentagon on the hand with 471 // some ambiguity. The problem is that each side 472 // is a polygon with four/five corners that is ambiguous in the tesselation 473 // it receives. Hence, we cannot directly test the linking but only 474 // the properties. 475 size_t NumberEdges_expected = 0; 476 for (SphericalPointDistribution::adjacency_t::const_iterator iter = expected.begin(); 477 iter != expected.begin(); ++iter) { 478 NumberEdges_expected += iter->second.size(); 479 CPPUNIT_ASSERT( iter->second.size() >= 4 ); 480 CPPUNIT_ASSERT( iter->second.size() <= 5 ); 481 } 482 size_t NumberEdges_adjacency = 0; 483 for (SphericalPointDistribution::adjacency_t::const_iterator iter = adjacency.begin(); 484 iter != adjacency.begin(); ++iter) { 485 NumberEdges_adjacency += iter->second.size(); 486 CPPUNIT_ASSERT( iter->second.size() >= 4 ); 487 CPPUNIT_ASSERT( iter->second.size() <= 5 ); 488 } 489 CPPUNIT_ASSERT_EQUAL( NumberEdges_expected, NumberEdges_adjacency); 490 } 491 492 /** UnitTest for getConnections() 493 */ 494 template <> 495 void SphericalPointDistributionTest_assistant::getConnectionTest<10>() 496 { 497 const int N=10; 498 499 SphericalPointDistribution::adjacency_t adjacency = getAdjacencyConnections<N>(); 500 SphericalPointDistribution::adjacency_t expected = getExpectedConnections<N>(); 501 502 // and compare the two 503 // CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 504 505 // with ten points we have two pentagons with some ambiguity. The problem is 506 // that each side is a polygon with five corners that is ambiguous in the 507 // tesselation it receives. Hence, we cannot directly test the linking but only 508 // the properties. 509 size_t NumberEdges_expected = 0; 510 for (SphericalPointDistribution::adjacency_t::const_iterator iter = expected.begin(); 511 iter != expected.begin(); ++iter) { 512 NumberEdges_expected += iter->second.size(); 513 CPPUNIT_ASSERT( iter->second.size() >= 4 ); 514 CPPUNIT_ASSERT( iter->second.size() <= 5 ); 515 } 516 size_t NumberEdges_adjacency = 0; 517 for (SphericalPointDistribution::adjacency_t::const_iterator iter = adjacency.begin(); 518 iter != adjacency.begin(); ++iter) { 519 NumberEdges_adjacency += iter->second.size(); 520 CPPUNIT_ASSERT( iter->second.size() >= 4 ); 521 CPPUNIT_ASSERT( iter->second.size() <= 5 ); 522 } 523 CPPUNIT_ASSERT_EQUAL( NumberEdges_expected, NumberEdges_adjacency); 524 } 525 526 /** UnitTest for getConnections() 527 */ 528 template <> 529 void SphericalPointDistributionTest_assistant::getConnectionTest<11>() 530 { 531 const int N=11; 532 533 SphericalPointDistribution::adjacency_t adjacency = getAdjacencyConnections<N>(); 534 SphericalPointDistribution::adjacency_t expected = getExpectedConnections<N>(); 535 536 // and compare the two 537 // CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 538 539 // again, we only check properties as tesselation has ambiguities. 540 size_t NumberEdges_expected = 0; 541 for (SphericalPointDistribution::adjacency_t::const_iterator iter = expected.begin(); 542 iter != expected.begin(); ++iter) { 543 NumberEdges_expected += iter->second.size(); 544 CPPUNIT_ASSERT( iter->second.size() >= 4 ); 545 CPPUNIT_ASSERT( iter->second.size() <= 6 ); 546 } 547 size_t NumberEdges_adjacency = 0; 548 for (SphericalPointDistribution::adjacency_t::const_iterator iter = adjacency.begin(); 549 iter != adjacency.begin(); ++iter) { 550 NumberEdges_adjacency += iter->second.size(); 551 CPPUNIT_ASSERT( iter->second.size() >= 4 ); 552 CPPUNIT_ASSERT( iter->second.size() <= 6 ); 553 } 554 CPPUNIT_ASSERT_EQUAL( NumberEdges_expected, NumberEdges_adjacency); 555 } 556 557 /** UnitTest for getConnections() 558 */ 559 template <> 560 void SphericalPointDistributionTest_assistant::getConnectionTest<12>() 561 { 562 const int N=12; 563 564 SphericalPointDistribution::adjacency_t adjacency = getAdjacencyConnections<N>(); 565 SphericalPointDistribution::adjacency_t expected = getExpectedConnections<N>(); 566 567 // and compare the two 568 // CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 569 570 // again, we only check properties as tesselation has ambiguities. 571 size_t NumberEdges_expected = 0; 572 for (SphericalPointDistribution::adjacency_t::const_iterator iter = expected.begin(); 573 iter != expected.begin(); ++iter) { 574 NumberEdges_expected += iter->second.size(); 575 CPPUNIT_ASSERT( iter->second.size() >= 5 ); 576 CPPUNIT_ASSERT( iter->second.size() <= 5 ); 577 } 578 size_t NumberEdges_adjacency = 0; 579 for (SphericalPointDistribution::adjacency_t::const_iterator iter = adjacency.begin(); 580 iter != adjacency.begin(); ++iter) { 581 NumberEdges_adjacency += iter->second.size(); 582 CPPUNIT_ASSERT( iter->second.size() >= 5 ); 583 CPPUNIT_ASSERT( iter->second.size() <= 5 ); 584 } 585 CPPUNIT_ASSERT_EQUAL( NumberEdges_expected, NumberEdges_adjacency); 586 } 587 588 /** UnitTest for getConnections() 589 */ 590 template <> 591 void SphericalPointDistributionTest_assistant::getConnectionTest<14>() 592 { 593 const int N=14; 594 595 SphericalPointDistribution::adjacency_t adjacency = getAdjacencyConnections<N>(); 596 SphericalPointDistribution::adjacency_t expected = getExpectedConnections<N>(); 597 598 // and compare the two 599 // CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 600 601 // again, we only check properties as tesselation has ambiguities. 602 size_t NumberEdges_expected = 0; 603 for (SphericalPointDistribution::adjacency_t::const_iterator iter = expected.begin(); 604 iter != expected.begin(); ++iter) { 605 NumberEdges_expected += iter->second.size(); 606 CPPUNIT_ASSERT( iter->second.size() >= 5 ); 607 CPPUNIT_ASSERT( iter->second.size() <= 6 ); 608 } 609 size_t NumberEdges_adjacency = 0; 610 for (SphericalPointDistribution::adjacency_t::const_iterator iter = adjacency.begin(); 611 iter != adjacency.begin(); ++iter) { 612 NumberEdges_adjacency += iter->second.size(); 613 CPPUNIT_ASSERT( iter->second.size() >= 5 ); 614 CPPUNIT_ASSERT( iter->second.size() <= 6 ); 615 } 616 CPPUNIT_ASSERT_EQUAL( NumberEdges_expected, NumberEdges_adjacency); 341 617 } 342 618 -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
r2d8c4e r2ccdf4 32 32 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<1>(); 33 33 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<2>(); 34 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<8>(); 35 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<9>(); 36 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<10>(); 37 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<11>(); 38 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<12>(); 39 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<14>(); 34 40 35 41 #include "SphericalPointDistributionUnitTest_assistant.hpp" -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest_assistant.hpp
r2d8c4e r2ccdf4 42 42 } 43 43 }; 44 45 // is declared in cpp module 46 void freeTesselPointSTLList(TesselPointSTLList &_Corners); 44 47 45 48 /** UnitTest for getConnections() … … 91 94 } 92 95 96 // free allocated TesselPoints 97 freeTesselPointSTLList(Corners); 98 93 99 // get the implemented connections 94 100 SphericalPointDistribution::adjacency_t expected =
Note:
See TracChangeset
for help on using the changeset viewer.