Quinoa all test code coverage report
Current view: top level - PDE/MultiSpecies/Problem - UserDefined.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 24 25 96.0 %
Date: 2025-05-30 09:37:40 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 17 62 27.4 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/MultiSpecies/Problem/UserDefined.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/MultiSpecies/MultiSpecies.h. See PDE/MultiSpecies/Problem.h
      11                 :            :     for general requirements on Problem policy classes for MultiSpecies.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : 
      15                 :            : #include <limits>
      16                 :            : 
      17                 :            : #include "UserDefined.hpp"
      18                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      19                 :            : #include "FieldOutput.hpp"
      20                 :            : #include "MultiSpecies/MultiSpeciesIndexing.hpp"
      21                 :            : #include "MultiSpecies/Mixture/Mixture.hpp"
      22                 :            : 
      23                 :            : namespace inciter {
      24                 :            : 
      25                 :            : extern ctr::InputDeck g_inputdeck;
      26                 :            : 
      27                 :            : } // ::inciter
      28                 :            : 
      29                 :            : using inciter::MultiSpeciesProblemUserDefined;
      30                 :            : 
      31                 :            : tk::InitializeFn::result_type
      32                 :     238746 : MultiSpeciesProblemUserDefined::initialize( ncomp_t ncomp,
      33                 :            :                                         const std::vector< EOS >& mat_blk,
      34                 :            :                                         tk::real,
      35                 :            :                                         tk::real,
      36                 :            :                                         tk::real,
      37                 :            :                                         tk::real )
      38                 :            : // *****************************************************************************
      39                 :            : //! Set initial conditions
      40                 :            : //! \param[in] ncomp Number of scalar components in this PDE system
      41                 :            : //! \return Values of all components
      42                 :            : //! \note The function signature must follow tk::InitializeFn
      43                 :            : // *****************************************************************************
      44                 :            : {
      45                 :     238746 :   tk::InitializeFn::result_type s( ncomp, 0.0 );
      46                 :            : 
      47                 :     238746 :   auto nspec = g_inputdeck.get< eq, tag::nspec >();
      48                 :            : 
      49                 :            :   // Set background ICs
      50                 :            :   const auto& ic = g_inputdeck.get< tag::ic >();
      51                 :            :   const auto& bgmassfrac = ic.get< tag::mass_fractions >();
      52                 :            :   const auto& bgvelic = ic.get< tag::velocity >();
      53                 :            :   const auto& bgpreic = ic.get< tag::pressure >();
      54                 :            :   const auto& bgtempic = ic.get< tag::temperature >();
      55                 :            : 
      56 [ -  + ][ -  - ]:     238746 :   if (bgtempic < 1e-12) Throw( "No background temperature IC" );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
      57 [ -  + ][ -  - ]:     238746 :   if (bgpreic < 1e-12) Throw( "No background pressure IC" );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
      58                 :            : 
      59                 :     238746 :   auto alphamin = 1.0e-12;
      60                 :            : 
      61                 :            :   // initialize background species states
      62         [ +  - ]:     238746 :   auto Ys = bgmassfrac;
      63                 :            :   tk::real total_al(0.0);
      64         [ +  + ]:     595740 :   for (std::size_t k=0; k<nspec; ++k) {
      65         [ +  + ]:     356994 :     Ys[k] = std::max(Ys[k], alphamin);
      66                 :     356994 :     total_al += Ys[k];
      67                 :            :   }
      68         [ +  + ]:     595740 :   for (std::size_t k=0; k<nspec; ++k) Ys[k] /= total_al;
      69                 :            : 
      70                 :     238746 :   tk::real u = bgvelic[0];
      71                 :     238746 :   tk::real v = bgvelic[1];
      72                 :     238746 :   tk::real w = bgvelic[2];
      73                 :            : 
      74                 :            :   // Initialize mixture
      75         [ +  - ]:     238746 :   Mixture mix(nspec, Ys, bgpreic, bgtempic, mat_blk);
      76                 :            : 
      77                 :     238746 :   auto rb = mix.get_mix_density();
      78         [ +  + ]:     595740 :   for (std::size_t k=0; k<nspec; ++k) {
      79                 :            :     // partial density
      80                 :     356994 :     s[multispecies::densityIdx(nspec,k)] = Ys[k] * rb;
      81                 :            :   }
      82                 :            : 
      83                 :            :   // total specific energy
      84 [ +  - ][ +  - ]:     238746 :   s[multispecies::energyIdx(nspec,0)] = mix.totalenergy(rb,
      85                 :            :     u, v, w, bgtempic, mat_blk);
      86                 :            : 
      87                 :            :   // bulk momentum
      88                 :     238746 :   s[multispecies::momentumIdx(nspec,0)] = rb * u;
      89         [ +  - ]:     238746 :   s[multispecies::momentumIdx(nspec,1)] = rb * v;
      90                 :     238746 :   s[multispecies::momentumIdx(nspec,2)] = rb * w;
      91                 :            : 
      92 [ +  - ][ -  + ]:     238746 :   if (bgpreic< 1e-12 || bgtempic< 1e-12)
      93 [ -  - ][ -  - ]:          0 :     Throw("User must specify background pressure and temperature in IC.");
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
      94                 :            : 
      95                 :     238746 :   return s;
      96                 :            : }

Generated by: LCOV version 1.14