1#ifndef AMREX_FFT_OPENBC_SOLVER_H_
2#define AMREX_FFT_OPENBC_SOLVER_H_
9template <
typename T = Real>
39#if (AMREX_SPACEDIM == 3)
54#if (AMREX_SPACEDIM == 3)
57 gdom.enclosedCells(2);
62 gdom.setBig(2, nprocs-1);
70 auto [sd, ord] =
m_r2c.getSpectralData();
72 m_G_fft.define(sd->boxArray(), sd->DistributionMap(), 1, 0);
84 auto const& lo = m_domain.smallEnd();
85 auto const& lo3 = lo.dim3();
86 auto const& len = m_domain.length3d();
88 auto const& a = infab->array();
89 auto box = infab->box();
91 int ndims = m_info.twod_mode ? AMREX_SPACEDIM-1 : AMREX_SPACEDIM;
92 for (
int idim = 0; idim < ndims; ++idim) {
93 if (box.smallEnd(idim) == lo[idim] && box.length(idim) == 2*len[idim]) {
94 box.growHi(idim, -len[idim]+1);
103 if (i == len[0] || j == len[1] || k == len[2]) {
107 auto jj = (j > len[1]) ? 2*len[1]-j : j;
108 auto kk = (k > len[2]) ? 2*len[2]-k : k;
109 G = greens_function(ii+lo3.x,jj+lo3.y,kk+lo3.z);
111 for (
int koff = 0; koff < nimages[2]; ++koff) {
112 int k2 = (koff == 0) ? k : 2*len[2]-k;
113 if ((k2 == 2*len[2]) || (koff == 1 && k == len[2])) {
116 for (
int joff = 0; joff < nimages[1]; ++joff) {
117 int j2 = (joff == 0) ? j : 2*len[1]-j;
118 if ((j2 == 2*len[1]) || (joff == 1 && j == len[1])) {
121 for (
int ioff = 0; ioff < nimages[0]; ++ioff) {
122 int i2 = (ioff == 0) ? i : 2*len[0]-i;
123 if ((i2 == 2*len[0]) || (ioff == 1 && i == len[0])) {
126 a(i2+lo3.x,j2+lo3.y,k2+lo3.z) = G;
133 if (m_info.twod_mode) {
134 m_r2c_green->forward(m_r2c_green->m_rx);
136 m_r2c.forward(m_r2c.m_rx);
139 if (!m_info.twod_mode) {
140 auto [sd, ord] = m_r2c.getSpectralData();
152 m_r2c.prepare_openbc();
161 auto& inmf = m_r2c.m_rx;
163 inmf.ParallelCopy(rho, 0, 0, 1);
165 m_r2c.m_openbc_half = !m_info.twod_mode;
167 m_r2c.m_openbc_half =
false;
169 auto scaling_factor = m_r2c.scalingFactor();
173 auto [sd, ord] = m_r2c.getSpectralData();
177 auto*
pdst = rhofab->dataPtr();
178 auto const* psrc = gfab->dataPtr();
179 Box const& rhobox = rhofab->box();
180#if (AMREX_SPACEDIM == 3)
181 Long leng = gfab->box().
numPts();
182 if (m_info.twod_mode) {
191#if (AMREX_SPACEDIM == 3)
192 Long isrc = i % leng;
196 pdst[i] *= psrc[isrc] * scaling_factor;
199 amrex::Abort(
"FFT::OpenBCSolver::solve: how did this happen?");
203 m_r2c.m_openbc_half = !m_info.twod_mode;
204 m_r2c.backward_doit(phi, phi.nGrowVect());
205 m_r2c.m_openbc_half =
false;
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#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
__host__ __device__ const IntVectND< dim > & bigEnd() const &noexcept
Get the bigend.
Definition AMReX_Box.H:119
__host__ __device__ Long numPts() const noexcept
Returns the number of points contained in the BoxND.
Definition AMReX_Box.H:349
__host__ __device__ IntVectND< dim > length() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:149
__host__ __device__ IndexTypeND< dim > ixType() const noexcept
Returns the indexing type.
Definition AMReX_Box.H:130
__host__ __device__ const IntVectND< dim > & smallEnd() const &noexcept
Get the smallend of the BoxND.
Definition AMReX_Box.H:108
Definition AMReX_FFT_OpenBCSolver.H:11
Info m_info
Definition AMReX_FFT_OpenBCSolver.H:29
Box const & Domain() const
Definition AMReX_FFT_OpenBCSolver.H:23
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:78
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
Parallel Discrete Fourier Transform.
Definition AMReX_FFT_R2C.H:40
std::conditional_t< C, cMF, std::conditional_t< std::is_same_v< T, Real >, MultiFab, FabArray< BaseFab< T > > > > MF
Definition AMReX_FFT_R2C.H:45
FA::FABType::value_type * get_fab(FA &fa)
Definition AMReX_FFT_Helper.H:1376
Definition AMReX_FFT.cpp:7
DomainStrategy
Definition AMReX_FFT_Helper.H:50
void dtod_memcpy_async(void *p_d_dst, const void *p_d_src, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:317
int NProcsSub() noexcept
number of ranks in current frame
Definition AMReX_ParallelContext.H:74
void ParallelForOMP(T n, L const &f) noexcept
Definition AMReX_GpuLaunch.H:249
@ make_alias
Definition AMReX_MakeType.H:7
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:138
BoxND< 3 > Box
Definition AMReX_BaseFwd.H:27
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:230
Definition AMReX_FFT_Helper.H:58
bool twod_mode
Definition AMReX_FFT_Helper.H:69
int nprocs
Max number of processes to use.
Definition AMReX_FFT_Helper.H:78
Definition AMReX_Array.H:34