From 228a0069f225f2362aac8fef024b712f5dc03bed Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 26 Mar 2021 12:28:22 -0400 Subject: [PATCH 1/3] implement the CMA method --- Source/hydro/riemann.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Source/hydro/riemann.cpp b/Source/hydro/riemann.cpp index e738bb980a..45f5b50298 100644 --- a/Source/hydro/riemann.cpp +++ b/Source/hydro/riemann.cpp @@ -263,4 +263,23 @@ Castro::riemann_state(const Box& bx, amrex::Error("ERROR: invalid value of riemann_solver"); #endif } + + // normalize the mass fractions on the interface + // this is the CMA algorithm + + amrex::ParallelFor(bx, + [=] AMREX_GPU_HOST_DEVICE (int i, int j, int k) + { + + Real sum_X = 0.0; + for (int n = 0; n < NumSpec; n++) { + qint(i,j,k,n) = amrex::max(0.0_rt, amrex::min(1.0_rt, qint(i,j,k,n))); + sum_X += qint(i,j,k,n); + } + + for (int n = 0; n < NumSpec; n++) { + qint(i,j,k,n) /= sum_X; + } + }); + } From 4f4a5cfbbe858e06030c5737872ba3a0b48da508 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 26 Mar 2021 13:28:03 -0400 Subject: [PATCH 2/3] fix indexing --- Source/hydro/riemann.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/hydro/riemann.cpp b/Source/hydro/riemann.cpp index 45f5b50298..20eb4a498c 100644 --- a/Source/hydro/riemann.cpp +++ b/Source/hydro/riemann.cpp @@ -273,12 +273,12 @@ Castro::riemann_state(const Box& bx, Real sum_X = 0.0; for (int n = 0; n < NumSpec; n++) { - qint(i,j,k,n) = amrex::max(0.0_rt, amrex::min(1.0_rt, qint(i,j,k,n))); - sum_X += qint(i,j,k,n); + qint(i,j,k,QFS+n) = amrex::max(0.0_rt, amrex::min(1.0_rt, qint(i,j,k,QFS+n))); + sum_X += qint(i,j,k,QFS+n); } for (int n = 0; n < NumSpec; n++) { - qint(i,j,k,n) /= sum_X; + qint(i,j,k,QFS+n) /= sum_X; } }); From 5c723afdd017a1c3ef97ef346dd471de71a04c23 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Wed, 9 Jun 2021 11:11:38 -0400 Subject: [PATCH 3/3] update CMA --- Source/hydro/riemann_solvers.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/hydro/riemann_solvers.H b/Source/hydro/riemann_solvers.H index 12b273aee8..1d6754c432 100644 --- a/Source/hydro/riemann_solvers.H +++ b/Source/hydro/riemann_solvers.H @@ -1380,12 +1380,12 @@ riemann_state(const int i, const int j, const int k, const int idir, #ifndef AMREX_USE_GPU } else { - amrex::Error("ERROR: invalid value of riemann_solver"); + amrex::Error("ERROR: invalid value of riemann_solver"); #endif } -} +} #endif