Changeset 6393ff
- Timestamp:
- Sep 12, 2016, 11:48:37 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, 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:
- 2d8c4e
- Parents:
- 3678eb
- git-author:
- Frederik Heber <heber@…> (07/12/14 11:57:54)
- git-committer:
- Frederik Heber <heber@…> (09/12/16 23:48:37)
- Location:
- src/Fragmentation
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.hpp
r3678eb r6393ff 19 19 #include <cmath> 20 20 #include <list> 21 #include <map> 22 #include <set> 23 #include <vector> 21 24 22 25 #include "LinearAlgebra/Vector.hpp" … … 48 51 //!> typedef for the list of points with integral weights 49 52 typedef std::list<std::pair<Vector, int> > WeightedPolygon_t; 53 //!> typedef for a sorted list of indices 54 typedef std::set<unsigned int> IndexSet_t; 55 //!> typedef for the adjacency list of a polygon 56 typedef std::map<unsigned int, IndexSet_t > adjacency_t; 50 57 51 58 /** General getter function for the distribution of points on the surface. … … 58 65 { 59 66 ASSERT(0, "SphericalPointDistribution::get() - not specialized for "+toString(N)+"."); 67 return Polygon_t(); 68 } 69 70 template <int N> adjacency_t getConnections() 71 { 72 ASSERT(0, "SphericalPointDistribution::getConnections() - not specialized for "+toString(N)+"."); 60 73 return Polygon_t(); 61 74 } … … 185 198 template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<14>() const; 186 199 200 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<0>(); 201 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<1>(); 202 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<2>(); 203 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<3>(); 204 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<4>(); 205 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<5>(); 206 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<6>(); 207 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<7>(); 208 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<8>(); 209 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<9>(); 210 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<10>(); 211 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<11>(); 212 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<12>(); 213 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<14>(); 214 187 215 #endif /* SPHERICALPOINTDISTRIBUTION_HPP_ */ -
src/Fragmentation/Exporters/unittests/Makefile.am
r3678eb r6393ff 12 12 ../Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.hpp \ 13 13 ../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.hpp \ 14 ../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp 14 ../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp \ 15 ../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest_assistant.hpp 15 16 16 17 FRAGMENTATIONEXPORTERSTESTS = \ -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
r3678eb r6393ff 45 45 #include "SphericalPointDistributionUnitTest.hpp" 46 46 47 #include <algorithm> 47 48 #include <boost/assign.hpp> 48 49 #include <boost/math/quaternion.hpp> … … 53 54 #include "LinearAlgebra/Line.hpp" 54 55 56 #include "Atom/TesselPoint.hpp" 55 57 #include "Fragmentation/Exporters/SphericalPointDistribution.hpp" 56 57 #include "LinearAlgebra/Line.hpp" 58 #include "LinkedCell/linkedcell.hpp" 59 #include "LinkedCell/PointCloudAdaptor.hpp" 60 #include "Tesselation/BoundaryLineSet.hpp" 61 #include "Tesselation/tesselation.hpp" 58 62 59 63 #ifdef HAVE_TESTRUNNER … … 78 82 ASSERT_DO(Assert::Throw); 79 83 80 setVerbosity( 6);84 setVerbosity(2); 81 85 } 82 86 … … 270 274 } 271 275 272 /** UnitTest for matchSphericalPointDistributions() with two points 273 */ 274 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2() 275 { 276 /** UnitTest for getConnections() 277 */ 278 template <> 279 void SphericalPointDistributionTest_assistant::getConnectionTest<0>() 280 { 281 const int N=0; 276 282 SphericalPointDistribution SPD(1.); 277 // test with one point, matching trivially 278 { 279 SphericalPointDistribution::WeightedPolygon_t polygon; 280 polygon += std::make_pair(Vector(1.,0.,0.), 1); 281 SphericalPointDistribution::Polygon_t newpolygon = 282 SPD.get<2>(); 283 SphericalPointDistribution::Polygon_t expected; 284 expected += Vector(-1.,0.,0.); 285 SphericalPointDistribution::Polygon_t remaining = 286 SphericalPointDistribution::matchSphericalPointDistributions( 287 polygon, 288 newpolygon); 289 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 290 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 291 } 292 293 // test with one point, just a flip of axis 294 { 295 SphericalPointDistribution::WeightedPolygon_t polygon; 296 polygon += std::make_pair( Vector(0.,1.,0.), 1); 297 SphericalPointDistribution::Polygon_t newpolygon = 298 SPD.get<2>(); 299 SphericalPointDistribution::Polygon_t expected; 300 expected += Vector(0.,-1.,0.); 301 SphericalPointDistribution::Polygon_t remaining = 302 SphericalPointDistribution::matchSphericalPointDistributions( 303 polygon, 304 newpolygon); 305 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 306 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 307 } 308 309 // test with one point, just a flip to another axis 310 { 311 SphericalPointDistribution::WeightedPolygon_t polygon; 312 polygon += std::make_pair( Vector(0.,0.,-1.), 1); 313 SphericalPointDistribution::Polygon_t newpolygon = 314 SPD.get<2>(); 315 SphericalPointDistribution::Polygon_t expected; 316 expected += Vector(0.,0.,1.); 317 SphericalPointDistribution::Polygon_t remaining = 318 SphericalPointDistribution::matchSphericalPointDistributions( 319 polygon, 320 newpolygon); 321 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 322 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 323 } 324 325 // test with one point, full rotation 326 { 327 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 328 SphericalPointDistribution::WeightedPolygon_t polygon; 329 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 330 SphericalPointDistribution::Polygon_t newpolygon = 331 SPD.get<2>(); 332 SphericalPointDistribution::Polygon_t expected; 333 expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 334 SphericalPointDistribution::Polygon_t remaining = 335 SphericalPointDistribution::matchSphericalPointDistributions( 336 polygon, 337 newpolygon); 338 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 339 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 340 } 283 284 // create empty adjacency 285 SphericalPointDistribution::adjacency_t adjacency; 286 287 // get the implemented connections 288 SphericalPointDistribution::adjacency_t expected = 289 SPD.getConnections<N>(); 290 291 // and compare the two 292 CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 293 } 294 295 /** UnitTest for getConnections() 296 */ 297 template <> 298 void SphericalPointDistributionTest_assistant::getConnectionTest<1>() 299 { 300 const int N=1; 301 SphericalPointDistribution SPD(1.); 302 303 // create empty adjacency 304 SphericalPointDistribution::adjacency_t adjacency; 305 306 // get the implemented connections 307 SphericalPointDistribution::adjacency_t expected = 308 SPD.getConnections<N>(); 309 310 // and compare the two 311 CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 312 } 313 314 /** UnitTest for getConnections() 315 */ 316 template <> 317 void SphericalPointDistributionTest_assistant::getConnectionTest<2>() 318 { 319 const int N=2; 320 SphericalPointDistribution SPD(1.); 321 322 // create empty adjacency 323 SphericalPointDistribution::adjacency_t adjacency; 324 adjacency += 325 make_pair< 326 unsigned int, 327 SphericalPointDistribution::IndexSet_t > 328 (0, list_of<unsigned int>(1)); 329 adjacency += 330 make_pair< 331 unsigned int, 332 SphericalPointDistribution::IndexSet_t > 333 (1, list_of<unsigned int>(0)); 334 335 // get the implemented connections 336 SphericalPointDistribution::adjacency_t expected = 337 SPD.getConnections<N>(); 338 339 // and compare the two 340 CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 341 341 } 342 342 … … 460 460 } 461 461 462 /** UnitTest for matchSphericalPointDistributions() with two points 463 */ 464 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2() 465 { 466 SphericalPointDistribution SPD(1.); 467 // test with one point, matching trivially 468 { 469 SphericalPointDistribution::WeightedPolygon_t polygon; 470 polygon += std::make_pair(Vector(1.,0.,0.), 1); 471 SphericalPointDistribution::Polygon_t newpolygon = 472 SPD.get<2>(); 473 SphericalPointDistribution::Polygon_t expected; 474 expected += Vector(-1.,0.,0.); 475 SphericalPointDistribution::Polygon_t remaining = 476 SphericalPointDistribution::matchSphericalPointDistributions( 477 polygon, 478 newpolygon); 479 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 480 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 481 } 482 483 // test with one point, just a flip of axis 484 { 485 SphericalPointDistribution::WeightedPolygon_t polygon; 486 polygon += std::make_pair( Vector(0.,1.,0.), 1); 487 SphericalPointDistribution::Polygon_t newpolygon = 488 SPD.get<2>(); 489 SphericalPointDistribution::Polygon_t expected; 490 expected += Vector(0.,-1.,0.); 491 SphericalPointDistribution::Polygon_t remaining = 492 SphericalPointDistribution::matchSphericalPointDistributions( 493 polygon, 494 newpolygon); 495 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 496 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 497 } 498 499 // test with one point, just a flip to another axis 500 { 501 SphericalPointDistribution::WeightedPolygon_t polygon; 502 polygon += std::make_pair( Vector(0.,0.,-1.), 1); 503 SphericalPointDistribution::Polygon_t newpolygon = 504 SPD.get<2>(); 505 SphericalPointDistribution::Polygon_t expected; 506 expected += Vector(0.,0.,1.); 507 SphericalPointDistribution::Polygon_t remaining = 508 SphericalPointDistribution::matchSphericalPointDistributions( 509 polygon, 510 newpolygon); 511 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 512 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 513 } 514 515 // test with one point, full rotation 516 { 517 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 518 SphericalPointDistribution::WeightedPolygon_t polygon; 519 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 520 SphericalPointDistribution::Polygon_t newpolygon = 521 SPD.get<2>(); 522 SphericalPointDistribution::Polygon_t expected; 523 expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 524 SphericalPointDistribution::Polygon_t remaining = 525 SphericalPointDistribution::matchSphericalPointDistributions( 526 polygon, 527 newpolygon); 528 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 529 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 530 } 531 } 532 462 533 /** UnitTest for matchSphericalPointDistributions() with three points 463 534 */ -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
r3678eb r6393ff 19 19 /********************************************** Test classes **************************************/ 20 20 21 class SphericalPointDistributionTest : public CppUnit::TestFixture 21 /** Template specialization needs to be in front of adding the test via CPPUNIT_TEST 22 * Hence,we put it in an extra class and inherit the functions. 23 */ 24 struct SphericalPointDistributionTest_assistant 22 25 { 26 public: 27 template <int N> 28 void getConnectionTest(); 29 }; 30 31 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<0>(); 32 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<1>(); 33 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<2>(); 34 35 #include "SphericalPointDistributionUnitTest_assistant.hpp" 36 37 class SphericalPointDistributionTest : 38 public CppUnit::TestFixture, 39 public SphericalPointDistributionTest_assistant 40 { 41 42 private: 23 43 CPPUNIT_TEST_SUITE( SphericalPointDistributionTest) ; 24 44 CPPUNIT_TEST( calculateCenterOfMinimumDistanceTest ); 25 45 CPPUNIT_TEST ( areEqualToWithinBoundsTest ); 26 46 CPPUNIT_TEST ( joinPointsTest ); 47 CPPUNIT_TEST ( getConnectionTest<0> ); 48 CPPUNIT_TEST ( getConnectionTest<1> ); 49 CPPUNIT_TEST ( getConnectionTest<2> ); 50 CPPUNIT_TEST ( getConnectionTest<3> ); 51 CPPUNIT_TEST ( getConnectionTest<4> ); 52 CPPUNIT_TEST ( getConnectionTest<5> ); 53 CPPUNIT_TEST ( getConnectionTest<6> ); 54 CPPUNIT_TEST ( getConnectionTest<7> ); 55 CPPUNIT_TEST ( getConnectionTest<8> ); 56 CPPUNIT_TEST ( getConnectionTest<9> ); 57 CPPUNIT_TEST ( getConnectionTest<10> ); 58 CPPUNIT_TEST ( getConnectionTest<11> ); 59 CPPUNIT_TEST ( getConnectionTest<12> ); 60 CPPUNIT_TEST ( getConnectionTest<14> ); 27 61 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 ); 28 62 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 ); … … 32 66 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_7 ); 33 67 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_8 ); 34 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple );68 // CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple ); 35 69 CPPUNIT_TEST_SUITE_END(); 36 70 -
src/Fragmentation/Makefile.am
r3678eb r6393ff 12 12 Fragmentation/Exporters/SaturationDistanceMaximizer.cpp \ 13 13 Fragmentation/Exporters/SphericalPointDistribution.cpp \ 14 Fragmentation/Exporters/SphericalPointDistribution_getConnections.cpp \ 14 15 Fragmentation/Exporters/SphericalPointDistribution_getPoints.cpp \ 15 16 Fragmentation/Homology/AtomFragmentsMap.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.