Closed ruohai0925 closed 5 years ago
I am not going to try to answer every one of your questions.
Regarding the compilation error, I guess you have to include the appropriate header file, AMReX_BLUtil.H
.
You asked a question on AmrCoreAdvPhysBC::FillBoundary
not knowing the level and geometry. It's just an example in a simple tutorial. You can adapt it to say YourAmrCoreAdvPhysBC
. You can then construct a YourAmrCoreAdvPhysBC
object on each level. You can have the constructor take anything including Geometry
.
If you have further questions, maybe you can ask just one or two at a time. Then we can help you step by step.
Thanks Weiqun.
I will follow your suggestions and have another try. Also, I will split my questions next time, which may be more convenient for others to answer.
Hello all,
Recently, I am learning the 4.16 section (P35) about BCs. Here are some notes about what I learned and also some issues that I cannot solve.
Firstly, I just want to clarify my future goal and my aim nowadays. My future goal is to combine the incompressible staggered grid flow solver in our group with the amrex package to make the grids adaptive. After reading the codes in the Advection_AmrCore directory carefully, I think I can initialize the cell-center variable pressure without ghost cell properly. Thus, my aim nowadays is to add the physical boundary conditions (add ghost cells) for pressure.
In section 4.16, there are three different types of BCs. The first type is internal BC. In the function FillPatchSingleLevel, the code shows:
mf.FillBoundary(dcomp, ncomp,geom.periodicity());
In my view, this FillBoundary function only fills the values of ghost cells on the same level like the following figure,
It does not fill the ghost cell on the physical boundary. Is it correct?
Then, for physical boundary, it uses the code:
physbcf.FillBoundary(mf, dcomp, ncomp, time)
Since this virtual function is not overridden in this example, here are three issues.
**1. To my understanding, the default physbcf.FillBoundary is to make all physical boundary condition perioidic, is it correct?
Since I aimed at adding different non-periodic physical boundary conditions for pressure and check them, I then did the following things.
A first try:
I added the codes on P36 to try to override the FillBoundary() for physical boundary condition, and used the FillDomainBoundary function, like this: //------------------------------Code starts-----------------------// void AmrCoreAdvPhysBC::FillBoundary (amrex::MultiFab& mf, int, int, amrex::Real time) { Array bc(mf.nComp());
for (int n = 0; n < mf.nComp(); ++n)
{
for (int idim = 0; idim < AMREX_SPACEDIM ; ++ idim )
{
if (Geometry::isPeriodic(idim))
{
bc[n].setLo(idim, BCType::int_dir); // interior
bc[n].setHi(idim, BCType::int_dir);
}
else
{
bc[n].setLo(idim, BCType::reflect_even); // reflect-even
bc[n].setHi(idim, BCType::reflect_even);
}
}
}
// for cell-centered data pressure
amrex::FillDomainBoundary (mf, geom[0], bc);
}
//------------------------------Code ends-----------------------//
Since I do not know the level of mf, I have no idea about how to give the input variable geom[lev]. I used the geom[0] here. I think it is wrong because finer grids can also touch the physical boundary.
A second try:
Then, I think I can add the codes on P36 somewhere else, so I added them in the AmrCoreAdv::FillPatch function after the amrex::FillPatchSingleLevel, like this:
void AmrCoreAdv::FillPatch (int lev, Real time, MultiFab& mf, int icomp, int ncomp) { … AmrCoreAdvPhysBC physbc; amrex::FillPatchSingleLevel(mf, time, smf, stime, 0, icomp, ncomp, geom[lev], physbc); //------------------------------Code starts-----------------------// Codes on page 36 amrex::FillDomainBoundary(mf, geom[lev], bc); //------------------------------Code ends------------------------// … }
The complier says: error: ‘FillDomainBoundary’ is not a member of ‘amrex’ amrex::FillDomainBoundary(mf, geom[lev], bc); How does this happen?
To summarize,
I still do not know how to add the physical boundary condition for cell-center variables (e.g. pressure) or edge-center variable? Also, where should I add the related codes based on the Advection_AmrCore frame? How can I output the ghost cell values to check whether the physical boundary condition has been applied properly?
(Notes: I noticed in the closed issue, @pbrady has proposed a similiar question
https://github.com/AMReX-Codes/amrex/issues/2
@WeiqunZhang gave some links about simliar examples, yet most of these links can not be found. I think there are some alternative ways in the Advection_F example, which is a fortran-driven codes. Now I am learning them.)
Thanks for your suggestions.
Ruohai