Quinoa all test code coverage report
Current view: top level - PDE/MultiMat/Problem - UserDefined.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 30 31 96.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: 23 66 34.8 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/MultiMat/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/MultiMat/MultiMat.h. See PDE/MultiMat/Problem.h
      11                 :            :     for general requirements on Problem policy classes for MultiMat.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : 
      15                 :            : #include <limits>
      16                 :            : 
      17                 :            : #include "UserDefined.hpp"
      18                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      19                 :            : #include "FieldOutput.hpp"
      20                 :            : #include "MultiMat/MultiMatIndexing.hpp"
      21                 :            : 
      22                 :            : namespace inciter {
      23                 :            : 
      24                 :            : extern ctr::InputDeck g_inputdeck;
      25                 :            : 
      26                 :            : } // ::inciter
      27                 :            : 
      28                 :            : using inciter::MultiMatProblemUserDefined;
      29                 :            : 
      30                 :            : tk::InitializeFn::result_type
      31                 :      23424 : MultiMatProblemUserDefined::initialize( ncomp_t ncomp,
      32                 :            :                                         const std::vector< EOS >& mat_blk,
      33                 :            :                                         tk::real,
      34                 :            :                                         tk::real,
      35                 :            :                                         tk::real,
      36                 :            :                                         tk::real )
      37                 :            : // *****************************************************************************
      38                 :            : //! Set initial conditions
      39                 :            : //! \param[in] ncomp Number of scalar components in this PDE system
      40                 :            : //! \return Values of all components
      41                 :            : //! \note The function signature must follow tk::InitializeFn
      42                 :            : // *****************************************************************************
      43                 :            : {
      44                 :      23424 :   tk::InitializeFn::result_type s( ncomp, 0.0 );
      45                 :            : 
      46                 :      23424 :   auto nmat = g_inputdeck.get< eq, tag::nmat >();
      47                 :            :   const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >();
      48                 :            : 
      49                 :            :   // Set background ICs
      50                 :            :   const auto& ic = g_inputdeck.get< tag::ic >();
      51                 :            :   const auto& bgmatid = ic.get< tag::materialid >();
      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 [ -  + ][ -  - ]:      23424 :   if (bgtempic < 1e-12) Throw( "No background temperature IC" );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
      57 [ +  - ][ -  - ]:      23424 :   if (bgpreic < 1e-12) Throw( "No background pressure IC" );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
      58                 :            : 
      59                 :            :   auto alphamin = 1.0e-12;
      60                 :            : 
      61                 :            :   // initialize background material states
      62         [ +  + ]:      70272 :   for (std::size_t k=0; k<nmat; ++k) {
      63         [ +  + ]:      46848 :     if (k == bgmatid-1) {
      64                 :      23424 :       s[volfracIdx(nmat,k)] = 1.0 - (static_cast< tk::real >(nmat-1))*alphamin;
      65                 :            :     }
      66                 :            :     else {
      67                 :      23424 :       s[volfracIdx(nmat,k)] = alphamin;
      68                 :            :     }
      69                 :            :   }
      70                 :            : 
      71                 :      23424 :   tk::real u = bgvelic[0];
      72                 :      23424 :   tk::real v = bgvelic[1];
      73                 :      23424 :   tk::real w = bgvelic[2];
      74                 :            : 
      75                 :            :   auto rb = 0.0;
      76         [ +  + ]:      70272 :   for (std::size_t k=0; k<nmat; ++k) {
      77                 :            :     // density
      78         [ +  - ]:      46848 :     auto rhok = mat_blk[k].compute< EOS::density >(bgpreic, bgtempic);
      79                 :            :     // partial density
      80         [ +  + ]:      46848 :     s[densityIdx(nmat,k)] = s[volfracIdx(nmat,k)] * rhok;
      81                 :            :     // deformation gradients
      82                 :            :     std::array< std::array< tk::real, 3 >, 3 > g;
      83         [ +  + ]:      46848 :     if (solidx[k] > 0) {
      84         [ +  + ]:      74432 :       for (std::size_t i=0; i<3; ++i) {
      85         [ +  + ]:     223296 :         for (std::size_t j=0; j<3; ++j) {
      86         [ +  + ]:     167472 :           if (i==j) g[i][j] = 1.0;
      87                 :     111648 :           else g[i][j] = 0.0;
      88                 :     167472 :           s[deformIdx(nmat,solidx[k],i,j)] = g[i][j];
      89                 :            :         }
      90                 :            :       }
      91                 :            :     }
      92                 :            :     else {
      93                 :      28240 :       g = {{}};
      94                 :            :     }
      95                 :            :     // total specific energy
      96                 :      46848 :     s[energyIdx(nmat,k)] = s[volfracIdx(nmat,k)] *
      97         [ +  - ]:      46848 :       mat_blk[k].compute< EOS::totalenergy >(rhok, u, v, w, bgpreic,
      98                 :            :       g);
      99                 :            :     // bulk density
     100                 :      46848 :     rb += s[densityIdx(nmat,k)];
     101                 :            :   }
     102                 :            : 
     103                 :            :   // bulk momentum
     104         [ +  - ]:      23424 :   s[momentumIdx(nmat,0)] = rb * u;
     105                 :      23424 :   s[momentumIdx(nmat,1)] = rb * v;
     106                 :      23424 :   s[momentumIdx(nmat,2)] = rb * w;
     107                 :            : 
     108 [ +  - ][ -  + ]:      23424 :   if (bgpreic< 1e-12 || bgtempic< 1e-12)
     109 [ -  - ][ -  - ]:          0 :     Throw("User must specify background pressure and temperature in IC.");
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     110                 :            : 
     111                 :      23424 :   return s;
     112                 :            : }

Generated by: LCOV version 1.14