| 1 | #include <simgear/constants.h> |
| 2 | #include <simgear/structure/SGSharedPtr.hxx> |
| 3 | #include <simgear/math/SGVec3.hxx> |
| 4 | |
| 5 | #include "FDM/AIWake/AeroElement.hxx" |
| 6 | |
| 7 | #include "testAeroElement.hxx" |
| 8 | |
| 9 | |
| 10 | void AeroElementTests::testNormal() |
| 11 | { |
| 12 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 13 | SGVec3d(0., -0.5, 0.), |
| 14 | SGVec3d(0., 0.5, 0.), |
| 15 | SGVec3d(-1., 0.5, 0.)); |
| 16 | SGVec3d n = el->getNormal(); |
| 17 | CPPUNIT_ASSERT_DOUBLES_EQUAL(n[0], 0.0, 1e-9); |
| 18 | CPPUNIT_ASSERT_DOUBLES_EQUAL(n[1], 0.0, 1e-9); |
| 19 | CPPUNIT_ASSERT_DOUBLES_EQUAL(n[2], -1.0, 1e-9); |
| 20 | } |
| 21 | |
| 22 | void AeroElementTests::testCollocationPoint() |
| 23 | { |
| 24 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 25 | SGVec3d(0., -0.5, 0.), |
| 26 | SGVec3d(0., 0.5, 0.), |
| 27 | SGVec3d(-1., 0.5, 0.)); |
| 28 | SGVec3d cp = el->getCollocationPoint(); |
| 29 | CPPUNIT_ASSERT_DOUBLES_EQUAL(cp[0], -0.75, 1e-9); |
| 30 | CPPUNIT_ASSERT_DOUBLES_EQUAL(cp[1], 0.0, 1e-9); |
| 31 | CPPUNIT_ASSERT_DOUBLES_EQUAL(cp[2], 0.0, 1e-9); |
| 32 | } |
| 33 | |
| 34 | void AeroElementTests::testBoundVortexMidPoint() |
| 35 | { |
| 36 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 37 | SGVec3d(0., -0.5, 0.), |
| 38 | SGVec3d(0., 0.5, 0.), |
| 39 | SGVec3d(-1., 0.5, 0.)); |
| 40 | SGVec3d mp = el->getBoundVortexMidPoint(); |
| 41 | CPPUNIT_ASSERT_DOUBLES_EQUAL(mp[0], -0.25, 1e-9); |
| 42 | CPPUNIT_ASSERT_DOUBLES_EQUAL(mp[1], 0.0, 1e-9); |
| 43 | CPPUNIT_ASSERT_DOUBLES_EQUAL(mp[2], 0.0, 1e-9); |
| 44 | } |
| 45 | |
| 46 | void AeroElementTests::testBoundVortex() |
| 47 | { |
| 48 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 49 | SGVec3d(0., -0.5, 0.), |
| 50 | SGVec3d(0., 0.5, 0.), |
| 51 | SGVec3d(-1., 0.5, 0.)); |
| 52 | SGVec3d v = el->getBoundVortex(); |
| 53 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9); |
| 54 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 1.0, 1e-9); |
| 55 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 0.0, 1e-9); |
| 56 | } |
| 57 | |
| 58 | void AeroElementTests::testInducedVelocityOnBoundVortex() |
| 59 | { |
| 60 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 61 | SGVec3d(0., -0.5, 0.), |
| 62 | SGVec3d(0., 0.5, 0.), |
| 63 | SGVec3d(-1., 0.5, 0.)); |
| 64 | SGVec3d mp = el->getBoundVortexMidPoint(); |
| 65 | SGVec3d v = el->getInducedVelocity(mp); |
| 66 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9); |
| 67 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9); |
| 68 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 1.0/M_PI, 1e-9); |
| 69 | } |
| 70 | |
| 71 | void AeroElementTests::testInducedVelocityOnCollocationPoint() |
| 72 | { |
| 73 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 74 | SGVec3d(0., -0.5, 0.), |
| 75 | SGVec3d(0., 0.5, 0.), |
| 76 | SGVec3d(-1., 0.5, 0.)); |
| 77 | SGVec3d cp = el->getCollocationPoint(); |
| 78 | SGVec3d v = el->getInducedVelocity(cp); |
| 79 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9); |
| 80 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9); |
| 81 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], (1.0+sqrt(2.0)/M_PI), 1e-9); |
| 82 | } |
| 83 | |
| 84 | void AeroElementTests::testInducedVelocityAtFarField() |
| 85 | { |
| 86 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 87 | SGVec3d(0., -0.5, 0.), |
| 88 | SGVec3d(0., 0.5, 0.), |
| 89 | SGVec3d(-1., 0.5, 0.)); |
| 90 | SGVec3d mp = el->getBoundVortexMidPoint(); |
| 91 | SGVec3d v = el->getInducedVelocity(mp+SGVec3d(-1000.,0.,0.)); |
| 92 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9); |
| 93 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9); |
| 94 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 2.0/M_PI, 1e-7); |
| 95 | } |
| 96 | |
| 97 | void AeroElementTests::testInducedVelocityAbove() |
| 98 | { |
| 99 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 100 | SGVec3d(0., -0.5, 0.), |
| 101 | SGVec3d(0., 0.5, 0.), |
| 102 | SGVec3d(-1., 0.5, 0.)); |
| 103 | SGVec3d mp = el->getBoundVortexMidPoint(); |
| 104 | SGVec3d v = el->getInducedVelocity(mp+SGVec3d(0.,0.,-0.5)); |
| 105 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], -1.0/(sqrt(2.0)*M_PI), 1e-9); |
| 106 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9); |
| 107 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 0.5/M_PI, 1e-9); |
| 108 | } |
| 109 | |
| 110 | void AeroElementTests::testInducedVelocityAboveWithOffset() |
| 111 | { |
| 112 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 113 | SGVec3d(0., -0.5, 0.), |
| 114 | SGVec3d(0., 0.5, 0.), |
| 115 | SGVec3d(-1., 0.5, 0.)); |
| 116 | SGVec3d mp = el->getBoundVortexMidPoint(); |
| 117 | SGVec3d v = el->getInducedVelocity(mp+SGVec3d(0.0, 0.5, -1.0)); |
| 118 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], -1.0/(4.0*M_PI*sqrt(2.0)), 1e-9); |
| 119 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], -0.125/M_PI, 1e-9); |
| 120 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 0.125/M_PI, 1e-9); |
| 121 | } |
| 122 | |
| 123 | void AeroElementTests::testInducedVelocityUpstream() |
| 124 | { |
| 125 | AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.), |
| 126 | SGVec3d(0., -0.5, 0.), |
| 127 | SGVec3d(0., 0.5, 0.), |
| 128 | SGVec3d(-1., 0.5, 0.)); |
| 129 | SGVec3d mp = el->getBoundVortexMidPoint(); |
| 130 | SGVec3d v = el->getInducedVelocity(mp+SGVec3d(0.5, 0.0, 0.0)); |
| 131 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9); |
| 132 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9); |
| 133 | CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], (1.0-sqrt(2.0))/M_PI, 1e-9); |
| 134 | } |