#include #include #include "JAcoustics/JGeometry.hh" #include "JAcoustics/JModel.hh" #include "JTools/JQuantile.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * Test application for acoustics geometry. */ int main(int argc, char **argv) { using namespace std; using namespace JPP; double precision; int debug; try { JParser<> zap("Test application for acoustics geometry."); zap['e'] = make_field(precision) = 1e-6; zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } // build string const double x0 = 100.0; const double y0 = 100.0; const double z0 = 0.0; const double z1 = 80.0; const double dz = 36.0; const int N = 18; JGEOMETRY::JString string(JPosition3D(x0, y0, z0)); string.mechanics.a = 0.00090; string.mechanics.b = 400.0; string[0] = JGEOMETRY::JFloor(z0); for (int i = 1; i <= N; ++i) { string[i] = JGEOMETRY::JFloor(z1 + (i - 1)*dz); } const double tx = +1.0e-2; const double ty = -1.0e-2; const double dtx = +1.0e-9; const double dty = -1.0e-9; const double dtx2 = +1.0e-9; const double dty2 = -1.0e-9; const double dvs = 1.0e-6; JMODEL::JString parameters[] = { JMODEL::JString(tx, ty, 0.0, 0.0, 0.0), // reference JMODEL::JString(dtx, dty, dtx2, dty2, dvs), // difference JMODEL::JString(tx + dtx, ty + dty, dtx2, dty2, dvs) // new }; DEBUG("Reference positions / differences:" << endl); for (int i = 1; i <= N; ++i) { JPosition3D pos[] = { string.getPosition(parameters[0], i), string.getPosition(parameters[2], i) }; DEBUG("" << setw(2) << i << ' ' << FIXED(7,3) << pos[0].getX() << ' ' << FIXED(7,3) << pos[0].getY() << ' ' << FIXED(7,3) << pos[0].getZ() << ' ' << FIXED(13,10) << pos[0].getX() - pos[1].getX() << ' ' << FIXED(13,10) << pos[0].getY() - pos[1].getY() << ' ' << FIXED(13,10) << pos[0].getZ() - pos[1].getZ() << endl); } for (const JVector3D& pos : { JVector3D( -500.0, +500.0, 0.0), JVector3D( +100.0, +100.0, 0.0), JVector3D(+1000.0, -1000.0, 0.0) }) { JQuantile Q; for (int i = 1; i <= N; ++i) { const JMODEL::JString gradient = string.getGradient(parameters[0], pos, i); const double D[] = { string.getDistance(parameters[0], pos, i), string.getDistance(parameters[2], pos, i) }; const double dot = gradient.getDot(parameters[1]); DEBUG("distance: " << setw(2) << i << ' ' << FIXED(9,3) << D[0] << ' ' << FIXED(12,9) << D[1] - D[0] << ' ' << FIXED(10,7) << gradient.tx << ' ' << FIXED(10,7) << gradient.ty << ' ' << FIXED(10,1) << gradient.tx2 << ' ' << FIXED(10,1) << gradient.ty2 << ' ' << FIXED(8,3) << gradient.vs << ' ' << FIXED(12,9) << dot << ' ' << endl); Q.put(D[1] - (D[0] + dot)); ASSERT(fabs(D[1] - (D[0] + dot)) <= precision, "Test of distance from gradient."); } Q.print(cout); } return 0; }