2017-06-10 16:27:19 +00:00
|
|
|
#include <simgear/constants.h>
|
|
|
|
#include <simgear/structure/SGSharedPtr.hxx>
|
|
|
|
#include <simgear/math/SGVec3.hxx>
|
|
|
|
|
|
|
|
#include "FDM/AIWake/AeroElement.hxx"
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
#include "testAeroElement.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
void AeroElementTests::testNormal()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d n = el->getNormal();
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(n[0], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(n[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(n[2], -1.0, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testCollocationPoint()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d cp = el->getCollocationPoint();
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(cp[0], -0.75, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(cp[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(cp[2], 0.0, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testBoundVortexMidPoint()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d mp = el->getBoundVortexMidPoint();
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(mp[0], -0.25, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(mp[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(mp[2], 0.0, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testBoundVortex()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d v = el->getBoundVortex();
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 1.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 0.0, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testInducedVelocityOnBoundVortex()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d mp = el->getBoundVortexMidPoint();
|
|
|
|
SGVec3d v = el->getInducedVelocity(mp);
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 1.0/M_PI, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testInducedVelocityOnCollocationPoint()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d cp = el->getCollocationPoint();
|
|
|
|
SGVec3d v = el->getInducedVelocity(cp);
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], (1.0+sqrt(2.0)/M_PI), 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testInducedVelocityAtFarField()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d mp = el->getBoundVortexMidPoint();
|
|
|
|
SGVec3d v = el->getInducedVelocity(mp+SGVec3d(-1000.,0.,0.));
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 2.0/M_PI, 1e-7);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testInducedVelocityAbove()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d mp = el->getBoundVortexMidPoint();
|
|
|
|
SGVec3d v = el->getInducedVelocity(mp+SGVec3d(0.,0.,-0.5));
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], -1.0/(sqrt(2.0)*M_PI), 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 0.5/M_PI, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testInducedVelocityAboveWithOffset()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d mp = el->getBoundVortexMidPoint();
|
|
|
|
SGVec3d v = el->getInducedVelocity(mp+SGVec3d(0.0, 0.5, -1.0));
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], -1.0/(4.0*M_PI*sqrt(2.0)), 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], -0.125/M_PI, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], 0.125/M_PI, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 20:15:13 +00:00
|
|
|
void AeroElementTests::testInducedVelocityUpstream()
|
2017-06-10 16:27:19 +00:00
|
|
|
{
|
|
|
|
AeroElement_ptr el = new AeroElement(SGVec3d(-1., -0.5, 0.),
|
|
|
|
SGVec3d(0., -0.5, 0.),
|
|
|
|
SGVec3d(0., 0.5, 0.),
|
|
|
|
SGVec3d(-1., 0.5, 0.));
|
|
|
|
SGVec3d mp = el->getBoundVortexMidPoint();
|
|
|
|
SGVec3d v = el->getInducedVelocity(mp+SGVec3d(0.5, 0.0, 0.0));
|
2018-06-06 20:15:13 +00:00
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[1], 0.0, 1e-9);
|
|
|
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(v[2], (1.0-sqrt(2.0))/M_PI, 1e-9);
|
2017-06-10 16:27:19 +00:00
|
|
|
}
|