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

Issue with Retrieving Cell Data in AMReX Using GetCellData Function #4107

Open
ztdepztdep opened this issue Aug 23, 2024 · 1 comment
Open

Comments

@ztdepztdep
Copy link

ztdepztdep commented Aug 23, 2024

I have the following function in my LBM_FVM class, which is supposed to get data from a specific cell (i, j) across different refinement levels. I want it to get data from the fineset level first.
but it sometimes give a "zero" value, i am not sure what had happed.

`double LBM_FVM::GetCellData(amrex::Vector<amrex::MultiFab>& data, int i, int j)
{
    IntVect cell(i, j);
    for(int i=finestLevel(); i>=0; i--)
    {
        auto v = amrex::get_cell_data(data[i], cell);
        auto const& ba = data[i].boxArray();
        bool test = ba.intersects(Box(cell, cell, ba.ixType()), 0);

        if (test)
        {
            auto const& ba = data[i].boxArray();
            auto isects = ba.intersections(Box(cell, cell, ba.ixType()));
            int root = data[i].DistributionMap()[isects[0].first];
            if (ParallelDescriptor::MyProc() != root) v.resize(1);
            ParallelDescriptor::Bcast(v.data(), v.size(), root);
            return v[0];
        }
    }
    return -1; // or some error value if cell not found
}
`
@pkufourier
Copy link

I think the data buffer in MPI Bcast should be equal size in all processors. And v is better to be a temporal vector with a copy of data you want to bcast, other than the data reference from MFI. Therefore, the following resize is not proper.
if (ParallelDescriptor::MyProc() != root) v.resize(1);
ParallelDescriptor::Bcast(v.data(), v.size(), root);

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

No branches or pull requests

2 participants