Ignore:
Timestamp:
Sep 12, 2016, 11:48:36 PM (9 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, 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:
653cea
Parents:
2199c2
git-author:
Frederik Heber <heber@…> (06/29/14 21:20:49)
git-committer:
Frederik Heber <heber@…> (09/12/16 23:48:36)
Message:

Extracted joinPoints() function to make it accessible to tests.

  • added unit test.
  • moved some function definitions around and added documentation.
Location:
src/Fragmentation/Exporters/unittests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp

    r2199c2 r450adf  
    245245}
    246246
     247/** UnitTest for joinPoints()
     248 */
     249void SphericalPointDistributionTest::joinPointsTest()
     250{
     251  // test with simple configuration of three points
     252  {
     253    SphericalPointDistribution::Polygon_t newpolygon;
     254    newpolygon += Vector(1.,0.,0.);
     255    newpolygon += Vector(0.,1.,0.);
     256    newpolygon += Vector(0.,0.,1.);
     257    SphericalPointDistribution::Polygon_t expectedpolygon = newpolygon;
     258    SphericalPointDistribution::IndexTupleList_t matching;
     259    matching += SphericalPointDistribution::IndexList_t(1,0);
     260    matching += SphericalPointDistribution::IndexList_t(1,1);
     261    matching += SphericalPointDistribution::IndexList_t(1,2);
     262    SphericalPointDistribution::IndexList_t IndexList =
     263        SphericalPointDistribution::joinPoints(
     264            newpolygon,
     265            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
     266            matching);
     267    SphericalPointDistribution::IndexList_t expected;
     268    expected += 0,1,2;
     269    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
     270    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
     271  }
     272
     273  // test with simple configuration of three points, only two are picked
     274  {
     275    SphericalPointDistribution::Polygon_t newpolygon;
     276    newpolygon += Vector(1.,0.,0.);
     277    newpolygon += Vector(0.,1.,0.);
     278    newpolygon += Vector(0.,0.,1.);
     279    SphericalPointDistribution::Polygon_t expectedpolygon = newpolygon;
     280    SphericalPointDistribution::IndexTupleList_t matching;
     281    matching += SphericalPointDistribution::IndexList_t(1,1);
     282    matching += SphericalPointDistribution::IndexList_t(1,2);
     283    SphericalPointDistribution::IndexList_t IndexList =
     284        SphericalPointDistribution::joinPoints(
     285            newpolygon,
     286            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
     287            matching);
     288    SphericalPointDistribution::IndexList_t expected;
     289    expected += 1,2;
     290    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
     291    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
     292  }
     293
     294  // test with simple configuration of three points, two are joined
     295  {
     296    SphericalPointDistribution::Polygon_t newpolygon;
     297    newpolygon += Vector(1.,0.,0.);
     298    newpolygon += Vector(0.,1.,0.);
     299    newpolygon += Vector(0.,0.,1.);
     300    SphericalPointDistribution::Polygon_t expectedpolygon;
     301    expectedpolygon += Vector(1.,0.,0.);
     302    expectedpolygon += Vector(0.,M_SQRT1_2,M_SQRT1_2);
     303    SphericalPointDistribution::IndexTupleList_t matching;
     304    SphericalPointDistribution::IndexList_t joined;
     305    joined += 1,2;
     306    matching += SphericalPointDistribution::IndexList_t(1,0);
     307    matching += joined;
     308    SphericalPointDistribution::IndexList_t IndexList =
     309        SphericalPointDistribution::joinPoints(
     310            newpolygon,
     311            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
     312            matching);
     313    SphericalPointDistribution::IndexList_t expected;
     314    expected += 0,1;
     315    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
     316    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
     317  }
     318
     319  // test with simple configuration of six points, two are joined, jumbled indices
     320  {
     321    SphericalPointDistribution::Polygon_t newpolygon;
     322    newpolygon += Vector(1.,0.,1.);
     323    newpolygon += Vector(1.,0.,0.);
     324    newpolygon += Vector(1.,1.,0.);
     325    newpolygon += Vector(0.,1.,0.);
     326    newpolygon += Vector(0.,0.,1.);
     327    newpolygon += Vector(1.,0.,1.);
     328    SphericalPointDistribution::Polygon_t expectedpolygon;
     329    expectedpolygon += Vector(1.,0.,1.);
     330    expectedpolygon += Vector(1.,0.,0.);
     331    expectedpolygon += Vector(1.,1.,0.);
     332    expectedpolygon += Vector(1.,0.,1.);
     333    expectedpolygon += Vector(0.,M_SQRT1_2,M_SQRT1_2); // new centers go last
     334    SphericalPointDistribution::IndexTupleList_t matching;
     335    SphericalPointDistribution::IndexList_t joined;
     336    joined += 3,4;
     337    matching += SphericalPointDistribution::IndexList_t(1,1);
     338    matching += joined;
     339    SphericalPointDistribution::IndexList_t IndexList =
     340        SphericalPointDistribution::joinPoints(
     341            newpolygon,
     342            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
     343            matching);
     344    SphericalPointDistribution::IndexList_t expected;
     345    expected += 1,4;
     346    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
     347    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
     348  }
     349}
    247350
    248351/** UnitTest for matchSphericalPointDistributions() with three points
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp

    r2199c2 r450adf  
    2323    CPPUNIT_TEST_SUITE( SphericalPointDistributionTest) ;
    2424    CPPUNIT_TEST ( areEqualToWithinBoundsTest );
     25    CPPUNIT_TEST ( joinPointsTest );
    2526    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 );
    2627    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 );
     
    3637      void tearDown();
    3738      void areEqualToWithinBoundsTest();
     39      void joinPointsTest();
    3840      void matchSphericalPointDistributionsTest_2();
    3941      void matchSphericalPointDistributionsTest_3();
Note: See TracChangeset for help on using the changeset viewer.