include "test.idp" load "Curvature" real t; real R = 1.; border axis(t=R,-R) {x=0; y=t; label=2;} border circle(t=pi/2,-pi/2) {x=R*cos(t); y=R*sin(t); label=1;} mesh Th = buildmesh(axis(10) + circle(-100)); fespace Vh(Th, P1); Vh c; { cout << functionDEFINITION << "Curvature" << endl; int[int] raxi = [1, 1, 1]; real courb; t = clock(); c[] = curvature(Th, 1); t = clock() - t; cout << timeELAPSED << t << endl; courb = c[].max; test(abs(courb - 1.) < 1.e-2); t = clock(); c[]=curvature(Th, raxi); t = clock() - t; cout << timeELAPSED << t << endl; courb = c[].max; test(abs(courb - 1.) < 1.e-2); cout << functionDEFINITION << "raxicurvature" << endl; t = clock(); c[]=raxicurvature(Th, 1); t = clock() - t; cout << timeELAPSED << t << endl; courb = c[].max; test(abs(courb - 2.) < 1.e-2); t = clock(); c[]=raxicurvature(Th, raxi); t = clock() - t; cout << timeELAPSED << t << endl; courb = c[].max; test(abs(courb - 2.) < 1.e-2); } cout << functionDEFINITION << "extractborder" << endl; { int[int] ll = [1, 2]; real[int, int] b12(1, 3); real l12, l; t = clock(); l12 = extractborder(Th, ll, b12); t = clock() - t; cout << timeELAPSED << t << endl; l = int1d(Th, 1, 2)(1.); test(abs(l - l12) < HWERROR); t = clock(); l12 = extractborder(Th, 1, b12); t = clock() - t; cout << timeELAPSED << t << endl; l = int1d(Th, 1)(1.); test(abs(l - l12) < HWERROR); } cout << functionDEFINITION << "curves" << endl; { real[int, int] raxi = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; t = clock(); curves(raxi, 1.); t = clock() - t; cout << timeELAPSED << t << endl; // TODO: usage ? } cout << functionDEFINITION << "setcurveabcisse" << endl; { int nsl = 10; real[int, int] SL(3, nsl); for (int i = 0; i < nsl; i++) { SL(0, i) = 0.1*i; SL(1, i) = 0.2*i; SL(2, i) = 0.3*(i+1); } t = clock(); real lgc = setcurveabcisse(SL); t = clock() - t; cout << timeELAPSED << t << endl; for (int i = 0; i < nsl; i++) test(SL(2, i) != 0.3*(i+1)); } cout << functionDEFINITION << "equiparameter" << endl; { int nsl = 100; real[int, int] SL(3, nsl); for (int i = 0; i < nsl; i++) { SL(0, i) = 0.1*i; SL(1, i) = 0.2*i; SL(2, i) = 0.3*(i+1); } real lgc = setcurveabcisse(SL); t = clock(); real[int, int] SL1 = equiparameter(SL, nsl); t = clock() - t; cout << timeELAPSED << t << endl; for (int i = 0; i < nsl; i++) test(SL1(2, i) != 0.3*(i+1)); } cout << functionDEFINITION << "Tresca" << endl; { real tresca; t = clock(); tresca = Tresca(10., 11., 12.); t = clock() - t; cout << timeELAPSED << t << endl; test(tresca == 0); t = clock(); tresca = Tresca(10., 11., 12., 13.); t = clock() - t; cout << timeELAPSED << t << endl; test(tresca == 13); t = clock(); tresca = Tresca(10., 11., 12., 13., 14., 15.); t = clock() - t; cout << timeELAPSED << t << endl; test(tresca == 0); // TODO non-sense code ? } cout << functionDEFINITION << "VonMises" << endl; { real vm; t = clock(); vm = VonMises(1., 2., 3.); t = clock() - t; cout << timeELAPSED << t << endl; test(vm == 0.); t = clock(); vm = VonMises(1., 2., 3., 4.); t = clock() - t; cout << timeELAPSED << t << endl; test(abs(vm - sqrt(8.)) < HWERROR); t = clock(); vm = VonMises(1., 2., 3., 4., 5., 6.); t = clock() - t; cout << timeELAPSED << t << endl; test(vm == 0.); // TODO non-sense code ? }