Quinoa all test code coverage report
Current view: top level - PDE/Riemann - LaxFriedrichs.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 34 34 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: 9 16 56.2 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/Riemann/LaxFriedrichs.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     Lax-Friedrichs Riemann flux function
       9                 :            :   \details   This file implements the Lax-Friedrichs Riemann solver.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef LaxFriedrichs_h
      13                 :            : #define LaxFriedrichs_h
      14                 :            : 
      15                 :            : #include <vector>
      16                 :            : 
      17                 :            : #include "Fields.hpp"
      18                 :            : #include "FunctionPrototypes.hpp"
      19                 :            : #include "Inciter/Options/Flux.hpp"
      20                 :            : #include "EoS/EOS.hpp"
      21                 :            : 
      22                 :            : namespace inciter {
      23                 :            : 
      24                 :            : //! Lax-Friedrichs approximate Riemann solver
      25                 :            : struct LaxFriedrichs {
      26                 :            : 
      27                 :            :   //! Lax-Friedrichs 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 Lax and Friedrichs
      31                 :            :   //! \note The function signature must follow tk::RiemannFluxFn
      32                 :            :   static tk::RiemannFluxFn::result_type
      33                 :    1248000 :   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         [ +  - ]:    1248000 :     std::vector< tk::real >  flx( u[0].size(), 0.0 ),
      39         [ +  - ]:    2496000 :                             fluxl( u[0].size(), 0.0 ),
      40         [ +  - ]:    2496000 :                             fluxr( u[0].size(), 0.0 );
      41                 :            : 
      42                 :            :     // Primitive variables
      43                 :    1248000 :     auto rhol = u[0][0];
      44                 :    1248000 :     auto rhor = u[1][0];
      45                 :            : 
      46                 :    1248000 :     auto ul = u[0][1]/rhol;
      47                 :    1248000 :     auto vl = u[0][2]/rhol;
      48                 :    1248000 :     auto wl = u[0][3]/rhol;
      49                 :            : 
      50                 :    1248000 :     auto ur = u[1][1]/rhor;
      51                 :    1248000 :     auto vr = u[1][2]/rhor;
      52                 :    1248000 :     auto wr = u[1][3]/rhor;
      53                 :            : 
      54         [ +  - ]:    2496000 :     auto pl = mat_blk[0].compute< EOS::pressure >( rhol, ul, vl, wl,
      55                 :    1248000 :       u[0][4] );
      56         [ +  - ]:    2496000 :     auto pr = mat_blk[0].compute< EOS::pressure >( rhor, ur, vr, wr,
      57                 :    1248000 :       u[1][4] );
      58                 :            : 
      59         [ +  - ]:    1248000 :     auto al = mat_blk[0].compute< EOS::soundspeed >( rhol, pl );
      60         [ +  - ]:    1248000 :     auto ar = mat_blk[0].compute< EOS::soundspeed >( rhor, pr );
      61                 :            : 
      62                 :            :     // Face-normal velocities
      63                 :    1248000 :     auto vnl = ul*fn[0] + vl*fn[1] + wl*fn[2];
      64                 :    1248000 :     auto vnr = ur*fn[0] + vr*fn[1] + wr*fn[2];
      65                 :            : 
      66                 :            :     // Flux functions
      67                 :    1248000 :     fluxl[0] = u[0][0] * vnl;
      68                 :    1248000 :     fluxl[1] = u[0][1] * vnl + pl*fn[0];
      69                 :    1248000 :     fluxl[2] = u[0][2] * vnl + pl*fn[1];
      70                 :    1248000 :     fluxl[3] = u[0][3] * vnl + pl*fn[2];
      71                 :    1248000 :     fluxl[4] = ( u[0][4] + pl ) * vnl;
      72                 :            : 
      73                 :    1248000 :     fluxr[0] = u[1][0] * vnr;
      74                 :    1248000 :     fluxr[1] = u[1][1] * vnr + pr*fn[0];
      75                 :    1248000 :     fluxr[2] = u[1][2] * vnr + pr*fn[1];
      76                 :    1248000 :     fluxr[3] = u[1][3] * vnr + pr*fn[2];
      77                 :    1248000 :     fluxr[4] = ( u[1][4] + pr ) * vnr;
      78                 :            : 
      79                 :    1248000 :     auto lambda = std::max(al,ar) + std::max( std::abs(vnl), std::abs(vnr) );
      80                 :            : 
      81                 :            :     // Numerical flux function
      82         [ +  + ]:    7488000 :     for(std::size_t c=0; c<5; ++c)
      83                 :    6240000 :       flx[c] = 0.5 * (fluxl[c] + fluxr[c] - lambda*(u[1][c] - u[0][c]));
      84                 :            : 
      85                 :    2496000 :     return flx;
      86                 :            :   }
      87                 :            : 
      88                 :            :   //! Flux type accessor
      89                 :            :   //! \return Flux type
      90                 :            :   static ctr::FluxType type() noexcept { return ctr::FluxType::LaxFriedrichs; }
      91                 :            : };
      92                 :            : 
      93                 :            : } // inciter::
      94                 :            : 
      95                 :            : #endif // LaxFriedrichs_h

Generated by: LCOV version 1.14