Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Base.show StructuredMesh #2228

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

MarcoArtiano
Copy link

@MarcoArtiano MarcoArtiano commented Jan 13, 2025

When the StructuredMesh was called without any mapping, the information was displayed incorrectly. See below.

Before
image

After
image

Same for 1D and 2D.

Copy link
Contributor

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.41%. Comparing base (6149104) to head (366b537).

Files with missing lines Patch % Lines
src/meshes/structured_mesh.jl 78.95% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2228      +/-   ##
==========================================
- Coverage   96.42%   96.41%   -0.01%     
==========================================
  Files         487      487              
  Lines       39345    39356      +11     
==========================================
+ Hits        37935    37942       +7     
- Misses       1410     1414       +4     
Flag Coverage Δ
unittests 96.41% <78.95%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MarcoArtiano
Copy link
Author

Now, when no mapping is provided to StructuredMesh, Trixi displays the following information:
image
Analogously for 1D and 2D cases.

Fixed also when StructuredMesh is called with faces
image

@MarcoArtiano MarcoArtiano changed the title Fix Base.show StructuredMesh WIP: Fix Base.show StructuredMesh Jan 14, 2025
@MarcoArtiano MarcoArtiano changed the title WIP: Fix Base.show StructuredMesh Fix Base.show StructuredMesh Jan 14, 2025
@ranocha
Copy link
Member

ranocha commented Jan 15, 2025

Thanks! What does the result look like when a mapping is passed?

@MarcoArtiano
Copy link
Author

MarcoArtiano commented Jan 15, 2025

Thanks! What does the result look like when a mapping is passed?

The user defined function is

function mapping(xi_, eta_)
    # Transform input variables between -1 and 1 onto [0,3]
    xi = 1.5 * xi_ + 1.5
    eta = 1.5 * eta_ + 1.5

    y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) *
                       cos(0.5 * pi * (2 * eta - 3) / 3))

    x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) *
                      cos(2 * pi * (2 * y - 3) / 3))

    return SVector(x, y)
end

from structured_2d_dgsem/elixir_advection_free_stream.jl

image

This is how it is displayed at the moment. I'm not really a fan of this visualization and if you have any suggestion I may try different options. Before everything was displayed in one single line and because of that incorrectly reported on the terminal.

ranocha
ranocha previously approved these changes Jan 15, 2025
Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks, I'm fine with these changes. It would be nice to get feedback from @sloede as well.

@ranocha ranocha requested a review from sloede January 15, 2025 08:44
@sloede
Copy link
Member

sloede commented Jan 16, 2025

Is there a way for custom mappings to just display the mapping function? Alternatively, I'd prefer to just write something like "custom mapping", since mapping functions might get long and this becomes ugly. But if you're keen on showing it here, I wouldn't be opposed either.

@MarcoArtiano
Copy link
Author

Is there a way for custom mappings to just display the mapping function? Alternatively, I'd prefer to just write something like "custom mapping", since mapping functions might get long and this becomes ugly. But if you're keen on showing it here, I wouldn't be opposed either.

image

With the last commit at the moment when a custom mapping or faces are passed to StructuredMesh, the Base.show displays simply that.

Unfortunately I couldn't find an easier way to at least distinguish mapping and faces inside the Base.show functoin. I would like to avoid making changes in the StructuredMesh call where the variable mapping_as_string is generated, because it may affect the restart function in Trixi.jl. In any case, I could display something like "custom mapping/faces", or reverse the commit and revert to the previous version, where the entire function was displayed.

@ranocha
Copy link
Member

ranocha commented Jan 21, 2025

@sloede Your decision. I am not against the previous (more verbose) version since the current output is already quite a bit...

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.

3 participants