Changeset 77968a for test/unit_test


Ignore:
Timestamp:
Feb 16, 2017, 8:47:08 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
5ff454
Parents:
d192f69
git-author:
Frederik Heber <heber@…> (02/16/17 20:47:04)
git-committer:
Frederik Heber <heber@…> (02/16/17 20:47:08)
Message:

Split up InterpolateSuite into two tests and toned down grid size.

  • toned down check precisions as well.
Location:
test/unit_test
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • test/unit_test/Makefile.am

    rd192f69 r77968a  
    2525
    2626BOOSTTESTS = \
     27        InterpolateSuite \
     28        InterpolateFieldSuite \
    2729        LibraryDirichletFASLRTest \
    2830        LibraryDirichletCSTest \
     
    3739        LibraryOpenFASMPITest \
    3840        LibraryDirichletFASMPITest \
    39         InterpolateSuite \
    4041        LibraryForceSinusUnitTest \
    4142        SmootherGSLexTest \
     
    126127InterpolateSuite_LDFLAGS = $(AM_LDFLAGS)
    127128InterpolateSuite_LDADD = $(TESTLIBS)
     129InterpolateFieldSuite_SOURCES = \
     130        unit_test/boost_test.cpp \
     131        unit_test/unit_test/interpolate_field_test.cpp
     132InterpolateFieldSuite_CPPFLAGS=$(AM_CPPFLAGS)
     133InterpolateFieldSuite_LDFLAGS = $(AM_LDFLAGS)
     134InterpolateFieldSuite_LDADD = $(TESTLIBS)
    128135LibraryForceSinusUnitTest_SOURCES = \
    129136        unit_test/boost_test.cpp \
  • test/unit_test/unit_test/interpolate_test.cpp

    rd192f69 r77968a  
    5454  InterpolateFixture()
    5555  {
    56     grid = new TempGrid(64, 5, 0.0, 1.0);
     56    grid = new TempGrid(32, 3, 0.0, 1.0);
    5757
    5858    Index i;
     
    9999        p.Pos() += 0.5 * grid->Extent().MeshWidth();
    100100        ip.Evaluate(p);
    101         BOOST_CHECK_SMALL(p.Pot() - f(p.Pos()), vmg_float(1.0e-6));
     101        BOOST_CHECK_SMALL(p.Pot() - f(p.Pos()), vmg_float(1.0e-4));
    102102
    103103      }
     
    105105}
    106106
    107 BOOST_AUTO_TEST_CASE(InterpolateFieldTest)
    108 {
    109   Index i;
    110   Index i_old = -1;
    111   Particle::Interpolation ip(5);
    112   Particle::Particle p;
    113 
    114   vmg_float max_error = std::numeric_limits<vmg_float>::min();
    115 
    116   for(p.Pos().X()=grid->Extent().Begin().X(); p.Pos().X()<grid->Extent().End().X(); p.Pos().X() += 0.01 * (grid->Extent().End().X() - grid->Extent().Begin().X()))
    117     for(p.Pos().Y()=grid->Extent().Begin().Y(); p.Pos().Y()<grid->Extent().End().Y(); p.Pos().Y() += 0.01 * (grid->Extent().End().Y() - grid->Extent().Begin().Y()))
    118       for(p.Pos().Z()=grid->Extent().Begin().Z(); p.Pos().Z()<grid->Extent().End().Z(); p.Pos().Z() += 0.01 * (grid->Extent().End().Z() - grid->Extent().Begin().Z())) {
    119 
    120         i = (p.Pos()-grid->Extent().Begin())/grid->Extent().MeshWidth()-grid->Global().LocalBegin()+grid->Local().Begin();
    121 
    122         if (i != i_old) {
    123           ip.ComputeCoefficients(*grid, i);
    124           i_old = i;
    125         }
    126 
    127         ip.Evaluate(p);
    128 
    129         for (int j=0; j<3; ++j) {
    130           BOOST_CHECK_SMALL(p.Field()[j] - grad_f(p.Pos())[j], vmg_float(1.0e-4));
    131           if (fabs(grad_f(p.Pos())[j]) > 1e-10)
    132                 max_error = std::max(max_error, fabs((p.Field()[j] - grad_f(p.Pos())[j])/grad_f(p.Pos())[j]));
    133         }
    134       }
    135 
    136   std::printf("Max rel. error: %e\n", max_error);
    137 
    138   max_error = std::numeric_limits<vmg_float>::min();
    139   p.Pos().X() = 0.25;
    140   p.Pos().Y() = 0.25;
    141   for(p.Pos().Z()=0.25; p.Pos().Z()<0.75; p.Pos().Z() += 0.001) {
    142 
    143     i = (p.Pos()-grid->Extent().Begin())/grid->Extent().MeshWidth()-grid->Global().LocalBegin()+grid->Local().Begin();
    144 
    145     if (i != i_old) {
    146       ip.ComputeCoefficients(*grid, i);
    147       i_old = i;
    148     }
    149 
    150     ip.Evaluate(p);
    151 
    152     for (int j=0; j<3; ++j) {
    153           BOOST_CHECK_SMALL(p.Field()[j] - grad_f(p.Pos())[j], vmg_float(1.0e-4));
    154       if (fabs(grad_f(p.Pos())[j]) > 1e-10)
    155         max_error = std::max(max_error, fabs((p.Field()[j] - grad_f(p.Pos())[j])/grad_f(p.Pos())[j]));
    156     }
    157   }
    158   std::printf("Max rel. error moving along z: %e\n", max_error);
    159 }
    160 
    161 
    162107BOOST_AUTO_TEST_SUITE_END()
Note: See TracChangeset for help on using the changeset viewer.