Skip to content

Commit 38547bb

Browse files
authored
OpenBC FFT Solver: Fix a 2d mode bug. (#4671)
This bug only affected 3D WarpX/ImpactX when there was only one cell in the z-direction for the solver. The fix is that we have simplified the logic for handling domain decomposition. If it's in the 2D mode in 3D, we simply do slab decomposition.
1 parent 488d156 commit 38547bb

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

Src/FFT/AMReX_FFT_R2C.H

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,7 @@ R2C<T,D,C>::R2C (Box const& domain, Info const& info)
491491
#if (AMREX_SPACEDIM == 3)
492492
if (m_info.domain_strategy == DomainStrategy::automatic) {
493493
if (m_info.twod_mode) {
494-
if (m_real_domain.length(2) < nprocs) {
495-
m_info.domain_strategy = DomainStrategy::pencil;
496-
} else {
497-
m_info.domain_strategy = DomainStrategy::slab;
498-
}
494+
m_info.domain_strategy = DomainStrategy::slab;
499495
} else {
500496
int shortside = m_real_domain.shortside();
501497
if (shortside < m_info.pencil_threshold*nprocs) {
@@ -505,19 +501,20 @@ R2C<T,D,C>::R2C (Box const& domain, Info const& info)
505501
}
506502
}
507503
}
508-
if (m_info.domain_strategy == DomainStrategy::slab && (m_real_domain.length(1) > 1)) {
509-
if (m_info.twod_mode && m_real_domain.length(2) == 1) {
510-
m_slab_decomp = false;
511-
} else {
512-
m_slab_decomp = true;
513-
}
504+
505+
if (m_info.twod_mode) {
506+
m_slab_decomp = true;
507+
} else if (m_info.domain_strategy == DomainStrategy::slab && (m_real_domain.length(1) > 1)) {
508+
m_slab_decomp = true;
514509
}
510+
515511
#endif
516512

517513
auto const ncomp = m_info.batch_size;
518514

519515
auto bax = amrex::decompose(m_real_domain, nprocs,
520-
{AMREX_D_DECL(false,!m_slab_decomp,true)}, true);
516+
{AMREX_D_DECL(false,!m_slab_decomp,m_real_domain.length(2)>1)}, true);
517+
521518
DistributionMapping dmx = detail::make_iota_distromap(bax.size());
522519
m_rx.define(bax, dmx, ncomp, 0, MFInfo().SetAlloc(false));
523520

@@ -540,13 +537,8 @@ R2C<T,D,C>::R2C (Box const& domain, Info const& info)
540537
//
541538

542539
#if (AMREX_SPACEDIM >= 2)
543-
#if (AMREX_SPACEDIM == 2)
544-
bool batch_on_y = false;
545-
#else
546-
bool batch_on_y = m_info.twod_mode && (m_real_domain.length(2) == 1);
547-
#endif
548540
DistributionMapping cdmy;
549-
if ((m_real_domain.length(1) > 1) && !m_slab_decomp && !batch_on_y)
541+
if ((m_real_domain.length(1) > 1) && !m_slab_decomp)
550542
{
551543
auto cbay = amrex::decompose(m_spectral_domain_y, nprocs,
552544
{AMREX_D_DECL(false,true,true)}, true);

0 commit comments

Comments
 (0)