Skip to content

Commit

Permalink
Merge pull request #48 from ProjectTorreyPines/get_grid_subset
Browse files Browse the repository at this point in the history
Update demo.ipynb
  • Loading branch information
anchal-physics authored Mar 20, 2024
2 parents 39a7ab8 + 243f324 commit 570cf41
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
32 changes: 16 additions & 16 deletions example/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion example/simple_demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 21 additions & 21 deletions src/supersize_profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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])
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -229,17 +229,17 @@ 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)
println("cleared ext mesh cache: ", cfn)
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]
Expand Down

0 comments on commit 570cf41

Please sign in to comment.