diff --git a/Src/LinearSolvers/MLMG/AMReX_MLMG.H b/Src/LinearSolvers/MLMG/AMReX_MLMG.H index 7fc822afa23..f1fed2d3db3 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLMG.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLMG.H @@ -545,7 +545,7 @@ MLMGT::getGradSolution (const Vector >& a_grad_so } linop.compGrad(alev, GetArrOfPtrs(grad_sol), sol[alev], a_loc); for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { - a_grad_sol[alev][idim]->LocalCopy(grad_sol, 0, 0, ncomp, IntVect(0)); + a_grad_sol[alev][idim]->LocalCopy(grad_sol[idim], 0, 0, ncomp, IntVect(0)); } } } diff --git a/Tests/LinearSolvers/EBflux_grad/MyTest.H b/Tests/LinearSolvers/EBflux_grad/MyTest.H index 17ccdec1604..f26ee4e1c0b 100644 --- a/Tests/LinearSolvers/EBflux_grad/MyTest.H +++ b/Tests/LinearSolvers/EBflux_grad/MyTest.H @@ -45,6 +45,7 @@ private: amrex::Vector phi; amrex::Vector> flux; amrex::Vector> grad; + amrex::Vector> fgrad; // Used to test getGradSolution when MF is different from AMF amrex::Vector rhs; amrex::Vector acoef; amrex::Vector > bcoef; diff --git a/Tests/LinearSolvers/EBflux_grad/MyTest.cpp b/Tests/LinearSolvers/EBflux_grad/MyTest.cpp index 782f3eece39..c814536203d 100644 --- a/Tests/LinearSolvers/EBflux_grad/MyTest.cpp +++ b/Tests/LinearSolvers/EBflux_grad/MyTest.cpp @@ -73,6 +73,7 @@ MyTest::solve () mlmg.solve(amrex::GetVecOfPtrs(phi), amrex::GetVecOfConstPtrs(rhs), tol_rel, tol_abs); mlmg.getFluxes(amrex::GetVecOfArrOfPtrs(flux)); mlmg.getGradSolution(amrex::GetVecOfArrOfPtrs(grad)); + mlmg.getGradSolution(amrex::GetVecOfArrOfPtrs(fgrad)); // Test when MF is different from AMF for (int ilev = 0; ilev <= max_level; ++ilev) { amrex::VisMF::Write(phi[0], "phi-"+std::to_string(ilev)); } @@ -146,6 +147,7 @@ MyTest::initData () bcoef.resize(nlevels); flux.resize(1); grad.resize(1); + fgrad.resize(1); for (int ilev = 0; ilev < nlevels; ++ilev) { dmap[ilev].define(grids[ilev]); @@ -193,5 +195,7 @@ MyTest::initData () dmap[0], 1, 0, MFInfo(), *factory[0]); grad[0][idim].define(amrex::convert(grids[0],IntVect::TheDimensionVector(idim)), dmap[0], 1, 0, MFInfo(), *factory[0]); + fgrad[0][idim].define(amrex::convert(grids[0],IntVect::TheDimensionVector(idim)), + dmap[0], 1, 0, MFInfo(), DefaultFabFactory>()); } }