What is the best way to create and access cell's flag ? #4706
-
Hello, I am very new to AMReX, and I am currently stuck on a problem. I am working on a project where I need to change the computation based on the type of a neighboring cell. I am in a D3Q19 domain (for LBM) and I am currently using a MultiFab called flags that has only 1 component, containing the cell's type. To clarify, I want to create the LBM roofline model where the lid has a constant fluid velocity. In order to correctly make the streaming step, I need to access all 19 neighbors and apply a specific update computation if the neighbor's flag is set as bounce back. But I find unexpected behavior when checking the neighbor's flag during computation (e.g.: accessing cell at x=x-1, y=y, z=z-1). My question is: What is the recommended way of creating and accessing cell's flags ? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 16 replies
-
@ToguyC -- have you created the MultiFab with ghost cells (you'll need to have at least one ghost cell if you want to check nearest neighbors)? Maybe you can share the MFIter / ParallelFor loops where you're checking the value of the cell? |
Beta Was this translation helpful? Give feedback.
-
What is the unexpected behavior that you see? |
Beta Was this translation helpful? Give feedback.
-
I'm not seeing anything obvious. Have you checked that you have correctly set the values of flag in the ghost cells? |
Beta Was this translation helpful? Give feedback.
-
FillBoundary will fill interior ghost cells, i.e. ones that overlap another Box in the BoxArray on which the MultiFab is defined. But it won't fill values outside of that, which are presumably outside the domain (unless you call FillBoundary(geom.periodicity() -- but then it will only fill ghost cells at periodic boundaries). I'm thinking that since you mentioned imposing a lid, you will need the ghost cells outside the physical domain? |
Beta Was this translation helpful? Give feedback.
-
What's the index type of your MultiFabs? Nodal or cell centered? |
Beta Was this translation helpful? Give feedback.
-
I might be better off rewritting from scratch trying not to include the bug. |
Beta Was this translation helpful? Give feedback.
-
Hello again ! I finally found out what the cause was. Whenever I use a I update the value of some neighbors based on some condition, and when the neighbor is a ghost cell, it causes issue. I do not really know how to handle such case in AMReX though. Is there a way to merge back the ghost cells on anything like that ? Sorry if I missed it in the documentation. |
Beta Was this translation helpful? Give feedback.
Right. iMultiFab's underlying type is int. You could also use your own type,
FabArray<BaseFab<CellType>>
.