forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAMReX_EBAmrUtil.cpp
70 lines (57 loc) · 1.82 KB
/
AMReX_EBAmrUtil.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <AMReX_EBAmrUtil.H>
#include <AMReX_EBFArrayBox.H>
#include <AMReX_EBCellFlag.H>
#ifdef AMREX_USE_OMP
#include <omp.h>
#endif
namespace amrex {
void
TagCutCells (TagBoxArray& tags, const MultiFab& state)
{
const char tagval = TagBox::SET;
// const char clearval = TagBox::CLEAR;
auto const& factory = dynamic_cast<EBFArrayBoxFactory const&>(state.Factory());
auto const& flags = factory.getMultiEBCellFlagFab();
#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (MFIter mfi(state, TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.tilebox();
const auto& flag = flags[mfi];
const FabType typ = flag.getType(bx);
if (typ != FabType::regular && typ != FabType::covered)
{
Array4<char> const& tagarr = tags.array(mfi);
Array4<EBCellFlag const> const& flagarr = flag.const_array();
AMREX_HOST_DEVICE_FOR_3D (bx, i, j, k,
{
if (flagarr(i,j,k).isSingleValued()) {
tagarr(i,j,k) = tagval;
}
});
}
}
}
void
TagVolfrac (TagBoxArray& tags, const MultiFab& volfrac, Real tol)
{
BL_PROFILE("amrex::TagVolfrac()");
// const char clearval = TagBox::CLEAR;
const char tagval = TagBox::SET;
#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (MFIter mfi(volfrac, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
const Box& bx = mfi.tilebox();
Array4<char> const& tagarr = tags.array(mfi);
Array4<Real const> const& volarr = volfrac.const_array(mfi);
AMREX_HOST_DEVICE_FOR_3D ( bx, i, j, k,
{
if (volarr(i,j,k) <= (1.-tol) && volarr(i,j,k) >= tol) {
tagarr(i,j,k) = tagval;
}
});
}
}
}