Skip to content

Cleanup ASCII mesh reader#1361

Merged
pcarruscag merged 11 commits intodevelopfrom
cleanup_meshreader
Sep 2, 2021
Merged

Cleanup ASCII mesh reader#1361
pcarruscag merged 11 commits intodevelopfrom
cleanup_meshreader

Conversation

@pcarruscag
Copy link
Member

@pcarruscag pcarruscag commented Aug 24, 2021

Proposed Changes

Reduce duplication and maybe make it a bit faster.

We were reading the entire mesh file in four passes (open-close, open-close, ...) one for metadata (NDIME, NELEM, etc.) one for points, one for elements, and then one for markers.
Now we have a maximum of 2 (meta + reading) and if the points are listed before the elements we do it in 1 pass (there are some meshes like that in TestCases).
If we need to split actuator disk surfaces there are more passes, don't ask me how many because I'm not going to touch that function (it is probably not used often).

We still do a lot of reading for single-file multizone meshes to get to each zone, and usually we put smaller meshes at the end right 😅 I won't get into that now.

Related Work

#1345

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with the '-Wall -Wextra -Wno-unused-parameter -Wno-empty-body' compiler flags, or simply --warnlevel=2 when using meson).
  • My contribution is commented and consistent with SU2 style.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp) , if necessary.

@pcarruscag pcarruscag linked an issue Aug 28, 2021 that may be closed by this pull request
@pcarruscag pcarruscag changed the title [WIP] Cleanup ASCII mesh reader Cleanup ASCII mesh reader Aug 28, 2021
Comment on lines +228 to +230
if (current_section_idx != 2) {
SU2_MPI::Error("Markers must be listed after points and elements in the SU2 mesh file.", CURRENT_FUNCTION);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This PR introduces this restriction. It could be avoided if we stop checking for v6-style periodicity in the mesh file.

Copy link
Contributor

@WallyMaier WallyMaier left a comment

Choose a reason for hiding this comment

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

Thanks for this work, Pedro! This looks good to me!


if (iProcessor >= (unsigned long)size)
iProcessor = (unsigned long)size-1;
unsigned long iProcessor = min<unsigned long>(index/sizeOnRank[0], size-1);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

text_line.erase (0,11);
string::size_type position;

for (unsigned short iChar = 0; iChar < 20; iChar++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does 20 come from?

Comment on lines -1213 to -1222
string::size_type position;

for (unsigned short iChar = 0; iChar < 20; iChar++) {
position = text_line.find( " ", 0 );
if (position != string::npos) text_line.erase (position,1);
position = text_line.find( "\r", 0 );
if (position != string::npos) text_line.erase (position,1);
position = text_line.find( "\n", 0 );
if (position != string::npos) text_line.erase (position,1);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Comes from the ancient ones, I suppose we strip up to 20 spaces anywhere from the marker names 🤷
I doubt the \r and \n ever do anything, because these are used by getline to know what is a line.
This should not be performance or correctness critical, so if it ain't broke...

Copy link
Contributor

@WallyMaier WallyMaier left a comment

Choose a reason for hiding this comment

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

LGTM!

@pcarruscag pcarruscag merged commit 34c46b6 into develop Sep 2, 2021
@pcarruscag pcarruscag deleted the cleanup_meshreader branch September 2, 2021 09:22
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.

a possible bug for loading grid points for a zone

2 participants