diff --git a/example/demo.ipynb b/example/demo.ipynb index 5f4e769..3c53f10 100644 --- a/example/demo.ipynb +++ b/example/demo.ipynb @@ -102,21 +102,21 @@ "\n", "# You can overlay any subset by giving a second argument\n", "# Labels \n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 6), markercolor=:chocolate1)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 7), linecolor=:red, linewidth=2)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 8), linecolor=:darkred, linewidth=2)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 9), linecolor=:limegreen, linewidth=2)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 10), linecolor=:darkgreen, linewidth=2)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 11), linecolor=:cyan, linewidth=2)\n", - "# plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 12), linecolor=:teal, linewidth=1)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 13), linecolor=:royalblue1, linewidth=2)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 14), linecolor=:navyblue, linewidth=2)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 15), linecolor=:fuchsia, linewidth=2, linestyle=:dash)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 16), linecolor=:purple4, linewidth=2, linestyle=:dash)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 101), markershape=:rect, markercolor=:royalblue1)\n", - "# plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 102), markershape=:rect, markercolor=:maroon)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 103), markershape=:diamond, markercolor=:fuchsia)\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 104), markershape=:diamond, markercolor=:purple4)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 6), markercolor=:chocolate1)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 7), linecolor=:red, linewidth=2)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 8), linecolor=:darkred, linewidth=2)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 9), linecolor=:limegreen, linewidth=2)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 10), linecolor=:darkgreen, linewidth=2)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 11), linecolor=:cyan, linewidth=2)\n", + "# plot!(space, GGDUtils.get_grid_subset(grid_ggd, 12), linecolor=:teal, linewidth=1)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 13), linecolor=:royalblue1, linewidth=2)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 14), linecolor=:navyblue, linewidth=2)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 15), linecolor=:fuchsia, linewidth=2, linestyle=:dash)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 16), linecolor=:purple4, linewidth=2, linestyle=:dash)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 101), markershape=:rect, markercolor=:royalblue1)\n", + "# plot!(space, GGDUtils.get_grid_subset(grid_ggd, 102), markershape=:rect, markercolor=:maroon)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 103), markershape=:diamond, markercolor=:fuchsia)\n", + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 104), markershape=:diamond, markercolor=:purple4)\n", "\n", "# Legend is supressed unless asked for specifically\n", "plot!(legend=true)\n", @@ -163,7 +163,7 @@ "# plotlyjs() # Use for interactive plot, can only save png\n", "\n", "plot(ids.edge_profiles.grid_ggd, n_e) # Note default label in colorbar\n", - "plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 16), linecolor=:black, linewidth=2, linestyle=:solid, label=\"Separatix\", legend=true)" + "plot!(space, GGDUtils.get_grid_subset(grid_ggd, 16), linecolor=:black, linewidth=2, linestyle=:solid, label=\"Separatix\", legend=true)" ] }, { diff --git a/example/simple_demo.jl b/example/simple_demo.jl index 7cd32fb..b191014 100644 --- a/example/simple_demo.jl +++ b/example/simple_demo.jl @@ -29,7 +29,7 @@ n_e = GGDUtils.get_prop_with_grid_subset_index( plot(dd.edge_profiles.grid_ggd, n_e; colorbar_title="Electrons density / m^(-3)") plot!( space, - GGDUtils.get_grid_subset_with_index(grid_ggd, 16); + GGDUtils.get_grid_subset(grid_ggd, 16); linecolor=:black, linewidth=2, linestyle=:solid, diff --git a/src/supersize_profile.jl b/src/supersize_profile.jl index a93223a..b541c75 100644 --- a/src/supersize_profile.jl +++ b/src/supersize_profile.jl @@ -6,7 +6,7 @@ Utilities for extrapolating profiles using OMAS: OMAS using Interpolations: Interpolations using GGDUtils: - GGDUtils, get_grid_subset_with_index, add_subset_element!, get_subset_boundary, + GGDUtils, get_grid_subset, add_subset_element!, get_subset_boundary, project_prop_on_subset!, get_subset_centers using PolygonOps: PolygonOps using JSON: JSON @@ -143,9 +143,9 @@ function fill_in_extrapolated_core_profile!( grid_ggd = dd.edge_profiles.grid_ggd[grid_ggd_idx] space = grid_ggd.space[space_idx] cell_subset = - get_grid_subset_with_index(grid_ggd, cell_subset_idx) + get_grid_subset(grid_ggd, cell_subset_idx) midplane_subset = - get_grid_subset_with_index(grid_ggd, 11) + get_grid_subset(grid_ggd, 11) if length(midplane_subset.element) < 1 throw( @@ -383,7 +383,7 @@ function mesh_psi_spacing( grid_ggd = dd.edge_profiles.grid_ggd[grid_ggd_idx] space = grid_ggd.space[space_idx] midplane_subset = - get_grid_subset_with_index(grid_ggd, 11) + get_grid_subset(grid_ggd, 11) midplane_cell_centers = get_subset_centers(space, midplane_subset) r_mesh = [midplane_cell_centers[i][1] for i ∈ eachindex(midplane_cell_centers)] z_mesh = [midplane_cell_centers[i][2] for i ∈ eachindex(midplane_cell_centers)] @@ -434,7 +434,7 @@ function pick_extension_psi_range( # Use ggd mesh to find inner limit of contouring project grid_ggd = dd.edge_profiles.grid_ggd[grid_ggd_idx] space = grid_ggd.space[space_idx] - midplane_subset = get_grid_subset_with_index(grid_ggd, 11) + midplane_subset = get_grid_subset(grid_ggd, 11) midplane_cell_centers = get_subset_centers(space, midplane_subset) psin_midplane = rzpi.(midplane_cell_centers[end][1], midplane_cell_centers[end][2]) @@ -478,11 +478,11 @@ Returns a tuple with vectors of R and Z starting points. function pick_mesh_ext_starting_points(grid_ggd, space) # Choose starting points for the orthogonal (to the contour) gridlines # Use the existing cells of the standard mesh - all_cell_subset = get_grid_subset_with_index(grid_ggd, 5) + all_cell_subset = get_grid_subset(grid_ggd, 5) all_border_edges = get_subset_boundary(space, all_cell_subset) - core_edges = get_grid_subset_with_index(grid_ggd, 15) - outer_target = get_grid_subset_with_index(grid_ggd, 13) - inner_target = get_grid_subset_with_index(grid_ggd, 14) + core_edges = get_grid_subset(grid_ggd, 15) + outer_target = get_grid_subset(grid_ggd, 13) + inner_target = get_grid_subset(grid_ggd, 14) ci = [ele.object[1].index for ele ∈ core_edges.element] oi = [ele.object[1].index for ele ∈ outer_target.element] ii = [ele.object[1].index for ele ∈ inner_target.element] @@ -742,16 +742,16 @@ function record_regular_mesh!( grid_ggd.grid_subset[n_existing_subsets+i].identifier.index = new_subset_indices[i] end - ext_nodes_sub = get_grid_subset_with_index(grid_ggd, -201) - ext_edges_sub = get_grid_subset_with_index(grid_ggd, -202) - ext_xedges_sub = get_grid_subset_with_index(grid_ggd, -203) - ext_yedges_sub = get_grid_subset_with_index(grid_ggd, -204) - ext_cells_sub = get_grid_subset_with_index(grid_ggd, -205) + ext_nodes_sub = get_grid_subset(grid_ggd, -201) + ext_edges_sub = get_grid_subset(grid_ggd, -202) + ext_xedges_sub = get_grid_subset(grid_ggd, -203) + ext_yedges_sub = get_grid_subset(grid_ggd, -204) + ext_cells_sub = get_grid_subset(grid_ggd, -205) # Preserve record of standard (non extended) mesh for i ∈ 1:5 - std_sub = get_grid_subset_with_index(grid_ggd, -i) - orig_sub = get_grid_subset_with_index(grid_ggd, i) + std_sub = get_grid_subset(grid_ggd, -i) + orig_sub = get_grid_subset(grid_ggd, i) resize!(std_sub.element, length(orig_sub.element)) for j ∈ 1:length(orig_sub.element) std_sub.element[j] = deepcopy(orig_sub.element[j]) @@ -760,11 +760,11 @@ function record_regular_mesh!( std_sub.dimension = deepcopy(orig_sub.dimension) std_sub.metric = deepcopy(orig_sub.metric) end - all_nodes_sub = get_grid_subset_with_index(grid_ggd, 1) - all_edges_sub = get_grid_subset_with_index(grid_ggd, 2) - all_xedges_sub = get_grid_subset_with_index(grid_ggd, 3) - all_yedges_sub = get_grid_subset_with_index(grid_ggd, 4) - all_cells_sub = get_grid_subset_with_index(grid_ggd, 5) + all_nodes_sub = get_grid_subset(grid_ggd, 1) + all_edges_sub = get_grid_subset(grid_ggd, 2) + all_xedges_sub = get_grid_subset(grid_ggd, 3) + all_yedges_sub = get_grid_subset(grid_ggd, 4) + all_cells_sub = get_grid_subset(grid_ggd, 5) nodes = resize!(o0.object, n_nodes) edges = resize!(o1.object, n_edges) diff --git a/test/runtests.jl b/test/runtests.jl index a8296e3..e2551c1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,7 +7,7 @@ using Test using Unitful: Unitful using Interpolations: Interpolations using ArgParse: ArgParse -using GGDUtils: GGDUtils, get_grid_subset_with_index +using GGDUtils: GGDUtils, get_grid_subset function parse_commandline() s = ArgParse.ArgParseSettings(; description="Run tests. Default is all tests.") @@ -229,7 +229,7 @@ if args["edge_profile_extension"] grid_ggd = dd.edge_profiles.grid_ggd[grid_ggd_idx] extended_subs = 1:5 orig_subs = [ - deepcopy(get_grid_subset_with_index(grid_ggd, i)) for + deepcopy(get_grid_subset(grid_ggd, i)) for i ∈ extended_subs ] cfn = SD4SOLPS.cached_mesh_extension!(dd, eqdsk, b2fgmtry; clear_cache=true) @@ -237,9 +237,9 @@ if args["edge_profile_extension"] SD4SOLPS.cached_mesh_extension!(dd, eqdsk, b2fgmtry; grid_ggd_idx=grid_ggd_idx) for j ∈ extended_subs orig_sub = orig_subs[j] - std_sub = get_grid_subset_with_index(grid_ggd, -j) - all_sub = get_grid_subset_with_index(grid_ggd, j) - ext_sub = get_grid_subset_with_index(grid_ggd, -200 - j) + std_sub = get_grid_subset(grid_ggd, -j) + all_sub = get_grid_subset(grid_ggd, j) + ext_sub = get_grid_subset(grid_ggd, -200 - j) orig_indices = [ele.object[1].index for ele ∈ orig_sub.element] std_indices = [ele.object[1].index for ele ∈ std_sub.element] all_indices = [ele.object[1].index for ele ∈ all_sub.element]