2 #ifndef AMREX_FABSET_H_
3 #define AMREX_FABSET_H_
4 #include <AMReX_Config.H>
44 template <
typename MF>
72 FAB const& operator[] (const
MFIter& mfi) const noexcept {
return m_mf[mfi]; }
88 [[nodiscard]]
Box fabbox (
int K)
const noexcept {
return m_mf.fabbox(K); }
90 [[nodiscard]]
int size () const noexcept {
return m_mf.size(); }
95 {
return m_mf.DistributionMap(); }
98 [[nodiscard]] MF
const&
multiFab () const noexcept {
return m_mf; }
100 [[nodiscard]]
int nComp () const noexcept {
return m_mf.nComp(); }
114 void copyTo (MF& dest,
int ngrow,
int scomp,
int dcomp,
int ncomp,
117 void plusTo (MF& dest,
int ngrow,
int scomp,
int dcomp,
int ncomp,
126 int scomp,
int dcomp,
int ncomp);
131 int dcomp,
int ncomp,
int ngrow);
135 void write (
const std::string& name)
const;
138 void read (
const std::string& name);
151 template <
typename MF>
156 template <
typename MF>
158 : m_mf(grids,dmap,ncomp,0)
161 template <
typename MF>
165 m_mf.define(grids, dm, ncomp, 0);
168 template <
typename MF>
174 #pragma omp parallel if (Gpu::notInLaunchRegion())
177 const Box& bx = fsi.validbox();
178 auto const srcfab = src.
array(fsi);
179 auto dstfab = this->array(fsi);
182 dstfab(i,j,k,n+dcomp) = srcfab(i,j,k,n+scomp);
186 m_mf.ParallelCopy(src.
m_mf,scomp,dcomp,ncomp);
191 template <
typename MF>
197 m_mf.ParallelCopy(src,scomp,dcomp,ncomp,ngrow,0,period);
201 template <
typename MF>
207 #pragma omp parallel if (Gpu::notInLaunchRegion())
210 const Box& bx = fsi.validbox();
211 auto const srcfab = src.
array(fsi);
212 auto dstfab = this->array(fsi);
215 dstfab(i,j,k,n+dcomp) += srcfab(i,j,k,n+scomp);
219 amrex::Abort(
"FabSetT<MF>::plusFrom: parallel plusFrom not supported");
224 template <
typename MF>
234 template <
typename MF>
240 dest.ParallelCopy(m_mf,scomp,dcomp,ncomp,0,ngrow,period);
243 template <
typename MF>
252 template <
typename MF>
256 const int ncomp =
nComp();
258 #pragma omp parallel if (Gpu::notInLaunchRegion())
261 const Box& bx = fsi.validbox();
262 auto fab = this->array(fsi);
270 template <
typename MF>
275 #pragma omp parallel if (Gpu::notInLaunchRegion())
278 const Box& bx = fsi.validbox();
279 auto fab = this->array(fsi);
282 fab(i,j,k,n+comp) = val;
289 template <
typename MF>
292 int scomp,
int dcomp,
int ncomp)
297 #pragma omp parallel if (Gpu::notInLaunchRegion())
301 const Box& bx = fsi.validbox();
302 auto const srcfab = src.
array(fsi);
303 auto dstfab = this->array(fsi);
306 dstfab(i,j,k,n+dcomp) = a*dstfab(i,j,k,n+dcomp) +
b*srcfab(i,j,k,n+scomp);
314 template <
typename MF>
318 int dcomp,
int ncomp,
int ngrow)
321 BL_ASSERT(mfa.nGrowVect().allGE(ngrow) && mfb.nGrowVect().allGE(ngrow));
322 BL_ASSERT(mfa.boxArray() == mfb.boxArray());
331 #pragma omp parallel if (Gpu::notInLaunchRegion())
335 const Box& bx = mfi.validbox();
336 auto afab = bdrya.array(mfi);
337 auto bfab = bdryb.array(mfi);
340 afab(i,j,k,n) = huge;
341 bfab(i,j,k,n) = huge;
345 bdrya.ParallelCopy(mfa,a_comp,0,ncomp,ngrow,0);
346 bdryb.ParallelCopy(mfb,b_comp,0,ncomp,ngrow,0);
349 #pragma omp parallel if (Gpu::notInLaunchRegion())
353 const Box& bx = fsi.validbox();
354 auto const afab = bdrya.array(fsi);
355 auto const bfab = bdryb.array(fsi);
356 auto dfab = this->array(fsi);
359 dfab(i,j,k,n+dcomp) = a*afab(i,j,k,n) +
b*bfab(i,j,k,n);
366 template <
typename MF>
377 template <
typename MF>
387 template <
typename MF>
393 int ncomp = dst.
nComp();
395 #pragma omp parallel if (Gpu::notInLaunchRegion())
398 const Box& bx = fsi.validbox();
399 auto const srcfab = src.
array(fsi);
400 auto dstfab = dst.
array(fsi);
403 dstfab(i,j,k,n) = srcfab(i,j,k,n);
#define BL_PROFILE(a)
Definition: AMReX_BLProfiler.H:551
#define BL_ASSERT(EX)
Definition: AMReX_BLassert.H:39
#define AMREX_HOST_DEVICE_PARALLEL_FOR_4D(...)
Definition: AMReX_GpuLaunch.nolint.H:55
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:550
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
@ ADD
Definition: AMReX_FabArrayBase.H:393
Definition: AMReX_FabSet.H:149
FabSetIter(const FabSetT< MF > &fs)
Definition: AMReX_FabSet.H:152
A FabSet is a group of FArrayBox's. The grouping is designed specifically to represent regions along ...
Definition: AMReX_FabSet.H:46
MF const & multiFab() const noexcept
Definition: AMReX_FabSet.H:98
Array4< value_type const > const_array(const MFIter &mfi) const noexcept
Definition: AMReX_FabSet.H:81
Array4< value_type const > array(const MFIter &mfi) const noexcept
Definition: AMReX_FabSet.H:77
int nComp() const noexcept
Definition: AMReX_FabSet.H:100
FAB const & operator[](const MFIter &mfi) const noexcept
Definition: AMReX_FabSet.H:72
static void Copy(FabSetT< MF > &dst, const FabSetT< MF > &src)
Definition: AMReX_FabSet.H:389
Array4< value_type > array(int i) noexcept
Definition: AMReX_FabSet.H:80
FabSetT< MF > & copyFrom(const FabSetT< MF > &src, int scomp, int dcomp, int ncomp)
Definition: AMReX_FabSet.H:170
FabSetT< MF > & plusFrom(const FabSetT< MF > &src, int scomp, int dcomp, int ncomp)
Definition: AMReX_FabSet.H:203
void read(const std::string &name)
Read (used for reading from checkpoint)
Definition: AMReX_FabSet.H:379
MultiArray4< value_type const > const_arrays() const noexcept
Definition: AMReX_FabSet.H:86
void clear()
Definition: AMReX_FabSet.H:102
const DistributionMapping & DistributionMap() const noexcept
Definition: AMReX_FabSet.H:94
void plusTo(MF &dest, int ngrow, int scomp, int dcomp, int ncomp, const Periodicity &period=Periodicity::NonPeriodic()) const
Definition: AMReX_FabSet.H:245
MultiArray4< value_type > arrays() noexcept
Definition: AMReX_FabSet.H:85
FabSetT< MF > & linComb(value_type a, value_type b, const FabSetT< MF > &src, int scomp, int dcomp, int ncomp)
Linear combination: this := a*mfa + b*mfb.
Definition: AMReX_FabSet.H:291
Box fabbox(int K) const noexcept
Definition: AMReX_FabSet.H:88
const BoxArray & boxArray() const noexcept
Definition: AMReX_FabSet.H:92
MF m_mf
Definition: AMReX_FabSet.H:144
void write(const std::string &name) const
Write (used for writing to checkpoint)
Definition: AMReX_FabSet.H:368
FabSetT() noexcept=default
The default constructor – you must later call define().
MF & multiFab() noexcept
Definition: AMReX_FabSet.H:97
typename FabDataType< MF >::value_type value_type
Definition: AMReX_FabSet.H:50
void setVal(value_type val)
Definition: AMReX_FabSet.H:254
MultiArray4< value_type const > arrays() const noexcept
Definition: AMReX_FabSet.H:84
int size() const noexcept
Definition: AMReX_FabSet.H:90
Array4< value_type > array(const MFIter &mfi) noexcept
Definition: AMReX_FabSet.H:78
typename FabDataType< MF >::fab_type FAB
Definition: AMReX_FabSet.H:51
Array4< value_type const > array(int i) const noexcept
Definition: AMReX_FabSet.H:79
Array4< value_type const > const_array(int i) const noexcept
Definition: AMReX_FabSet.H:82
void define(const BoxArray &grids, const DistributionMapping &dmap, int ncomp)
Define a FabSetT<MF> constructed via default constructor.
Definition: AMReX_FabSet.H:163
void copyTo(MF &dest, int ngrow, int scomp, int dcomp, int ncomp, const Periodicity &period=Periodicity::NonPeriodic()) const
Definition: AMReX_FabSet.H:236
Flux Register.
Definition: AMReX_FluxRegister.H:20
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
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition: AMReX_Periodicity.H:17
static const Periodicity & NonPeriodic() noexcept
Definition: AMReX_Periodicity.cpp:52
static void Read(FabArray< FArrayBox > &mf, const std::string &name, const char *faHeader=nullptr, int coordinatorProc=ParallelDescriptor::IOProcessorNumber(), int allow_empty_mf=0)
Read a FabArray<FArrayBox> from disk written using VisMF::Write(). If the FabArray<FArrayBox> fafab h...
Definition: AMReX_VisMF.cpp:1536
static Long Write(const FabArray< FArrayBox > &mf, const std::string &name, VisMF::How how=NFiles, bool set_ghost=false)
Write a FabArray<FArrayBox> to disk in a "smart" way. Returns the total number of bytes written on th...
Definition: AMReX_VisMF.cpp:975
static void AsyncWrite(const FabArray< FArrayBox > &mf, const std::string &mf_name, bool valid_cells_only=false)
Definition: AMReX_VisMF.cpp:2264
bool UseAsyncOut()
Definition: AMReX_AsyncOut.cpp:70
AMREX_GPU_HOST_DEVICE Long size(T const &b) noexcept
integer version
Definition: AMReX_GpuRange.H:26
Definition: AMReX_Amr.cpp:49
DistributionMapping const & DistributionMap(FabArrayBase const &fa)
int nComp(FabArrayBase const &fa)
BoxArray const & boxArray(FabArrayBase const &fa)
bool match(const BoxArray &x, const BoxArray &y)
Note that two BoxArrays that match are not necessarily equal.
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
Definition: AMReX_Array4.H:61
Definition: AMReX_FabDataType.H:9
FabArray memory allocation information.
Definition: AMReX_FabArray.H:66
Definition: AMReX_FabArray.H:152