Changeset 77968a for test/unit_test
- Timestamp:
- Feb 16, 2017, 8:47:08 PM (9 years ago)
- 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)
- Location:
- test/unit_test
- Files:
-
- 1 added
- 2 edited
-
Makefile.am (modified) (3 diffs)
-
unit_test/interpolate_field_test.cpp (added)
-
unit_test/interpolate_test.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/unit_test/Makefile.am
rd192f69 r77968a 25 25 26 26 BOOSTTESTS = \ 27 InterpolateSuite \ 28 InterpolateFieldSuite \ 27 29 LibraryDirichletFASLRTest \ 28 30 LibraryDirichletCSTest \ … … 37 39 LibraryOpenFASMPITest \ 38 40 LibraryDirichletFASMPITest \ 39 InterpolateSuite \40 41 LibraryForceSinusUnitTest \ 41 42 SmootherGSLexTest \ … … 126 127 InterpolateSuite_LDFLAGS = $(AM_LDFLAGS) 127 128 InterpolateSuite_LDADD = $(TESTLIBS) 129 InterpolateFieldSuite_SOURCES = \ 130 unit_test/boost_test.cpp \ 131 unit_test/unit_test/interpolate_field_test.cpp 132 InterpolateFieldSuite_CPPFLAGS=$(AM_CPPFLAGS) 133 InterpolateFieldSuite_LDFLAGS = $(AM_LDFLAGS) 134 InterpolateFieldSuite_LDADD = $(TESTLIBS) 128 135 LibraryForceSinusUnitTest_SOURCES = \ 129 136 unit_test/boost_test.cpp \ -
test/unit_test/unit_test/interpolate_test.cpp
rd192f69 r77968a 54 54 InterpolateFixture() 55 55 { 56 grid = new TempGrid( 64, 5, 0.0, 1.0);56 grid = new TempGrid(32, 3, 0.0, 1.0); 57 57 58 58 Index i; … … 99 99 p.Pos() += 0.5 * grid->Extent().MeshWidth(); 100 100 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)); 102 102 103 103 } … … 105 105 } 106 106 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 162 107 BOOST_AUTO_TEST_SUITE_END()
Note:
See TracChangeset
for help on using the changeset viewer.
