-
Notifications
You must be signed in to change notification settings - Fork 345
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
Comments
You are correct that you don't need to (or want to) use MFIter -- you can
simply loop over the boxes in the boxArray
Access to the information about each box can be gotten by something like
this:
void amrex_fi_boxarray_get_box (const BoxArray* ba, int i, int lo[3],
int hi[3])
{
const Box& bx = (*ba)[i];
const int* lov = bx.loVect();
const int* hiv = bx.hiVect();
for (int idim = 0; idim < BL_SPACEDIM; ++idim) {
lo[idim] = lov[idim];
hi[idim] = hiv[idim];
}
}
…On Mon, Aug 19, 2024 at 12:25 PM Olivier Desjardins < ***@***.***> wrote:
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
—
Reply to this email directly, view it on GitHub
<#4094>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACRE6YSM3INCY7WGXDDNQYLZSJBCPAVCNFSM6AAAAABMYOCPXOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TIMBUGIZDENY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Ann Almgren
Senior Scientist; Dept. Head, Applied Mathematics
Pronouns: she/her/hers
|
Thanks for the amazingly quick answer! |
I don't work with the Fortran stuff so try
size(ba)
and let me know if that works?
:-)
…On Mon, Aug 19, 2024 at 12:34 PM Olivier Desjardins < ***@***.***> wrote:
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.
—
Reply to this email directly, view it on GitHub
<#4094 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACRE6YWX7U4NVBTKXMXWFHDZSJCGBAVCNFSM6AAAAABMYOCPXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJXGI4TSNRSGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Ann Almgren
Senior Scientist; Dept. Head, Applied Mathematics
Pronouns: she/her/hers
|
Fair enough :) |
@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. |
We only added a subset of the BoxArray functions. We don't have a size function for Fortran |
Thanks for confirming - that'd be awesome if it could be added, I appreciate it very much! |
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:
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
The text was updated successfully, but these errors were encountered: