diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2001-09-12 16:46:58 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2001-09-12 16:46:58 +0000 |
commit | 2a37ecbdc7119e2ae7de3ce10561c6aec7169a71 (patch) | |
tree | 5036f089af2e5c5634d054e3ac6398587c2e83e0 /src/patch/test_patch_system.cc | |
parent | dd1b26349f1507ef961565c9b94efe695c8d5313 (diff) |
allow selection of which gridfn to print; also echo command line args
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@319 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/patch/test_patch_system.cc')
-rw-r--r-- | src/patch/test_patch_system.cc | 162 |
1 files changed, 97 insertions, 65 deletions
diff --git a/src/patch/test_patch_system.cc b/src/patch/test_patch_system.cc index b3715ea..91a3edb 100644 --- a/src/patch/test_patch_system.cc +++ b/src/patch/test_patch_system.cc @@ -109,36 +109,50 @@ Usage:\n\ interpolator_order\n\ { fn | ghost-zone\ | deriv.{fn|rho|sigma|rho.rho|rho.sigma|sigma.sigma|all} }\n\ + [ fn | ghosted-fn | deriv-fd | deriv-analytic | error ]\n\ \n\ This program tests patch_system:: and its subsidiary classes. After\n\ -creating a patch system specified by the first N-1 arguments, it does\n\ -the test specified by the last argument:\n\ -\n\ +creating a patch system specified by the first 5 arguments, it does\n\ +the test specified by the 6th argument:\n\ fn\n\ - Set up a test function on the ghosted grid with symmetry just matching\n\ - that of the patch system, then print it out\n\ -\n\ + Test gridfn storage, indexing, and coordinates:\n\ + * set up a test function on the ghosted grid with symmetry just matching\n\ + that of the patch system + * [default] print the gridfn\n\ ghost-zone\n\ - tests extending a gridfn to ghost zones\n\ + Test extending a gridfn to ghost zones:\n\ * set up test function on the nominal grid with symmetry just matching\n\ that of the patch system\n\ * call patch_system::extend_scalar_gridfn_to_all_ghost_zones()\n\ * set up the same test function on the ghosted grid\n\ * compute error\n\ - * print the error\n\ -\n\ + * [default] print the error\n\ deriv.*\n\ - tests finite differencing\n\ + Test finite differencing:\n\ * set up a test function (separately specified as fn(rho,sigma)\n\ for each patch) on the ghosted grid\n\ * compute specified linear combination of finite differences\n\ * compute specified linear combination of true analytical derivatives\n\ * compute error\n\ - * print the error\n\ + * [default] print the error\n\ +\n\ +The optional last (7th) argument specifies which gridfn to print; for\n\ +each test this has the default given above.\n\ "; + +// gridfn numbers +static const int gfn_min = -1; +static const int gfn_max = 2; +static const int gfn_fn = -1; // common to all tests +static const int gfn_ghosted_fn = 0; // for ghost-zone setup tests +static const int gfn_deriv_fd = 0; // for finite diff tests +static const int gfn_deriv_analytic = 1; // for finite diff tests +static const int gfn_error = 2; // for finite diff tests + + // -// ***** command line arguments ***** +// ***** command line parsing ***** // if ((argc == 2) && STRING_EQUAL(argv[1], "--help")) @@ -147,7 +161,7 @@ if ((argc == 2) && STRING_EQUAL(argv[1], "--help")) return 0; /*NOTREACHED*/ } -if (! ((argc == 6) || (argc == 7)) ) +if (! ((argc == 7) || (argc == 8)) ) then error_exit(ERROR_EXIT, "%s", help_msg); /*NOTREACHED*/ enum patch_system::patch_system_type type; @@ -174,51 +188,77 @@ if (! ( (sscanf(argv[2], "%d", &N_ghost_points) == 1) enum {test_fn, test_ghost_zone, test_deriv} which_test; int which_derivs; +int gfn_to_print = gfn_error; +if (STRING_EQUAL(argv[6], "fn")) + then { + which_test = test_fn; + gfn_to_print = gfn_fn; + } +else if (STRING_EQUAL(argv[6], "ghost-zone")) + then which_test = test_ghost_zone; +else if (STRING_EQUAL(argv[6], "deriv.fn")) + then { + which_test = test_deriv; + which_derivs = which_deriv_fn; + } +else if (STRING_EQUAL(argv[6], "deriv.rho")) + then { + which_test = test_deriv; + which_derivs = which_deriv_rho; + } +else if (STRING_EQUAL(argv[6], "deriv.sigma")) + then { + which_test = test_deriv; + which_derivs = which_deriv_sigma; + } +else if (STRING_EQUAL(argv[6], "deriv.rho.rho")) + then { + which_test = test_deriv; + which_derivs = which_deriv_rho_rho; + } +else if (STRING_EQUAL(argv[6], "deriv.rho.sigma")) + then { + which_test = test_deriv; + which_derivs = which_deriv_rho_sigma; + } +else if (STRING_EQUAL(argv[6], "deriv.sigma.sigma")) + then { + which_test = test_deriv; + which_derivs = which_deriv_sigma_sigma; + } +else if (STRING_EQUAL(argv[6], "deriv.all")) + then { + which_test = test_deriv; + which_derivs = which_deriv_all; + } +else error_exit(ERROR_EXIT, "%s", help_msg); /*NOTREACHED*/ -if (argc >= 7) +if (argc >= 8) then { - if (STRING_EQUAL(argv[6], "fn")) - then which_test = test_fn; - else if (STRING_EQUAL(argv[6], "ghost-zone")) - then which_test = test_ghost_zone; - else if (STRING_EQUAL(argv[6], "deriv.fn")) - then { - which_test = test_deriv; - which_derivs = which_deriv_fn; - } - else if (STRING_EQUAL(argv[6], "deriv.rho")) - then { - which_test = test_deriv; - which_derivs = which_deriv_rho; - } - else if (STRING_EQUAL(argv[6], "deriv.sigma")) - then { - which_test = test_deriv; - which_derivs = which_deriv_sigma; - } - else if (STRING_EQUAL(argv[6], "deriv.rho.rho")) - then { - which_test = test_deriv; - which_derivs = which_deriv_rho_rho; - } - else if (STRING_EQUAL(argv[6], "deriv.rho.sigma")) - then { - which_test = test_deriv; - which_derivs = which_deriv_rho_sigma; - } - else if (STRING_EQUAL(argv[6], "deriv.sigma.sigma")) - then { - which_test = test_deriv; - which_derivs = which_deriv_sigma_sigma; - } - else if (STRING_EQUAL(argv[6], "deriv.all")) - then { - which_test = test_deriv; - which_derivs = which_deriv_all; - } - else error_exit(ERROR_EXIT, "%s", help_msg); /*NOTREACHED*/ + if (STRING_EQUAL(argv[7], "fn")) + then gfn_to_print = gfn_fn; + else if (STRING_EQUAL(argv[7], "ghosted-fn")) + then gfn_to_print = gfn_ghosted_fn; + else if (STRING_EQUAL(argv[7], "deriv-fd")) + then gfn_to_print = gfn_deriv_fd; + else if (STRING_EQUAL(argv[7], "deriv-analytic")) + then gfn_to_print = gfn_deriv_analytic; + else if (STRING_EQUAL(argv[7], "error")) + then gfn_to_print = gfn_error; } +// +// ***** end of command line parsing ***** +// + + +printf("##"); + for (int ap < 0 ; ap < argc ; ++ap) + { + printf("%s", argv[ap]); + } +printf("\n"); + fp origin_x = 0.314, origin_y = 0.159, origin_z = 0.265; switch (type) { @@ -245,14 +285,6 @@ default: } printf("## creating patch_system...\n"); -// what gridfns will we use -static const int gfn_min = -1; -static const int gfn_max = 2; -static const int gfn_fn = -1; // common to all tests -static const int gfn_ghosted_fn = 0; // for ghost-zone setup tests -static const int gfn_deriv_fd = 0; // for finite diff tests -static const int gfn_deriv_analytic = 1; // for finite diff tests -static const int gfn_error = 2; // for finite diff tests patch_system ps(origin_x, origin_y, origin_z, type, N_ghost_points, N_overlap_points, delta_drho_dsigma, @@ -263,7 +295,7 @@ switch (which_test) { case test_fn: setup_fn_xyz(ps, gfn_fn, true); - ps.print_gridfn(gfn_fn, true); + ps.print_gridfn(gfn_to_print, true); break; case test_ghost_zone: @@ -271,7 +303,7 @@ case test_ghost_zone: ps.extend_scalar_gridfn_to_all_ghost_zones(gfn_fn); setup_fn_xyz(ps, gfn_ghosted_fn, true); gridfn_minus(ps, gfn_fn, gfn_ghosted_fn, gfn_error, true); - ps.print_gridfn(gfn_error, true); + ps.print_gridfn(gfn_to_print, true); break; case test_deriv: @@ -279,7 +311,7 @@ case test_deriv: finite_diff(ps, gfn_fn, gfn_deriv_fd, which_derivs); analytic_derivs(ps, gfn_deriv_analytic, which_derivs); gridfn_minus(ps, gfn_deriv_fd, gfn_deriv_analytic, gfn_error, false); - ps.print_gridfn(gfn_error, false); + ps.print_gridfn(gfn_to_print, false); break; } } |