Skip to content
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
29 changes: 0 additions & 29 deletions Source/NSB_K.H

This file was deleted.

175 changes: 0 additions & 175 deletions Source/NS_init_eb2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ using namespace amrex;
#include <AMReX_EB2.H>
#include <AMReX_EB2_IF.H>
#include <EBUserDefined.H>
#include <NSB_K.H>

#include <AMReX_ParmParse.H>
#include <AMReX_Geometry.H>
Expand All @@ -16,12 +15,6 @@ using namespace amrex;



inline
bool NavierStokesBase::ebInitialized()
{
return eb_initialized;
}

#if (AMREX_SPACEDIM == 3)
static
void reentrant_profile(std::vector<amrex::RealVect> &points) {
Expand Down Expand Up @@ -387,172 +380,4 @@ initialize_EB2 (const Geometry& geom, int required_coarsening_level,
}
}

void
NavierStokesBase::init_eb (const Geometry& /*level_geom*/, const BoxArray& /*ba*/, const DistributionMapping& /*dm*/)
{
// Build the geometry information; this is done for each new set of grids
initialize_eb2_structs();

}

void
NavierStokesBase::initialize_eb2_structs() {

amrex::Print() << "Initializing EB2 structs" << '\n';

// NOTE: THIS NEEDS TO BE REPLACED WITH A FLAGFAB

// n.b., could set this to 1 if geometry is all_regular as an optimization
no_eb_in_domain = false;

// 1->regular, 0->irregular, -1->covered, 2->outside
ebmask.define(grids, dmap, 1, 0);

const auto& ebfactory = dynamic_cast<EBFArrayBoxFactory const&>(Factory());

// These are the data sources
volfrac = &(ebfactory.getVolFrac());
areafrac = ebfactory.getAreaFrac();
facecent = ebfactory.getFaceCent();

auto const& flags = ebfactory.getMultiEBCellFlagFab();

#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (MFIter mfi(*volfrac, false); mfi.isValid(); ++mfi)
{
BaseFab<int>& mfab = ebmask[mfi];
const Box tbox = mfi.growntilebox();
const Box bx = mfi.tilebox();
const EBCellFlagFab& flagfab = flags[mfi];

FabType typ = flagfab.getType(tbox);

if (typ == FabType::regular) {
const auto& mask = ebmask.array(mfi);
amrex::ParallelFor(bx, [mask]
AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
mask(i,j,k) = 1;
});
}
else if (typ == FabType::covered) {
const auto& mask = ebmask.array(mfi);
amrex::ParallelFor(bx, [mask]
AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
mask(i,j,k) = -1;
});
}
else if (typ == FabType::singlevalued) {
for (BoxIterator bit(tbox); bit.ok(); ++bit) {
const EBCellFlag& flag = flagfab(bit(), 0);

if (!(flag.isRegular() || flag.isCovered())) {
if (mfab.box().contains(bit())) mfab(bit()) = 0;
} else {
if (flag.isRegular()) {
if (mfab.box().contains(bit())) mfab(bit()) = 1;
} else if (flag.isCovered()) {
if (mfab.box().contains(bit())) mfab(bit()) = -1;
} else {
if (mfab.box().contains(bit())) mfab(bit()) = 2;
}
}
}
}
else {
amrex::Print() << "unknown (or multivalued) fab type" << '\n';
amrex::Abort();
}
}
}

void
NavierStokesBase::define_body_state()
{
if (no_eb_in_domain) return;

// Scan over data and find a point in the fluid to use to
// set computable values in cells outside the domain
if (!body_state_set)
{
bool foundPt = false;
const MultiFab& S = get_new_data(State_Type);
AMREX_ASSERT(S.boxArray() == ebmask.boxArray());
AMREX_ASSERT(S.DistributionMap() == ebmask.DistributionMap());

body_state.resize(S.nComp(),0);
for (MFIter mfi(S,false); mfi.isValid() && !foundPt; ++mfi)
{
const Box vbox = mfi.validbox();
const BaseFab<int>& m = ebmask[mfi];
const FArrayBox& fab = S[mfi];
AMREX_ASSERT(m.box().contains(vbox));

// TODO: Remove this dog and do this work in fortran
for (BoxIterator bit(vbox); bit.ok() && !foundPt; ++bit)
{
const IntVect& iv = bit();
if (m(iv,0) == 1) {
foundPt = true;
for (int n=0; n<S.nComp(); ++n)
{
body_state[n] = fab(iv,n);
}
}
}
}

// Find proc with lowest rank to find valid point, use that for all
std::vector<int> found(ParallelDescriptor::NProcs(),0);
found[ParallelDescriptor::MyProc()] = (int)foundPt;
ParallelDescriptor::ReduceIntSum(&(found[0]),int(found.size()));
int body_rank = -1;
int found_size = static_cast<int>(found.size());
for (int i=0; i < found_size; ++i) {
if (found[i]==1) {
body_rank = i;
}
}
AMREX_ASSERT(body_rank>=0);
ParallelDescriptor::Bcast(&(body_state[0]),body_state.size(),body_rank);
body_state_set = true;
}
}

void
NavierStokesBase::set_body_state(MultiFab& S)
{
if (no_eb_in_domain) return;

if (!body_state_set)
{
define_body_state();
}

AMREX_ASSERT(S.nComp() == static_cast<int>(body_state.size()));
int nc = S.nComp();
int l_covered_val = -1;

// Need a GPU copy of body_state that's not a static attribute of the NSB class
AsyncArray<amrex::Real> body_state_lcl(body_state.data(),nc);

#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (MFIter mfi(S,TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.tilebox();
auto const& state_arr = S.array(mfi);
auto const& mask = ebmask.array(mfi);
Real* state_lcl = body_state_lcl.data();
amrex::ParallelFor(bx, [state_arr,mask,nc,l_covered_val,state_lcl]
AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
set_body_state_k(i,j,k,nc,state_lcl,l_covered_val,mask,state_arr);
});
}
}
#endif
11 changes: 4 additions & 7 deletions Source/NavierStokes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,10 @@ NavierStokes::initData ()
//
// In some cases, it may be necessary for the covered cells to
// contain a value typical (or around the same order of magnitude)
// to the uncovered cells (e.g. if code to compute variable
// viscosity fails for COVERED_VAL).
// of the uncovered cells (e.g. if code to compute variable
// viscosity fails for COVERED_VAL). There is no such facility
// here; fill them by hand if a problem needs it.
//
// set_body_state(S_new);
}
#endif

Expand Down Expand Up @@ -870,9 +870,6 @@ NavierStokes::scalar_update (Real dt,
scalar_diffusion_update(dt, first_scalar, last_scalar);

MultiFab& S_new = get_new_data(State_Type);
//#ifdef AMREX_USE_EB
// set_body_state(S_new);
//#endif
for (int sigma = first_scalar; sigma <= last_scalar; sigma++)
{
if (S_new.contains_nan(sigma,1,0))
Expand Down Expand Up @@ -1243,7 +1240,7 @@ NavierStokes::writePlotFilePost (const std::string& dir,
auto& sdata = state[i].newData();
// only cell-centered state data goes into plotfile
if ( sdata.ixType().cellCentered() ){
// put COVERED_VAL back or set_body_state
// put COVERED_VAL back
EB_set_covered(sdata, COVERED_VAL);
}
}
Expand Down
16 changes: 0 additions & 16 deletions Source/NavierStokesBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -579,18 +579,7 @@ public:
static void floor(amrex::MultiFab& mf);

#ifdef AMREX_USE_EB
void init_eb (const amrex::Geometry& level_geom, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);

void initialize_eb2_structs();
void define_body_state();

void InitialRedistribution ();

static bool ebInitialized();
static bool eb_initialized;
static bool body_state_set;
static bool no_eb_in_domain;
static std::vector<amrex::Real> body_state;
#endif

void ComputeAofs (int comp, int ncomp,
Expand Down Expand Up @@ -622,14 +611,9 @@ public:
std::unique_ptr<amrex::iMultiFab> coarse_fine_mask;

#ifdef AMREX_USE_EB
void set_body_state(amrex::MultiFab& S);

const amrex::MultiFab* volfrac;
amrex::FabArray<amrex::BaseFab<int>> ebmask;

std::array<const amrex::MultiCutFab*, AMREX_SPACEDIM> areafrac;
std::array<const amrex::MultiCutFab*, AMREX_SPACEDIM> facecent;

#endif


Expand Down
5 changes: 0 additions & 5 deletions Source/NavierStokesBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <AMReX_FillPatchUtil.H>
#include <AMReX_Extrapolater.H>
#include <NavierStokesBase.H>
#include <NSB_K.H>
#include <NS_util.H>
#include <iamr_constants.H>

Expand Down Expand Up @@ -138,10 +137,6 @@ bool NavierStokesBase::godunov_use_forces_in_trans = false;

#ifdef AMREX_USE_EB
int NavierStokesBase::refine_cutcells = 1;
bool NavierStokesBase::eb_initialized = false;
bool NavierStokesBase::no_eb_in_domain = true;
bool NavierStokesBase::body_state_set = false;
std::vector<Real> NavierStokesBase::body_state;
std::string NavierStokesBase::redistribution_type = "StateRedist";
#endif

Expand Down
1 change: 0 additions & 1 deletion Source/Projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <AMReX_BLProfiler.H>
#include <Projection.H>
#include <OutFlowBC.H>
#include <NSB_K.H>

#include <AMReX_MLMG.H>
#include <AMReX_MLNodeLaplacian.H>
Expand Down
1 change: 0 additions & 1 deletion Source/SyncRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <AMReX_FluxRegister.H>
#include <SyncRegister.H>
#include <AMReX_BLProfiler.H>
#include <NSB_K.H>

#ifdef _OPENMP
#include <omp.h>
Expand Down
Loading