xref: /petsc/src/ksp/ksp/tutorials/amrex/initEB.cxx (revision daba9d70159ea2f6905738fcbec7404635487b2b)
1 #include <AMReX_EB2.H>
2 #include <AMReX_EB2_IF.H>
3 
4 #include <AMReX_ParmParse.H>
5 
6 #include <cmath>
7 #include <algorithm>
8 
9 #include "MyTest.H"
10 #include "MyEB.H"
11 
12 using namespace amrex;
13 
initializeEB()14 void MyTest::initializeEB()
15 {
16   ParmParse   pp("eb2");
17   std::string geom_type;
18   pp.get("geom_type", geom_type);
19 
20   if (geom_type == "combustor") {
21     amrex::Abort("initializeEB: todo");
22   } else if (geom_type == "rotated_box") {
23     EB2::BoxIF box({AMREX_D_DECL(0.25, 0.25, 0.25)}, {AMREX_D_DECL(0.75, 0.75, 0.75)}, false);
24     auto       gshop = EB2::makeShop(EB2::translate(EB2::rotate(EB2::translate(box, {AMREX_D_DECL(-0.5, -0.5, -0.5)}), std::atan(1.0) * 0.3, 2), {AMREX_D_DECL(0.5, 0.5, 0.5)}));
25     EB2::Build(gshop, geom.back(), max_level, max_level + max_coarsening_level);
26   } else if (geom_type == "two_spheres") {
27     EB2::SphereIF sphere1(0.2, {AMREX_D_DECL(0.45, 0.4, 0.58)}, false);
28     EB2::SphereIF sphere2(0.2, {AMREX_D_DECL(0.55, 0.42, 0.6)}, false);
29     auto          twospheres = EB2::makeUnion(sphere1, sphere2);
30     auto          gshop      = EB2::makeShop(twospheres);
31     EB2::Build(gshop, geom.back(), max_level, max_level + max_coarsening_level);
32   } else if (geom_type == "two_spheres_one_box") {
33     EB2::SphereIF sphere1(0.2, {AMREX_D_DECL(0.5, 0.48, 0.5)}, false);
34     EB2::SphereIF sphere2(0.2, {AMREX_D_DECL(0.55, 0.58, 0.5)}, false);
35     EB2::BoxIF    box({AMREX_D_DECL(0.25, 0.75, 0.5)}, {AMREX_D_DECL(0.75, 0.8, 0.75)}, false);
36     auto          twospheres = EB2::makeUnion(sphere1, sphere2, box);
37     auto          gshop      = EB2::makeShop(twospheres);
38     EB2::Build(gshop, geom.back(), max_level, max_level + max_coarsening_level);
39   } else if (geom_type == "flower") {
40     FlowerIF flower(0.2, 0.1, 6, {AMREX_D_DECL(0.5, 0.5, 0.5)}, false);
41     auto     gshop = EB2::makeShop(flower);
42     EB2::Build(gshop, geom.back(), max_level, max_level + max_coarsening_level);
43   } else {
44     EB2::Build(geom.back(), max_level, max_level + max_coarsening_level);
45   }
46 }
47