From e6d3490ed5ff200c677e00bd2860e0bed5811e76 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Tue, 5 Nov 2024 15:10:22 -0700 Subject: [PATCH 01/17] Initial inlet commit (just uses supplied P/vel, not own block) --- src/PDE/MultiMat/BCFunctions.hpp | 122 +++++++++++++++++++++++++++++++ src/PDE/MultiMat/FVMultiMat.hpp | 68 ++++++++++++----- 2 files changed, 171 insertions(+), 19 deletions(-) diff --git a/src/PDE/MultiMat/BCFunctions.hpp b/src/PDE/MultiMat/BCFunctions.hpp index 4703675c4e..d68b915552 100644 --- a/src/PDE/MultiMat/BCFunctions.hpp +++ b/src/PDE/MultiMat/BCFunctions.hpp @@ -116,6 +116,128 @@ namespace inciter { return {{ std::move(ul), std::move(ur) }}; } + //! \todo Fix all of this for inlet. Just trying to get this working + //! \brief Boundary state function providing the left and right state of a + //! face at farfield boundaries + //! \param[in] ncomp Number of scalar components in this PDE system + //! \param[in] ul Left (domain-internal) state + //! \param[in] fn Unit face normal + //! \return Left and right states for all scalar components in this PDE + //! system + //! \details The farfield boudary calculation, implemented here, is + //! based on the characteristic theory of hyperbolic systems. + //! \note The function signature must follow tk::StateFn + static tk::StateFn::result_type + inlet( ncomp_t ncomp, + const std::vector< EOS >& mat_blk, + const std::vector< tk::real >& ul, + tk::real, tk::real, tk::real, tk::real, + const std::array< tk::real, 3 >& fn ) + { + auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >(); + const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >(); + + // Farfield primitive quantities + auto fp = + g_inputdeck.get< tag::bc >()[0].get< tag::pressure >(); + auto ft = + g_inputdeck.get< tag::bc >()[0].get< tag::temperature >(); + auto fu = + g_inputdeck.get< tag::bc >()[0].get< tag::velocity >(); + auto fmat = + g_inputdeck.get< tag::bc >()[0].get< tag::materialid >() - 1; + + [[maybe_unused]] auto nsld = numSolids(nmat, solidx); + + Assert( ul.size() == ncomp+nmat+3+nsld*6, "Incorrect size for appended " + "internal state vector" ); + + auto ur = ul; + + // Internal cell velocity components + auto v1l = ul[ncomp+velocityIdx(nmat, 0)]; + auto v2l = ul[ncomp+velocityIdx(nmat, 1)]; + auto v3l = ul[ncomp+velocityIdx(nmat, 2)]; + + // Normal velocity + auto vn = v1l*fn[0] + v2l*fn[1] + v3l*fn[2]; + + // Acoustic speed + tk::real a(0.0); + for (std::size_t k=0; k 1.0e-04) + a = std::max( a, mat_blk[k].compute< EOS::soundspeed >( + ul[densityIdx(nmat, k)], ul[ncomp+pressureIdx(nmat, k)], + ul[volfracIdx(nmat, k)], k ) ); + + // Mach number + auto Ma = vn / a; + + tk::real alphamin = 1e-12; + + //! \note: it seems that using internal pressure does not lead to the + //! correct behavior (!) + if (true) { // Supersonic inflow + // For supersonic inflow, all the characteristics are from outside. + // Therefore, we calculate the ghost cell state using the primitive + // variables from outside. + tk::real rho(0.0); + for (std::size_t k=0; k(nmat-1))*alphamin; + else + ur[volfracIdx(nmat,k)] = alphamin; + auto rhok = mat_blk[k].compute< EOS::density >(fp, ft); + ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rhok; + ur[energyIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * + mat_blk[k].compute< EOS::totalenergy >(rhok, fu[0], fu[1], fu[2], fp); + + // material pressures + ur[ncomp+pressureIdx(nmat, k)] = ul[volfracIdx(nmat, k)] * fp; + + rho += ur[densityIdx(nmat,k)]; + } + for (std::size_t i=0; i<3; ++i) { + ur[momentumIdx(nmat,i)] = rho * fu[i]; + ur[ncomp+velocityIdx(nmat, i)] = fu[i]; + } + + } else if (Ma > -1) { // Subsonic inflow + // For subsonic inflow, there is 1 outgoing characteristic and 4 + // incoming characteristics. Therefore, we calculate the ghost cell state + // by taking pressure from the internal cell and other quantities from + // the outside. + tk::real rho(0.0); + for (std::size_t k=0; k(nmat-1))*alphamin; + else + ur[volfracIdx(nmat,k)] = alphamin; + auto p = ul[ncomp+pressureIdx(nmat,k)] / ul[volfracIdx(nmat,k)]; + auto rhok = mat_blk[k].compute< EOS::density >(p, ft); + ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rhok; + ur[energyIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * + mat_blk[k].compute< EOS::totalenergy >(rhok, fu[0], fu[1], fu[2], p); + + // material pressures + ur[ncomp+pressureIdx(nmat, k)] = ul[volfracIdx(nmat, k)] * p; + + rho += ur[densityIdx(nmat,k)]; + } + for (std::size_t i=0; i<3; ++i) { + ur[momentumIdx(nmat,i)] = rho * fu[i]; + ur[ncomp+velocityIdx(nmat, i)] = fu[i]; + } + } + + Assert( ur.size() == ncomp+nmat+3+nsld*6, "Incorrect size for appended " + "boundary state vector" ); + + return {{ std::move(ul), std::move(ur) }}; + } + //! \brief Boundary state function providing the left and right state of a //! face at farfield boundaries //! \param[in] ncomp Number of scalar components in this PDE system diff --git a/src/PDE/MultiMat/FVMultiMat.hpp b/src/PDE/MultiMat/FVMultiMat.hpp index 5cab89dd57..02f39a4b97 100644 --- a/src/PDE/MultiMat/FVMultiMat.hpp +++ b/src/PDE/MultiMat/FVMultiMat.hpp @@ -70,25 +70,55 @@ class MultiMat { m_riemann( multimatRiemannSolver( g_inputdeck.get< tag::flux >() ) ) { - // associate boundary condition configurations with state functions - brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, - // BC State functions - { dirichlet - , symmetry - , invalidBC // Inlet BC not implemented - , invalidBC // Outlet BC not implemented - , farfield - , extrapolate - , noslipwall }, - // BC Gradient functions - { noOpGrad - , symmetryGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad } - ) ); + + // associate boundary condition configurations with state functions, + // manually looping through all BCs and state functions + const auto& bc = g_inputdeck.get< tag::bc >(); + std::vector< std::size_t > v; + for (const auto& ib : bc) { + const auto& dir = ib.get< tag::dirichlet >(); + if (!dir.empty()) { + v.insert(v.end(), dir.begin(), dir.end()); + m_bc.push_back( { v, dirichlet, noOpGrad } ); + }; + + const auto& sym = ib.get< tag::symmetry >(); + if (!sym.empty()) { + v.insert(v.end(), sym.begin(), sym.end()); + m_bc.push_back( { v, symmetry, symmetryGrad } ); + }; + + const auto& in = ib.get< tag::inlet >(); + if (!in.empty()) { + v.insert(v.end(), in.begin(), in.end()); + m_bc.push_back( { v, inlet, noOpGrad } ); + }; + + const auto& fs = ib.get< tag::farfield >(); + if (!fs.empty()) { + v.insert(v.end(), fs.begin(), fs.end()); + m_bc.push_back( { v, farfield, noOpGrad } ); + }; + + const auto& ext = ib.get< tag::extrapolate >(); + if (!ext.empty()) { + v.insert(v.end(), ext.begin(), ext.end()); + m_bc.push_back( { v, extrapolate, noOpGrad } ); + }; + + const auto& nsw = ib.get< tag::noslipwall >(); + if (!nsw.empty()) { + v.insert(v.end(), nsw.begin(), nsw.end()); + m_bc.push_back( { v, noslipwall, noOpGrad } ); + }; + + // const auto& timedep = ib.get< tag::timedep >(); + // if (!timedep.empty()) { + // for (const auto& bndry : timedep) { + // nfo.emplace_back( "Time dependent BC sideset(s)", + // parameters(bndry.get< tag::sideset >()) ); + // } + } // EoS initialization initializeMaterialEoS( m_mat_blk ); From 5961c3f20aafa44871d1431c278a6e25becba9ac Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Wed, 6 Nov 2024 11:53:05 -0700 Subject: [PATCH 02/17] Made sure to clear vector containing bc information before inserting into bc configuration vec --- src/PDE/MultiMat/FVMultiMat.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/PDE/MultiMat/FVMultiMat.hpp b/src/PDE/MultiMat/FVMultiMat.hpp index 02f39a4b97..691d65e590 100644 --- a/src/PDE/MultiMat/FVMultiMat.hpp +++ b/src/PDE/MultiMat/FVMultiMat.hpp @@ -78,46 +78,45 @@ class MultiMat { for (const auto& ib : bc) { const auto& dir = ib.get< tag::dirichlet >(); if (!dir.empty()) { + v.clear(); v.insert(v.end(), dir.begin(), dir.end()); m_bc.push_back( { v, dirichlet, noOpGrad } ); }; const auto& sym = ib.get< tag::symmetry >(); if (!sym.empty()) { + v.clear(); v.insert(v.end(), sym.begin(), sym.end()); m_bc.push_back( { v, symmetry, symmetryGrad } ); }; const auto& in = ib.get< tag::inlet >(); if (!in.empty()) { + v.clear(); v.insert(v.end(), in.begin(), in.end()); m_bc.push_back( { v, inlet, noOpGrad } ); }; const auto& fs = ib.get< tag::farfield >(); if (!fs.empty()) { + v.clear(); v.insert(v.end(), fs.begin(), fs.end()); m_bc.push_back( { v, farfield, noOpGrad } ); }; const auto& ext = ib.get< tag::extrapolate >(); if (!ext.empty()) { + v.clear(); v.insert(v.end(), ext.begin(), ext.end()); m_bc.push_back( { v, extrapolate, noOpGrad } ); }; const auto& nsw = ib.get< tag::noslipwall >(); if (!nsw.empty()) { + v.clear(); v.insert(v.end(), nsw.begin(), nsw.end()); m_bc.push_back( { v, noslipwall, noOpGrad } ); }; - - // const auto& timedep = ib.get< tag::timedep >(); - // if (!timedep.empty()) { - // for (const auto& bndry : timedep) { - // nfo.emplace_back( "Time dependent BC sideset(s)", - // parameters(bndry.get< tag::sideset >()) ); - // } } // EoS initialization From 54b0232d0846e12aedb65d41a457c99c7668a612 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Wed, 6 Nov 2024 11:58:45 -0700 Subject: [PATCH 03/17] Made inlet it's own block. Not very robust. Some ideas of how to fix. --- src/Control/Inciter/InputDeck/InputDeck.hpp | 18 +++++- src/Control/Inciter/InputDeck/LuaParser.cpp | 20 ++++++- src/Inciter/Transporter.cpp | 12 +++- src/PDE/CompFlow/DGCompFlow.hpp | 53 ++++++++++------- src/PDE/ConfigureTransport.cpp | 6 +- src/PDE/MultiMat/BCFunctions.hpp | 16 +++++- src/PDE/MultiMat/DGMultiMat.hpp | 63 ++++++++++++++------- src/PDE/MultiMat/FVMultiMat.hpp | 9 ++- src/PDE/Transport/DGTransport.hpp | 52 ++++++++++------- 9 files changed, 176 insertions(+), 73 deletions(-) diff --git a/src/Control/Inciter/InputDeck/InputDeck.hpp b/src/Control/Inciter/InputDeck/InputDeck.hpp index 664d93f323..c3601e28cd 100644 --- a/src/Control/Inciter/InputDeck/InputDeck.hpp +++ b/src/Control/Inciter/InputDeck/InputDeck.hpp @@ -47,7 +47,14 @@ using ncomp_t = std::size_t; using bclist = tk::TaggedTuple< brigand::list< tag::dirichlet, std::vector< std::size_t >, tag::symmetry, std::vector< std::size_t >, - tag::inlet, std::vector< std::size_t >, + tag::inlet, std::vector< + tk::TaggedTuple< brigand::list< + tag::sideset, std::vector< uint64_t >, + tag::velocity, std::vector< tk::real >, + tag::pressure, tk::real, + tag::temperature, tk::real + > > + >, tag::outlet, std::vector< std::size_t >, tag::farfield, std::vector< std::size_t >, tag::extrapolate, std::vector< std::size_t >, @@ -123,7 +130,14 @@ using bcList = tk::TaggedTuple< brigand::list< tag::mesh, std::vector< std::size_t >, tag::dirichlet, std::vector< std::size_t >, tag::symmetry, std::vector< std::size_t >, - tag::inlet, std::vector< std::size_t >, + tag::inlet, std::vector< + tk::TaggedTuple< brigand::list< + tag::sideset, std::vector< uint64_t >, + tag::velocity, std::vector< tk::real >, + tag::pressure, tk::real, + tag::temperature, tk::real + > > + >, tag::outlet, std::vector< std::size_t >, tag::farfield, std::vector< std::size_t >, tag::extrapolate, std::vector< std::size_t >, diff --git a/src/Control/Inciter/InputDeck/LuaParser.cpp b/src/Control/Inciter/InputDeck/LuaParser.cpp index 897c21b90f..f84a05f531 100644 --- a/src/Control/Inciter/InputDeck/LuaParser.cpp +++ b/src/Control/Inciter/InputDeck/LuaParser.cpp @@ -1050,8 +1050,24 @@ LuaParser::storeInputDeck( storeVecIfSpecd< uint64_t >(sol_bc[i+1], "symmetry", bc_deck[i].get< tag::symmetry >(), {}); - storeVecIfSpecd< uint64_t >(sol_bc[i+1], "inlet", - bc_deck[i].get< tag::inlet >(), {}); + if (sol_bc[i+1]["inlet"].valid()) { + const sol::table& sol_inbc = sol_bc[i+1]["inlet"]; + auto& inbc_deck = bc_deck[i].get< tag::inlet >(); + inbc_deck.resize(sol_inbc.size()); + + for (std::size_t j=0; j(sol_inbc[j+1], "sideset", + inbc_deck[j].get< tag::sideset >(), {}); + storeVecIfSpecd< tk::real >(sol_inbc[j+1], "velocity", + inbc_deck[j].get< tag::velocity >(), {0.0, 0.0, 0.0}); + if (inbc_deck[j].get< tag::velocity >().size() != 3) + Throw("Inlet velocity requires 3 components."); + storeIfSpecd< tk::real >(sol_inbc[j+1], "pressure", + inbc_deck[j].get< tag::pressure >(), 0.0); + storeIfSpecd< tk::real >(sol_inbc[j+1], "temperature", + inbc_deck[j].get< tag::temperature >(), 0.0); + } + } storeVecIfSpecd< uint64_t >(sol_bc[i+1], "outlet", bc_deck[i].get< tag::outlet >(), {}); diff --git a/src/Inciter/Transporter.cpp b/src/Inciter/Transporter.cpp index e7ac47b122..763f593089 100644 --- a/src/Inciter/Transporter.cpp +++ b/src/Inciter/Transporter.cpp @@ -475,14 +475,22 @@ Transporter::matchBCs( std::map< int, std::vector< std::size_t > >& bnd ) // ***************************************************************************** { // Query side set ids at which BCs assigned for all BC types for all PDEs - using bclist = ctr::bclist::Keys; std::unordered_set< int > usedsets; - brigand::for_each< bclist >( UserBC( g_inputdeck, usedsets ) ); // Query side sets of time dependent BCs (since tag::bctimedep is not a part // of tag::bc) const auto& bcs = g_inputdeck.get< tag::bc >(); for (const auto& bci : bcs) { + usedsets.insert( bci.get< tag::dirichlet >().begin(), bci.get< tag::dirichlet >().end() ); + usedsets.insert( bci.get< tag::symmetry >().begin(), bci.get< tag::symmetry >().end() ); + usedsets.insert( bci.get< tag::outlet >().begin(), bci.get< tag::outlet >().end() ); + usedsets.insert( bci.get< tag::farfield >().begin(), bci.get< tag::farfield >().end() ); + usedsets.insert( bci.get< tag::extrapolate >().begin(), bci.get< tag::extrapolate >().end() ); + usedsets.insert( bci.get< tag::noslipwall >().begin(), bci.get< tag::noslipwall >().end() ); + for (const auto& b : bci.get< tag::inlet >()) { + for (auto i : b.get< tag::sideset >()) + usedsets.insert(static_cast(i)); + } for (const auto& b : bci.get< tag::timedep >()) { for (auto i : b.get< tag::sideset >()) usedsets.insert(static_cast(i)); diff --git a/src/PDE/CompFlow/DGCompFlow.hpp b/src/PDE/CompFlow/DGCompFlow.hpp index bf8fd5afcd..9d0c8f137e 100644 --- a/src/PDE/CompFlow/DGCompFlow.hpp +++ b/src/PDE/CompFlow/DGCompFlow.hpp @@ -69,26 +69,39 @@ class CompFlow { m_riemann( compflowRiemannSolver( g_inputdeck.get< tag::flux >() ) ) { - // associate boundary condition configurations with state functions, the - // order in which the state functions listed matters, see ctr::bc::Keys - brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, - // BC State functions - { dirichlet - , symmetry - , invalidBC // Inlet BC not implemented - , invalidBC // Outlet BC not implemented - , farfield - , extrapolate - , invalidBC }, // No slip wall BC not implemented - // BC Gradient functions - { noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad } - ) ); + // associate boundary condition configurations with state functions, + // manually looping through all BCs and state functions + const auto& bc = g_inputdeck.get< tag::bc >(); + std::vector< std::size_t > v; + for (const auto& ib : bc) { + const auto& dir = ib.get< tag::dirichlet >(); + if (!dir.empty()) { + v.clear(); + v.insert(v.end(), dir.begin(), dir.end()); + m_bc.push_back( { v, dirichlet, noOpGrad } ); + }; + + const auto& sym = ib.get< tag::symmetry >(); + if (!sym.empty()) { + v.clear(); + v.insert(v.end(), sym.begin(), sym.end()); + m_bc.push_back( { v, symmetry, noOpGrad } ); + }; + + const auto& fs = ib.get< tag::farfield >(); + if (!fs.empty()) { + v.clear(); + v.insert(v.end(), fs.begin(), fs.end()); + m_bc.push_back( { v, farfield, noOpGrad } ); + }; + + const auto& ext = ib.get< tag::extrapolate >(); + if (!ext.empty()) { + v.clear(); + v.insert(v.end(), ext.begin(), ext.end()); + m_bc.push_back( { v, extrapolate, noOpGrad } ); + }; + }; // EoS initialization const auto& matprop = diff --git a/src/PDE/ConfigureTransport.cpp b/src/PDE/ConfigureTransport.cpp index 4d27e5cb5e..342011569e 100644 --- a/src/PDE/ConfigureTransport.cpp +++ b/src/PDE/ConfigureTransport.cpp @@ -101,8 +101,10 @@ infoTransport( std::map< ctr::PDEType, tk::ncomp_t >& cnt ) const auto& bcinlet = ib.get< tag::inlet >(); if (!bcinlet.empty()) - nfo.emplace_back( "Inlet boundary [" + std::to_string( ncomp ) + "]", - parameters( bcinlet ) ); + for (const auto& bndry : bcinlet) { + nfo.emplace_back( "Inlet boundary [" + std::to_string( ncomp ) + "]", + parameters(bndry.get< tag::sideset >()) ); + } const auto& bcoutlet = ib.get< tag::outlet >(); diff --git a/src/PDE/MultiMat/BCFunctions.hpp b/src/PDE/MultiMat/BCFunctions.hpp index d68b915552..f5110834e9 100644 --- a/src/PDE/MultiMat/BCFunctions.hpp +++ b/src/PDE/MultiMat/BCFunctions.hpp @@ -138,12 +138,22 @@ namespace inciter { const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >(); // Farfield primitive quantities + // how do we make sure we have called the proper sideset for this input? + // This is necessary for multiple independent inputs, but I can't quite + // figure out how to get it to work considering all function signatures + // must follow the same signature, so I can't just put it in as an input. + // For now, leave it so it just takes the first block, but maybe there's a + // way to do this a bit more intelligently. + auto& inbc = g_inputdeck.get< tag::bc >()[0].get< tag::inlet >(); auto fp = - g_inputdeck.get< tag::bc >()[0].get< tag::pressure >(); + // g_inputdeck.get< tag::bc >()[0].get< tag::pressure >(); + inbc[0].get< tag::pressure >(); auto ft = - g_inputdeck.get< tag::bc >()[0].get< tag::temperature >(); + // g_inputdeck.get< tag::bc >()[0].get< tag::temperature >(); + inbc[0].get< tag::temperature >(); auto fu = - g_inputdeck.get< tag::bc >()[0].get< tag::velocity >(); + // g_inputdeck.get< tag::bc >()[0].get< tag::velocity >(); + inbc[0].get< tag::velocity >(); auto fmat = g_inputdeck.get< tag::bc >()[0].get< tag::materialid >() - 1; diff --git a/src/PDE/MultiMat/DGMultiMat.hpp b/src/PDE/MultiMat/DGMultiMat.hpp index 037680f3eb..dd7346cf4b 100644 --- a/src/PDE/MultiMat/DGMultiMat.hpp +++ b/src/PDE/MultiMat/DGMultiMat.hpp @@ -74,25 +74,50 @@ class MultiMat { m_riemann( multimatRiemannSolver( g_inputdeck.get< tag::flux >() ) ) { - // associate boundary condition configurations with state functions - brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, - // BC State functions - { dirichlet - , symmetry - , invalidBC // Inlet BC not implemented - , invalidBC // Outlet BC not implemented - , farfield - , extrapolate - , noslipwall }, - // BC Gradient functions - { noOpGrad - , symmetryGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad } - ) ); + // associate boundary condition configurations with state functions, + // manually looping through all BCs and state functions + const auto& bc = g_inputdeck.get< tag::bc >(); + std::vector< std::size_t > v; + for (const auto& ib : bc) { + const auto& dir = ib.get< tag::dirichlet >(); + if (!dir.empty()) { + v.insert(v.end(), dir.begin(), dir.end()); + m_bc.push_back( { v, dirichlet, noOpGrad } ); + }; + + const auto& sym = ib.get< tag::symmetry >(); + if (!sym.empty()) { + v.insert(v.end(), sym.begin(), sym.end()); + m_bc.push_back( { v, symmetry, symmetryGrad } ); + }; + + const auto& in = ib.get< tag::inlet >(); + if (!in.empty()) { + for (const auto& bndry : in) { + const auto& sideset = bndry.get< tag::sideset >(); + v.insert(v.end(), sideset.begin(), sideset.end()); + m_bc.push_back( { v, inlet, noOpGrad } ); + } + }; + + const auto& fs = ib.get< tag::farfield >(); + if (!fs.empty()) { + v.insert(v.end(), fs.begin(), fs.end()); + m_bc.push_back( { v, farfield, noOpGrad } ); + }; + + const auto& ext = ib.get< tag::extrapolate >(); + if (!ext.empty()) { + v.insert(v.end(), ext.begin(), ext.end()); + m_bc.push_back( { v, extrapolate, noOpGrad } ); + }; + + const auto& nsw = ib.get< tag::noslipwall >(); + if (!nsw.empty()) { + v.insert(v.end(), nsw.begin(), nsw.end()); + m_bc.push_back( { v, noslipwall, noOpGrad } ); + }; + } // EoS initialization initializeMaterialEoS( m_mat_blk ); diff --git a/src/PDE/MultiMat/FVMultiMat.hpp b/src/PDE/MultiMat/FVMultiMat.hpp index 691d65e590..642617b274 100644 --- a/src/PDE/MultiMat/FVMultiMat.hpp +++ b/src/PDE/MultiMat/FVMultiMat.hpp @@ -92,9 +92,12 @@ class MultiMat { const auto& in = ib.get< tag::inlet >(); if (!in.empty()) { - v.clear(); - v.insert(v.end(), in.begin(), in.end()); - m_bc.push_back( { v, inlet, noOpGrad } ); + for (const auto& bndry : in) { + const auto& sideset = bndry.get< tag::sideset >(); + v.clear(); + v.insert(v.end(), sideset.begin(), sideset.end()); + m_bc.push_back( { v, inlet, noOpGrad } ); + } }; const auto& fs = ib.get< tag::farfield >(); diff --git a/src/PDE/Transport/DGTransport.hpp b/src/PDE/Transport/DGTransport.hpp index 1b4bda2947..d5e4b3696a 100644 --- a/src/PDE/Transport/DGTransport.hpp +++ b/src/PDE/Transport/DGTransport.hpp @@ -65,26 +65,38 @@ class Transport { m_problem( Problem() ), m_ncomp( g_inputdeck.get< tag::ncomp >() ) { - // associate boundary condition configurations with state functions, the - // order in which the state functions listed matters, see ctr::bc::Keys - brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, - // BC State functions - { dirichlet - , invalidBC // Symmetry BC not implemented - , inlet - , outlet - , invalidBC // Characteristic BC not implemented - , extrapolate - , invalidBC }, // No slip wall BC not implemented - // BC Gradient functions - { noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad - , noOpGrad } - ) ); + // associate boundary condition configurations with state functions, + // manually looping through all BCs and state functions + const auto& bc = g_inputdeck.get< tag::bc >(); + std::vector< std::size_t > v; + for (const auto& ib : bc) { + const auto& dir = ib.get< tag::dirichlet >(); + if (!dir.empty()) { + v.insert(v.end(), dir.begin(), dir.end()); + m_bc.push_back( { v, dirichlet, noOpGrad } ); + }; + + const auto& in = ib.get< tag::inlet >(); + if (!in.empty()) { + for (const auto& bndry : in) { + const auto& sideset = bndry.get< tag::sideset >(); + v.insert(v.end(), sideset.begin(), sideset.end()); + m_bc.push_back( { v, inlet, noOpGrad } ); + } + }; + + const auto& out = ib.get< tag::outlet >(); + if (!out.empty()) { + v.insert(v.end(), out.begin(), out.end()); + m_bc.push_back( { v, outlet, noOpGrad } ); + }; + + const auto& ext = ib.get< tag::extrapolate >(); + if (!ext.empty()) { + v.insert(v.end(), ext.begin(), ext.end()); + m_bc.push_back( { v, extrapolate, noOpGrad } ); + }; + }; m_problem.errchk( m_ncomp ); } From dc8dc7fe9d2deda981f7522233320e621a38c385 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Tue, 12 Nov 2024 08:24:07 -0700 Subject: [PATCH 04/17] Reverted so ConfigBC loop still used, inlet is just popped out as an exception --- src/Control/Inciter/InputDeck/InputDeck.hpp | 8 --- src/Inciter/Transporter.cpp | 10 +--- src/PDE/CompFlow/DGCompFlow.hpp | 47 ++++++---------- src/PDE/MultiMat/DGMultiMat.hpp | 52 +++++++----------- src/PDE/MultiMat/FVMultiMat.hpp | 61 ++++++++------------- src/PDE/Transport/DGTransport.hpp | 45 +++++++-------- 6 files changed, 84 insertions(+), 139 deletions(-) diff --git a/src/Control/Inciter/InputDeck/InputDeck.hpp b/src/Control/Inciter/InputDeck/InputDeck.hpp index c3601e28cd..7c719f5adf 100644 --- a/src/Control/Inciter/InputDeck/InputDeck.hpp +++ b/src/Control/Inciter/InputDeck/InputDeck.hpp @@ -47,14 +47,6 @@ using ncomp_t = std::size_t; using bclist = tk::TaggedTuple< brigand::list< tag::dirichlet, std::vector< std::size_t >, tag::symmetry, std::vector< std::size_t >, - tag::inlet, std::vector< - tk::TaggedTuple< brigand::list< - tag::sideset, std::vector< uint64_t >, - tag::velocity, std::vector< tk::real >, - tag::pressure, tk::real, - tag::temperature, tk::real - > > - >, tag::outlet, std::vector< std::size_t >, tag::farfield, std::vector< std::size_t >, tag::extrapolate, std::vector< std::size_t >, diff --git a/src/Inciter/Transporter.cpp b/src/Inciter/Transporter.cpp index 763f593089..87d9485d3c 100644 --- a/src/Inciter/Transporter.cpp +++ b/src/Inciter/Transporter.cpp @@ -477,16 +477,12 @@ Transporter::matchBCs( std::map< int, std::vector< std::size_t > >& bnd ) // Query side set ids at which BCs assigned for all BC types for all PDEs std::unordered_set< int > usedsets; - // Query side sets of time dependent BCs (since tag::bctimedep is not a part + // Query side sets of time dependent and inlet BCs (since these are not a part // of tag::bc) + using bclist = ctr::bclist::Keys; const auto& bcs = g_inputdeck.get< tag::bc >(); + brigand::for_each< bclist >( UserBC( g_inputdeck, usedsets ) ); for (const auto& bci : bcs) { - usedsets.insert( bci.get< tag::dirichlet >().begin(), bci.get< tag::dirichlet >().end() ); - usedsets.insert( bci.get< tag::symmetry >().begin(), bci.get< tag::symmetry >().end() ); - usedsets.insert( bci.get< tag::outlet >().begin(), bci.get< tag::outlet >().end() ); - usedsets.insert( bci.get< tag::farfield >().begin(), bci.get< tag::farfield >().end() ); - usedsets.insert( bci.get< tag::extrapolate >().begin(), bci.get< tag::extrapolate >().end() ); - usedsets.insert( bci.get< tag::noslipwall >().begin(), bci.get< tag::noslipwall >().end() ); for (const auto& b : bci.get< tag::inlet >()) { for (auto i : b.get< tag::sideset >()) usedsets.insert(static_cast(i)); diff --git a/src/PDE/CompFlow/DGCompFlow.hpp b/src/PDE/CompFlow/DGCompFlow.hpp index 9d0c8f137e..158ee4474f 100644 --- a/src/PDE/CompFlow/DGCompFlow.hpp +++ b/src/PDE/CompFlow/DGCompFlow.hpp @@ -71,37 +71,22 @@ class CompFlow { { // associate boundary condition configurations with state functions, // manually looping through all BCs and state functions - const auto& bc = g_inputdeck.get< tag::bc >(); - std::vector< std::size_t > v; - for (const auto& ib : bc) { - const auto& dir = ib.get< tag::dirichlet >(); - if (!dir.empty()) { - v.clear(); - v.insert(v.end(), dir.begin(), dir.end()); - m_bc.push_back( { v, dirichlet, noOpGrad } ); - }; - - const auto& sym = ib.get< tag::symmetry >(); - if (!sym.empty()) { - v.clear(); - v.insert(v.end(), sym.begin(), sym.end()); - m_bc.push_back( { v, symmetry, noOpGrad } ); - }; - - const auto& fs = ib.get< tag::farfield >(); - if (!fs.empty()) { - v.clear(); - v.insert(v.end(), fs.begin(), fs.end()); - m_bc.push_back( { v, farfield, noOpGrad } ); - }; - - const auto& ext = ib.get< tag::extrapolate >(); - if (!ext.empty()) { - v.clear(); - v.insert(v.end(), ext.begin(), ext.end()); - m_bc.push_back( { v, extrapolate, noOpGrad } ); - }; - }; + brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, + // BC State functions + { dirichlet + , symmetry + , invalidBC // Outlet BC not implemented + , farfield + , extrapolate + , invalidBC }, // No slip wall BC not implemented + // BC Gradient functions + { noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad } + ) ); // EoS initialization const auto& matprop = diff --git a/src/PDE/MultiMat/DGMultiMat.hpp b/src/PDE/MultiMat/DGMultiMat.hpp index dd7346cf4b..556b336cb0 100644 --- a/src/PDE/MultiMat/DGMultiMat.hpp +++ b/src/PDE/MultiMat/DGMultiMat.hpp @@ -74,23 +74,29 @@ class MultiMat { m_riemann( multimatRiemannSolver( g_inputdeck.get< tag::flux >() ) ) { - // associate boundary condition configurations with state functions, - // manually looping through all BCs and state functions + // associate boundary condition configurations with state functions + brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, + // BC State functions + { dirichlet + , symmetry + , invalidBC // Outlet BC not implemented + , farfield + , extrapolate + , noslipwall }, + // BC Gradient functions + { noOpGrad + , symmetryGrad + , noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad } + ) ); + + // Inlet BC has a different structure than above BCs, so it must be + // handled differently than with ConfigBC const auto& bc = g_inputdeck.get< tag::bc >(); std::vector< std::size_t > v; for (const auto& ib : bc) { - const auto& dir = ib.get< tag::dirichlet >(); - if (!dir.empty()) { - v.insert(v.end(), dir.begin(), dir.end()); - m_bc.push_back( { v, dirichlet, noOpGrad } ); - }; - - const auto& sym = ib.get< tag::symmetry >(); - if (!sym.empty()) { - v.insert(v.end(), sym.begin(), sym.end()); - m_bc.push_back( { v, symmetry, symmetryGrad } ); - }; - const auto& in = ib.get< tag::inlet >(); if (!in.empty()) { for (const auto& bndry : in) { @@ -99,24 +105,6 @@ class MultiMat { m_bc.push_back( { v, inlet, noOpGrad } ); } }; - - const auto& fs = ib.get< tag::farfield >(); - if (!fs.empty()) { - v.insert(v.end(), fs.begin(), fs.end()); - m_bc.push_back( { v, farfield, noOpGrad } ); - }; - - const auto& ext = ib.get< tag::extrapolate >(); - if (!ext.empty()) { - v.insert(v.end(), ext.begin(), ext.end()); - m_bc.push_back( { v, extrapolate, noOpGrad } ); - }; - - const auto& nsw = ib.get< tag::noslipwall >(); - if (!nsw.empty()) { - v.insert(v.end(), nsw.begin(), nsw.end()); - m_bc.push_back( { v, noslipwall, noOpGrad } ); - }; } // EoS initialization diff --git a/src/PDE/MultiMat/FVMultiMat.hpp b/src/PDE/MultiMat/FVMultiMat.hpp index 642617b274..0c7a75d535 100644 --- a/src/PDE/MultiMat/FVMultiMat.hpp +++ b/src/PDE/MultiMat/FVMultiMat.hpp @@ -71,25 +71,29 @@ class MultiMat { g_inputdeck.get< tag::flux >() ) ) { - // associate boundary condition configurations with state functions, - // manually looping through all BCs and state functions + // associate boundary condition configurations with state functions + brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, + // BC State functions + { dirichlet + , symmetry + , invalidBC // Outlet BC not implemented + , farfield + , extrapolate + , noslipwall }, + // BC Gradient functions + { noOpGrad + , symmetryGrad + , noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad } + ) ); + + // Inlet BC has a different structure than above BCs, so it must be + // handled differently than with ConfigBC const auto& bc = g_inputdeck.get< tag::bc >(); std::vector< std::size_t > v; for (const auto& ib : bc) { - const auto& dir = ib.get< tag::dirichlet >(); - if (!dir.empty()) { - v.clear(); - v.insert(v.end(), dir.begin(), dir.end()); - m_bc.push_back( { v, dirichlet, noOpGrad } ); - }; - - const auto& sym = ib.get< tag::symmetry >(); - if (!sym.empty()) { - v.clear(); - v.insert(v.end(), sym.begin(), sym.end()); - m_bc.push_back( { v, symmetry, symmetryGrad } ); - }; - const auto& in = ib.get< tag::inlet >(); if (!in.empty()) { for (const auto& bndry : in) { @@ -98,29 +102,8 @@ class MultiMat { v.insert(v.end(), sideset.begin(), sideset.end()); m_bc.push_back( { v, inlet, noOpGrad } ); } - }; - - const auto& fs = ib.get< tag::farfield >(); - if (!fs.empty()) { - v.clear(); - v.insert(v.end(), fs.begin(), fs.end()); - m_bc.push_back( { v, farfield, noOpGrad } ); - }; - - const auto& ext = ib.get< tag::extrapolate >(); - if (!ext.empty()) { - v.clear(); - v.insert(v.end(), ext.begin(), ext.end()); - m_bc.push_back( { v, extrapolate, noOpGrad } ); - }; - - const auto& nsw = ib.get< tag::noslipwall >(); - if (!nsw.empty()) { - v.clear(); - v.insert(v.end(), nsw.begin(), nsw.end()); - m_bc.push_back( { v, noslipwall, noOpGrad } ); - }; - } + } + } // EoS initialization initializeMaterialEoS( m_mat_blk ); diff --git a/src/PDE/Transport/DGTransport.hpp b/src/PDE/Transport/DGTransport.hpp index d5e4b3696a..9485618f92 100644 --- a/src/PDE/Transport/DGTransport.hpp +++ b/src/PDE/Transport/DGTransport.hpp @@ -65,17 +65,30 @@ class Transport { m_problem( Problem() ), m_ncomp( g_inputdeck.get< tag::ncomp >() ) { - // associate boundary condition configurations with state functions, - // manually looping through all BCs and state functions + // associate boundary condition configurations with state functions, the + // order in which the state functions listed matters, see ctr::bc::Keys + brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, + // BC State functions + { dirichlet + , invalidBC // Symmetry BC not implemented + , outlet + , invalidBC // Characteristic BC not implemented + , extrapolate + , invalidBC }, // No slip wall BC not implemented + // BC Gradient functions + { noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad + , noOpGrad } + ) ); + + // Inlet BC has a different structure than above BCs, so it must be + // handled differently than with ConfigBC const auto& bc = g_inputdeck.get< tag::bc >(); std::vector< std::size_t > v; for (const auto& ib : bc) { - const auto& dir = ib.get< tag::dirichlet >(); - if (!dir.empty()) { - v.insert(v.end(), dir.begin(), dir.end()); - m_bc.push_back( { v, dirichlet, noOpGrad } ); - }; - const auto& in = ib.get< tag::inlet >(); if (!in.empty()) { for (const auto& bndry : in) { @@ -83,20 +96,8 @@ class Transport { v.insert(v.end(), sideset.begin(), sideset.end()); m_bc.push_back( { v, inlet, noOpGrad } ); } - }; - - const auto& out = ib.get< tag::outlet >(); - if (!out.empty()) { - v.insert(v.end(), out.begin(), out.end()); - m_bc.push_back( { v, outlet, noOpGrad } ); - }; - - const auto& ext = ib.get< tag::extrapolate >(); - if (!ext.empty()) { - v.insert(v.end(), ext.begin(), ext.end()); - m_bc.push_back( { v, extrapolate, noOpGrad } ); - }; - }; + } + } m_problem.errchk( m_ncomp ); } From a39588ed11a1437d47fb0f246b25921cac21fa87 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Tue, 12 Nov 2024 11:41:37 -0700 Subject: [PATCH 05/17] Removed colon TeamCity was mad about --- src/PDE/MultiMat/DGMultiMat.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PDE/MultiMat/DGMultiMat.hpp b/src/PDE/MultiMat/DGMultiMat.hpp index 556b336cb0..4e952f02b6 100644 --- a/src/PDE/MultiMat/DGMultiMat.hpp +++ b/src/PDE/MultiMat/DGMultiMat.hpp @@ -104,7 +104,7 @@ class MultiMat { v.insert(v.end(), sideset.begin(), sideset.end()); m_bc.push_back( { v, inlet, noOpGrad } ); } - }; + } } // EoS initialization From eb4e88a1ae06c55de9a8141e178f4db9a9268c5b Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Tue, 12 Nov 2024 11:44:40 -0700 Subject: [PATCH 06/17] Changed lua files in tests --- tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua | 4 +++- .../inciter/mesh_refinement/dtref/gauss_hump_reord.lua | 4 +++- .../inciter/mesh_refinement/t0ref/gauss_hump_dg.lua | 4 +++- .../mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua | 4 +++- .../mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua | 4 +++- .../inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua | 4 +++- tests/regression/inciter/transport/GaussHump/gauss_hump.lua | 4 +++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua index 10859d0282..a881dbcb92 100644 --- a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua +++ b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua @@ -18,7 +18,9 @@ inciter = { bc = { { extrapolate = { 1 }, - inlet = { 2 }, + inlet = { + sideset = { 2 } + }, outlet = { 3 } } }, diff --git a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua index b3e41dd289..199080c5b1 100644 --- a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua +++ b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua @@ -19,7 +19,9 @@ inciter = { bc = { { extrapolate = { 1 }, - inlet = { 2 }, + inlet = { + sideset = { 2 } + }, outlet = { 3 } } }, diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua index b18bee1e51..3f26454c8a 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua @@ -18,7 +18,9 @@ inciter = { bc = { { extrapolate = { 1 }, - inlet = { 2 }, + inlet = { + sideset = { 2 } + }, outlet = { 3 } } }, diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua index ecde9caf5c..1e32de51f2 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua @@ -18,7 +18,9 @@ inciter = { bc = { { extrapolate = { 1 }, - inlet = { 2 }, + inlet = { + sideset = { 2 } + }, outlet = { 3 } } }, diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua index 5dc9b80f40..7f0d48e6e7 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua @@ -18,7 +18,9 @@ inciter = { bc = { { extrapolate = { 1 }, - inlet = { 2 }, + inlet = { + sideset = { 2 } + }, outlet = { 3 } } }, diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua index 6af2dc37ff..b9c3f49608 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua @@ -19,7 +19,9 @@ inciter = { bc = { { extrapolate = { 1 }, - inlet = { 2 }, + inlet = { + sideset = { 2 } + }, outlet = { 3 } } }, diff --git a/tests/regression/inciter/transport/GaussHump/gauss_hump.lua b/tests/regression/inciter/transport/GaussHump/gauss_hump.lua index fde9d1166d..f0ba4daf7c 100644 --- a/tests/regression/inciter/transport/GaussHump/gauss_hump.lua +++ b/tests/regression/inciter/transport/GaussHump/gauss_hump.lua @@ -16,7 +16,9 @@ inciter = { bc = { { extrapolate = {1}, - inlet = {2}, + inlet = { + sideset = { 2 } + }, outlet = {3} } }, From f2f61cda336c6895d401bd4aa1618fab97d8ff76 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Tue, 12 Nov 2024 15:36:15 -0700 Subject: [PATCH 07/17] Fixed test lua files to actually pass. Made DG_Transport consistent w/ FVMultiMat --- src/PDE/Transport/DGTransport.hpp | 1 + tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua | 4 +++- .../inciter/mesh_refinement/dtref/gauss_hump_reord.lua | 4 +++- .../inciter/mesh_refinement/t0ref/gauss_hump_dg.lua | 4 +++- .../mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua | 4 +++- .../mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua | 4 +++- .../inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua | 4 +++- tests/regression/inciter/transport/GaussHump/gauss_hump.lua | 4 +++- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/PDE/Transport/DGTransport.hpp b/src/PDE/Transport/DGTransport.hpp index 9485618f92..e5e0c3eef2 100644 --- a/src/PDE/Transport/DGTransport.hpp +++ b/src/PDE/Transport/DGTransport.hpp @@ -93,6 +93,7 @@ class Transport { if (!in.empty()) { for (const auto& bndry : in) { const auto& sideset = bndry.get< tag::sideset >(); + v.clear(); v.insert(v.end(), sideset.begin(), sideset.end()); m_bc.push_back( { v, inlet, noOpGrad } ); } diff --git a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua index a881dbcb92..7325b30a9c 100644 --- a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua +++ b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump.lua @@ -19,7 +19,9 @@ inciter = { { extrapolate = { 1 }, inlet = { - sideset = { 2 } + { + sideset = { 2 } + } }, outlet = { 3 } } diff --git a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua index 199080c5b1..bfb7154bcb 100644 --- a/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua +++ b/tests/regression/inciter/mesh_refinement/dtref/gauss_hump_reord.lua @@ -20,7 +20,9 @@ inciter = { { extrapolate = { 1 }, inlet = { - sideset = { 2 } + { + sideset = { 2 } + } }, outlet = { 3 } } diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua index 3f26454c8a..ed25f6a110 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg.lua @@ -19,7 +19,9 @@ inciter = { { extrapolate = { 1 }, inlet = { - sideset = { 2 } + { + sideset = { 2 } + } }, outlet = { 3 } } diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua index 1e32de51f2..5024552cf3 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref.lua @@ -19,7 +19,9 @@ inciter = { { extrapolate = { 1 }, inlet = { - sideset = { 2 } + { + sideset = { 2 } + } }, outlet = { 3 } } diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua index 7f0d48e6e7..0119caf414 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_dg_uniform_deref_x2.lua @@ -19,7 +19,9 @@ inciter = { { extrapolate = { 1 }, inlet = { - sideset = { 2 } + { + sideset = { 2 } + } }, outlet = { 3 } } diff --git a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua index b9c3f49608..c802427c80 100644 --- a/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua +++ b/tests/regression/inciter/mesh_refinement/t0ref/gauss_hump_reord_dg.lua @@ -20,7 +20,9 @@ inciter = { { extrapolate = { 1 }, inlet = { - sideset = { 2 } + { + sideset = { 2 } + } }, outlet = { 3 } } diff --git a/tests/regression/inciter/transport/GaussHump/gauss_hump.lua b/tests/regression/inciter/transport/GaussHump/gauss_hump.lua index f0ba4daf7c..3ec14f1056 100644 --- a/tests/regression/inciter/transport/GaussHump/gauss_hump.lua +++ b/tests/regression/inciter/transport/GaussHump/gauss_hump.lua @@ -17,7 +17,9 @@ inciter = { { extrapolate = {1}, inlet = { - sideset = { 2 } + { + sideset = { 2 } + } }, outlet = {3} } From 42913dbc7c7b7dd65a4dd8722303f116007a325a Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Wed, 13 Nov 2024 07:18:39 -0700 Subject: [PATCH 08/17] Added mass_fractions tag back in that got lost when a merge conflict was resolved --- src/Control/Inciter/InputDeck/InputDeck.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Control/Inciter/InputDeck/InputDeck.hpp b/src/Control/Inciter/InputDeck/InputDeck.hpp index 13b329610f..66c30f8cb6 100644 --- a/src/Control/Inciter/InputDeck/InputDeck.hpp +++ b/src/Control/Inciter/InputDeck/InputDeck.hpp @@ -148,6 +148,7 @@ using bcList = tk::TaggedTuple< brigand::list< tag::pressure, tk::real, tag::density, tk::real, tag::temperature, tk::real, + tag::mass_fractions, std::vector< tk::real >, tag::materialid, std::size_t, tag::timedep, std::vector< tk::TaggedTuple< brigand::list< From 49061a471e0cae7c54949cc320926db684095df9 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Wed, 20 Nov 2024 07:39:09 -0700 Subject: [PATCH 09/17] Changed inlet s.t. it uses pressure and density of interior cell to not have momentum flux from these --- src/PDE/MultiMat/BCFunctions.hpp | 116 ++++++++++--------------------- 1 file changed, 37 insertions(+), 79 deletions(-) diff --git a/src/PDE/MultiMat/BCFunctions.hpp b/src/PDE/MultiMat/BCFunctions.hpp index f5110834e9..a14a3a4b67 100644 --- a/src/PDE/MultiMat/BCFunctions.hpp +++ b/src/PDE/MultiMat/BCFunctions.hpp @@ -116,7 +116,6 @@ namespace inciter { return {{ std::move(ul), std::move(ur) }}; } - //! \todo Fix all of this for inlet. Just trying to get this working //! \brief Boundary state function providing the left and right state of a //! face at farfield boundaries //! \param[in] ncomp Number of scalar components in this PDE system @@ -132,7 +131,7 @@ namespace inciter { const std::vector< EOS >& mat_blk, const std::vector< tk::real >& ul, tk::real, tk::real, tk::real, tk::real, - const std::array< tk::real, 3 >& fn ) + const std::array< tk::real, 3 >& ) { auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >(); const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >(); @@ -144,16 +143,13 @@ namespace inciter { // must follow the same signature, so I can't just put it in as an input. // For now, leave it so it just takes the first block, but maybe there's a // way to do this a bit more intelligently. + auto& inbc = g_inputdeck.get< tag::bc >()[0].get< tag::inlet >(); - auto fp = - // g_inputdeck.get< tag::bc >()[0].get< tag::pressure >(); - inbc[0].get< tag::pressure >(); - auto ft = - // g_inputdeck.get< tag::bc >()[0].get< tag::temperature >(); - inbc[0].get< tag::temperature >(); - auto fu = - // g_inputdeck.get< tag::bc >()[0].get< tag::velocity >(); - inbc[0].get< tag::velocity >(); + //! \todo With changes, ft and fp are not used, since interior cell is used + //! instead. Remove, and also add matid tag + auto fp = inbc[0].get< tag::pressure >(); + auto ft = inbc[0].get< tag::temperature >(); + auto fu = inbc[0].get< tag::velocity >(); auto fmat = g_inputdeck.get< tag::bc >()[0].get< tag::materialid >() - 1; @@ -169,78 +165,40 @@ namespace inciter { auto v2l = ul[ncomp+velocityIdx(nmat, 1)]; auto v3l = ul[ncomp+velocityIdx(nmat, 2)]; - // Normal velocity - auto vn = v1l*fn[0] + v2l*fn[1] + v3l*fn[2]; - - // Acoustic speed - tk::real a(0.0); - for (std::size_t k=0; k 1.0e-04) - a = std::max( a, mat_blk[k].compute< EOS::soundspeed >( - ul[densityIdx(nmat, k)], ul[ncomp+pressureIdx(nmat, k)], - ul[volfracIdx(nmat, k)], k ) ); - - // Mach number - auto Ma = vn / a; + // External cell velocity, such that velocity = fu at face + auto v1r = 2.0*fu[0] - v1l; + auto v2r = 2.0*fu[1] - v2l; + auto v3r = 2.0*fu[2] - v3l; tk::real alphamin = 1e-12; + tk::real rho(0.0); + for (std::size_t k=0; k(nmat-1))*alphamin; + else + ur[volfracIdx(nmat,k)] = alphamin; + + auto p = ul[ncomp+pressureIdx(nmat,k)] / ul[volfracIdx(nmat,k)]; + auto rhok = ul[densityIdx(nmat, k)]; + + ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rhok; + ur[energyIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * + mat_blk[k].compute< EOS::totalenergy >(rhok, v1r, v2r, v3r, p); + // material pressures + ur[ncomp+pressureIdx(nmat, k)] = ul[volfracIdx(nmat, k)] * p; + + rho += ur[densityIdx(nmat,k)]; + } - //! \note: it seems that using internal pressure does not lead to the - //! correct behavior (!) - if (true) { // Supersonic inflow - // For supersonic inflow, all the characteristics are from outside. - // Therefore, we calculate the ghost cell state using the primitive - // variables from outside. - tk::real rho(0.0); - for (std::size_t k=0; k(nmat-1))*alphamin; - else - ur[volfracIdx(nmat,k)] = alphamin; - auto rhok = mat_blk[k].compute< EOS::density >(fp, ft); - ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rhok; - ur[energyIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * - mat_blk[k].compute< EOS::totalenergy >(rhok, fu[0], fu[1], fu[2], fp); - - // material pressures - ur[ncomp+pressureIdx(nmat, k)] = ul[volfracIdx(nmat, k)] * fp; - - rho += ur[densityIdx(nmat,k)]; - } - for (std::size_t i=0; i<3; ++i) { - ur[momentumIdx(nmat,i)] = rho * fu[i]; - ur[ncomp+velocityIdx(nmat, i)] = fu[i]; - } - - } else if (Ma > -1) { // Subsonic inflow - // For subsonic inflow, there is 1 outgoing characteristic and 4 - // incoming characteristics. Therefore, we calculate the ghost cell state - // by taking pressure from the internal cell and other quantities from - // the outside. - tk::real rho(0.0); - for (std::size_t k=0; k(nmat-1))*alphamin; - else - ur[volfracIdx(nmat,k)] = alphamin; - auto p = ul[ncomp+pressureIdx(nmat,k)] / ul[volfracIdx(nmat,k)]; - auto rhok = mat_blk[k].compute< EOS::density >(p, ft); - ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rhok; - ur[energyIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * - mat_blk[k].compute< EOS::totalenergy >(rhok, fu[0], fu[1], fu[2], p); - - // material pressures - ur[ncomp+pressureIdx(nmat, k)] = ul[volfracIdx(nmat, k)] * p; + ur[momentumIdx(nmat, 0)] = rho * v1r; + ur[momentumIdx(nmat, 1)] = rho * v2r; + ur[momentumIdx(nmat, 2)] = rho * v3r; - rho += ur[densityIdx(nmat,k)]; - } - for (std::size_t i=0; i<3; ++i) { - ur[momentumIdx(nmat,i)] = rho * fu[i]; - ur[ncomp+velocityIdx(nmat, i)] = fu[i]; - } - } + // velocity + ur[ncomp+velocityIdx(nmat, 0)] = v1r; + ur[ncomp+velocityIdx(nmat, 1)] = v2r; + ur[ncomp+velocityIdx(nmat, 2)] = v3r; Assert( ur.size() == ncomp+nmat+3+nsld*6, "Incorrect size for appended " "boundary state vector" ); From 0958afe641bb9817a219050df1b02b119e1c2059 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 5 Dec 2024 09:35:50 -0700 Subject: [PATCH 10/17] inlet now takes materialid instead of pressure and temperature --- src/Control/Inciter/InputDeck/InputDeck.hpp | 3 +-- src/Control/Inciter/InputDeck/LuaParser.cpp | 6 ++---- src/PDE/CompFlow/DGCompFlow.hpp | 4 ++-- src/PDE/MultiMat/FVMultiMat.hpp | 1 - 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Control/Inciter/InputDeck/InputDeck.hpp b/src/Control/Inciter/InputDeck/InputDeck.hpp index 66c30f8cb6..44123f8b0f 100644 --- a/src/Control/Inciter/InputDeck/InputDeck.hpp +++ b/src/Control/Inciter/InputDeck/InputDeck.hpp @@ -134,8 +134,7 @@ using bcList = tk::TaggedTuple< brigand::list< tk::TaggedTuple< brigand::list< tag::sideset, std::vector< uint64_t >, tag::velocity, std::vector< tk::real >, - tag::pressure, tk::real, - tag::temperature, tk::real + tag::materialid, std::size_t > > >, tag::outlet, std::vector< std::size_t >, diff --git a/src/Control/Inciter/InputDeck/LuaParser.cpp b/src/Control/Inciter/InputDeck/LuaParser.cpp index 584d36af37..7db7e3b998 100644 --- a/src/Control/Inciter/InputDeck/LuaParser.cpp +++ b/src/Control/Inciter/InputDeck/LuaParser.cpp @@ -1099,10 +1099,8 @@ LuaParser::storeInputDeck( inbc_deck[j].get< tag::velocity >(), {0.0, 0.0, 0.0}); if (inbc_deck[j].get< tag::velocity >().size() != 3) Throw("Inlet velocity requires 3 components."); - storeIfSpecd< tk::real >(sol_inbc[j+1], "pressure", - inbc_deck[j].get< tag::pressure >(), 0.0); - storeIfSpecd< tk::real >(sol_inbc[j+1], "temperature", - inbc_deck[j].get< tag::temperature >(), 0.0); + storeIfSpecd< std::size_t >(sol_bc[i+1], "materialid", + bc_deck[i].get< tag::materialid >(), 1); } } diff --git a/src/PDE/CompFlow/DGCompFlow.hpp b/src/PDE/CompFlow/DGCompFlow.hpp index 158ee4474f..0c46cfe76d 100644 --- a/src/PDE/CompFlow/DGCompFlow.hpp +++ b/src/PDE/CompFlow/DGCompFlow.hpp @@ -69,8 +69,8 @@ class CompFlow { m_riemann( compflowRiemannSolver( g_inputdeck.get< tag::flux >() ) ) { - // associate boundary condition configurations with state functions, - // manually looping through all BCs and state functions + // associate boundary condition configurations with state functions, the + // order in which the state functions listed matters, see ctr::bc::Keys brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, // BC State functions { dirichlet diff --git a/src/PDE/MultiMat/FVMultiMat.hpp b/src/PDE/MultiMat/FVMultiMat.hpp index 0c7a75d535..072507ba0a 100644 --- a/src/PDE/MultiMat/FVMultiMat.hpp +++ b/src/PDE/MultiMat/FVMultiMat.hpp @@ -70,7 +70,6 @@ class MultiMat { m_riemann( multimatRiemannSolver( g_inputdeck.get< tag::flux >() ) ) { - // associate boundary condition configurations with state functions brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc, // BC State functions From 4dfaa33304c3caf12a5bc30de233b5e88ab74675 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 5 Dec 2024 09:57:35 -0700 Subject: [PATCH 11/17] fixed a couple breaking typos when reading materialid --- src/Control/Inciter/InputDeck/LuaParser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Control/Inciter/InputDeck/LuaParser.cpp b/src/Control/Inciter/InputDeck/LuaParser.cpp index 7db7e3b998..40f6014ecc 100644 --- a/src/Control/Inciter/InputDeck/LuaParser.cpp +++ b/src/Control/Inciter/InputDeck/LuaParser.cpp @@ -1099,8 +1099,8 @@ LuaParser::storeInputDeck( inbc_deck[j].get< tag::velocity >(), {0.0, 0.0, 0.0}); if (inbc_deck[j].get< tag::velocity >().size() != 3) Throw("Inlet velocity requires 3 components."); - storeIfSpecd< std::size_t >(sol_bc[i+1], "materialid", - bc_deck[i].get< tag::materialid >(), 1); + storeIfSpecd< std::size_t >(sol_inbc[j+1], "materialid", + inbc_deck[j].get< tag::materialid >(), 1); } } From 4c786c66ea4dbe6570b8675711f12ede049b308a Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 5 Dec 2024 10:01:39 -0700 Subject: [PATCH 12/17] changed inlet BC so it enforces bulk pressure & density grad = 0 for multi mats --- src/PDE/MultiMat/BCFunctions.hpp | 60 +++++++++++++------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/src/PDE/MultiMat/BCFunctions.hpp b/src/PDE/MultiMat/BCFunctions.hpp index a14a3a4b67..7572ec93c2 100644 --- a/src/PDE/MultiMat/BCFunctions.hpp +++ b/src/PDE/MultiMat/BCFunctions.hpp @@ -13,6 +13,7 @@ #ifndef BCFunctions_h #define BCFunctions_h +#include #include "FunctionPrototypes.hpp" #include "MiscMultiMatFns.hpp" @@ -117,14 +118,13 @@ namespace inciter { } //! \brief Boundary state function providing the left and right state of a - //! face at farfield boundaries + //! face at inlet boundaries //! \param[in] ncomp Number of scalar components in this PDE system //! \param[in] ul Left (domain-internal) state - //! \param[in] fn Unit face normal //! \return Left and right states for all scalar components in this PDE //! system - //! \details The farfield boudary calculation, implemented here, is - //! based on the characteristic theory of hyperbolic systems. + //! \details The inlet boundary condition specifies a velocity at a + //! sideset and assumes a zero bulk pressure and density gradient //! \note The function signature must follow tk::StateFn static tk::StateFn::result_type inlet( ncomp_t ncomp, @@ -135,23 +135,11 @@ namespace inciter { { auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >(); const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >(); - - // Farfield primitive quantities - // how do we make sure we have called the proper sideset for this input? - // This is necessary for multiple independent inputs, but I can't quite - // figure out how to get it to work considering all function signatures - // must follow the same signature, so I can't just put it in as an input. - // For now, leave it so it just takes the first block, but maybe there's a - // way to do this a bit more intelligently. - auto& inbc = g_inputdeck.get< tag::bc >()[0].get< tag::inlet >(); - //! \todo With changes, ft and fp are not used, since interior cell is used - //! instead. Remove, and also add matid tag - auto fp = inbc[0].get< tag::pressure >(); - auto ft = inbc[0].get< tag::temperature >(); - auto fu = inbc[0].get< tag::velocity >(); - auto fmat = - g_inputdeck.get< tag::bc >()[0].get< tag::materialid >() - 1; + + // inlet velocity and material + auto u_in = inbc[0].get< tag::velocity >(); + auto mat_in = inbc[0].get< tag::materialid >() - 1; [[maybe_unused]] auto nsld = numSolids(nmat, solidx); @@ -165,30 +153,32 @@ namespace inciter { auto v2l = ul[ncomp+velocityIdx(nmat, 1)]; auto v3l = ul[ncomp+velocityIdx(nmat, 2)]; - // External cell velocity, such that velocity = fu at face - auto v1r = 2.0*fu[0] - v1l; - auto v2r = 2.0*fu[1] - v2l; - auto v3r = 2.0*fu[2] - v3l; + // External cell velocity, such that velocity = v_in at face + auto v1r = 2.0*u_in[0] - v1l; + auto v2r = 2.0*u_in[1] - v2l; + auto v3r = 2.0*u_in[2] - v3l; - tk::real alphamin = 1e-12; + // Calculate bulk pressure/density to ensure zero gradient + tk::real p(0.0); tk::real rho(0.0); for (std::size_t k=0; k(nmat-1))*alphamin; else ur[volfracIdx(nmat,k)] = alphamin; - auto p = ul[ncomp+pressureIdx(nmat,k)] / ul[volfracIdx(nmat,k)]; - auto rhok = ul[densityIdx(nmat, k)]; - - ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rhok; + // zero bulk pressure and density gradient + ur[ncomp+pressureIdx(nmat, k)] = ur[volfracIdx(nmat, k)] * p; + ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rho; ur[energyIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * - mat_blk[k].compute< EOS::totalenergy >(rhok, v1r, v2r, v3r, p); - // material pressures - ur[ncomp+pressureIdx(nmat, k)] = ul[volfracIdx(nmat, k)] * p; - - rho += ur[densityIdx(nmat,k)]; + mat_blk[k].compute< EOS::totalenergy >(rho, v1r, v2r, v3r, p); } ur[momentumIdx(nmat, 0)] = rho * v1r; From 315eecf6ee1f721ca30d5039802dcbb2f383b09f Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 5 Dec 2024 10:24:11 -0700 Subject: [PATCH 13/17] remove include I was using to debug --- src/PDE/MultiMat/BCFunctions.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PDE/MultiMat/BCFunctions.hpp b/src/PDE/MultiMat/BCFunctions.hpp index 7572ec93c2..077622a1e2 100644 --- a/src/PDE/MultiMat/BCFunctions.hpp +++ b/src/PDE/MultiMat/BCFunctions.hpp @@ -13,7 +13,6 @@ #ifndef BCFunctions_h #define BCFunctions_h -#include #include "FunctionPrototypes.hpp" #include "MiscMultiMatFns.hpp" From 7ad27923b7bc48a250b4bf35e1ec42c5dba3d288 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 9 Jan 2025 14:35:27 -0700 Subject: [PATCH 14/17] Change stylistic requests from review --- src/Control/Inciter/InputDeck/InputDeck.hpp | 14 ++++----- src/Inciter/Transporter.cpp | 5 ++-- src/PDE/DGPDE.cpp | 32 ++++++++++++++++++++- src/PDE/DGPDE.hpp | 6 ++++ src/PDE/MultiMat/DGMultiMat.hpp | 13 +-------- src/PDE/MultiMat/FVMultiMat.hpp | 14 +-------- src/PDE/Transport/DGTransport.hpp | 15 ++-------- 7 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/Control/Inciter/InputDeck/InputDeck.hpp b/src/Control/Inciter/InputDeck/InputDeck.hpp index 48edfe2404..dd595e2f19 100644 --- a/src/Control/Inciter/InputDeck/InputDeck.hpp +++ b/src/Control/Inciter/InputDeck/InputDeck.hpp @@ -130,13 +130,6 @@ using bcList = tk::TaggedTuple< brigand::list< tag::mesh, std::vector< std::size_t >, tag::dirichlet, std::vector< std::size_t >, tag::symmetry, std::vector< std::size_t >, - tag::inlet, std::vector< - tk::TaggedTuple< brigand::list< - tag::sideset, std::vector< uint64_t >, - tag::velocity, std::vector< tk::real >, - tag::materialid, std::size_t - > > - >, tag::outlet, std::vector< std::size_t >, tag::farfield, std::vector< std::size_t >, tag::extrapolate, std::vector< std::size_t >, @@ -149,6 +142,13 @@ using bcList = tk::TaggedTuple< brigand::list< tag::temperature, tk::real, tag::mass_fractions, std::vector< tk::real >, tag::materialid, std::size_t, + tag::inlet, std::vector< + tk::TaggedTuple< brigand::list< + tag::sideset, std::vector< uint64_t >, + tag::velocity, std::vector< tk::real >, + tag::materialid, std::size_t + > > + >, tag::timedep, std::vector< tk::TaggedTuple< brigand::list< tag::sideset, std::vector< uint64_t >, diff --git a/src/Inciter/Transporter.cpp b/src/Inciter/Transporter.cpp index 87d9485d3c..70c40078e7 100644 --- a/src/Inciter/Transporter.cpp +++ b/src/Inciter/Transporter.cpp @@ -477,11 +477,12 @@ Transporter::matchBCs( std::map< int, std::vector< std::size_t > >& bnd ) // Query side set ids at which BCs assigned for all BC types for all PDEs std::unordered_set< int > usedsets; - // Query side sets of time dependent and inlet BCs (since these are not a part - // of tag::bc) using bclist = ctr::bclist::Keys; const auto& bcs = g_inputdeck.get< tag::bc >(); brigand::for_each< bclist >( UserBC( g_inputdeck, usedsets ) ); + + // Query side sets of time dependent and inlet BCs (since these are not a part + // of tag::bc) for (const auto& bci : bcs) { for (const auto& b : bci.get< tag::inlet >()) { for (auto i : b.get< tag::sideset >()) diff --git a/src/PDE/DGPDE.cpp b/src/PDE/DGPDE.cpp index 6f3ec5ceee..f71e499675 100644 --- a/src/PDE/DGPDE.cpp +++ b/src/PDE/DGPDE.cpp @@ -11,9 +11,37 @@ // ***************************************************************************** #include "DGPDE.hpp" +namespace inciter { + +void ConfigInletBC( BCStateFn& s, + const tk::StateFn& f, + const tk::StateFn& gf ) +// ***************************************************************************** +// Extract information from input deck on inlet boundary conditions, and append +// to BC configuration vector +//! \param[inout] s BC configuration vector +//! \param[in] f Function to evaluate the left and right solution state at +//! boundaries +//! \param[in] gf Function to evaluate the left and right solution gradients +//! at boundaries +// ***************************************************************************** +{ + const auto& bc = g_inputdeck.get< tag::bc >(); + std::vector< std::size_t > v; + for (const auto& ib : bc) { + const auto& in = ib.get< tag::inlet >(); + if (!in.empty()) { + for (const auto& bndry : in) { + const auto& sideset = bndry.get< tag::sideset >(); + v.insert(v.end(), sideset.begin(), sideset.end()); + s.push_back( { v, f, gf } ); + } + } + } +} [[noreturn]] tk::StateFn::result_type -inciter::invalidBC( ncomp_t, const std::vector< EOS >&, +invalidBC( ncomp_t, const std::vector< EOS >&, const std::vector< tk::real >&, tk::real, tk::real, tk::real, tk::real, const std::array< tk::real, 3>& ) // ***************************************************************************** @@ -24,3 +52,5 @@ inciter::invalidBC( ncomp_t, const std::vector< EOS >&, Throw( "Invalid boundary condition set up in input file or the PDE does not " "support this BC type" ); } + +} // inciter:: \ No newline at end of file diff --git a/src/PDE/DGPDE.hpp b/src/PDE/DGPDE.hpp index 5d523b3fb1..25b3343907 100644 --- a/src/PDE/DGPDE.hpp +++ b/src/PDE/DGPDE.hpp @@ -71,6 +71,12 @@ struct ConfigBC { } }; +//! \brief Extract information on inlet BCs, which have a different structure +//! than other BCs +void ConfigInletBC( BCStateFn& , + const tk::StateFn& , + const tk::StateFn& ); + //! State function for invalid/un-configured boundary conditions [[noreturn]] tk::StateFn::result_type invalidBC( ncomp_t, const std::vector< EOS >&, diff --git a/src/PDE/MultiMat/DGMultiMat.hpp b/src/PDE/MultiMat/DGMultiMat.hpp index 4e952f02b6..be45082aad 100644 --- a/src/PDE/MultiMat/DGMultiMat.hpp +++ b/src/PDE/MultiMat/DGMultiMat.hpp @@ -94,18 +94,7 @@ class MultiMat { // Inlet BC has a different structure than above BCs, so it must be // handled differently than with ConfigBC - const auto& bc = g_inputdeck.get< tag::bc >(); - std::vector< std::size_t > v; - for (const auto& ib : bc) { - const auto& in = ib.get< tag::inlet >(); - if (!in.empty()) { - for (const auto& bndry : in) { - const auto& sideset = bndry.get< tag::sideset >(); - v.insert(v.end(), sideset.begin(), sideset.end()); - m_bc.push_back( { v, inlet, noOpGrad } ); - } - } - } + ConfigInletBC(m_bc, inlet, noOpGrad); // EoS initialization initializeMaterialEoS( m_mat_blk ); diff --git a/src/PDE/MultiMat/FVMultiMat.hpp b/src/PDE/MultiMat/FVMultiMat.hpp index a2d5d75697..5aa7c7adb5 100644 --- a/src/PDE/MultiMat/FVMultiMat.hpp +++ b/src/PDE/MultiMat/FVMultiMat.hpp @@ -90,19 +90,7 @@ class MultiMat { // Inlet BC has a different structure than above BCs, so it must be // handled differently than with ConfigBC - const auto& bc = g_inputdeck.get< tag::bc >(); - std::vector< std::size_t > v; - for (const auto& ib : bc) { - const auto& in = ib.get< tag::inlet >(); - if (!in.empty()) { - for (const auto& bndry : in) { - const auto& sideset = bndry.get< tag::sideset >(); - v.clear(); - v.insert(v.end(), sideset.begin(), sideset.end()); - m_bc.push_back( { v, inlet, noOpGrad } ); - } - } - } + ConfigInletBC(m_bc, inlet, noOpGrad); // EoS initialization initializeMaterialEoS( m_mat_blk ); diff --git a/src/PDE/Transport/DGTransport.hpp b/src/PDE/Transport/DGTransport.hpp index e5e0c3eef2..4b4e0f0dfa 100644 --- a/src/PDE/Transport/DGTransport.hpp +++ b/src/PDE/Transport/DGTransport.hpp @@ -86,19 +86,8 @@ class Transport { // Inlet BC has a different structure than above BCs, so it must be // handled differently than with ConfigBC - const auto& bc = g_inputdeck.get< tag::bc >(); - std::vector< std::size_t > v; - for (const auto& ib : bc) { - const auto& in = ib.get< tag::inlet >(); - if (!in.empty()) { - for (const auto& bndry : in) { - const auto& sideset = bndry.get< tag::sideset >(); - v.clear(); - v.insert(v.end(), sideset.begin(), sideset.end()); - m_bc.push_back( { v, inlet, noOpGrad } ); - } - } - } + ConfigInletBC(m_bc, inlet, noOpGrad); + m_problem.errchk( m_ncomp ); } From 900ef7d6210d71d4070a12d7ed47610c3755a790 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 9 Jan 2025 15:04:25 -0700 Subject: [PATCH 15/17] funcitonality to read inlet pressure (+ formatting fix from prev commit) --- src/Control/Inciter/InputDeck/InputDeck.hpp | 1 + src/Control/Inciter/InputDeck/LuaParser.cpp | 2 ++ src/PDE/DGPDE.hpp | 6 +++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Control/Inciter/InputDeck/InputDeck.hpp b/src/Control/Inciter/InputDeck/InputDeck.hpp index dd595e2f19..971afbff47 100644 --- a/src/Control/Inciter/InputDeck/InputDeck.hpp +++ b/src/Control/Inciter/InputDeck/InputDeck.hpp @@ -146,6 +146,7 @@ using bcList = tk::TaggedTuple< brigand::list< tk::TaggedTuple< brigand::list< tag::sideset, std::vector< uint64_t >, tag::velocity, std::vector< tk::real >, + tag::pressure, tk::real, tag::materialid, std::size_t > > >, diff --git a/src/Control/Inciter/InputDeck/LuaParser.cpp b/src/Control/Inciter/InputDeck/LuaParser.cpp index 40f6014ecc..f1e31aabba 100644 --- a/src/Control/Inciter/InputDeck/LuaParser.cpp +++ b/src/Control/Inciter/InputDeck/LuaParser.cpp @@ -1099,6 +1099,8 @@ LuaParser::storeInputDeck( inbc_deck[j].get< tag::velocity >(), {0.0, 0.0, 0.0}); if (inbc_deck[j].get< tag::velocity >().size() != 3) Throw("Inlet velocity requires 3 components."); + storeIfSpecd< tk::real >(sol_inbc[j+1], "pressure", + inbc_deck[j].get< tag::pressure >(), 0.0); storeIfSpecd< std::size_t >(sol_inbc[j+1], "materialid", inbc_deck[j].get< tag::materialid >(), 1); } diff --git a/src/PDE/DGPDE.hpp b/src/PDE/DGPDE.hpp index 25b3343907..61b824d489 100644 --- a/src/PDE/DGPDE.hpp +++ b/src/PDE/DGPDE.hpp @@ -73,9 +73,9 @@ struct ConfigBC { //! \brief Extract information on inlet BCs, which have a different structure //! than other BCs -void ConfigInletBC( BCStateFn& , - const tk::StateFn& , - const tk::StateFn& ); +void ConfigInletBC( BCStateFn&, + const tk::StateFn&, + const tk::StateFn& ); //! State function for invalid/un-configured boundary conditions [[noreturn]] tk::StateFn::result_type From 4b03a00b274323a2c843f8abb9e891b5688b48b4 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 9 Jan 2025 15:50:18 -0700 Subject: [PATCH 16/17] Functionality to read an inlet temperature --- src/Control/Inciter/InputDeck/InputDeck.hpp | 1 + src/Control/Inciter/InputDeck/LuaParser.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Control/Inciter/InputDeck/InputDeck.hpp b/src/Control/Inciter/InputDeck/InputDeck.hpp index 971afbff47..24a86d79a0 100644 --- a/src/Control/Inciter/InputDeck/InputDeck.hpp +++ b/src/Control/Inciter/InputDeck/InputDeck.hpp @@ -147,6 +147,7 @@ using bcList = tk::TaggedTuple< brigand::list< tag::sideset, std::vector< uint64_t >, tag::velocity, std::vector< tk::real >, tag::pressure, tk::real, + tag::temperature, tk::real, tag::materialid, std::size_t > > >, diff --git a/src/Control/Inciter/InputDeck/LuaParser.cpp b/src/Control/Inciter/InputDeck/LuaParser.cpp index f1e31aabba..e6e0dc20ba 100644 --- a/src/Control/Inciter/InputDeck/LuaParser.cpp +++ b/src/Control/Inciter/InputDeck/LuaParser.cpp @@ -1101,6 +1101,8 @@ LuaParser::storeInputDeck( Throw("Inlet velocity requires 3 components."); storeIfSpecd< tk::real >(sol_inbc[j+1], "pressure", inbc_deck[j].get< tag::pressure >(), 0.0); + storeIfSpecd< tk::real >(sol_inbc[j+1], "temperature", + inbc_deck[j].get< tag::temperature >(), 0.0); storeIfSpecd< std::size_t >(sol_inbc[j+1], "materialid", inbc_deck[j].get< tag::materialid >(), 1); } From 7dd7fe078f553889ae2aa7afd613d5a998822b67 Mon Sep 17 00:00:00 2001 From: g-rydquist Date: Thu, 9 Jan 2025 16:03:44 -0700 Subject: [PATCH 17/17] Adjustments to bulk vs material properties per review (+ formatting) --- src/Control/Inciter/InputDeck/LuaParser.cpp | 4 ++ src/PDE/MultiMat/BCFunctions.hpp | 45 +++++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/Control/Inciter/InputDeck/LuaParser.cpp b/src/Control/Inciter/InputDeck/LuaParser.cpp index e6e0dc20ba..35af9dddc6 100644 --- a/src/Control/Inciter/InputDeck/LuaParser.cpp +++ b/src/Control/Inciter/InputDeck/LuaParser.cpp @@ -1095,14 +1095,18 @@ LuaParser::storeInputDeck( for (std::size_t j=0; j(sol_inbc[j+1], "sideset", inbc_deck[j].get< tag::sideset >(), {}); + storeVecIfSpecd< tk::real >(sol_inbc[j+1], "velocity", inbc_deck[j].get< tag::velocity >(), {0.0, 0.0, 0.0}); if (inbc_deck[j].get< tag::velocity >().size() != 3) Throw("Inlet velocity requires 3 components."); + storeIfSpecd< tk::real >(sol_inbc[j+1], "pressure", inbc_deck[j].get< tag::pressure >(), 0.0); + storeIfSpecd< tk::real >(sol_inbc[j+1], "temperature", inbc_deck[j].get< tag::temperature >(), 0.0); + storeIfSpecd< std::size_t >(sol_inbc[j+1], "materialid", inbc_deck[j].get< tag::materialid >(), 1); } diff --git a/src/PDE/MultiMat/BCFunctions.hpp b/src/PDE/MultiMat/BCFunctions.hpp index 077622a1e2..0b67033da0 100644 --- a/src/PDE/MultiMat/BCFunctions.hpp +++ b/src/PDE/MultiMat/BCFunctions.hpp @@ -120,6 +120,7 @@ namespace inciter { //! face at inlet boundaries //! \param[in] ncomp Number of scalar components in this PDE system //! \param[in] ul Left (domain-internal) state + //! \param[in] fn Unit face normal //! \return Left and right states for all scalar components in this PDE //! system //! \details The inlet boundary condition specifies a velocity at a @@ -130,7 +131,7 @@ namespace inciter { const std::vector< EOS >& mat_blk, const std::vector< tk::real >& ul, tk::real, tk::real, tk::real, tk::real, - const std::array< tk::real, 3 >& ) + const std::array< tk::real, 3 >& fn ) { auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >(); const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >(); @@ -139,6 +140,8 @@ namespace inciter { // inlet velocity and material auto u_in = inbc[0].get< tag::velocity >(); auto mat_in = inbc[0].get< tag::materialid >() - 1; + auto p_in = inbc[0].get< tag::pressure >(); + auto t_in = inbc[0].get< tag::temperature >(); [[maybe_unused]] auto nsld = numSolids(nmat, solidx); @@ -157,15 +160,23 @@ namespace inciter { auto v2r = 2.0*u_in[1] - v2l; auto v3r = 2.0*u_in[2] - v3l; - // Calculate bulk pressure/density to ensure zero gradient - tk::real p(0.0); - tk::real rho(0.0); - for (std::size_t k=0; k 1.0e-04) + a = std::max( a, mat_blk[k].compute< EOS::soundspeed >( + ul[densityIdx(nmat, k)], ul[ncomp+pressureIdx(nmat, k)], + ul[volfracIdx(nmat, k)], k ) ); + + // Mach number + auto Ma = vn / a; tk::real alphamin = 1e-12; + tk::real pk(0.0); + tk::real rho(0.0); for (std::size_t k=0; k(pk, t_in); + + ur[ncomp+pressureIdx(nmat, k)] = ur[volfracIdx(nmat,k)] * pk; + ur[densityIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * rhok; ur[energyIdx(nmat,k)] = ur[volfracIdx(nmat,k)] * - mat_blk[k].compute< EOS::totalenergy >(rho, v1r, v2r, v3r, p); + mat_blk[k].compute< EOS::totalenergy >(rhok, v1r, v2r, v3r, pk); + + // bulk density + rho += ur[densityIdx(nmat,k)]; } ur[momentumIdx(nmat, 0)] = rho * v1r;