2#ifndef AMREX_INTERPBNDRYDATA_H_
3#define AMREX_INTERPBNDRYDATA_H_
4#include <AMReX_Config.H>
8#include <AMReX_InterpBndryData_K.H>
21 struct InterpBndryTag {
24 Array4<int const> mask;
29 Box const& box () const noexcept {
return bx; }
122 int bnd_start,
int num_comp, const
IntVect& ratio,
147template <typename MF>
156template <
typename MF>
162 const Box& fine_domain = this->
geom.Domain();
165#pragma omp parallel if (Gpu::notInLaunchRegion())
169 const Box& bx = mfi.validbox();
172 if (bx[face] == fine_domain[face] && !(this->
geom.isPeriodic(face.
coordDir())))
175 auto & bnd_fab = this->
bndry[face][mfi];
176 auto const& src_fab = mf[mfi];
177 auto const& bnd_array = bnd_fab.array();
178 auto const& src_array = src_fab.const_array();
179 const Box& b = src_fab.box() & bnd_fab.box();
182 bnd_array(i,j,k,n+bnd_start) = src_array(i,j,k,n+mf_start);
189template <
typename MF>
192 int f_start,
int bnd_start,
int num_comp,
const IntVect& ratio,
193 int max_order,
int max_width)
197 const Box& fine_domain = this->
geom.Domain();
203 if (max_order == 3) {
205 "InterpBndryDataT<MF>::setBndryValues: max_order=3 requires refinement ratio <= 4");
212 using Tag = detail::InterpBndryTag<value_type>;
214 tags.reserve(std::size_t(fine.local_size())*std::size_t(2*AMREX_SPACEDIM));
217 const Box& fine_bx = mfi.validbox();
221 if (fine_bx[face] != fine_domain[face] || this->
geom.isPeriodic(dir))
223 tags.push_back(Tag{.bdry = this->
bndry[face].array(mfi),
224 .src = crse[face].const_array(mfi),
225 .mask = (max_order == 3) ? this->
masks[face].const_array(mfi)
227 .bx = this->
bndry[face][mfi].box(),
230 else if (fine.defined(mfi)) {
231 auto & bnd_fab = this->
bndry[face][mfi];
232 auto const& src_fab = fine[mfi];
233 tags.push_back(Tag{.bdry = bnd_fab.array(),
234 .src = src_fab.const_array(),
236 .bx = bnd_fab.box() & src_fab.box(),
242 const auto rr = ratio.
dim3();
248 tag.bdry(i,j,k,n+bnd_start) = tag.src(i,j,k,n+f_start);
249 }
else if (max_order == 1) {
250 interpbndrydata_o1(i,j,k,n,tag.bdry,bnd_start,tag.src,c_start,rr);
251 }
else if (tag.dir == 0) {
252 interpbndrydata_x_o3(i,j,k,n,tag.bdry,bnd_start,tag.src,c_start,rr,
253 tag.mask, is_not_covered, max_width);
255#if (AMREX_SPACEDIM >= 2)
256 else if (tag.dir == 1) {
257 interpbndrydata_y_o3(i,j,k,n,tag.bdry,bnd_start,tag.src,c_start,rr,
258 tag.mask, is_not_covered, max_width);
260#if (AMREX_SPACEDIM == 3)
262 interpbndrydata_z_o3(i,j,k,n,tag.bdry,bnd_start,tag.src,c_start,rr,
263 tag.mask, is_not_covered, max_width);
274 if (max_order==3 || max_order==1)
281 const Box& fine_bx = mfi.validbox();
285 if (fine_bx[face] != fine_domain[face] || this->
geom.isPeriodic(dir))
287 auto const& crse_array = crse[face].const_array(mfi);
288 auto const& bdry_array = this->
bndry[face].array(mfi);
289 Box const& b = this->
bndry[face][mfi].box();
290 const auto rr = ratio.
dim3();
296 interpbndrydata_o1(it,jt,kt,n,bdry_array,bnd_start,
297 crse_array,c_start,rr);
302 auto const& mask_array = this->
masks[face].const_array(mfi);
309 interpbndrydata_x_o3(it,jt,kt,n,bdry_array,bnd_start,
310 crse_array,c_start,rr,
311 mask_array, is_not_covered, max_width);
315#if (AMREX_SPACEDIM >= 2)
320 interpbndrydata_y_o3(it,jt,kt,n,bdry_array,bnd_start,
321 crse_array,c_start,rr,
322 mask_array, is_not_covered, max_width);
326#if (AMREX_SPACEDIM == 3)
331 interpbndrydata_z_o3(it,jt,kt,n,bdry_array,bnd_start,
332 crse_array,c_start,rr,
333 mask_array, is_not_covered, max_width);
343 else if (fine.defined(mfi)) {
345 auto & bnd_fab = this->
bndry[face][mfi];
346 auto const& src_fab = fine[mfi];
347 auto const& bnd_array = bnd_fab.array();
348 auto const& src_array = src_fab.const_array();
349 const Box& b = bnd_fab.box() & src_fab.box();
352 bnd_array(ii,jj,kk,nn+bnd_start) = src_array(ii,jj,kk,nn+f_start);
360 amrex::Abort(
"InterpBndryDataT<MF>::setBndryValues supports only max_order=1 or 3");
364template <
typename MF>
367 int num_comp,
const IntVect& ratio,
int max_order,
int max_width)
370 setBndryValues(crse, c_start, foo, 0, bnd_start, num_comp, ratio, max_order, max_width);
373template <
typename MF>
Boundary condition descriptors used throughout AMReX.
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
Boundary data container that owns masks, boundary values, and metadata.
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:123
#define AMREX_HOST_DEVICE_PARALLEL_FOR_4D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:111
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
BndryDataT() noexcept=default
Default constructor.
Vector< MultiMask > masks
Boundary condition mask.
Definition AMReX_BndryData.H:171
@ not_covered
Definition AMReX_BndryData.H:50
Geometry geom
Definition AMReX_BndryData.H:173
A BndryRegister organizes FabSets bounding each grid in a BoxArray. A FabSet is maintained for each b...
Definition AMReX_BndryRegister.H:46
BoxArray grids
Definition AMReX_BndryRegister.H:173
const DistributionMapping & DistributionMap() const noexcept
Returns the DistributionMapping describing which MPI ranks own each boundary FAB.
Definition AMReX_BndryRegister.H:143
FabSetT< MF > bndry[2 *3]
The data.
Definition AMReX_BndryRegister.H:172
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:55
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:87
__host__ __device__ constexpr Dim3 dim3() const noexcept
Definition AMReX_IntVect.H:269
__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:499
An InterpBndryData object adds to a BndryData object the ability to manipulate and set the data store...
Definition AMReX_InterpBndryData.H:62
void setPhysBndryValues(const MultiFab &mf, int mf_start, int bnd_start, int num_comp)
static constexpr int IBD_max_order_DEF
Definition AMReX_InterpBndryData.H:143
void updateBndryValues(BndryRegisterT< MultiFab > &crse, int c_start, int bnd_start, int num_comp, const IntVect &ratio, int max_order=IBD_max_order_DEF, int max_width=2)
InterpBndryDataT() noexcept=default
default constructor
void setBndryValues(BndryRegisterT< MultiFab > const &crse, int c_start, const MultiFab &fine, int f_start, int bnd_start, int num_comp, const IntVect &ratio, int max_order=IBD_max_order_DEF, int max_width=2)
typename MF::value_type value_type
Definition AMReX_InterpBndryData.H:65
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:176
An Iterator over the Orientation of Faces of a Box.
Definition AMReX_Orientation.H:135
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
__host__ __device__ int coordDir() const noexcept
Returns the coordinate direction.
Definition AMReX_Orientation.H:83
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
ArrayND< T, 4, true > Array4
Convenient alias for a 4D ArrayND with three spatial dimensions plus a component dimension.
Definition AMReX_Array4.H:1352
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:329
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
bool inNoSyncRegion() noexcept
Definition AMReX_GpuControl.H:148
Definition AMReX_Amr.cpp:50
InterpBndryDataT< MultiFab > InterpBndryData
Definition AMReX_InterpBndryData.H:380
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
InterpBndryDataT< fMultiFab > fInterpBndryData
Definition AMReX_InterpBndryData.H:381
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:388
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:239
void setVal(MF &dst, typename MF::value_type val)
dst = val
Definition AMReX_FabArrayUtility.H:2174
FabArray memory allocation information.
Definition AMReX_FabArray.H:73
Definition AMReX_MFIter.H:20