diff --git a/src/fluid/constrainedTransport/enforceVectorPotentialBoundary.hpp b/src/fluid/constrainedTransport/enforceVectorPotentialBoundary.hpp index fea9b47b..3019edfd 100644 --- a/src/fluid/constrainedTransport/enforceVectorPotentialBoundary.hpp +++ b/src/fluid/constrainedTransport/enforceVectorPotentialBoundary.hpp @@ -13,23 +13,31 @@ template void ConstrainedTransport::EnforceVectorPotentialBoundary(IdefixArray4D &Vein) { idfx::pushRegion("Emf::EnforceVectorPotentialBoundary"); - auto Ax1 = Kokkos::subview(Vein, IDIR, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()); - auto Ax2 = Kokkos::subview(Vein, JDIR, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()); - auto Ax3 = Kokkos::subview(Vein, KDIR, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()); - if(this->hydro->haveAxis) { - this->hydro->boundary->axis->RegularizeEMFs(Ax1, Ax2, Ax3); - } + IdefixArray3D Ax1, Ax2, Ax3; - #ifdef ENFORCE_EMF_CONSISTENCY - #ifdef WITH_MPI - // This average the vector potential at the domain surface with immediate neighbours - // to ensure the vector potentials exactly match + #ifdef EVOLVE_VECTOR_POTENTIAL + #if DIMENSIONS == 3 + Ax1 = Kokkos::subview(Vein, AX1e, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()); + Ax2 = Kokkos::subview(Vein, AX2e, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()); + #endif + Ax3 = Kokkos::subview(Vein, AX3e, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()); + + + if(this->hydro->haveAxis) { + this->hydro->boundary->axis->RegularizeEMFs(Ax1, Ax2, Ax3); + } + + #ifdef ENFORCE_EMF_CONSISTENCY + #ifdef WITH_MPI + // This average the vector potential at the domain surface with immediate neighbours + // to ensure the vector potentials exactly match - this->ExchangeAll(Ax1, Ax2, Ax3); + this->ExchangeAll(Ax1, Ax2, Ax3); + #endif + EnforceEMFBoundaryPeriodic(Ax1, Ax2, Ax3); #endif - EnforceEMFBoundaryPeriodic(Ax1, Ax2, Ax3); - #endif + #endif // EVOLVE_VECTOR_POTENTIAL idfx::popRegion(); }