AMReX-Combustion / PeleLM

An adaptive mesh hydrodynamics simulation code for low Mach number reacting flows
https://amrex-combustion.github.io/PeleLM/
Other
83 stars 41 forks source link

Multiple Embedded boundaries using PeleLM #154

Closed RSuryaNarayan closed 3 years ago

RSuryaNarayan commented 3 years ago

Hello, I am trying to simulate the external flow around four cylinders using PeleLM. I decided to create a new case by copying the FlowPastCylinder tutorial and tweak it for my case. I am confused about how I can create a union of the embedded boundaries of the 4 spheres in the my case. I have done this in PeleC by adding a new if case in the PeleC_init_eb.cpp file and copying it to my case directory.This worked fine. I am not able to locate a similar file where I can make changes to the EB or add a new case to simulate more complex geometries in PeleLM. Any help on this is much appreciated. For the sake of clarity, my geometry would look something like this: (with a smaller number of cylinders): image

Thanks Surya

esclapez commented 3 years ago

Hello Surya,

Thank you for your question!

In the case of PeleLM, the EB initialization lives in IAMR. A simple way to gain control of that piece of code without touching IAMR is to copy the IAMR/Sources/NS_init_eb2.cpp file into your run folder and make sure the makefile system includes it by setting CEXE_sources += NS_init_eb2.cpp in the GNUmakefile. The content of the file is very similar to its PeleC counterpart so you should be able to append an 'if' statement with your desired union of cylinders.

Let us know if you run into troubles.

Lucas

RSuryaNarayan commented 3 years ago

Thank you so much for your reply. I copied the IAMR/Sources/NS_init_eb2.cpp to my folder in Tutorials and appended the code below (Also modified the GNUMakefile to include the CEXE_sources += NS_init_eb2.cpp): `else if(geom_type=="cylinder_grid"){ // Initialise parameters Real radius_1=0.005; Real radius_2=0.005; bool flow_inside_cyl = false;

Vector<Real> centervec1(3);
Vector<Real> centervec2(3);

// Get information from inputs file.
ParmParse pp("cylinder_grid");

pp.query("radius_1", radius_1);
pp.query("radius_2", radius_2);
pp.getarr("center_1", centervec1, 0, 3);
pp.getarr("center_2", centervec2, 0, 3);

Array<Real, 3> center1 = {centervec1[0], centervec1[1], centervec1[2]};
Array<Real, 3> center2 = {centervec2[0], centervec2[1], centervec2[2]};
// Build the implicit function as a union of two spheres
EB2::SphereIF sphere1(radius_1,center1,flow_inside_cyl);
EB2::SphereIF sphere2(radius_2,center2,flow_inside_cyl);
auto twospheres = EB2::makeUnion(sphere1, sphere2);

// Generate GeometryShop
auto gshop = EB2::makeShop(twospheres);
// Build index space
int max_level_here = 0;
int max_coarsening_level = 100;
EB2::Build(gshop, geom, required_coarsening_level, max_coarsening_level);

} I still get the error: amrex::Abort::0::geom_type cylinder_grid not supported !!! SIGABRT Thanks once again

drummerdoc commented 3 years ago

Try make clean then make again. It probably did not grab the correct .o file

RSuryaNarayan commented 3 years ago

@drummerdoc @esclapez I tried the make clean and then make again. None of the ifs in the file seem to run. Is there anything wrong with my installation?

esclapez commented 3 years ago

In NS_init_eb2.cpp, most of the 'if' are within an ifdef AMREX_SPACEDIM == 3 region. Are you compiling with DIM = 3 ?

RSuryaNarayan commented 3 years ago

@esclapez No. My DIM was set to 2 by default in the GNUMakefile. I am attempting a 2-D solution. Should I set the DIM to 3 nonetheless?

esclapez commented 3 years ago

You don't have to switch to 3D, but you should add your 'if' after the end of the ifdef AMREX_SPACEDIM == 3. Or you can remove the ifdef AMREX_SPACEDIM == 3 and the #endif near the end of the 'if' switches altogether. The way this is setup is actually somewhat weird, so I'll go ahead and update IAMR, but the easiest way for you at this point is to remove the compiler ifdef.

RSuryaNarayan commented 3 years ago

Makes sense. Just to be on the same page I have an #if BL_SPACEDIM > 2 in my NS_init_eb2.cpp file. I hope you are referring to the same if-else.

esclapez commented 3 years ago

Yes, sorry about that, I'm referring to #if BL_SPACEDIM > 2. Legacy BoxLib defines (BL_) can still be found in IAMR instead of AMReX ones (AMREX_).

RSuryaNarayan commented 3 years ago

I have now put the condition after the #endif and it compiles beyond that and throws this error: NS_init_eb2.cpp:392:59: error: no matching function for call to ‘amrex::EB2::SphereIF::SphereIF(amrex::Real&, amrex::Array<double, 3>&, bool&)’ which makes it an error with the way I am using SphereIF. But I am following this and my code seems fine!

RSuryaNarayan commented 3 years ago

@esclapez I tried putting in one of the Ifs already defined outside and I recieve the same error. Is it because its expecting a different 2-D initialization while we are trying to provide a 3-D one?

RSuryaNarayan commented 3 years ago

removing the #ifdef throws this error on every case under the if-else block!

RSuryaNarayan commented 3 years ago

@esclapez the 3-D case finally worked just fine! Here's the screenshot. I hope the same can be done in 2-D once you update IAMR. Thanks so much for the help so far! image

RSuryaNarayan commented 3 years ago

Thanks a ton @esclapez and @drummerdoc for your support. And special thanks to @esclapez to have created the separate case for the 2-d grid of cylinders in the IAMR/Ns_init_eb2.cpp file. Finally got it working! image

drummerdoc commented 3 years ago

Awesome! Thanks Lucas. Let us know what happens next.

RSuryaNarayan commented 3 years ago

Sure @drummerdoc I will be attempting a case like EB_FlamePastCylinderwith this grid of cylinders. Will report any bugs/errors and any interesting results I get!