1#ifndef AMREX_PhysBCFunct_H_
2#define AMREX_PhysBCFunct_H_
3#include <AMReX_Config.H>
9#include <AMReX_FilCC_C.H>
10#include <AMReX_FilND_C.H>
11#include <AMReX_FilFC_C.H>
19 const int* dom_lo,
const int* dom_hi,
21 const Real* time,
const int* bc);
23 const int* dom_lo,
const int* dom_hi,
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);
184 : m_geom(geom), m_bcr(bcr), m_f(f)
188 : m_geom(geom), m_bcr(bcr), m_f(std::move(f))
192 m_geom = geom; m_bcr = bcr; m_f = f;
196 m_geom = geom; m_bcr = bcr; m_f = std::move(f);
200 Real time,
int bccomp)
210 Box gdomain = domain;
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);
233 amrex::setBC(bx, domain, bccomp, 0, ncomp, m_bcr, bcrs);
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 (bx.
ixType().cellCentered()) {
264 ccfcdoit(bx,dest,dcomp,numcomp,geom,time,bcr,bcomp,orig_comp, FilccCell{});
265 }
else if (bx.
ixType().nodeCentered()) {
266 nddoit(bx,dest,dcomp,numcomp,geom,time,bcr,bcomp,orig_comp);
268 ccfcdoit(bx,dest,dcomp,numcomp,geom,time,bcr,bcomp,orig_comp, FilfcFace{});
275 int dcomp,
int numcomp,
283 Box gdomain = domain;
284 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
286 gdomain.
grow(idim,len[idim]);
290 if (gdomain.
contains(bx)) {
return; }
293 const auto geomdata = geom.
data();
298 const auto f_user = m_user_f;
307 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
308 fab(i,j,k,n) = fab(dxlo,j,k,n);
311 bcr_p, 0, orig_comp);
318 int dxhi = domain.
bigEnd(0);
322 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
323 fab(i,j,k,n) = fab(dxhi,j,k,n);
326 bcr_p, 0, orig_comp);
330#if (AMREX_SPACEDIM >= 2)
338 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
339 fab(i,j,k,n) = fab(i,dylo,k,n);
342 bcr_p, 0, orig_comp);
349 int dyhi = domain.
bigEnd(1);
353 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
354 fab(i,j,k,n) = fab(i,dyhi,k,n);
357 bcr_p, 0, orig_comp);
362#if (AMREX_SPACEDIM == 3)
370 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
371 fab(i,j,k,n) = fab(i,j,dzlo,n);
374 bcr_p, 0, orig_comp);
381 int dzhi = domain.
bigEnd(2);
385 for (
int n = dcomp; n < dcomp+numcomp; ++n) {
386 fab(i,j,k,n) = fab(i,j,dzhi,n);
389 bcr_p, 0, orig_comp);
399 int dcomp,
int numcomp,
402 int orig_comp, FF
const& fillfunc)
408 Box gdomain = domain;
409 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
411 gdomain.
grow(idim,len[idim]);
415 if (gdomain.
contains(bx)) {
return; }
418 const auto geomdata = geom.
data();
424 const auto f_user = m_user_f;
437 for (
const Box& b : dom_face_boxes) {
439 if (tmp.
ok()) { face_boxes.push_back(tmp); }
441 const int n_face_boxes = face_boxes.
size();
442 if (n_face_boxes == 1) {
448 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
449 f_user(idx, fab, dcomp, numcomp, geomdata, time,
450 bcr_p, 0, orig_comp);
452 }
else if (n_face_boxes > 1) {
454 Box* boxes_p = face_boxes_aa.
data();
456 for (
const auto& b : face_boxes) {
457 ncounts += b.numPts();
462 const auto& idx =
getCell(boxes_p, n_face_boxes, icount);
463 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
464 f_user(idx, fab, dcomp, numcomp, geomdata, time,
465 bcr_p, 0, orig_comp);
470#if (AMREX_SPACEDIM >= 2)
473#if (AMREX_SPACEDIM == 2)
497 for (
const Box& b : dom_edge_boxes) {
499 if (tmp.
ok()) { edge_boxes.push_back(tmp); }
501 const int n_edge_boxes = edge_boxes.
size();
502 if (n_edge_boxes == 1) {
508 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
509 f_user(idx, fab, dcomp, numcomp, geomdata, time,
510 bcr_p, 0, orig_comp);
512 }
else if (n_edge_boxes > 1) {
514 Box* boxes_p = edge_boxes_aa.
data();
516 for (
const auto& b : edge_boxes) {
517 ncounts += b.numPts();
522 const auto& idx =
getCell(boxes_p, n_edge_boxes, icount);
523 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
524 f_user(idx, fab, dcomp, numcomp, geomdata, time,
525 bcr_p, 0, orig_comp);
531#if (AMREX_SPACEDIM == 3)
545 for (
const Box& b : dom_corner_boxes) {
547 if (tmp.
ok()) { corner_boxes.push_back(tmp); }
549 const int n_corner_boxes = corner_boxes.
size();
550 if (n_corner_boxes == 1) {
555 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
556 f_user(idx, fab, dcomp, numcomp, geomdata, time,
557 bcr_p, 0, orig_comp);
559 }
else if (n_corner_boxes > 1) {
561 Box* boxes_p = corner_boxes_aa.
data();
563 for (
const auto& b : corner_boxes) {
564 ncounts += b.numPts();
569 const auto& idx =
getCell(boxes_p, n_corner_boxes, icount);
570 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
571 f_user(idx, fab, dcomp, numcomp, geomdata, time,
572 bcr_p, 0, orig_comp);
579 BCRec const* bcr_p = bcr.data()+bcomp;
581 const auto& f_user = m_user_f;
593 for (
const Box& b : dom_face_boxes) {
595 amrex::For(tmp, [=] (
int i,
int j,
int k)
noexcept
599 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
600 f_user(idx, fab, dcomp, numcomp, geomdata, time,
601 bcr_p, 0, orig_comp);
606#if (AMREX_SPACEDIM >= 2)
609#if (AMREX_SPACEDIM == 2)
633 for (
const Box& b : dom_edge_boxes) {
635 amrex::For(tmp, [=] (
int i,
int j,
int k)
noexcept
639 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
640 f_user(idx, fab, dcomp, numcomp, geomdata, time,
641 bcr_p, 0, orig_comp);
647#if (AMREX_SPACEDIM == 3)
660 for (
const Box& b : dom_corner_boxes) {
662 amrex::For(tmp, [=] (
int i,
int j,
int k)
noexcept
665 fillfunc(idx, fab, dcomp, numcomp, domain, bcr_p, 0);
666 f_user(idx, fab, dcomp, numcomp, geomdata, time,
667 bcr_p, 0, orig_comp);
#define AMREX_ARLIM_P(x)
Definition AMReX_ArrayLim.H:30
Boundary condition descriptors used throughout AMReX.
#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:173
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Boundary condition record storing low/high face types per coordinate.
Definition AMReX_BCRec.H:25
Array4< T const > array() const noexcept
Create an Array4 view over all components.
Definition AMReX_BaseFab.H:475
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:1252
__host__ __device__ BoxND & grow(int i) noexcept
Grow in all directions by i cells (negative shrinks).
Definition AMReX_Box.H:668
__host__ __device__ const IntVectND< dim > & bigEnd() const &noexcept
Return the inclusive upper bound of the box.
Definition AMReX_Box.H:136
__host__ __device__ BoxND & setBig(const IntVectND< dim > &bg) noexcept
Redefine the big end of the BoxND.
Definition AMReX_Box.H:516
__host__ __device__ IntVectND< dim > length() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:167
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
__host__ __device__ IndexTypeND< dim > ixType() const noexcept
Return the indexing type.
Definition AMReX_Box.H:148
__host__ __device__ bool ok() const noexcept
Return true if high bounds are >= low bounds and the index type is valid.
Definition AMReX_Box.H:229
__host__ __device__ const IntVectND< dim > & smallEnd() const &noexcept
Return the inclusive lower bound of the box.
Definition AMReX_Box.H:124
__host__ __device__ BoxND & setSmall(const IntVectND< dim > &sm) noexcept
Definition AMReX_Box.H:508
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:237
IntVect nGrowVect() const noexcept
Definition AMReX_FabArrayBase.H:80
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:95
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:75
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:216
GeometryData data() const noexcept
Returns non-static copy of geometry's stored data.
Definition AMReX_Geometry.H:125
bool isAllPeriodic() const noexcept
Is domain periodic in all directions?
Definition AMReX_Geometry.H:344
bool isPeriodic(int dir) const noexcept
Is the domain periodic in the specified direction?
Definition AMReX_Geometry.H:337
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:274
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:398
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:35
T const * data() const noexcept
Definition AMReX_GpuAsyncArray.H:76
__host__ __device__ constexpr CellIndex ixType(int dir) const noexcept
Returns the CellIndex in direction dir.
Definition AMReX_IndexType.H:117
__host__ __device__ constexpr int min() const noexcept
minimum (no absolute values) value
Definition AMReX_IntVect.H:324
__host__ __device__ constexpr 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:542
__host__ static __device__ constexpr 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:801
__host__ __device__ constexpr 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:492
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:172
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
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
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
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:29
Long size() const noexcept
Definition AMReX_Vector.H:54
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
amrex_long Long
Definition AMReX_INT.H:30
__host__ __device__ BoxND< dim > adjCellHi(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the high end along coordinate direction dir.
Definition AMReX_Box.H:1848
__host__ __device__ BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Return a copy of b converted to the nodal flags typ.
Definition AMReX_Box.H:1630
__host__ __device__ BoxND< dim > adjCellLo(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the low end along coordinate direction dir.
Definition AMReX_Box.H:1817
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1326
std::array< T, N > Array
Definition AMReX_Array.H:31
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:259
void(*)(Real *data, const int &, const int &, const int &, const int &, const int &, const int &, 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
IntVect nGrowVect(FabArrayBase const &fa)
Definition AMReX_FabArrayBase.cpp:2857
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
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
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
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
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
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
Populate a span of BCRec objects based on a domain record.
Definition AMReX_BCRec.cpp:8
__host__ __device__ IntVectND< dim > getCell(BoxND< dim > const *boxes, int nboxes, Long icell) noexcept
Return the point coordinate corresponding to the flattened index icell.
Definition AMReX_Box.H:2408
AMREX_ATTRIBUTE_FLATTEN_FOR void For(T n, L const &f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:136
A multidimensional array accessor.
Definition AMReX_Array4.H:288
Definition AMReX_PhysBCFunct.H:94
__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_Geometry.H:26