-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add PyVista mesh support to Field #59
Conversation
gstools/field/base.py
Outdated
if isinstance(out, np.ndarray): | ||
mesh[name] = out | ||
else: | ||
# if multiple values are returned, take the first one | ||
mesh[name] = out[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really messy... we should leverage #60 to handle adding all returned arrays to the PyVista and meshio meshes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can now be discussed in #65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably the best as is and we can use #65 to change this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@banesullivan I added a workaround for this problem.
Please make this PR in the |
the base has been changed to |
If you "squash and merge" on GitHub, this should be good |
I should probably add some tests to make sure all PyVista meshes work |
Yeah, I think if you add some tests, we can merge this as is and then, when I finally get along with PR #65, I will automatically be reminded to change this. |
@LSchueler, will do! And I'll get looking at #65 ASAP too |
Apologies for doing a rebase and force push... this got outdated quickly. I'm trying to add tests but having trouble running the tests locally... |
This same error is happening for like all of the tests:
any suggestions? |
Well, I took |
I added a basic test in I also noticed the the |
@banesullivan welcome back!! have a look at the new mesh class from #65 .. we plan to include the meshIO stuff there and you are warmly welcome to provide input and wishes there (since we mostly had the vtk format in mind creating this)! the hankel problem comes in your case from an outdated hankel package (update to 1.0 and it should work!) maybe we could close this PR in favor of #65 and start over with the new mesh class. What do you think? |
@banesullivan Are you fine with closing this PR? |
All good by me to close this PR! The code will remain here for reference if needed and #59 should take precedence |
@banesullivan I reopened this PR, since we decided, that the mesh class will be a separate class in GSTools, that can be passed to the I think, the way you proposed here is the best one for now. Sorry for this! |
To solve the problem with multiple returns: We could think about allowing a list of names for the def _names(name, cnt):
name = [name] if isinstance(name, str) else list(name)[:cnt]
if len(name) < cnt:
name += [name[-1] + str(i + 1) for i in range(cnt - len(name))]
return name Then we could do something like the following after the field was generated: fields = [out] if isinstance(out, np.ndarray) else out
for f_name, field in zip(_names(name, len(fields)), fields):
mesh[f_name] = field This would result in the names |
…le name for multiple fields; check for ogs5py
@MuellerSeb, looks good to me! I like your fix for handling the field names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@banesullivan thanks for supporting this! 👍
Resolve #32 (see #32 (comment)) by giving the
Field
class a way to handle PyVista meshes. After this, I see no advantage for implementing a custom PyVista plotting routine but to just let users do PyVista plotting on their own.Originally, this function would do everything implicitly without importing the mesh packages... IMO, this isn't a very stable/clean way to implement that as it was checking for attributes on the objects which could be shared across types or the name could be present on an unsupported type that isn't what is expected. I implemented PyVista by bare try/except import and then checking if the passed mesh is a PyVista dataset.
I would HIGHLY recommend implementing type checking for the other meshes and add an alert the user if they are passing an unsupported object.
Example usage with PyVista from the code in #36 (comment)
Another concern. This method does not leverage structured grids... does having a structured grid even help? Because if so, there are a number of PyVista mesh types that can be recast to structured grids which would improve performance