Thanks to visit codestin.com
Credit goes to github.com

Skip to content

update manual images for convection-box-2d - #7306

Open
JarettBakerDunn wants to merge 2 commits into
geodynamics:mainfrom
JarettBakerDunn:pyvista_convection_box_update_doc
Open

update manual images for convection-box-2d#7306
JarettBakerDunn wants to merge 2 commits into
geodynamics:mainfrom
JarettBakerDunn:pyvista_convection_box_update_doc

Conversation

@JarettBakerDunn

Copy link
Copy Markdown
Contributor

I noticed that I did not actually update that images used in the manual in #6993 .

This should update the figures in the convection in a 2d box section of the manual.

@alarshi alarshi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making this PR to add the images that are actually used in the manual! I just have one comment, otherwise it looks good.

@alarshi alarshi Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the gridlines you are plotting in this image show the mesh (see the relevant line here. The grey overlain lines are passing through the figure ticks, but reading the text in the manual section, we want to overlay the mesh grid to discuss the subsequent subsection.
There is a way that you can plot the mesh edges in pyvista using plotter.add_mesh(mesh, show_edges=True) . I would suggest to plot the mesh gridlines on the right image here and remove the gridlines from both the combined images and the individual images in this folder that got merger earlier to avoid confusion.

@JarettBakerDunn

Copy link
Copy Markdown
Contributor Author

Thanks Arushi, I updated the files. I noticed that the mesh plots triangles instead of rectangles when using pyvista. It does this whether or not I use the technique that I did in the script or the one you suggest.

I noticed that in PR #7107 pyvista does not plot cells as rectangles, I am not sure why but I wonder if it is because that model is spherical.

I think that this problem might be related to this issue.

It doesn't seem ideal that pyvista plots the mesh as a grid of triangles since this doesn't represent the actual ASPECT mesh... I'll see if I can fix this tomorrow.

@alarshi alarshi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see the issue. I have a suggestion if you're still looking for one.

# For example, to generate an image at time step 1, change to path to:
# "../../output-convection-box/solution/solution-00001.pvtu"
# Remember to change the name of the output file as well.
mesh = pv.read("../output-convection-box/solution/solution-00004.pvtu")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mesh_grid = mesh.extract_all_edges()

# scale the meshes down to put the scale bar on the side (like in the docs)
mesh = mesh.scale(0.75)
arrows = arrows.scale(0.75)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mesh_grid = mesh_grid.scale(0.75)

mesh_actor = plotter.add_mesh(mesh, scalars="T", log_scale=False, scalar_bar_args=sargs,cmap=cm.vik)
arrows_actor = plotter.add_mesh(arrows,color='white')
# Comment out the cells_actor variables if you don't want to plot the ASPECT mesh cells.
#cells_actor = plotter.add_mesh(mesh.extract_cells(range(mesh.n_cells)),style="wireframe",color="ivory_black",line_width=0.3,opacity=0.1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this solution does not work as we expect it to. I think this is because pyvista internally uses trianglular cells for rendering (you already identified this), and when you extract those cells and show its edges, it looks different than our input mesh edges.
I would recommend you to instead use the function extract_all_edges() on the mesh (see my suggestion above).
You can replace this line with:
grid_actor = plotter.add_mesh(mesh_grid, color="ivory_black", line_width=0.3, opacity=0.1)

Comment on lines +55 to +56

#cells_actor.position = (0.225,0.15,0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#cells_actor.position = (0.225,0.15,0)
grid_actor.position = (0.225, 0.15, 0)

@JarettBakerDunn

JarettBakerDunn commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Hmm, using your suggestions seems to have the same problem with plotting triangles. did it work on your computer?

I think I found the problem. using mesh.clip_box() seems to automatically do some retopology of the mesh or something. If this function isn't used then the cells are properly plotted as quads...

I think this is ready for another review.

@JarettBakerDunn
JarettBakerDunn force-pushed the pyvista_convection_box_update_doc branch from 4bb11ea to ff97562 Compare August 27, 2026 01:15
@alarshi

alarshi commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

/rebuild

@alarshi alarshi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks good now.

@alarshi alarshi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one last change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mesh on the right looks finer than what is currently in the manual because by default, Interpolate output is set to true (see parameter description here).
This parameter was probably added after this section was written in the manual. There are two ways you can reconcile the text and the image: one is to modify the caption that reflects this (add "The mesh has 16 × 16 cells, but its representation is finer than the actual mesh geometry because the Interpolate output parameter is set to true by default`") (refer to the parameter documentation here) or generate images with this parameter value set to false. In either case, the relevant results (i.e., heat flux statistics) do not change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thank you for figuring this out! I wasn't sure why it was doing that. I will set Interpolate output to false and regenerate the images.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I uploaded the new image with interpolate output set to false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this doesn't look right. I think you accidentally replaced the figure that corresponds to Ra=1e4.

@alarshi alarshi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Almost there, just one more suggestion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this doesn't look right. I think you accidentally replaced the figure that corresponds to Ra=1e4.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would have to replace the right sub-figure here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants