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

How to get a non-round off corner cell in EB and the coincide EB boundary problem #3753

Closed
pkufourier opened this issue Feb 13, 2024 · 1 comment

Comments

@pkufourier
Copy link

I have the following test code with BoxIF:
//box_test.cpp
#include <AMReX.H>
#include <AMReX_EB2.H>
#include <AMReX_EB2_IF.H>
#include <AMReX_EBFabFactory.H>

int main(int argc, char* argv[])
{
using namespace amrex;
amrex::Initialize(argc, argv);

const int n_cell = 16;
const int max_grid_size = 32;

Geometry geom;
{
	RealBox rb({ 0.0,0.0,0.0 }, { n_cell,n_cell,n_cell }); // physical domain
	Array<int, AMREX_SPACEDIM> is_periodic{ false, false, false };
	Geometry::Setup(&rb, 0, is_periodic.data());
	Box domain(IntVect(0), IntVect(n_cell - 1));
	geom.define(domain);
}

//Testing parameters
const Real x0 = 1e-15, z0=-100;
EB2::BoxIF cube({ x0,0,z0 }, { n_cell,n_cell,100 }, true);

const int nghost = 3;
auto gshop = EB2::makeShop(cube);
EB2::Build(gshop, geom, 0, nghost);

MultiFab mf;

BoxArray ba(geom.Domain());
ba.maxSize(max_grid_size);
DistributionMapping dm{ ba };
Vector<int> ng_ebs = { nghost,nghost,nghost };
std::unique_ptr<EBFArrayBoxFactory> ebfactory = amrex::makeEBFabFactory(
	geom, ba, dm, ng_ebs, EBSupport::full);

const FabArray<EBCellFlagFab>& flags = ebfactory->getMultiEBCellFlagFab();
mf.define(ba, dm, 1, nghost, MFInfo(), *ebfactory);

const MultiFab& vfrac_mf = ebfactory->getVolFrac();
for (MFIter mfi(mf); mfi.isValid(); ++mfi)
{
	const Box& box = mfi.validbox();
	Array4<const EBCellFlag> const& flag_arr = flags.array(mfi);
	auto const& vfrac_arr = vfrac_mf[mfi].const_array();

	printf("is_singleV=%d,%d,%d\n", 
		flag_arr(-1, 0, 0).isSingleValued(), flag_arr(0, 0, 0).isSingleValued(), 
		flag_arr(1, 0, 0).isSingleValued());
	printf("vfrac(-1,0,0),(0,0,0),(1,0,0)=%6f,%6f,%6f\n", 
		vfrac_arr(-1, 0, 0),vfrac_arr(0, 0, 0), vfrac_arr(1, 0, 0));
}

amrex::Finalize();

}

Notice the testing parameters x0 and z0. For simplicity, we can set z0=-100 and this is a 2D box actually. Then with x0=0 or x0=1e-15, the final output would be
//x0=0, z0=-100
is_singleV=0,0,0
vfrac(-1,0,0),(0,0,0),(1,0,0)=1.000000,1.000000,1.000000

//x0=1e-15, z0=-100
is_singleV=0,1,1
vfrac(-1,0,0),(0,0,0),(1,0,0)=0.000000,0.500000,1.000000

Here I have two questions:
(1)When the EB box’s boundary coincides with the Geometry domain, the EB build shop seems do nothing? (see the first output) It seems to be a little buggy?
(2)When setting a little offset for the EB box(x0=1e-15), obviously the (0,0,0) cell was rounded off to be a triangle at the corner (see the second output). Could I get a non-round off cell at the box corner?

The testing code can be found here:
box_test.zip

@WeiqunZhang
Copy link
Member

(1) By default we extrapolate the implicit function's value from the domain face to what's outside the domain. You can turn it off by setting a runtime parameter eb2.extend_domain_false.

(2) The EB in a cut cell is approximated by a single plane. So we cannot have a sharp corner in a cell.

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