Skip to content

Commit 996d1de

Browse files
committed
Start EB
This is still work in progress. You can build EB and create EBFArrayBoxFactory objects from python.
1 parent 49c917f commit 996d1de

File tree

6 files changed

+97
-1
lines changed

6 files changed

+97
-1
lines changed

docs/source/usage/api.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,19 @@ This is for the legacy, AoS + SoA particle containers only:
280280
.. autoclass:: amrex.space3d.Particle_2_1
281281
:members:
282282
:undoc-members:
283+
284+
.. _usage-api-eb:
285+
286+
Embedded Boundaries
287+
-------------------
288+
289+
Embedded boundary (EB) support is still experimental. To build pyAMReX with
290+
EB support, you need to add ``-DAMReX_EB=ON`` to CMake build options.
291+
292+
.. autofunction:: amrex.space3d.EB2_Build
293+
294+
.. autoclass:: amrex.space3d.EBFArrayBoxFactory
295+
:members:
296+
:undoc-members:
297+
298+
.. autofunction:: amrex.space3d.makeEBFabFactory

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
add_subdirectory(AmrCore)
33
add_subdirectory(Base)
44
#add_subdirectory(Boundary)
5-
#add_subdirectory(EB)
5+
if (AMReX_EB)
6+
add_subdirectory(EB)
7+
endif()
68
#add_subdirectory(Extern)
79
#add_subdirectory(LinearSolvers)
810
add_subdirectory(Particle)

src/EB/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
foreach(D IN LISTS AMReX_SPACEDIM)
2+
if (D EQUAL 1)
3+
return()
4+
endif()
5+
6+
target_sources(pyAMReX_${D}d
7+
PRIVATE
8+
EB.cpp
9+
EBFabFactory.cpp
10+
)
11+
endforeach()

src/EB/EB.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "pyAMReX.H"
2+
3+
#include <AMReX_EB2.H>
4+
5+
void init_EBFabFactory (py::module& m);
6+
7+
void init_EB (py::module& m)
8+
{
9+
using namespace amrex;
10+
11+
m.def(
12+
"EB2_Build",
13+
[] (Geometry const& geom, int required_coarsening_level, int max_coarsening_level,
14+
int ngrow, bool build_coarse_level_by_coarsening, bool extend_domain_face,
15+
int num_coarsen_opt)
16+
{
17+
EB2::Build(geom, required_coarsening_level, max_coarsening_level, ngrow,
18+
build_coarse_level_by_coarsening, extend_domain_face, num_coarsen_opt);
19+
},
20+
py::arg("geom"), py::arg("required_coarsening_level"), py::arg("max_coarsening_level"),
21+
py::arg("ngrow") = 4, py::arg("build_coarse_level_by_coarsening") = true,
22+
py::arg("extend_domain_face") = EB2::ExtendDomainFace(),
23+
py::arg("num_coarsen_opt") = EB2::NumCoarsenOpt(),
24+
"EB generation"
25+
);
26+
27+
init_EBFabFactory(m);
28+
}

src/EB/EBFabFactory.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
#include "pyAMReX.H"
3+
4+
#include <AMReX_EBFabFactory.H>
5+
#include <AMReX_MultiFab.H>
6+
7+
void init_EBFabFactory (py::module& m)
8+
{
9+
using namespace amrex;
10+
11+
py::class_<EBFArrayBoxFactory, FabFactory<FArrayBox>>(m, "EBFArrayBoxFactory")
12+
.def("getVolFrac", &EBFArrayBoxFactory::getVolFrac,
13+
py::return_value_policy::reference_internal,
14+
"Return volume faction MultiFab");
15+
16+
py::enum_<EBSupport>(m, "EBSupport")
17+
.value("basic", EBSupport::basic)
18+
.value("volume", EBSupport::volume)
19+
.value("full", EBSupport::full);
20+
21+
m.def(
22+
"makeEBFabFactory",
23+
[] (Geometry const& geom, BoxArray const& ba, DistributionMapping const& dm,
24+
Vector<int> const& ngrow, EBSupport support)
25+
{
26+
return makeEBFabFactory(geom, ba, dm, ngrow, support);
27+
},
28+
py::arg("geom"), py::arg("ba"), py::arg("dm"), py::arg("ngrow"),
29+
py::arg("support").
30+
"Make EBFArrayBoxFactory for given Geometry, BoxArray and DistributionMapping"
31+
);
32+
}

src/pyAMReX.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ void init_Utility(py::module &);
4848
void init_Vector(py::module &);
4949
void init_Version(py::module &);
5050
void init_VisMF(py::module &);
51+
#ifdef AMREX_USE_EB
52+
void init_EB(py::module &);
53+
#endif
5154

5255
#if AMREX_SPACEDIM == 1
5356
PYBIND11_MODULE(amrex_1d_pybind, m) {
@@ -139,6 +142,10 @@ PYBIND11_MODULE(amrex_3d_pybind, m) {
139142
init_Version(m);
140143
init_VisMF(m);
141144

145+
#ifdef AMREX_USE_EB
146+
init_EB(m);
147+
#endif
148+
142149
// authors
143150
m.attr("__author__") =
144151
"Axel Huebl, Ryan T. Sandberg, Shreyas Ananthan, David P. Grote, "

0 commit comments

Comments
 (0)