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

bug: weird logic for checking "Size of vector" in add_transient_vector() #2210

Open
mickey-tsai opened this issue Jun 6, 2024 · 2 comments
Labels
Milestone

Comments

@mickey-tsai
Copy link
Contributor

Describe the bug

https://github.com/modflowpy/flopy/blob/develop/flopy/export/vtk.py#L969-L975

I am not a modflow professional.
The assertion error "Size of vector must be 3 * nnodes or 3 * ncpl" is triggered when value.size != 3 * self.ncpl or value.size != 3 * self.nnodes. This assertion error is always triggered in most normal cases.

Expected behavior
To my understanding, nnodes =layer*ncpl. Should the condition "layer =1" be considered?

if value.size == 3 * self.ncpl:
  //do something
elif value.size == 3 * self.nnodes:
  //do something
elif layer == 1:
  //do something
else:
  raise Exception()
@mickey-tsai mickey-tsai added the bug label Jun 6, 2024
@wpbonelli
Copy link
Member

Hi @mickey-tsai

nnodes is the total number of nodes in the grid. This is defined differently for each grid type

  • structured: nlay * nrow * ncol
  • vertex: nlay * ncpl
  • unstructured: ncpl.sum()

I think you are right, something is funny here. At very least, we need to switch or -> and

- value.size != 3 * self.ncpl or value.size != 3 * self.nnodes
+ value.size != 3 * self.ncpl and value.size != 3 * self.nnodes

... or pull the negation out front per de morgan.

But I'm not clear on the intent behind this code, nor do we have test cases or example models using add_transient_vector() in context, maybe @jlarsen-usgs can come to the rescue

@wpbonelli wpbonelli added this to the 3.8.0 milestone Jun 17, 2024
@jlarsen-usgs
Copy link
Contributor

@mickey-tsai

I'll have to look a little more into how and why I developed the vector a little more. It's been awhile.

My guess is that since the VTK file is in three dimensional space the associated vector would need to have three components. An example of this is Specific Discharge which has the components [qx, qy, qz].

@wpbonelli wpbonelli modified the milestones: 3.8.0, 3.8.1 Aug 5, 2024
@wpbonelli wpbonelli modified the milestones: 3.8.1, 3.9.1 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants