In AdvDiffSystem::forwardEulerAdvection the advection is computed as second order upwind that regresses to first order based on the minmod flux limiter value.
The fast minmod_S_vNeg implementation is incorrect:
|
inline double minmod_S_vNeg(int pointID) const noexcept{ |
|
if(!isValidPointID(pointID - 1) || neighbor_point(FaceDirection::NORTH, pointID)) return 0; |
|
double phi_P = phi_[pointID]; |
|
double phi_S = phi_[pointID - 1]; |
|
double phi_N = phi_[neighbor_point(FaceDirection::NORTH, pointID)]; |
|
double r = (phi_P - phi_S == 0) ? 0 : (phi_N - phi_P) / (phi_P - phi_S); |
|
return std::max(0.0, std::min(r, 1.0)); |
|
} |
It should instead be:
inline double minmod_S_vNeg(int pointID) const noexcept{
if(!isValidPointID(pointID - 1) || !isValidPointID(pointID + 1)) return 0;
double phi_P = phi_[pointID];
double phi_S = phi_[pointID - 1];
double phi_N = phi_[pointID + 1]; // this line was correct but slower than this (all the other functions do this too)
double r = (phi_P - phi_S == 0) ? 0 : (phi_N - phi_P) / (phi_P - phi_S);
return std::max(0.0, std::min(r, 1.0));
This is probably a leftover from the copy pasting of the more general function which used neighbor_point. The if check is incorrect because neighbor_point returns an index which is rarely 0 -> if check is true ->function almost always returned 0. This meant the advection scheme for all advection on the southern face of a cell with a negative velocity (most common case given that ice crystals settle) regressed to first order advection instead of second due to the bug in minmod.
In
AdvDiffSystem::forwardEulerAdvectionthe advection is computed as second order upwind that regresses to first order based on theminmodflux limiter value.The fast
minmod_S_vNegimplementation is incorrect:APCEMM/Code.v05-00/include/FVM_ANDS/AdvDiffSystem.hpp
Lines 289 to 296 in adf714b
It should instead be:
This is probably a leftover from the copy pasting of the more general function which used
neighbor_point. The if check is incorrect becauseneighbor_pointreturns an index which is rarely 0 -> if check is true ->function almost always returned 0. This meant the advection scheme for all advection on the southern face of a cell with a negative velocity (most common case given that ice crystals settle) regressed to first order advection instead of second due to the bug in minmod.