1 #ifndef AMREX_PhysBCFunct_H_
2 #define AMREX_PhysBCFunct_H_
3 #include <AMReX_Config.H>
19 const int* dom_lo,
const int* dom_hi,
20 const Real* dx,
const Real* grd_lo,
21 const Real* time,
const int* bc);
23 const int* dom_lo,
const int* dom_hi,
24 const Real* dx,
const Real* grd_lo,
25 const Real* time,
const int* bc);
29 int dcomp,
int numcomp,
31 const BCRec* bcr,
int bcomp,
43 int dcomp,
int numcomp,
71 int dcomp,
int numcomp,
78 int dcomp,
int numcomp,
81 int orig_comp, FF
const& fillfunc);
84 int dcomp,
int numcomp,
110 int dcomp,
int numcomp,
133 template <
typename MF,
typename Interp>
135 IntVect const& a_nghost_outside_domain,
136 IntVect const& ratio, Interp* mapper)
143 const auto& coarsener = mapper->BoxCoarsener(ratio);
145 Box tmp2 = coarsener.doit(tmp);
149 tmp2 = coarsener.doit(tmp);
200 Real time,
int bccomp)
211 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
213 gdomain.
grow(i, nghost[i]);
218 #pragma omp parallel if (Gpu::notInLaunchRegion())
225 const Box& bx =
grow(mfi.validbox(),nghost);
236 m_f(bx, dest, icomp, ncomp,
m_geom, time, bcrs, 0, bccomp);
244 Real time,
int bccomp) {
246 this->
operator()(mf,icomp,ncomp,nghost,time,bccomp);
258 int dcomp,
int numcomp,
263 #if defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ == 11) && (__CUDACC_VER_MINOR__ == 6)
268 static_assert(std::is_same<F,int>::value,
269 "CUDA 11.6 bug: https://github.com/AMReX-Codes/amrex/issues/2607");
271 if (bx.
ixType().cellCentered()) {
272 ccfcdoit(bx,dest,dcomp,numcomp,geom,time,bcr,bcomp,orig_comp,
FilccCell{});
273 }
else if (bx.
ixType().nodeCentered()) {
274 nddoit(bx,dest,dcomp,numcomp,geom,time,bcr,bcomp,orig_comp);
276 ccfcdoit(bx,dest,dcomp,numcomp,geom,time,bcr,bcomp,orig_comp,
FilfcFace{});
283 int dcomp,
int numcomp,
291 Box gdomain = domain;
292 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
294 gdomain.
grow(idim,len[idim]);
298 if (gdomain.
contains(bx)) {
return; }
301 const auto geomdata = geom.
data();
306 const auto f_user = m_user_f;
315 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
316 fab(i,j,k,n) = fab(dxlo,j,k,n);
319 bcr_p, 0, orig_comp);
326 int dxhi = domain.
bigEnd(0);
330 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
331 fab(i,j,k,n) = fab(dxhi,j,k,n);
334 bcr_p, 0, orig_comp);
338 #if (AMREX_SPACEDIM >= 2)
346 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
347 fab(i,j,k,n) = fab(i,dylo,k,n);
350 bcr_p, 0, orig_comp);
357 int dyhi = domain.
bigEnd(1);
361 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
362 fab(i,j,k,n) = fab(i,dyhi,k,n);
365 bcr_p, 0, orig_comp);
370 #if (AMREX_SPACEDIM == 3)
378 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
379 fab(i,j,k,n) = fab(i,j,dzlo,n);
382 bcr_p, 0, orig_comp);
389 int dzhi = domain.
bigEnd(2);
393 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
394 fab(i,j,k,n) = fab(i,j,dzhi,n);
397 bcr_p, 0, orig_comp);
407 int dcomp,
int numcomp,
410 int orig_comp, FF
const& fillfunc)
416 Box gdomain = domain;
417 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
419 gdomain.
grow(idim,len[idim]);
423 if (gdomain.
contains(bx)) {
return; }
426 const auto geomdata = geom.
data();
432 const auto f_user = m_user_f;
445 for (
const Box&
b : dom_face_boxes) {
447 if (tmp.
ok()) { face_boxes.push_back(tmp); }
449 const int n_face_boxes = face_boxes.
size();
450 if (n_face_boxes == 1) {
456 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
457 f_user(idx, fab, dcomp, numcomp, geomdata, time,
458 bcr_p, 0, orig_comp);
460 }
else if (n_face_boxes > 1) {
462 Box* boxes_p = face_boxes_aa.
data();
464 for (
const auto&
b : face_boxes) {
465 ncounts +=
b.numPts();
470 const auto& idx =
getCell(boxes_p, n_face_boxes, icount);
471 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
472 f_user(idx, fab, dcomp, numcomp, geomdata, time,
473 bcr_p, 0, orig_comp);
478 #if (AMREX_SPACEDIM >= 2)
481 #if (AMREX_SPACEDIM == 2)
505 for (
const Box&
b : dom_edge_boxes) {
507 if (tmp.
ok()) { edge_boxes.push_back(tmp); }
509 const int n_edge_boxes = edge_boxes.
size();
510 if (n_edge_boxes == 1) {
516 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
517 f_user(idx, fab, dcomp, numcomp, geomdata, time,
518 bcr_p, 0, orig_comp);
520 }
else if (n_edge_boxes > 1) {
522 Box* boxes_p = edge_boxes_aa.
data();
524 for (
const auto&
b : edge_boxes) {
525 ncounts +=
b.numPts();
530 const auto& idx =
getCell(boxes_p, n_edge_boxes, icount);
531 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
532 f_user(idx, fab, dcomp, numcomp, geomdata, time,
533 bcr_p, 0, orig_comp);
539 #if (AMREX_SPACEDIM == 3)
553 for (
const Box&
b : dom_corner_boxes) {
555 if (tmp.
ok()) { corner_boxes.push_back(tmp); }
557 const int n_corner_boxes = corner_boxes.
size();
558 if (n_corner_boxes == 1) {
563 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
564 f_user(idx, fab, dcomp, numcomp, geomdata, time,
565 bcr_p, 0, orig_comp);
567 }
else if (n_corner_boxes > 1) {
569 Box* boxes_p = corner_boxes_aa.
data();
571 for (
const auto&
b : corner_boxes) {
572 ncounts +=
b.numPts();
577 const auto& idx =
getCell(boxes_p, n_corner_boxes, icount);
578 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
579 f_user(idx, fab, dcomp, numcomp, geomdata, time,
580 bcr_p, 0, orig_comp);
587 BCRec const* bcr_p = bcr.data()+bcomp;
589 const auto& f_user = m_user_f;
601 for (
const Box&
b : dom_face_boxes) {
603 amrex::For(tmp, [=] (
int i,
int j,
int k) noexcept
607 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
608 f_user(idx, fab, dcomp, numcomp, geomdata, time,
609 bcr_p, 0, orig_comp);
614 #if (AMREX_SPACEDIM >= 2)
617 #if (AMREX_SPACEDIM == 2)
641 for (
const Box&
b : dom_edge_boxes) {
643 amrex::For(tmp, [=] (
int i,
int j,
int k) noexcept
647 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
648 f_user(idx, fab, dcomp, numcomp, geomdata, time,
649 bcr_p, 0, orig_comp);
655 #if (AMREX_SPACEDIM == 3)
668 for (
const Box&
b : dom_corner_boxes) {
670 amrex::For(tmp, [=] (
int i,
int j,
int k) noexcept
673 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
674 f_user(idx, fab, dcomp, numcomp, geomdata, time,
675 bcr_p, 0, orig_comp);
#define BL_PROFILE(a)
Definition: AMReX_BLProfiler.H:551
#define AMREX_ASSERT(EX)
Definition: AMReX_BLassert.H:38
#define AMREX_ALWAYS_ASSERT(EX)
Definition: AMReX_BLassert.H:50
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
#define AMREX_D_PICK(a, b, c)
Definition: AMReX_SPACE.H:151
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
Boundary Condition Records. Necessary information and functions for computing boundary conditions.
Definition: AMReX_BCRec.H:17
AMREX_FORCE_INLINE Array4< T const > array() const noexcept
Definition: AMReX_BaseFab.H:379
This version calls function working on array.
Definition: AMReX_PhysBCFunct.H:36
BndryFuncArray() noexcept=default
bool m_run_on_gpu
Definition: AMReX_PhysBCFunct.H:54
void operator()(Box const &bx, FArrayBox &dest, int dcomp, int numcomp, Geometry const &geom, Real time, const Vector< BCRec > &bcr, int bcomp, int orig_comp)
Definition: AMReX_PhysBCFunct.cpp:7
BndryFuncArray(BndryFunc3DDefault inFunc) noexcept
Definition: AMReX_PhysBCFunct.H:40
BndryFunc3DDefault m_func3D
Definition: AMReX_PhysBCFunct.H:53
BndryFuncDefault m_func
Definition: AMReX_PhysBCFunct.H:52
bool RunOnGPU() const noexcept
Definition: AMReX_PhysBCFunct.H:48
IndexType ixType() const noexcept
Return index type of this BoxArray.
Definition: AMReX_BoxArray.H:837
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & smallEnd() const &noexcept
Get the smallend of the BoxND.
Definition: AMReX_Box.H:105
AMREX_GPU_HOST_DEVICE BoxND & grow(int i) noexcept
Definition: AMReX_Box.H:627
AMREX_GPU_HOST_DEVICE IndexTypeND< dim > ixType() const noexcept
Returns the indexing type.
Definition: AMReX_Box.H:127
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & bigEnd() const &noexcept
Get the bigend.
Definition: AMReX_Box.H:116
AMREX_GPU_HOST_DEVICE IntVectND< dim > length() const noexcept
Return the length of the BoxND.
Definition: AMReX_Box.H:146
AMREX_GPU_HOST_DEVICE BoxND & setSmall(const IntVectND< dim > &sm) noexcept
Redefine the small end of the BoxND.
Definition: AMReX_Box.H:466
AMREX_GPU_HOST_DEVICE bool ok() const noexcept
Checks if it is a proper BoxND (including a valid type).
Definition: AMReX_Box.H:200
AMREX_GPU_HOST_DEVICE BoxND & setBig(const IntVectND< dim > &bg) noexcept
Redefine the big end of the BoxND.
Definition: AMReX_Box.H:474
AMREX_GPU_HOST_DEVICE bool contains(const IntVectND< dim > &p) const noexcept
Returns true if argument is contained within BoxND.
Definition: AMReX_Box.H:204
This cpu version calls function working on FArrayBox.
Definition: AMReX_PhysBCFunct.H:104
UserFillBox f_user
Definition: AMReX_PhysBCFunct.H:116
CpuBndryFuncFab()=default
CpuBndryFuncFab(UserFillBox a_f)
Definition: AMReX_PhysBCFunct.H:107
void operator()(Box const &bx, FArrayBox &dest, int dcomp, int numcomp, Geometry const &geom, Real time, const Vector< BCRec > &bcr, int bcomp, int orig_comp)
Definition: AMReX_PhysBCFunct.cpp:48
A Fortran Array of REALs.
Definition: AMReX_FArrayBox.H:229
IntVect nGrowVect() const noexcept
Definition: AMReX_FabArrayBase.H:79
const BoxArray & boxArray() const noexcept
Return a constant reference to the BoxArray that defines the valid region associated with this FabArr...
Definition: AMReX_FabArrayBase.H:94
Rectangular problem domain geometry.
Definition: AMReX_Geometry.H:73
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition: AMReX_Geometry.H:210
GeometryData data() const noexcept
Returns non-static copy of geometry's stored data.
Definition: AMReX_Geometry.H:123
bool isAllPeriodic() const noexcept
Is domain periodic in all directions?
Definition: AMReX_Geometry.H:338
bool isPeriodic(int dir) const noexcept
Is the domain periodic in the specified direction?
Definition: AMReX_Geometry.H:331
Definition: AMReX_PhysBCFunct.H:64
GpuBndryFuncFab(F const &a_f)
Definition: AMReX_PhysBCFunct.H:67
void nddoit(Box const &bx, FArrayBox &dest, int dcomp, int numcomp, Geometry const &geom, Real time, const Vector< BCRec > &bcr, int bcomp, int orig_comp)
Definition: AMReX_PhysBCFunct.H:282
GpuBndryFuncFab(F &&a_f)
Definition: AMReX_PhysBCFunct.H:68
GpuBndryFuncFab()=default
void ccfcdoit(Box const &bx, FArrayBox &dest, int dcomp, int numcomp, Geometry const &geom, Real time, const Vector< BCRec > &bcr, int bcomp, int orig_comp, FF const &fillfunc)
Definition: AMReX_PhysBCFunct.H:406
void operator()(Box const &bx, FArrayBox &dest, int dcomp, int numcomp, Geometry const &geom, Real time, const Vector< BCRec > &bcr, int bcomp, int orig_comp)
Definition: AMReX_PhysBCFunct.H:257
F m_user_f
Definition: AMReX_PhysBCFunct.H:90
Definition: AMReX_GpuAsyncArray.H:29
T const * data() const noexcept
Definition: AMReX_GpuAsyncArray.H:69
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE CellIndex ixType(int dir) const noexcept
Returns the CellIndex in direction dir.
Definition: AMReX_IndexType.H:116
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allGE(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than or equal to argument for all components. NOTE: This is NOT a str...
Definition: AMReX_IntVect.H:443
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLE(const IntVectND< dim > &rhs) const noexcept
Returns true if this is less than or equal to argument for all components. NOTE: This is NOT a strict...
Definition: AMReX_IntVect.H:393
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheNodeVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:702
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int min() const noexcept
minimum (no absolute values) value
Definition: AMReX_IntVect.H:225
Definition: AMReX_MFIter.H:57
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition: AMReX_MFIter.H:141
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
Definition: AMReX_PhysBCFunct.H:120
void operator()(MultiFab &, int, int, IntVect const &, Real, int)
Definition: AMReX_PhysBCFunct.H:122
Definition: AMReX_PhysBCFunct.H:127
IntVect src_ghost_outside_domain
Definition: AMReX_PhysBCFunct.H:169
IntVect fp1_src_ghost
Definition: AMReX_PhysBCFunct.H:174
PhysBCFunctUseCoarseGhost(IntVect const &a_fp1_src_ghost)
Definition: AMReX_PhysBCFunct.H:130
IntVect cghost
Definition: AMReX_PhysBCFunct.H:172
void operator()(MultiFab &, int, int, IntVect const &, Real, int)
Definition: AMReX_PhysBCFunct.H:156
IntVect src_ghost
Definition: AMReX_PhysBCFunct.H:165
IntVect nghost
Definition: AMReX_PhysBCFunct.H:159
PhysBCFunctUseCoarseGhost(MF const &cmf, IntVect const &a_nghost, IntVect const &a_nghost_outside_domain, IntVect const &ratio, Interp *mapper)
Definition: AMReX_PhysBCFunct.H:134
IntVect nghost_outside_domain
Definition: AMReX_PhysBCFunct.H:161
Definition: AMReX_PhysBCFunct.H:179
void define(const Geometry &geom, const Vector< BCRec > &bcr, F const &f)
Definition: AMReX_PhysBCFunct.H:191
void define(const Geometry &geom, const Vector< BCRec > &bcr, F &&f)
Definition: AMReX_PhysBCFunct.H:195
PhysBCFunct(const Geometry &geom, const Vector< BCRec > &bcr, F const &f)
Definition: AMReX_PhysBCFunct.H:183
Vector< BCRec > m_bcr
Definition: AMReX_PhysBCFunct.H:251
void operator()(MultiFab &mf, int icomp, int ncomp, IntVect const &nghost, Real time, int bccomp)
Definition: AMReX_PhysBCFunct.H:199
PhysBCFunct(const Geometry &geom, const Vector< BCRec > &bcr, F &&f)
Definition: AMReX_PhysBCFunct.H:187
Geometry m_geom
Definition: AMReX_PhysBCFunct.H:250
F m_f
Definition: AMReX_PhysBCFunct.H:252
void FillBoundary(MultiFab &mf, int icomp, int ncomp, IntVect const &nghost, Real time, int bccomp)
Definition: AMReX_PhysBCFunct.H:243
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Long size() const noexcept
Definition: AMReX_Vector.H:50
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition: AMReX_CTOParallelForImpl.H:200
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > adjCellLo(const BoxND< dim > &b, int dir, int len=1) noexcept
Returns the cell centered BoxND of length len adjacent to b on the low end along the coordinate direc...
Definition: AMReX_Box.H:1591
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
IntVect nGrowVect(FabArrayBase const &fa)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > adjCellHi(const BoxND< dim > &b, int dir, int len=1) noexcept
Similar to adjCellLo but builds an adjacent BoxND on the high end.
Definition: AMReX_Box.H:1612
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Grow BoxND in all directions by given amount.
Definition: AMReX_Box.H:1211
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Returns a BoxND with different type.
Definition: AMReX_Box.H:1435
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > getCell(BoxND< dim > const *boxes, int nboxes, Long icell) noexcept
Definition: AMReX_Box.H:1978
void(*)(Real *data, const int *lo, const int *hi, const int *dom_lo, const int *dom_hi, const Real *dx, const Real *grd_lo, const Real *time, const int *bc) BndryFunc3DDefault
Definition: AMReX_PhysBCFunct.H:25
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
void(*)(Box const &bx, Array4< Real > const &dest, int dcomp, int numcomp, GeometryData const &geom, Real time, const BCRec *bcr, int bcomp, int orig_comp) UserFillBox
Definition: AMReX_PhysBCFunct.H:32
void(*)(Real *data, AMREX_ARLIM_P(lo), AMREX_ARLIM_P(hi), const int *dom_lo, const int *dom_hi, const Real *dx, const Real *grd_lo, const Real *time, const int *bc) BndryFuncDefault
Definition: AMReX_PhysBCFunct.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
void setBC(const Box &bx, const Box &domain, int src_comp, int dest_comp, int ncomp, const Vector< BCRec > &bc_dom, Vector< BCRec > &bcr) noexcept
Function for setting array of BCs.
Definition: AMReX_BCRec.cpp:8
AMREX_ATTRIBUTE_FLATTEN_FOR void For(T n, L const &f) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:134
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_Array4.H:61
Definition: AMReX_PhysBCFunct.H:94
AMREX_GPU_DEVICE void operator()(const amrex::IntVect &, amrex::Array4< amrex::Real > const &, int, int, amrex::GeometryData const &, amrex::Real, const amrex::BCRec *, int, int) const
Definition: AMReX_PhysBCFunct.H:96
Definition: AMReX_FilCC_1D_C.H:12
Definition: AMReX_FilFC_1D_C.H:12
Definition: AMReX_Geometry.H:25