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

Ma2 file reader for nek5000 #47

Closed
wants to merge 3 commits into from
Closed

Ma2 file reader for nek5000 #47

wants to merge 3 commits into from

Conversation

Simkern
Copy link
Contributor

@Simkern Simkern commented Jan 28, 2022

Here's the function to read the ma2 file. The ordering is the same as in the elmap list from the re2 file iirc.

Function to read the binary ma2 files for nek5000
@ashwinvis
Copy link
Member

Thanks a lot @Simkern. I will take a look soon.

@ashwinvis ashwinvis linked an issue Jan 29, 2022 that may be closed by this pull request
pymech/readma2.py Show resolved Hide resolved
Comment on lines +24 to +31
header = infile.read(132).split()
nel = int(header[1])
nactive = int(header[2])
depth = int(header[3])
d2 = int(header[4])
npts = int(header[5])
nrnk = int(header[6])
noutflow = int(header[7])
Copy link
Member

Choose a reason for hiding this comment

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

You don't have to use cryptic variable names. Longer variable names would be nice to have here (and comments if it is still unclear).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of these are not really used, but since I started parsing the header I thought I'd add all data there. I have added comments but kept the naming since it's not as cryptic as you make it sound, especially regarding the values that are being used in this function.

Copy link
Member

Choose a reason for hiding this comment

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

I see. In that case leave a comment, so we know read more about it in Nek5000's code in the future.

file name
ldim : int
dimension of the mesh
"""
Copy link
Member

Choose a reason for hiding this comment

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

Describe the return values (type) and what it contains in the docstring here (just like you did for Parameters).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I have added the information about the return values.

@ashwinvis
Copy link
Member

I am taking a look at your function now @Simkern . Let me know if you are available to fix it.

@ashwinvis
Copy link
Member

Does the user really have to specify the number of dimensions ldim. I wonder if it specified in the header part of the ma2 files?

Co-authored-by: Ashwin V. Mohanan <9155111+ashwinvis@users.noreply.github.com>
@Simkern
Copy link
Contributor Author

Simkern commented Jun 10, 2022

Does the user really have to specify the number of dimensions ldim. I wonder if it specified in the header part of the ma2 files?

I went through the function again and indeed it is not necessary to specify the mesh dimension although it is not saved in the header. It can be inferred from the auxiliary data and I have added this step.

@Simkern Simkern closed this Jun 10, 2022
@ashwinvis
Copy link
Member

I have added this step.

I am not sure I understand. Have you made the changes? Let me know when you pushed the new commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read connectivity of elements and index them
2 participants