Skip to content

Commit

Permalink
add EB to libamrex.a as optional feature
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Aug 14, 2018
1 parent 76af532 commit 1cdf1f9
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 67 deletions.
4 changes: 4 additions & 0 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions Src/Amr/AMReX_StateData.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#include <AMReX_RealBox.H>
#include <AMReX_StateDescriptor.H>
#ifdef AMREX_USE_EB
#ifndef AMREX_NO_DEPRECATED_EB
#include <AMReX_EBLevelGrid.H>
#endif
#endif

namespace amrex {

Expand Down
4 changes: 3 additions & 1 deletion Src/EB/AMReX_EBTower.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box>
getPeriodicGhostBoxes(const Box & a_valid,
Expand Down
14 changes: 11 additions & 3 deletions Src/EB/AMReX_EBTower.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

#include <AMReX_EBTower.H>
#include <AMReX_Vector.H>

#ifndef AMREX_NO_DEPRECATED_EB
#include <AMReX_EBISLevel.H>
#include <AMReX_EBLevelGrid.H>
#endif

#include <algorithm>

Expand Down Expand Up @@ -41,6 +45,7 @@ EBTower::coarestDomain ()
return m_instance->m_domains.back();
}

#ifndef AMREX_NO_DEPRECATED_EB
EBTower::EBTower ()
{
BL_PROFILE("EBTower::EBTower()");
Expand Down Expand Up @@ -133,11 +138,13 @@ EBTower::EBTower ()
}
}
}
#endif

EBTower::~EBTower ()
{
}

#ifndef AMREX_NO_DEPRECATED_EB
void
EBTower::initCellFlags (int lev, const EBLevelGrid& eblg)
{
Expand Down Expand Up @@ -306,6 +313,7 @@ EBTower::initFaceGeometry (int lev, const EBLevelGrid& eblg)
}
}
}
#endif

int
EBTower::getIndex (const Box& domain) const
Expand Down Expand Up @@ -360,7 +368,7 @@ getPeriodicGhostBoxes(const Box & a_valid,
Box edgeBoxHiIHiJ = adjCellHi(flapBoxHiI, jdir, a_ngrow);


vector<Box> edgeBoxes(4);
Vector<Box> edgeBoxes(4);
edgeBoxes[0] = edgeBoxLoILoJ;
edgeBoxes[1] = edgeBoxHiILoJ;
edgeBoxes[2] = edgeBoxLoIHiJ;
Expand Down Expand Up @@ -397,7 +405,7 @@ getPeriodicGhostBoxes(const Box & a_valid,
Box cornerBoxLoIHiJHiK = adjCellHi(edgeBoxLoIHiJ, 2, a_ngrow);
Box cornerBoxHiIHiJHiK = adjCellHi(edgeBoxHiIHiJ, 2, a_ngrow);

vector<Box> cornerBoxes(8);
Vector<Box> cornerBoxes(8);

cornerBoxes[0] = cornerBoxLoILoJLoK;
cornerBoxes[1] = cornerBoxHiILoJLoK;
Expand Down Expand Up @@ -457,7 +465,7 @@ EBTower::fillEBCellFlag (FabArray<EBCellFlagFab>& a_flag, const Geometry& a_geom
{
Box valid = bagrids[mfi];
Periodicity peri = a_geom.periodicity();
vector<IntVect> periodicShifts = peri.shiftIntVect();
const auto& periodicShifts = peri.shiftIntVect();
int ngrow = a_flag.nGrow();
Vector<Box> ghostBoxes = getPeriodicGhostBoxes(valid, domain, ngrow, peri);
for(int ibox = 0; ibox < ghostBoxes.size(); ibox++)
Expand Down
4 changes: 4 additions & 0 deletions Src/EB/AMReX_EB_levelset.H
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef AMREX_EB_LEVELSET_H_
#define AMREX_EB_LEVELSET_H_

#ifndef AMREX_NO_DEPRECATED_EB

#include <AMReX_REAL.H>
#include <AMReX_Vector.H>
#include <AMReX_RealVect.H>
Expand Down Expand Up @@ -188,3 +190,5 @@ class PolynomialDF : public PolynomialIF {
}

#endif

#endif
4 changes: 4 additions & 0 deletions Src/EB/AMReX_EB_levelset.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "AMReX_EB_levelset.H"

#ifndef AMREX_NO_DEPRECATED_EB

#include <AMReX_REAL.H>
#include <AMReX_Vector.H>
#include <AMReX_RealVect.H>
Expand Down Expand Up @@ -886,3 +888,5 @@ BaseIF * PolynomialDF::newImplicitFunction() const {
}

}

#endif
8 changes: 8 additions & 0 deletions Tools/libamrex/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions Tutorials/EB/CNS/Exec/Make.CNS
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions Tutorials/EB/CNS/Source/CNS.H
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
57 changes: 0 additions & 57 deletions Tutorials/EB/CNS/Source/CNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<EBFArrayBox const&>(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
Expand Down

0 comments on commit 1cdf1f9

Please sign in to comment.