From 1cdf1f952f59bee27b625b11b232447d0fbd8eb4 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Mon, 13 Aug 2018 17:22:21 -0700 Subject: [PATCH] add EB to libamrex.a as optional feature --- GNUmakefile.in | 4 +++ Src/Amr/AMReX_StateData.H | 2 ++ Src/EB/AMReX_EBTower.H | 4 ++- Src/EB/AMReX_EBTower.cpp | 14 ++++++-- Src/EB/AMReX_EB_levelset.H | 4 +++ Src/EB/AMReX_EB_levelset.cpp | 4 +++ Tools/libamrex/configure.py | 8 +++++ Tutorials/EB/CNS/Exec/Make.CNS | 3 ++ Tutorials/EB/CNS/Source/CNS.H | 6 ---- Tutorials/EB/CNS/Source/CNS.cpp | 57 --------------------------------- 10 files changed, 39 insertions(+), 67 deletions(-) diff --git a/GNUmakefile.in b/GNUmakefile.in index e04b3da0129..826b2d5db63 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -16,6 +16,10 @@ ifeq ($(USE_LINEAR_SOLVERS),TRUE) Pdirs += F_Interfaces/LinearSolvers endif endif +ifeq ($(USE_EB),TRUE) + DEFINES += -DAMREX_NO_DEPRECATED_EB + Pdirs += EB EB2 +endif Ppack := $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)/Make.package) include $(Ppack) diff --git a/Src/Amr/AMReX_StateData.H b/Src/Amr/AMReX_StateData.H index b15b1c57c95..c3df0453218 100644 --- a/Src/Amr/AMReX_StateData.H +++ b/Src/Amr/AMReX_StateData.H @@ -18,8 +18,10 @@ #include #include #ifdef AMREX_USE_EB +#ifndef AMREX_NO_DEPRECATED_EB #include #endif +#endif namespace amrex { diff --git a/Src/EB/AMReX_EBTower.H b/Src/EB/AMReX_EBTower.H index ab5d0606414..a1fe9cdb45a 100644 --- a/Src/EB/AMReX_EBTower.H +++ b/Src/EB/AMReX_EBTower.H @@ -31,13 +31,15 @@ public: private: - EBTower (); ~EBTower (); +#ifndef AMREX_NO_DEPRECATED_EB + EBTower (); void initCellFlags (int lev, const EBLevelGrid& eblg); void initVolumeGeometry (int lev, const EBLevelGrid& eblg); void initBndryCent (int lev, const EBLevelGrid& eblg); void initFaceGeometry (int lev, const EBLevelGrid& eblg); +#endif static Vector getPeriodicGhostBoxes(const Box & a_valid, diff --git a/Src/EB/AMReX_EBTower.cpp b/Src/EB/AMReX_EBTower.cpp index 958e4f75566..a07d90e14c4 100644 --- a/Src/EB/AMReX_EBTower.cpp +++ b/Src/EB/AMReX_EBTower.cpp @@ -1,7 +1,11 @@ #include +#include + +#ifndef AMREX_NO_DEPRECATED_EB #include #include +#endif #include @@ -41,6 +45,7 @@ EBTower::coarestDomain () return m_instance->m_domains.back(); } +#ifndef AMREX_NO_DEPRECATED_EB EBTower::EBTower () { BL_PROFILE("EBTower::EBTower()"); @@ -133,11 +138,13 @@ EBTower::EBTower () } } } +#endif EBTower::~EBTower () { } +#ifndef AMREX_NO_DEPRECATED_EB void EBTower::initCellFlags (int lev, const EBLevelGrid& eblg) { @@ -306,6 +313,7 @@ EBTower::initFaceGeometry (int lev, const EBLevelGrid& eblg) } } } +#endif int EBTower::getIndex (const Box& domain) const @@ -360,7 +368,7 @@ getPeriodicGhostBoxes(const Box & a_valid, Box edgeBoxHiIHiJ = adjCellHi(flapBoxHiI, jdir, a_ngrow); - vector edgeBoxes(4); + Vector edgeBoxes(4); edgeBoxes[0] = edgeBoxLoILoJ; edgeBoxes[1] = edgeBoxHiILoJ; edgeBoxes[2] = edgeBoxLoIHiJ; @@ -397,7 +405,7 @@ getPeriodicGhostBoxes(const Box & a_valid, Box cornerBoxLoIHiJHiK = adjCellHi(edgeBoxLoIHiJ, 2, a_ngrow); Box cornerBoxHiIHiJHiK = adjCellHi(edgeBoxHiIHiJ, 2, a_ngrow); - vector cornerBoxes(8); + Vector cornerBoxes(8); cornerBoxes[0] = cornerBoxLoILoJLoK; cornerBoxes[1] = cornerBoxHiILoJLoK; @@ -457,7 +465,7 @@ EBTower::fillEBCellFlag (FabArray& a_flag, const Geometry& a_geom { Box valid = bagrids[mfi]; Periodicity peri = a_geom.periodicity(); - vector periodicShifts = peri.shiftIntVect(); + const auto& periodicShifts = peri.shiftIntVect(); int ngrow = a_flag.nGrow(); Vector ghostBoxes = getPeriodicGhostBoxes(valid, domain, ngrow, peri); for(int ibox = 0; ibox < ghostBoxes.size(); ibox++) diff --git a/Src/EB/AMReX_EB_levelset.H b/Src/EB/AMReX_EB_levelset.H index e8465969459..16d3cece362 100644 --- a/Src/EB/AMReX_EB_levelset.H +++ b/Src/EB/AMReX_EB_levelset.H @@ -1,6 +1,8 @@ #ifndef AMREX_EB_LEVELSET_H_ #define AMREX_EB_LEVELSET_H_ +#ifndef AMREX_NO_DEPRECATED_EB + #include #include #include @@ -188,3 +190,5 @@ class PolynomialDF : public PolynomialIF { } #endif + +#endif diff --git a/Src/EB/AMReX_EB_levelset.cpp b/Src/EB/AMReX_EB_levelset.cpp index a5477c06d7b..8b797eaf5e5 100644 --- a/Src/EB/AMReX_EB_levelset.cpp +++ b/Src/EB/AMReX_EB_levelset.cpp @@ -1,5 +1,7 @@ #include "AMReX_EB_levelset.H" +#ifndef AMREX_NO_DEPRECATED_EB + #include #include #include @@ -886,3 +888,5 @@ BaseIF * PolynomialDF::newImplicitFunction() const { } } + +#endif diff --git a/Tools/libamrex/configure.py b/Tools/libamrex/configure.py index 28e0536ab21..e5b8bb5a3b9 100755 --- a/Tools/libamrex/configure.py +++ b/Tools/libamrex/configure.py @@ -47,6 +47,10 @@ def configure(argv): help="Enable AMReX linear solvers [default=yes]", choices=["yes","no"], default="yes") + parser.add_argument("--enable-eb", + help="Enable AMReX embedded boundary capability [default=no]", + choices=["yes","no"], + default="no") parser.add_argument("--enable-xsdk-defaults", help="Enable XSDK mode [default=no]", choices=["yes","no"], @@ -85,6 +89,10 @@ def configure(argv): f.write("USE_LINEAR_SOLVERS = FALSE\n") else: f.write("USE_LINEAR_SOLVERS = TRUE\n") + if args.enable_eb == "yes": + f.write("USE_EB = TRUE\n") + else: + f.write("USE_EB = FALSE\n") if args.enable_xsdk_defaults == "yes": f.write("AMREX_XSDK = TRUE\n") else: diff --git a/Tutorials/EB/CNS/Exec/Make.CNS b/Tutorials/EB/CNS/Exec/Make.CNS index 62455a446ce..7b8e79f8b05 100644 --- a/Tutorials/EB/CNS/Exec/Make.CNS +++ b/Tutorials/EB/CNS/Exec/Make.CNS @@ -11,6 +11,9 @@ LAZY := TRUE include $(AMREX_HOME)/Tools/GNUMake/Make.defs +# CNS does not use any deprecated EB code +DEFINES += -DAMREX_NO_DEPRECATED_EB + # CNS uses a coarse grained OMP approach DEFINES += -DAMREX_CRSEGRNDOMP diff --git a/Tutorials/EB/CNS/Source/CNS.H b/Tutorials/EB/CNS/Source/CNS.H index f2be945ffc3..2dd62097281 100644 --- a/Tutorials/EB/CNS/Source/CNS.H +++ b/Tutorials/EB/CNS/Source/CNS.H @@ -123,12 +123,6 @@ protected: // Compute initial time step. amrex::Real initialTimeStep (); - void printPointStuff(const EBCellFlag& flag, - const IntVect& a_iv, - const MFIter & a_mfi) const; - - void testEBStuff() const; - void computeTemp (amrex::MultiFab& State, int ng); void compute_dSdt (const amrex::MultiFab& S, amrex::MultiFab& dSdt, amrex::Real dt, diff --git a/Tutorials/EB/CNS/Source/CNS.cpp b/Tutorials/EB/CNS/Source/CNS.cpp index 0736d75ac1f..c70a5f921ce 100644 --- a/Tutorials/EB/CNS/Source/CNS.cpp +++ b/Tutorials/EB/CNS/Source/CNS.cpp @@ -111,63 +111,6 @@ CNS::initData () MultiFab& C_new = get_new_data(Cost_Type); C_new.setVal(1.0); - -#if 0 - testEBStuff(); -#endif - -} - -void -CNS:: -testEBStuff() const -{ - //test for geometry info outside domain - Box domain = geom.Domain(); - const MultiFab& S_new = get_new_data(State_Type); - for(int idir = 0; idir < SpaceDim; idir++) - { - for (MFIter mfi(S_new); mfi.isValid(); ++mfi) - { - - Box validbox = mfi.validbox(); - Box grownbox = grow(validbox, 1); - const EBFArrayBox& sfab = dynamic_cast(S_new[mfi]); - const EBCellFlagFab& flagfab = sfab.getEBCellFlagFab(); - for(BoxIterator bit(grownbox); bit.ok(); ++bit) - { - if(!domain.contains(bit())) - { - const EBCellFlag& flag = flagfab(bit(), 0); - printPointStuff(flag, bit(), mfi); - } - } - } - } -} - -void -CNS::printPointStuff(const EBCellFlag& a_flag, - const IntVect& a_iv, - const MFIter & a_mfi) const -{ - amrex::Print() << a_iv << ":" ; - if(a_flag.isRegular()) - { - amrex::Print() << "regular, " ; - } - else if(a_flag.isCovered()) - { - amrex::Print() << "covered, " ; - } - else - { - amrex::Print() << "irregular, " ; - } - Real kappa = (*volfrac)[a_mfi](a_iv, 0); - amrex::Print() << "kappa= " << kappa; - amrex::Print() << endl; - } void