Skip to content

Commit

Permalink
WIP: added 2D inviscid Roe flux. #28
Browse files Browse the repository at this point in the history
Works for:
2D Normal shock weno5
2D Double Mach Reflection weno3

Does not work for:
2D Double Mach Reflection weno5
  • Loading branch information
pjb236 committed Aug 5, 2021
1 parent ae3d7c4 commit dc7fb9e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
12 changes: 6 additions & 6 deletions include/pressiodemoapps/euler2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ T createEe2dImpl(const mesh_t & meshObj,
("Stencil size in the mesh object not compatible with desired inviscid flux reconstruction.");
}

if (probEnum == ::pressiodemoapps::Euler2d::DoubleMachReflection and
recEnum == ::pressiodemoapps::InviscidFluxReconstruction::Weno5)
{
throw std::runtime_error
("Double mach reflection does NOT currently suppot Weno5.");
}
//if (probEnum == ::pressiodemoapps::Euler2d::DoubleMachReflection and
// recEnum == ::pressiodemoapps::InviscidFluxReconstruction::Weno5)
//{
// throw std::runtime_error
// ("Double mach reflection does NOT currently suppot Weno5.");
//}


if (probEnum == ::pressiodemoapps::Euler2d::PeriodicSmooth)
Expand Down
18 changes: 17 additions & 1 deletion include/pressiodemoapps/impl_apps/euler2d/euler2d_app_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ class Euler2dAppT
eeRusanovFluxFourDof(FL, uMinusHalfNeg, uMinusHalfPos, normalX_, m_gamma);
eeRusanovFluxFourDof(FR, uPlusHalfNeg, uPlusHalfPos, normalX_, m_gamma);
break;
case ::pressiodemoapps::InviscidFluxScheme::Roe:
eeRoeFluxFourDof(FL, uMinusHalfNeg, uMinusHalfPos, normalX_, m_gamma);
eeRoeFluxFourDof(FR, uPlusHalfNeg, uPlusHalfPos, normalX_, m_gamma);
break;
}

// Y
Expand All @@ -259,6 +263,10 @@ class Euler2dAppT
eeRusanovFluxFourDof(FD, uMinusHalfNeg, uMinusHalfPos, normalY_, m_gamma);
eeRusanovFluxFourDof(FU, uPlusHalfNeg, uPlusHalfPos, normalY_, m_gamma);
break;
case ::pressiodemoapps::InviscidFluxScheme::Roe:
eeRoeFluxFourDof(FD, uMinusHalfNeg, uMinusHalfPos, normalY_, m_gamma);
eeRoeFluxFourDof(FU, uPlusHalfNeg, uPlusHalfPos, normalY_, m_gamma);
break;
}

const auto vIndex = smPt*numDofPerCell;
Expand Down Expand Up @@ -319,6 +327,10 @@ class Euler2dAppT
eeRusanovFluxFourDof(FL, uMinusHalfNeg, uMinusHalfPos, normalX_, m_gamma);
eeRusanovFluxFourDof(FR, uPlusHalfNeg, uPlusHalfPos, normalX_, m_gamma);
break;
case ::pressiodemoapps::InviscidFluxScheme::Roe:
eeRoeFluxFourDof(FL, uMinusHalfNeg, uMinusHalfPos, normalX_, m_gamma);
eeRoeFluxFourDof(FR, uPlusHalfNeg, uPlusHalfPos, normalX_, m_gamma);
break;
}

// Y
Expand All @@ -329,7 +341,11 @@ class Euler2dAppT
eeRusanovFluxFourDof(FD, uMinusHalfNeg, uMinusHalfPos, normalY_, m_gamma);
eeRusanovFluxFourDof(FU, uPlusHalfNeg, uPlusHalfPos, normalY_, m_gamma);
break;
}
case ::pressiodemoapps::InviscidFluxScheme::Roe:
eeRoeFluxFourDof(FD, uMinusHalfNeg, uMinusHalfPos, normalY_, m_gamma);
eeRoeFluxFourDof(FU, uPlusHalfNeg, uPlusHalfPos, normalY_, m_gamma);
break;
}

const auto vIndex = smPt*numDofPerCell;
vEval(vIndex);
Expand Down
11 changes: 6 additions & 5 deletions include/pressiodemoapps/impl_apps/eulerCommon/fluxes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void eeRusanovFluxThreeDof(T & F,
F(2) = half*( FL[2] + FR[2] + smax*(qL(2) - qR(2)) );
}

template<class T, typename sc_t>
template<class T, class normal_t, typename sc_t>
void eeRoeFluxFourDof(T & F,
const T & qL,
const T & qR,
Expand Down Expand Up @@ -189,13 +189,14 @@ void eeRoeFluxFourDof(T & F,
const auto unTilde = (rLsqrt * unL + rRsqrt * unR) / rSqrtSum;
const auto HTilde = (rLsqrt * HL + rRsqrt * HR) / rSqrtSum;
const auto VTilde2 = uTilde * uTilde + vTilde * vTilde;
const auto aTilde = std::sqrt((gamma-1)*(HTilde - half * VTilde));
const auto aTilde = std::sqrt((gamma-1)*(HTilde - half * VTilde2));


// Compute Eigenvalues
auto lam1 = unTilde - aTilde;
auto lam2 = unTilde;
auto lam3 = unTilde + aTilde;
auto lam3 = unTilde;
auto lam4 = unTilde + aTilde;

// Entropy fix (San and Kara: Evaluation of Riemann flux solvers for WENO reconstruction
// schemes: Kelvin–Helmholtz instability), Computers & Fluids, 117 (2015), 24-41. Eqn. 35
Expand Down Expand Up @@ -232,8 +233,8 @@ void eeRoeFluxFourDof(T & F,
const auto dq3 = qR[2] - qL[2];
const auto dq4 = qR[3] - qL[3];

const auto alpha3 = (dq3*n[0] - dq2*n[1] + dq1*n[1]*u - dq1*n[0]*vTilde)/(n[0]*n[0] - n[1]*n[1])
const auto alpha2 = (gamma-1) / (aTilde * aTilde) * (dq1 * (HTilde - VTilde2) + uTilde * dq2 -dq4 +dq3*vTilde)
const auto alpha3 = (dq3*n[0] - dq2*n[1] + dq1*n[1]*uTilde - dq1*n[0]*vTilde)/(n[0]*n[0] - n[1]*n[1]);
const auto alpha2 = (gamma-1) / (aTilde * aTilde) * (dq1 * (HTilde - VTilde2) + uTilde * dq2 -dq4 +dq3*vTilde);

const auto b1 = dq1-alpha2;
const auto b2 = dq2-alpha2*uTilde-alpha3*n[1];
Expand Down
3 changes: 2 additions & 1 deletion tests_cpp/2d_double_mach_reflection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

add_subdirectory(firstorder)
add_subdirectory(weno3)
add_subdirectory(weno3)
add_subdirectory(weno5)
11 changes: 8 additions & 3 deletions tests_cpp/2d_double_mach_reflection/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ int main(int argc, char *argv[])

namespace pda = pressiodemoapps;
const auto meshObj = pda::loadCellCenterUniformMeshEigen(".");
#if defined USE_WENO3
#ifdef USE_WENO5
const auto order = pda::InviscidFluxReconstruction::Weno5;
const auto iFlux = pda::InviscidFluxScheme::Roe;
#elif defined USE_WENO3
const auto order = pda::InviscidFluxReconstruction::Weno3;
const auto iFlux = pda::InviscidFluxScheme::Rusanov;
#else
const auto order = pda::InviscidFluxReconstruction::FirstOrder;
const auto iFlux = pda::InviscidFluxScheme::Rusanov;
#endif

const auto probId = pda::Euler2d::DoubleMachReflection;
auto appObj = pda::createProblemEigen(meshObj, probId, order);
auto appObj = pda::createProblemEigen(meshObj, probId, order, iFlux, 1);
using app_t = decltype(appObj);
using app_state_t = typename app_t::state_type;
using ode_state_t = pressio::containers::Vector<app_state_t>;
Expand All @@ -28,7 +33,7 @@ int main(int argc, char *argv[])
const auto dt = 0.0005;
const auto Nsteps = 0.25/dt;
auto time = 0.0;
FomObserver<ode_state_t> Obs("doubleMach2d_solution.bin", 50);
FomObserver<ode_state_t> Obs("doubleMach2d_solution.bin", 1);
app_state_t state1(stateSize);
app_state_t state2(stateSize);
app_state_t veloTmp(stateSize);
Expand Down

0 comments on commit dc7fb9e

Please sign in to comment.