Quinoa all test code coverage report
Current view: top level - PDE/Riemann - HLLC.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 62 62 100.0 %
Date: 2024-05-15 17:17:09 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 22 63.6 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/Riemann/HLLC.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Harten-Lax-van Leer-Contact (HLLC) Riemann flux function
       9                 :            :   \details   This file implements the Harten-Lax-van Leer-Contact (HLLC) Riemann
      10                 :            :              solver.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #ifndef HLLC_h
      14                 :            : #define HLLC_h
      15                 :            : 
      16                 :            : #include <vector>
      17                 :            : 
      18                 :            : #include "Fields.hpp"
      19                 :            : #include "FunctionPrototypes.hpp"
      20                 :            : #include "Inciter/Options/Flux.hpp"
      21                 :            : 
      22                 :            : namespace inciter {
      23                 :            : 
      24                 :            : //! HLLC approximate Riemann solver
      25                 :            : struct HLLC {
      26                 :            : 
      27                 :            :   //! HLLC approximate Riemann solver flux function
      28                 :            :   //! \param[in] fn Face/Surface normal
      29                 :            :   //! \param[in] u Left and right unknown/state vector
      30                 :            :   //! \return Riemann solution according to Harten-Lax-van Leer-Contact
      31                 :            :   //! \note The function signature must follow tk::RiemannFluxFn
      32                 :            :   static tk::RiemannFluxFn::result_type
      33                 :   25431867 :   flux( const std::vector< EOS >& mat_blk,
      34                 :            :         const std::array< tk::real, 3 >& fn,
      35                 :            :         const std::array< std::vector< tk::real >, 2 >& u,
      36                 :            :         const std::vector< std::array< tk::real, 3 > >& = {} )
      37                 :            :   {
      38         [ +  - ]:   25431867 :     std::vector< tk::real > flx( u[0].size(), 0 );
      39                 :            : 
      40                 :            :     // Primitive variables
      41                 :   25431867 :     auto rhol = u[0][0];
      42                 :   25431867 :     auto rhor = u[1][0];
      43                 :            : 
      44                 :   25431867 :     auto ul = u[0][1]/rhol;
      45                 :   25431867 :     auto vl = u[0][2]/rhol;
      46                 :   25431867 :     auto wl = u[0][3]/rhol;
      47                 :            : 
      48                 :   25431867 :     auto ur = u[1][1]/rhor;
      49                 :   25431867 :     auto vr = u[1][2]/rhor;
      50                 :   25431867 :     auto wr = u[1][3]/rhor;
      51                 :            : 
      52         [ +  - ]:   50863734 :     auto pl = mat_blk[0].compute< EOS::pressure >( rhol, ul, vl, wl,
      53                 :   25431867 :       u[0][4] );
      54         [ +  - ]:   50863734 :     auto pr = mat_blk[0].compute< EOS::pressure >( rhor, ur, vr, wr,
      55                 :   25431867 :       u[1][4] );
      56                 :            : 
      57         [ +  - ]:   25431867 :     auto al = mat_blk[0].compute< EOS::soundspeed >( rhol, pl );
      58         [ +  - ]:   25431867 :     auto ar = mat_blk[0].compute< EOS::soundspeed >( rhor, pr );
      59                 :            : 
      60                 :            :     // Face-normal velocities
      61                 :   25431867 :     tk::real vnl = ul*fn[0] + vl*fn[1] + wl*fn[2];
      62                 :   25431867 :     tk::real vnr = ur*fn[0] + vr*fn[1] + wr*fn[2];
      63                 :            : 
      64                 :            :     // Roe-averaged variables
      65                 :   25431867 :     auto rlr = sqrt(rhor/rhol);
      66                 :   25431867 :     auto rlr1 = 1.0 + rlr;
      67                 :            : 
      68                 :   25431867 :     auto vnroe = (vnr*rlr + vnl)/rlr1 ;
      69                 :   25431867 :     auto aroe = (ar*rlr + al)/rlr1 ;
      70                 :            : 
      71                 :            :     // Signal velocities
      72                 :   25431867 :     auto Sl = fmin(vnl-al, vnroe-aroe);
      73                 :   25431867 :     auto Sr = fmax(vnr+ar, vnroe+aroe);
      74                 :   25431867 :     auto Sm = ( rhor*vnr*(Sr-vnr) - rhol*vnl*(Sl-vnl) + pl-pr )
      75                 :   25431867 :              /( rhor*(Sr-vnr) - rhol*(Sl-vnl) );
      76                 :            : 
      77                 :            :     // Middle-zone (star) variables
      78                 :   25431867 :     auto pStar = rhol*(vnl-Sl)*(vnl-Sm) + pl;
      79         [ +  - ]:   50863734 :     auto uStar = u;
      80                 :            : 
      81                 :   25431867 :     uStar[0][0] = (Sl-vnl) * rhol/ (Sl-Sm);
      82                 :   25431867 :     uStar[0][1] = ((Sl-vnl) * u[0][1] + (pStar-pl)*fn[0]) / (Sl-Sm);
      83                 :   25431867 :     uStar[0][2] = ((Sl-vnl) * u[0][2] + (pStar-pl)*fn[1]) / (Sl-Sm);
      84                 :   25431867 :     uStar[0][3] = ((Sl-vnl) * u[0][3] + (pStar-pl)*fn[2]) / (Sl-Sm);
      85                 :   25431867 :     uStar[0][4] = ((Sl-vnl) * u[0][4] - pl*vnl + pStar*Sm) / (Sl-Sm);
      86                 :            : 
      87                 :   25431867 :     uStar[1][0] = (Sr-vnr) * rhor/ (Sr-Sm);
      88                 :   25431867 :     uStar[1][1] = ((Sr-vnr) * u[1][1] + (pStar-pr)*fn[0]) / (Sr-Sm);
      89                 :   25431867 :     uStar[1][2] = ((Sr-vnr) * u[1][2] + (pStar-pr)*fn[1]) / (Sr-Sm);
      90                 :   25431867 :     uStar[1][3] = ((Sr-vnr) * u[1][3] + (pStar-pr)*fn[2]) / (Sr-Sm);
      91                 :   25431867 :     uStar[1][4] = ((Sr-vnr) * u[1][4] - pr*vnr + pStar*Sm) / (Sr-Sm);
      92                 :            : 
      93                 :            :     // Numerical fluxes
      94         [ +  + ]:   25431867 :     if (Sl > 0.0) {
      95                 :     229172 :       flx[0] = u[0][0] * vnl;
      96                 :     229172 :       flx[1] = u[0][1] * vnl + pl*fn[0];
      97                 :     229172 :       flx[2] = u[0][2] * vnl + pl*fn[1];
      98                 :     229172 :       flx[3] = u[0][3] * vnl + pl*fn[2];
      99                 :     229172 :       flx[4] = ( u[0][4] + pl ) * vnl;
     100                 :            :     }
     101 [ +  - ][ +  + ]:   25202695 :     else if (Sl <= 0.0 && Sm > 0.0) {
     102                 :    9819813 :       flx[0] = uStar[0][0] * Sm;
     103                 :    9819813 :       flx[1] = uStar[0][1] * Sm + pStar*fn[0];
     104                 :    9819813 :       flx[2] = uStar[0][2] * Sm + pStar*fn[1];
     105                 :    9819813 :       flx[3] = uStar[0][3] * Sm + pStar*fn[2];
     106                 :    9819813 :       flx[4] = ( uStar[0][4] + pStar ) * Sm;
     107                 :            :     }
     108 [ +  - ][ +  + ]:   15382882 :     else if (Sm <= 0.0 && Sr >= 0.0) {
     109                 :   15131818 :       flx[0] = uStar[1][0] * Sm;
     110                 :   15131818 :       flx[1] = uStar[1][1] * Sm + pStar*fn[0];
     111                 :   15131818 :       flx[2] = uStar[1][2] * Sm + pStar*fn[1];
     112                 :   15131818 :       flx[3] = uStar[1][3] * Sm + pStar*fn[2];
     113                 :   15131818 :       flx[4] = ( uStar[1][4] + pStar ) * Sm;
     114                 :            :     }
     115                 :            :     else {
     116                 :     251064 :       flx[0] = u[1][0] * vnr;
     117                 :     251064 :       flx[1] = u[1][1] * vnr + pr*fn[0];
     118                 :     251064 :       flx[2] = u[1][2] * vnr + pr*fn[1];
     119                 :     251064 :       flx[3] = u[1][3] * vnr + pr*fn[2];
     120                 :     251064 :       flx[4] = ( u[1][4] + pr ) * vnr;
     121                 :            :     }
     122                 :            : 
     123                 :   50863734 :     return flx;
     124                 :            :   }
     125                 :            : 
     126                 :            :   //! Flux type accessor
     127                 :            :   //! \return Flux type
     128                 :            :   static ctr::FluxType type() noexcept { return ctr::FluxType::HLLC; }
     129                 :            : };
     130                 :            : 
     131                 :            : } // inciter::
     132                 :            : 
     133                 :            : #endif // HLLC_h

Generated by: LCOV version 1.14