diff options
Diffstat (limited to 'src/patch/patch_system.cc')
-rw-r--r-- | src/patch/patch_system.cc | 229 |
1 files changed, 115 insertions, 114 deletions
diff --git a/src/patch/patch_system.cc b/src/patch/patch_system.cc index ec80133..dcc54c4 100644 --- a/src/patch/patch_system.cc +++ b/src/patch/patch_system.cc @@ -1151,6 +1151,7 @@ void patch_system::synchronize(int ghosted_min_gfn_to_sync, // void patch_system::compute_synchronize_Jacobian(int ghosted_min_gfn_to_sync, int ghosted_max_gfn_to_sync) + const { for (int pn = 0 ; pn < N_patches() ; ++pn) { @@ -1227,89 +1228,89 @@ return xgz.Jacobian(x_iperp, x_ipar, y_ipar_m); // specified (unknown-grid) radius gridfn. // void patch_system::print_unknown_gridfn -(bool ghosted_flag, int unknown_gfn, - bool print_xyz_flag, bool radius_is_ghosted_flag, - int unknown_radius_gfn, - const char output_file_name[], bool want_ghost_zones) -const + (bool ghosted_flag, int unknown_gfn, + bool print_xyz_flag, bool radius_is_ghosted_flag, + int unknown_radius_gfn, + const char output_file_name[], bool want_ghost_zones) + const { if (want_ghost_zones && !ghosted_flag) -then error_exit(PANIC_EXIT, + then error_exit(PANIC_EXIT, "***** patch_system::print_unknown_gridfn(unknown_gfn=%d):\n" " can't have want_ghost_zones && !ghosted_flag !\n" , - unknown_gfn); /*NOTREACHED*/ + unknown_gfn); /*NOTREACHED*/ if (want_ghost_zones && print_xyz_flag && !radius_is_ghosted_flag) -then error_exit(PANIC_EXIT, + then error_exit(PANIC_EXIT, "***** patch_system::print_unknown_gridfn(unknown_gfn=%d):\n" " can't have want_ghost_zones && print_xyz_flag\n" " && !radius_is_ghosted_flag!\n" " unknown_radius_gfn=%d\n" , - unknown_gfn, - unknown_radius_gfn); /*NOTREACHED*/ + unknown_gfn, + unknown_radius_gfn); /*NOTREACHED*/ FILE *output_fp = std::fopen(output_file_name, "w"); if (output_fp == NULL) -then error_exit(ERROR_EXIT, + then error_exit(ERROR_EXIT, "***** patch_system::print_unknown_gridfn(unknown_gfn=%d):\n" " can't open output file \"%s\"\n!" , - unknown_gfn, - output_file_name); /*NOTREACHED*/ - -for (int pn = 0 ; pn < N_patches() ; ++pn) -{ -const patch& p = ith_patch(pn); - -fprintf(output_fp, "### %s patch\n", p.name()); -fprintf(output_fp, "# %s_gfn=%d\n", - (ghosted_flag ? "ghosted" : "nominal"), unknown_gfn); -fprintf(output_fp, "# dpx = %s\n", p.name_of_dpx()); -fprintf(output_fp, "# dpy = %s\n", p.name_of_dpy()); -fprintf(output_fp, "#\n"); -fprintf(output_fp, - print_xyz_flag - ? "# dpx\tdpy\tgridfn\tglobal_x\tglobal_y\tglobal_z\n" - : "# dpx\tdpy\tgridfn\n"); + unknown_gfn, + output_file_name); /*NOTREACHED*/ - for (int irho = p.effective_min_irho(want_ghost_zones) ; - irho <= p.effective_max_irho(want_ghost_zones) ; - ++irho) - { - for (int isigma = p.effective_min_isigma(want_ghost_zones) ; - isigma <= p.effective_max_isigma(want_ghost_zones) ; - ++isigma) + for (int pn = 0 ; pn < N_patches() ; ++pn) { - const fp rho = p.rho_of_irho(irho); - const fp sigma = p.sigma_of_isigma(isigma); - const fp dpx = p.dpx_of_rho_sigma(rho, sigma); - const fp dpy = p.dpy_of_rho_sigma(rho, sigma); + const patch& p = ith_patch(pn); + + fprintf(output_fp, "### %s patch\n", p.name()); + fprintf(output_fp, "# %s_gfn=%d\n", + (ghosted_flag ? "ghosted" : "nominal"), unknown_gfn); + fprintf(output_fp, "# dpx = %s\n", p.name_of_dpx()); + fprintf(output_fp, "# dpy = %s\n", p.name_of_dpy()); + fprintf(output_fp, "#\n"); fprintf(output_fp, - "%g\t%g\t%#.15g", - dpx, dpy, p.unknown_gridfn(ghosted_flag, - unknown_gfn, irho,isigma)); - if (print_xyz_flag) - then { - const fp r = p.unknown_gridfn(radius_is_ghosted_flag, - unknown_radius_gfn, - irho,isigma); - fp local_x, local_y, local_z; - p.xyz_of_r_rho_sigma(r,rho,sigma, - local_x,local_y,local_z); - const fp global_x = global_x_of_local_x(local_x); - const fp global_y = global_y_of_local_y(local_y); - const fp global_z = global_z_of_local_z(local_z); + print_xyz_flag + ? "# dpx\tdpy\tgridfn\tglobal_x\tglobal_y\tglobal_z\n" + : "# dpx\tdpy\tgridfn\n"); + + for (int irho = p.effective_min_irho(want_ghost_zones) ; + irho <= p.effective_max_irho(want_ghost_zones) ; + ++irho) + { + for (int isigma = p.effective_min_isigma(want_ghost_zones) ; + isigma <= p.effective_max_isigma(want_ghost_zones) ; + ++isigma) + { + const fp rho = p.rho_of_irho(irho); + const fp sigma = p.sigma_of_isigma(isigma); + const fp dpx = p.dpx_of_rho_sigma(rho, sigma); + const fp dpy = p.dpy_of_rho_sigma(rho, sigma); fprintf(output_fp, - "\t%#g\t%#g\t%#g", - global_x, global_y, global_z); + "%g\t%g\t%#.15g", + dpx, dpy, p.unknown_gridfn(ghosted_flag, + unknown_gfn, irho,isigma)); + if (print_xyz_flag) + then { + const fp r = p.unknown_gridfn(radius_is_ghosted_flag, + unknown_radius_gfn, + irho,isigma); + fp local_x, local_y, local_z; + p.xyz_of_r_rho_sigma(r,rho,sigma, + local_x,local_y,local_z); + const fp global_x = global_x_of_local_x(local_x); + const fp global_y = global_y_of_local_y(local_y); + const fp global_z = global_z_of_local_z(local_z); + fprintf(output_fp, + "\t%#g\t%#g\t%#g", + global_x, global_y, global_z); + } + fprintf(output_fp, "\n"); + } + fprintf(output_fp, "\n"); } fprintf(output_fp, "\n"); } - fprintf(output_fp, "\n"); - } -fprintf(output_fp, "\n"); -} std::fclose(output_fp); } @@ -1329,89 +1330,89 @@ void patch_system::read_unknown_gridfn(bool ghosted_flag, int unknown_gfn, bool want_ghost_zones) { if (want_ghost_zones && !ghosted_flag) -then error_exit(PANIC_EXIT, + then error_exit(PANIC_EXIT, "***** patch_system::read_unknown_gridfn(unknown_gfn=%d):\n" " can't have want_ghost_zones && !ghosted_flag !\n" , - unknown_gfn); /*NOTREACHED*/ + unknown_gfn); /*NOTREACHED*/ FILE *input_fp = std::fopen(input_file_name, "r"); if (input_fp == NULL) -then error_exit(ERROR_EXIT, + then error_exit(ERROR_EXIT, "***** patch_system::read_unknown_gridfn(unknown_gfn=%d):\n" " can't open input file \"%s\"\n!" , - unknown_gfn, - input_file_name); /*NOTREACHED*/ + unknown_gfn, + input_file_name); /*NOTREACHED*/ int line_number = 1; -for (int pn = 0 ; pn < N_patches() ; ++pn) -{ -patch& p = ith_patch(pn); + for (int pn = 0 ; pn < N_patches() ; ++pn) + { + patch& p = ith_patch(pn); -for (int irho = p.effective_min_irho(want_ghost_zones) ; - irho <= p.effective_max_irho(want_ghost_zones) ; - ++irho) -{ -for (int isigma = p.effective_min_isigma(want_ghost_zones) ; - isigma <= p.effective_max_isigma(want_ghost_zones) ; - ++isigma) -{ -const fp rho = p.rho_of_irho(irho); -const fp sigma = p.sigma_of_isigma(isigma); -const fp dpx = p.dpx_of_rho_sigma(rho, sigma); -const fp dpy = p.dpy_of_rho_sigma(rho, sigma); - -const int N_buffer = 100; -char buffer[N_buffer]; -// read/discard comments and blank lines - do + for (int irho = p.effective_min_irho(want_ghost_zones) ; + irho <= p.effective_max_irho(want_ghost_zones) ; + ++irho) { - if (std::fgets(buffer, N_buffer, input_fp) == NULL) - then error_exit(ERROR_EXIT, + for (int isigma = p.effective_min_isigma(want_ghost_zones) ; + isigma <= p.effective_max_isigma(want_ghost_zones) ; + ++isigma) + { + const fp rho = p.rho_of_irho(irho); + const fp sigma = p.sigma_of_isigma(isigma); + const fp dpx = p.dpx_of_rho_sigma(rho, sigma); + const fp dpy = p.dpy_of_rho_sigma(rho, sigma); + + const int N_buffer = 100; + char buffer[N_buffer]; + // read/discard comments and blank lines + do + { + if (std::fgets(buffer, N_buffer, input_fp) == NULL) + then error_exit(ERROR_EXIT, "***** patch::read_unknown_gridfn(%s patch, unknown_gfn=%d):\n" " I/O error or unexpected end-of-file on input!\n" " at irho=%d of [%d,%d], isigma=%d of [%d,%d]\n" " dpx=%g dpy=%g\n" , - p.name(), unknown_gfn, - irho, p.effective_min_irho(want_ghost_zones), - p.effective_max_irho(want_ghost_zones), - isigma, - p.effective_min_isigma(want_ghost_zones), - p.effective_max_isigma(want_ghost_zones), - dpx, dpy); /*NOTREACHED*/ - ++line_number; - } while ((buffer[0] == '#') || (buffer[0] == '\n')); - -double read_dpx, read_dpy, read_gridfn_value; -if (sscanf(buffer, "%lf %lf %lf", - &read_dpx, &read_dpy, &read_gridfn_value) != 3) - then error_exit(ERROR_EXIT, + p.name(), unknown_gfn, + irho, p.effective_min_irho(want_ghost_zones), + p.effective_max_irho(want_ghost_zones), + isigma, + p.effective_min_isigma(want_ghost_zones), + p.effective_max_isigma(want_ghost_zones), + dpx, dpy); /*NOTREACHED*/ + ++line_number; + } while ((buffer[0] == '#') || (buffer[0] == '\n')); + + double read_dpx, read_dpy, read_gridfn_value; + if (sscanf(buffer, "%lf %lf %lf", + &read_dpx, &read_dpy, &read_gridfn_value) != 3) + then error_exit(ERROR_EXIT, "***** patch::read_unknown_gridfn(%s patch, unknown_gfn=%d):\n" " bad input data at input line %d!\n" , - p.name(), unknown_gfn, - line_number); /*NOTREACHED*/ -if (! ( jtutil::fuzzy<fp>::EQ(read_dpx,dpx) - && jtutil::fuzzy<fp>::EQ(read_dpy,dpy) ) ) - then error_exit(ERROR_EXIT, + p.name(), unknown_gfn, + line_number); /*NOTREACHED*/ + if (! ( jtutil::fuzzy<fp>::EQ(read_dpx,dpx) + && jtutil::fuzzy<fp>::EQ(read_dpy,dpy) ) ) + then error_exit(ERROR_EXIT, "***** patch::read_unknown_gridfn(%s patch, unknown_gfn=%d):\n" " wrong (dpx,dpy) at input line %d!\n" " expected (%g,%g)\n" " read (%g,%g)\n" , - p.name(), unknown_gfn, - line_number, - dpx, dpy, - read_dpx, read_dpy); /*NOTREACHED*/ + p.name(), unknown_gfn, + line_number, + dpx, dpy, + read_dpx, read_dpy); /*NOTREACHED*/ -p.unknown_gridfn(ghosted_flag, - unknown_gfn, irho,isigma) = read_gridfn_value; -} -} + p.unknown_gridfn(ghosted_flag, + unknown_gfn, irho,isigma) = read_gridfn_value; + } + } -} + } std::fclose(input_fp); } |