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

Start Embedded Boundary development #1641

Merged
merged 8 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set_default_install_dirs()
#
option(WarpX_APP "Build the WarpX executable application" ON)
option(WarpX_ASCENT "Ascent in situ diagnostics" OFF)
option(WarpX_EB "Embedded boundary support" OFF)
option(WarpX_LIB "Build WarpX as a shared library" OFF)
option(WarpX_MPI "Multi-node support (message-passing)" ON)
option(WarpX_OPENPMD "openPMD I/O (HDF5, ADIOS)" OFF)
Expand Down Expand Up @@ -181,6 +182,7 @@ endif()

add_subdirectory(Source/BoundaryConditions)
add_subdirectory(Source/Diagnostics)
add_subdirectory(Source/EmbeddedBoundary)
add_subdirectory(Source/Evolve)
add_subdirectory(Source/FieldSolver)
add_subdirectory(Source/Filter)
Expand Down
1 change: 1 addition & 0 deletions Docs/source/building/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ CMake Option Default & Values Descr
``WarpX_ASCENT`` ON/**OFF** Ascent in situ visualization
``WarpX_COMPUTE`` NOACC/**OMP**/CUDA/SYCL/HIP On-node, accelerated computing backend
``WarpX_DIMS`` **3**/2/RZ Simulation dimensionality
``WarpX_EB`` ON/**OFF** Embedded boundary support
``WarpX_LIB`` ON/**OFF** Build WarpX as a shared library
``WarpX_MPI`` **ON**/OFF Multi-node support (message-passing)
``WarpX_MPI_THREAD_MULTIPLE`` **ON**/OFF MPI thread-multiple support, i.e. for ``async_io``
Expand Down
2 changes: 2 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ USE_PSATD = FALSE
USE_PSATD_PICSAR = FALSE
USE_RZ = FALSE

USE_EB = FALSE

WARPX_HOME := .
include $(WARPX_HOME)/Source/Make.WarpX
4 changes: 4 additions & 0 deletions Source/EmbeddedBoundary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target_sources(WarpX
PRIVATE
WarpXInitEB.cpp
)
3 changes: 3 additions & 0 deletions Source/EmbeddedBoundary/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CEXE_sources += WarpXInitEB.cpp

VPATH_LOCATIONS += $(WARPX_HOME)/Source/EmbeddedBoundary
22 changes: 22 additions & 0 deletions Source/EmbeddedBoundary/WarpXInitEB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "WarpX.H"

#include <AMReX_Config.H>
#ifdef AMREX_USE_EB
# include <AMReX_EB2.H>
# include <AMReX_ParmParse.H>
#endif


void
WarpX::InitEB ()
{
#ifdef AMREX_USE_EB
BL_PROFILE("InitEB");

amrex::ParmParse pp("eb2");
if (!pp.contains("geom_type")) {
pp.add("geom_type", "all_regular"); // use all_regular by default
}
amrex::EB2::Build(Geom(maxLevel()), maxLevel(), maxLevel());
#endif
}
6 changes: 6 additions & 0 deletions Source/Make.WarpX
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ endif
include $(WARPX_HOME)/Source/Make.package
include $(WARPX_HOME)/Source/BoundaryConditions/Make.package
include $(WARPX_HOME)/Source/Diagnostics/Make.package
include $(WARPX_HOME)/Source/EmbeddedBoundary/Make.package
include $(WARPX_HOME)/Source/FieldSolver/Make.package
include $(WARPX_HOME)/Source/Filter/Make.package
include $(WARPX_HOME)/Source/Initialization/Make.package
Expand All @@ -90,6 +91,11 @@ ifeq ($(USE_SENSEI_INSITU),TRUE)
include $(AMREX_HOME)/Src/Extern/SENSEI/Make.package
endif

ifeq ($(USE_EB),TRUE)
include $(AMREX_HOME)/Src/EB/Make.package
USERSuffix := $(USERSuffix).EB
endif

ifeq ($(QED),TRUE)
INCLUDE_LOCATIONS += $(PICSAR_HOME)/src/multi_physics/QED/src
CXXFLAGS += -DWARPX_QED
Expand Down
8 changes: 8 additions & 0 deletions Source/Parallelization/WarpXRegrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi
{
if (ParallelDescriptor::NProcs() == 1) return;

#ifdef AMREX_USE_EB
m_field_factory[lev] = amrex::makeEBFabFactory(Geom(lev), ba, dm,
{1,1,1}, // Not clear how many ghost cells we need yet
amrex::EBSupport::full);
#else
m_field_factory[lev] = std::make_unique<FArrayBoxFactory>();
#endif

// Fine patch
for (int idim=0; idim < 3; ++idim)
{
Expand Down
18 changes: 18 additions & 0 deletions Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,24 @@ private:
// Domain decomposition on Level 0
amrex::IntVect numprocs{0};

//
// Embeded Boundary
//

// Factory for field data
amrex::Vector<std::unique_ptr<amrex::FabFactory<amrex::FArrayBox> > > m_field_factory;

amrex::FabFactory<amrex::FArrayBox> const& fieldFactory (int lev) const noexcept {
return *m_field_factory[lev];
}
#ifdef AMREX_USE_EB
amrex::EBFArrayBoxFactory const& fieldEBFactory (int lev) const noexcept {
return static_cast<amrex::EBFArrayBoxFactory const&>(*m_field_factory[lev]);
}
#endif

void InitEB ();

private:
// void EvolvePSATD (int numsteps);
void PushPSATD (amrex::Real dt);
Expand Down
10 changes: 10 additions & 0 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ WarpX::WarpX ()

BackwardCompatibility();

InitEB();

// Geometry on all levels has been defined already.

// No valid BoxArray and DistributionMapping have been defined.
Expand Down Expand Up @@ -236,6 +238,7 @@ WarpX::WarpX ()
pml.resize(nlevs_max);
costs.resize(nlevs_max);

m_field_factory.resize(nlevs_max);

if (em_solver_medium == MediumForEM::Macroscopic) {
// create object for macroscopic solver
Expand Down Expand Up @@ -949,6 +952,13 @@ WarpX::ClearLevel (int lev)
void
WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& dm)
{
#ifdef AMREX_USE_EB
m_field_factory[lev] = amrex::makeEBFabFactory(Geom(lev), ba, dm,
{1,1,1}, // Not clear how many ghost cells we need yet
amrex::EBSupport::full);
#else
m_field_factory[lev] = std::make_unique<FArrayBoxFactory>();
#endif

bool aux_is_nodal = (field_gathering_algo == GatheringAlgo::MomentumConserving);

Expand Down
5 changes: 5 additions & 0 deletions cmake/WarpXFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ function(set_warpx_binary_name)
set_property(TARGET ${tgt} APPEND_STRING PROPERTY OUTPUT_NAME ".PSATD")
endif()

if(WarpX_EB)
set_property(TARGET ${tgt} APPEND_STRING PROPERTY OUTPUT_NAME ".EB")
endif()

if(WarpX_QED)
set_property(TARGET ${tgt} APPEND_STRING PROPERTY OUTPUT_NAME ".QED")
endif()
Expand Down Expand Up @@ -272,6 +276,7 @@ function(warpx_print_summary)
message(" ASCENT: ${WarpX_ASCENT}")
message(" COMPUTE: ${WarpX_COMPUTE}")
message(" DIMS: ${WarpX_DIMS}")
message(" Embedded Boundary: ${WarpX_EB}")
message(" LIB: ${WarpX_LIB}")
message(" MPI: ${WarpX_MPI}")
if(MPI)
Expand Down
13 changes: 12 additions & 1 deletion cmake/dependencies/AMReX.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ macro(find_amrex)
set(AMReX_OMP OFF CACHE INTERNAL "")
endif()

if(WarpX_EB)
set(AMReX_EB ON CACHE INTERNAL "")
else()
set(AMReX_EB OFF CACHE INTERNAL "")
endif()

if(WarpX_MPI)
set(AMReX_MPI ON CACHE INTERNAL "")
if(WarpX_MPI_THREAD_MULTIPLE)
Expand Down Expand Up @@ -137,14 +143,19 @@ macro(find_amrex)
else()
set(COMPONENT_DIM ${WarpX_DIMS}D)
endif()
if(WarpX_EB)
set(COMPONENT_EB EB)
else()
set(COMPONENT_EB)
endif()
if(WarpX_LIB)
set(COMPONENT_PIC PIC)
else()
set(COMPONENT_PIC)
endif()
set(COMPONENT_PRECISION ${WarpX_PRECISION} P${WarpX_PRECISION})

find_package(AMReX 20.11 CONFIG REQUIRED COMPONENTS ${COMPONENT_ASCENT} ${COMPONENT_DIM} PARTICLES ${COMPONENT_PIC} ${COMPONENT_PRECISION} TINYP LSOLVERS)
find_package(AMReX 21.01 CONFIG REQUIRED COMPONENTS ${COMPONENT_ASCENT} ${COMPONENT_DIM} ${COMPONENT_EB} PARTICLES ${COMPONENT_PIC} ${COMPONENT_PRECISION} TINYP LSOLVERS)
message(STATUS "AMReX: Found version '${AMReX_VERSION}'")
endif()
endmacro()
Expand Down