1 #ifndef AMREX_FFT_OPENBC_SOLVER_H_
2 #define AMREX_FFT_OPENBC_SOLVER_H_
9 template <
typename T = Real>
39 #if (AMREX_SPACEDIM == 3)
51 m_r2c(
OpenBCSolver<T>::make_grown_domain(domain,info), info)
53 #if (AMREX_SPACEDIM == 3)
56 gdom.enclosedCells(2);
61 gdom.setBig(2, nprocs-1);
69 auto [sd, ord] =
m_r2c.getSpectralData();
71 m_G_fft.define(sd->boxArray(), sd->DistributionMap(), 1, 0);
81 auto const& lo = m_domain.smallEnd();
82 auto const& lo3 = lo.dim3();
83 auto const& len = m_domain.length3d();
85 auto const& a = infab->array();
86 auto box = infab->box();
88 int ndims = m_info.batch_mode ? AMREX_SPACEDIM : AMREX_SPACEDIM-1;
89 for (
int idim = 0; idim < ndims; ++idim) {
90 if (box.smallEnd(idim) == lo[idim] && box.length(idim) == 2*len[idim]) {
91 box.growHi(idim, -len[idim]+1);
100 if (i == len[0] || j == len[1] || k == len[2]) {
104 auto jj = (j > len[1]) ? 2*len[1]-j : j;
105 auto kk = (k > len[2]) ? 2*len[2]-k : k;
106 G = greens_function(ii+lo3.x,jj+lo3.y,kk+lo3.z);
108 for (
int koff = 0; koff < nimages[2]; ++koff) {
109 int k2 = (koff == 0) ? k : 2*len[2]-k;
110 if ((k2 == 2*len[2]) || (koff == 1 && k == len[2])) {
113 for (
int joff = 0; joff < nimages[1]; ++joff) {
114 int j2 = (joff == 0) ? j : 2*len[1]-j;
115 if ((j2 == 2*len[1]) || (joff == 1 && j == len[1])) {
118 for (
int ioff = 0; ioff < nimages[0]; ++ioff) {
119 int i2 = (ioff == 0) ? i : 2*len[0]-i;
120 if ((i2 == 2*len[0]) || (ioff == 1 && i == len[0])) {
123 a(i2+lo3.x,j2+lo3.y,k2+lo3.z) = G;
130 if (m_info.batch_mode) {
131 m_r2c_green->forward(m_r2c_green->m_rx);
133 m_r2c.forward(m_r2c.m_rx);
136 if (!m_info.batch_mode) {
137 auto [sd, ord] = m_r2c.getSpectralData();
143 #if defined(AMREX_USE_GPU)
148 (dstfab->dataPtr(), srcfab->dataPtr(), dstfab->nBytes());
156 template <
typename T>
159 auto& inmf = m_r2c.m_rx;
161 inmf.ParallelCopy(rho, 0, 0, 1);
163 m_r2c.m_openbc_half =
true;
165 m_r2c.m_openbc_half =
false;
167 auto scaling_factor = m_r2c.scalingFactor();
171 auto [sd, ord] = m_r2c.getSpectralData();
175 auto*
pdst = rhofab->dataPtr();
176 auto const* psrc = gfab->dataPtr();
177 Box const& rhobox = rhofab->box();
178 #if (AMREX_SPACEDIM == 3)
179 Long leng = gfab->box().
numPts();
180 if (m_info.batch_mode) {
189 #if (AMREX_SPACEDIM == 3)
190 Long isrc = i % leng;
194 pdst[i] *= psrc[isrc] * scaling_factor;
197 amrex::Abort(
"FFT::OpenBCSolver::solve: how did this happen?");
201 m_r2c.m_openbc_half =
true;
202 m_r2c.backward_doit(phi, phi.nGrowVect());
203 m_r2c.m_openbc_half =
false;
#define AMREX_ASSERT(EX)
Definition: AMReX_BLassert.H:38
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
Real * pdst
Definition: AMReX_HypreMLABecLap.cpp:1090
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 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 Long numPts() const noexcept
Returns the number of points contained in the BoxND.
Definition: AMReX_Box.H:346
Definition: AMReX_FFT_OpenBCSolver.H:11
Info m_info
Definition: AMReX_FFT_OpenBCSolver.H:29
cMF m_G_fft
Definition: AMReX_FFT_OpenBCSolver.H:31
typename R2C< T >::MF MF
Definition: AMReX_FFT_OpenBCSolver.H:13
void solve(MF &phi, MF const &rho)
Definition: AMReX_FFT_OpenBCSolver.H:157
R2C< T > m_r2c
Definition: AMReX_FFT_OpenBCSolver.H:30
void setGreensFunction(F const &greens_function)
Definition: AMReX_FFT_OpenBCSolver.H:77
Box m_domain
Definition: AMReX_FFT_OpenBCSolver.H:28
typename R2C< T >::cMF cMF
Definition: AMReX_FFT_OpenBCSolver.H:14
std::unique_ptr< R2C< T > > m_r2c_green
Definition: AMReX_FFT_OpenBCSolver.H:32
static Box make_grown_domain(Box const &domain, Info const &info)
Definition: AMReX_FFT_OpenBCSolver.H:36
OpenBCSolver(Box const &domain, Info const &info=Info{})
Definition: AMReX_FFT_OpenBCSolver.H:48
Box const & Domain() const
Definition: AMReX_FFT_OpenBCSolver.H:23
Parallel Discrete Fourier Transform.
Definition: AMReX_FFT_R2C.H:34
std::conditional_t< std::is_same_v< T, Real >, MultiFab, FabArray< BaseFab< T > > > MF
Definition: AMReX_FFT_R2C.H:37
An Array of FortranArrayBox(FAB)-like Objects.
Definition: AMReX_FabArray.H:344
FA::FABType::value_type * get_fab(FA &fa)
Definition: AMReX_FFT_Helper.H:1303
Definition: AMReX_FFT.cpp:7
void dtod_memcpy_async(void *p_d_dst, const void *p_d_src, const std::size_t sz) noexcept
Definition: AMReX_GpuDevice.H:279
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void * memcpy(void *dest, const void *src, std::size_t count)
Definition: AMReX_GpuUtility.H:214
int NProcsSub() noexcept
number of ranks in current frame
Definition: AMReX_ParallelContext.H:74
@ min
Definition: AMReX_ParallelReduce.H:18
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
@ make_alias
Definition: AMReX_MakeType.H:7
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
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 Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
Definition: AMReX_FFT_Helper.H:56
bool batch_mode
Definition: AMReX_FFT_Helper.H:60
int nprocs
Max number of processes to use.
Definition: AMReX_FFT_Helper.H:63