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

Easiest way to access boxes in fortran #4094

Closed
desjardi opened this issue Aug 19, 2024 · 7 comments · Fixed by #4096
Closed

Easiest way to access boxes in fortran #4094

desjardi opened this issue Aug 19, 2024 · 7 comments · Fixed by #4096

Comments

@desjardi
Copy link

Hello,

I'm using the amrcore fortran interface, and I'm trying to gain access to the details of all the boxes at each level. I can access the array of geometry objects which gives me info about extent, periodicity, and cell size. I can also access the BoxArray object at each level, but I haven't been able to identify an easy way to loop through each box in the BoxArray and extract - say - its range of indices. Is there a simple way to do that?

I think I understand how it's done using MFiter starting from a multifab, but it's not exactly what I'm looking for for a few reasons:

  • I'm interested in looking into what the grid looks like, independently of the data stored on that grid
  • I'm interested in doing that on a single processor (doing I/O, for example). I understand that a boxarray is a global concept, so it seems all processors should have all the details of all the boxes. It seems however that mfiter would only loop through the box owned specifically by the processor doing the call.

Is there a simple way to do that from fortran? Maybe I'm fundamentally misunderstanding things. For example, I could imagine a scenario where the concept of a box is fundamentally tied to the multifab, i.e., each multifab might have a different distribution of boxes, and therefore my question is meaningless. But I feel that it's probably not the case, and that given an amrcore, all zero-ghost single-component multifabs would have exactly the same boxes at all levels.

Thanks for your help!

Olivier

@asalmgren
Copy link
Member

asalmgren commented Aug 19, 2024 via email

@desjardi
Copy link
Author

Thanks for the amazingly quick answer!
If I may, quick follow-up: how do I know the range of i, the second input to the fi function you mentioned? I would like to loop from (I assume) 0 to the number-of-boxes-in-the-boxarray, but I'm not sure how to get that on the fortran side.

@asalmgren
Copy link
Member

asalmgren commented Aug 19, 2024 via email

@desjardi
Copy link
Author

Fair enough :)
It's not gonna work since ba is a derived datatype that essentially contains a c-pointer to the amex object. I think we may need an extra function the fortran interface to return the size of the ba...
Is the fortran interface still more or less actively supported?

@asalmgren
Copy link
Member

@WeiqunZhang -- can you chime in?

The Fortran interface is much less actively supported than the C++ functionality itself, but I don't think anything should have broken it.

@WeiqunZhang
Copy link
Member

We only added a subset of the BoxArray functions. We don't have a size function for Fortran type boxarray because we didn't need it in our Fortran codes. But we can add it. Then you should be able to use it and get_box to get all the boxes into the Fortran side.

@desjardi
Copy link
Author

Thanks for confirming - that'd be awesome if it could be added, I appreciate it very much!
Olivier

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 a pull request may close this issue.

3 participants