Quinoa all test code coverage report
Current view: top level - PDE/MultiMat/Problem - InterfaceAdvection.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 30 32 93.8 %
Date: 2024-04-22 13:03:21 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 34 55.9 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/MultiMat/Problem/InterfaceAdvection.cpp
       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     Problem configuration for the compressible flow equations
       9                 :            :   \details   This file defines a Problem policy class for the compressible flow
      10                 :            :     equations, defined in PDE/MultiMat/MultiMat.h. See PDE/MultiMat/Problem.h
      11                 :            :     for general requirements on Problem policy classes for MultiMat.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : 
      15                 :            : #include "InterfaceAdvection.hpp"
      16                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      17                 :            : #include "MultiMat/MultiMatIndexing.hpp"
      18                 :            : 
      19                 :            : namespace inciter {
      20                 :            : 
      21                 :            : extern ctr::InputDeck g_inputdeck;
      22                 :            : 
      23                 :            : } // ::inciter
      24                 :            : 
      25                 :            : using inciter::MultiMatProblemInterfaceAdvection;
      26                 :            : 
      27                 :            : tk::InitializeFn::result_type
      28                 :     459006 : MultiMatProblemInterfaceAdvection::initialize(
      29                 :            :   ncomp_t ncomp,
      30                 :            :   const std::vector< EOS >& mat_blk,
      31                 :            :   tk::real x,
      32                 :            :   tk::real y,
      33                 :            :   tk::real /*z*/,
      34                 :            :   tk::real t )
      35                 :            : // *****************************************************************************
      36                 :            : //! Evaluate analytical solution at (x,y,z,t) for all components
      37                 :            : //! \param[in] ncomp Number of scalar components in this PDE system
      38                 :            : //! \param[in] x X coordinate where to evaluate the solution
      39                 :            : //! \param[in] y Y coordinate where to evaluate the solution
      40                 :            : //! \param[in] t Time where to evaluate the solution
      41                 :            : //! \return Values of all components evaluated at (x)
      42                 :            : //! \note The function signature must follow tk::InitializeFn
      43                 :            : // *****************************************************************************
      44                 :            : {
      45                 :            :   auto nmat =
      46                 :     459006 :     g_inputdeck.get< eq, tag::nmat >();
      47                 :            : 
      48                 :            :   // see also Control/Inciter/InputDeck/Grammar.hpp
      49                 :            :   Assert( ncomp == 3*nmat+3, "Incorrect number of components in multi-material "
      50                 :            :           "system" );
      51                 :            : 
      52                 :     459006 :   std::vector< tk::real > s( ncomp, 0.0 );
      53                 :     459006 :   auto u = std::sqrt(50.0);
      54                 :     459006 :   auto v = std::sqrt(50.0);
      55                 :     459006 :   auto w = 0.0;
      56                 :            :   auto alphamin = 1.0e-12;
      57                 :            : 
      58                 :            :   // center of the cylinder
      59                 :     459006 :   auto x0 = 0.45 + u*t;
      60                 :            :   auto y0 = 0.45 + v*t;
      61                 :            : 
      62                 :            :   // radii of the material-rings
      63 [ +  - ][ -  - ]:     459006 :   std::vector< tk::real > r0(nmat, 0.0);
      64                 :     459006 :   r0[nmat-1] = 0.0;
      65                 :     459006 :   r0[nmat-2] = 0.1;
      66                 :     459006 :   r0[0] = 0.35;
      67         [ +  - ]:     459006 :   for (std::size_t k=1; k<nmat-2; ++k)
      68         [ -  - ]:          0 :     r0[k] = r0[k-1] - (r0[0]-r0[nmat-2])
      69         [ -  - ]:          0 :                       /(std::max( 1.0, static_cast<tk::real>(nmat-2)) );
      70                 :            : 
      71         [ +  + ]:    1836024 :   for (std::size_t k=0; k<nmat; ++k)
      72                 :    1377018 :     s[volfracIdx(nmat, k)] = alphamin;
      73                 :            : 
      74                 :            :   // interface location
      75                 :     459006 :   auto r = std::sqrt( (x-x0)*(x-x0) + (y-y0)*(y-y0) );
      76                 :            :   bool is_mat(false);
      77         [ +  + ]:    1377018 :   for (std::size_t k=0; k<nmat-1; ++k)
      78                 :            :   {
      79 [ +  + ][ +  + ]:     918012 :     if (r<r0[k] && r>=r0[k+1])
      80                 :            :     {
      81                 :     138750 :       s[volfracIdx(nmat, k)] = 1.0 - static_cast<tk::real>(nmat-1)*alphamin;
      82                 :            :       is_mat = true;
      83                 :            :     }
      84                 :            :   }
      85         [ +  + ]:     459006 :   if (!is_mat)
      86                 :            :   {
      87                 :     320256 :     s[volfracIdx(nmat, nmat-1)] = 1.0 - static_cast<tk::real>(nmat-1)*alphamin;
      88                 :            :   }
      89                 :            : 
      90                 :            :   auto rhob = 0.0;
      91         [ +  + ]:    1836024 :   for (std::size_t k=0; k<nmat; ++k)
      92                 :            :   {
      93         [ +  - ]:    1377018 :     auto rhok = mat_blk[k].compute< EOS::density >( 1.0e5, 300.0 );
      94         [ +  - ]:    1377018 :     s[densityIdx(nmat, k)] = s[volfracIdx(nmat, k)] * rhok;
      95                 :    1377018 :     s[energyIdx(nmat, k)] = s[volfracIdx(nmat, k)]
      96 [ +  - ][ -  - ]:    2754036 :       * mat_blk[k].compute< EOS::totalenergy >( rhok, u, v, w, 1.0e5 );
      97                 :    1377018 :     rhob += s[densityIdx(nmat, k)];
      98                 :            :   }
      99         [ +  - ]:     459006 :   s[momentumIdx(nmat, 0)] = rhob * u;
     100                 :     459006 :   s[momentumIdx(nmat, 1)] = rhob * v;
     101         [ +  - ]:     459006 :   s[momentumIdx(nmat, 2)] = rhob * w;
     102                 :            : 
     103                 :     459006 :   return s;
     104                 :            : }

Generated by: LCOV version 1.14