Skip to content

Commit 30d2f8b

Browse files
authored
fix a bug in artificial viscosity (quokka-astro#1605)
### Description In the current implementation of artificial viscosity, the viscosity term is added in the wrong direction. This PR fixes the bug by using the variable `F_canonical` to store intermediate fluxes and then applying the correct permutation. ### Related issues Are there any GitHub issues that are fixed by this pull request? Add a link to them here. ### Checklist _Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an `x` inside the square brackets `[ ]` in the Markdown source below:_ - [x] I have added a description (see above). - [ ] I have added a link to any related issues (if applicable; see above). - [ ] I have read the [Contributing Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md). - [ ] I have added tests for any new physics that this PR adds to the code. - [x] *(For quokka-astro org members)* I have manually triggered the GPU tests with the magic comment `/azp run`.
1 parent a47a6a4 commit 30d2f8b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/hydro/hydro_system.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,13 +1410,6 @@ void HydroSystem<problem_t>::ComputeFluxes(amrex::MultiFab &x1Flux_mf, amrex::Mu
14101410
x1FSpds(i, j, k, 1) = fspd_p;
14111411
}
14121412

1413-
quokka::valarray<double, nHydroScalars_> F = F_canonical;
1414-
1415-
// permute momentum components according to flux direction DIR
1416-
F[velN_index] = F_canonical[x1Momentum_index];
1417-
F[velV_index] = F_canonical[x2Momentum_index];
1418-
F[velW_index] = F_canonical[x3Momentum_index];
1419-
14201413
// add artificial viscosity
14211414
// following Colella & Woodward (1984), eq. (4.2)
14221415
const double div_v = AMREX_D_TERM(du, +0.5 * (dvl + dvr), +0.5 * (dwl + dwr));
@@ -1441,7 +1434,14 @@ void HydroSystem<problem_t>::ComputeFluxes(amrex::MultiFab &x1Flux_mf, amrex::Mu
14411434
}
14421435
}
14431436

1444-
F = F + viscosity * (U_L - U_R);
1437+
F_canonical = F_canonical + viscosity * (U_L - U_R);
1438+
1439+
quokka::valarray<double, nHydroScalars_> F = F_canonical;
1440+
1441+
// permute momentum components according to flux direction DIR
1442+
F[velN_index] = F_canonical[x1Momentum_index];
1443+
F[velV_index] = F_canonical[x2Momentum_index];
1444+
F[velW_index] = F_canonical[x3Momentum_index];
14451445

14461446
// set energy fluxes to zero if EOS is isothermal
14471447
if constexpr (HydroSystem<problem_t>::is_eos_isothermal()) {

0 commit comments

Comments
 (0)