Changeset 3f6604
- Timestamp:
- Sep 6, 2015, 10:27:54 PM (10 years ago)
- Children:
- 199fe3
- Parents:
- b303d0
- git-author:
- Frederik Heber <heber@…> (03/13/15 15:03:26)
- git-committer:
- Frederik Heber <heber@…> (09/06/15 22:27:54)
- File:
-
- 1 edited
-
test/unit_test/unit_test/interpolate_test.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/unit_test/unit_test/interpolate_test.cpp
rb303d0 r3f6604 34 34 using namespace VMG; 35 35 36 const vmg_float sine_factor = 2.0 * Math::pi;36 const Vector sine_factor(1.5 * Math::pi, 3.7 * Math::pi, 2.213 * Math::pi); 37 37 38 38 static inline vmg_float f(const Vector& pos) 39 39 { 40 return std::sin(sine_factor *pos.X())41 * std::sin(sine_factor *pos.Y())42 * std::sin(sine_factor *pos.Z());40 return std::sin(sine_factor[0]*pos.X()) 41 * std::sin(sine_factor[1]*pos.Y()) 42 * std::sin(sine_factor[2]*pos.Z()); 43 43 } 44 44 45 /*46 45 static inline Vector grad_f(const Vector& pos) 47 46 { 48 return -1.0 * sine_factor * Vector(std::cos(sine_factor *pos.X()) * std::sin(sine_factor*pos.Y()) * std::sin(sine_factor*pos.Z()),49 std::sin(sine_factor *pos.X()) * std::cos(sine_factor*pos.Y()) * std::sin(sine_factor*pos.Z()),50 std::sin(sine_factor *pos.X()) * std::sin(sine_factor*pos.Y()) * std::cos(sine_factor*pos.Z()));47 return -1.0 * sine_factor * Vector(std::cos(sine_factor[0]*pos.X()) * std::sin(sine_factor[1]*pos.Y()) * std::sin(sine_factor[2]*pos.Z()), 48 std::sin(sine_factor[0]*pos.X()) * std::cos(sine_factor[1]*pos.Y()) * std::sin(sine_factor[2]*pos.Z()), 49 std::sin(sine_factor[0]*pos.X()) * std::sin(sine_factor[1]*pos.Y()) * std::cos(sine_factor[2]*pos.Z())); 51 50 } 52 */53 51 54 52 struct InterpolateFixture … … 101 99 p.Pos() += 0.5 * grid->Extent().MeshWidth(); 102 100 ip.Evaluate(p); 103 BOOST_CHECK_SMALL(p.Pot() - f(p.Pos()), vmg_float(1.0e- 7));101 BOOST_CHECK_SMALL(p.Pot() - f(p.Pos()), vmg_float(1.0e-6)); 104 102 105 103 } … … 107 105 } 108 106 109 /*110 107 BOOST_AUTO_TEST_CASE(InterpolateFieldTest) 111 108 { … … 115 112 Particle::Particle p; 116 113 117 vmg_float max_error = 0.0;114 vmg_float max_error = std::numeric_limits<vmg_float>::min(); 118 115 119 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())) … … 130 127 ip.Evaluate(p); 131 128 132 for (int j=0; j<3; ++j) 133 max_error = std::max(max_error, p.Field()[j] - grad_f(p.Pos())[j]); 134 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 } 135 134 } 136 135 137 std::printf("Max error: %e\n", max_error);136 std::printf("Max rel. error: %e\n", max_error); 138 137 138 max_error = std::numeric_limits<vmg_float>::min(); 139 139 p.Pos().X() = 0.25; 140 140 p.Pos().Y() = 0.25; … … 149 149 150 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 } 151 157 } 158 std::printf("Max rel. error moving along z: %e\n", max_error); 152 159 } 153 */ 160 154 161 155 162 BOOST_AUTO_TEST_SUITE_END()
Note:
See TracChangeset
for help on using the changeset viewer.
