diff --git a/Src/AmrCore/AMReX_Interp_3D_C.H b/Src/AmrCore/AMReX_Interp_3D_C.H index b29ba4aca40..382962d11b2 100644 --- a/Src/AmrCore/AMReX_Interp_3D_C.H +++ b/Src/AmrCore/AMReX_Interp_3D_C.H @@ -294,13 +294,13 @@ facediv_int (int ci, int cj, int ck, int nf, + dy*(2*dx*dx+dy*dy)/(8*dz*xspys)*(w000+w012-w002-w010) + dy3/(8*dz*xspys)*(w100+w112-w102-w110); - fine[1](fi+1, fj+1, fk , nf) = Real(0.5)*(v001+v021) + fine[1](fi+1, fj+1, fk , nf) = Real(0.5)*(v100+v120) + dy*(2*dz*dz+dy*dy)/(8*dx*yspzs)*(u000+u210-u010-u200) + dy3/(8*dx*yspzs)*(u001+u211-u011-u201) + dy*(2*dx*dx+dy*dy)/(8*dz*xspys)*(w100+w112-w102-w110) + dy3/(8*dz*xspys)*(w000+w012-w002-w010); - fine[1](fi , fj+1, fk+1, nf) = Real(0.5)*(v100+v120) + fine[1](fi , fj+1, fk+1, nf) = Real(0.5)*(v001+v021) + dy*(2*dz*dz+dy*dy)/(8*dx*yspzs)*(u001+u211-u011-u201) + dy3/(8*dx*yspzs)*(u000+u210-u010-u200) + dy*(2*dx*dx+dy*dy)/(8*dz*xspys)*(w000+w012-w002-w010) @@ -319,17 +319,17 @@ facediv_int (int ci, int cj, int ck, int nf, + dz3/(8*dy*zspxs)*(v100+v121-v101-v120); fine[2](fi , fj+1, fk+1, nf) = Real(0.5)*(w010+w012) - + dz*(2*dy*dy+dz*dz)/(8*dx*yspzs)*(u000+u201-u001-u200) - + dz3/(8*dx*yspzs)*(u010+u211-u011-u210) - + dz*(2*dx*dx+dz*dz)/(8*dy*zspxs)*(v100+v121-v101-v120) - + dz3/(8*dy*zspxs)*(v000+v021-v001-v020); - - fine[2](fi+1, fj , fk+1, nf) = Real(0.5)*(w100+w102) + dz*(2*dy*dy+dz*dz)/(8*dx*yspzs)*(u010+u211-u011-u210) + dz3/(8*dx*yspzs)*(u000+u201-u001-u200) + dz*(2*dx*dx+dz*dz)/(8*dy*zspxs)*(v000+v021-v001-v020) + dz3/(8*dy*zspxs)*(v100+v121-v101-v120); + fine[2](fi+1, fj , fk+1, nf) = Real(0.5)*(w100+w102) + + dz*(2*dy*dy+dz*dz)/(8*dx*yspzs)*(u000+u201-u001-u200) + + dz3/(8*dx*yspzs)*(u010+u211-u011-u210) + + dz*(2*dx*dx+dz*dz)/(8*dy*zspxs)*(v100+v121-v101-v120) + + dz3/(8*dy*zspxs)*(v000+v021-v001-v020); + fine[2](fi+1, fj+1, fk+1, nf) = Real(0.5)*(w110+w112) + dz*(2*dy*dy+dz*dz)/(8*dx*yspzs)*(u010+u211-u011-u210) + dz3/(8*dx*yspzs)*(u000+u201-u001-u200) diff --git a/Src/AmrCore/AMReX_Interpolater.H b/Src/AmrCore/AMReX_Interpolater.H index c13fb283a35..6333112aae8 100644 --- a/Src/AmrCore/AMReX_Interpolater.H +++ b/Src/AmrCore/AMReX_Interpolater.H @@ -565,6 +565,9 @@ public: * of the divergence of the underlying crse cell. All fine cells overlying * a given coarse cell will have the same divergence, even when the coarse * grid divergence is spatially varying. +* Based on Vanella et. al. (doi:10.1016/j.jcp.2010.05.003, section 3.2), +* but solves the interior closure problem using least squares with an +* initial guess equal to the average of fine face values across the cell. */ class FaceDivFree : diff --git a/Tests/DivFreePatch/main.cpp b/Tests/DivFreePatch/main.cpp index 7358946c434..857461a1f64 100644 --- a/Tests/DivFreePatch/main.cpp +++ b/Tests/DivFreePatch/main.cpp @@ -94,11 +94,14 @@ void CoarsenToFine(MultiFab& div_refined_coarse, Real MFdiff(const MultiFab& lhs, const MultiFab& rhs, - int strt_comp, int num_comp, int nghost, const std::string name = "") + int strt_comp, int num_comp, int nghost, const std::string name = "", + bool relative = false) { MultiFab temp(lhs.boxArray(), lhs.DistributionMap(), lhs.nComp(), nghost); Copy(temp, lhs, strt_comp, strt_comp, num_comp, nghost); temp.minus(rhs, strt_comp, num_comp, nghost); + if (relative) { + temp.divide(rhs, strt_comp, num_comp, nghost); } if (name != "") { amrex::VisMF::Write(temp, std::string("pltfiles/" + name)); } @@ -301,7 +304,7 @@ void main_main () // Setup initial value on the coarse faces. for (int i=0; i max_i) ? max_diff : max_i; + amrex::Print() << " Fine valid region maximum change, comp "<