Quinoa all test code coverage report
Current view: top level - PDE/CompFlow/Problem - FieldOutput.cpp (source / functions) Hit Total Coverage
Commit: Quinoa_v0.3-957-gb4f0efae0 Lines: 48 81 59.3 %
Date: 2021-11-09 15:14:18 Functions: 4 6 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 38 128 29.7 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/CompFlow/Problem/FieldOutput.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     Field outputs for single-material equation solver
       9                 :            :   \details   This file defines functions for field quantites to be output to
      10                 :            :     files for compressible single-material equations.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : 
      14                 :            : #include "FieldOutput.hpp"
      15                 :            : #include "EoS/EoS.hpp"
      16                 :            : #include "ContainerUtil.hpp"
      17                 :            : #include "History.hpp"
      18                 :            : 
      19                 :            : namespace inciter {
      20                 :            : 
      21         [ -  - ]:          0 : std::vector< std::string > CompFlowFieldNames()
      22                 :            : // *****************************************************************************
      23                 :            : // Return field names to be output to file
      24                 :            : //! \return Vector of strings labelling fields output in file
      25                 :            : // *****************************************************************************
      26                 :            : {
      27                 :            :   std::vector< std::string > n;
      28                 :            : 
      29         [ -  - ]:          0 :   n.push_back( "density_numerical" );
      30         [ -  - ]:          0 :   n.push_back( "x-velocity_numerical" );
      31         [ -  - ]:          0 :   n.push_back( "y-velocity_numerical" );
      32         [ -  - ]:          0 :   n.push_back( "z-velocity_numerical" );
      33         [ -  - ]:          0 :   n.push_back( "specific_total_energy_numerical" );
      34         [ -  - ]:          0 :   n.push_back( "pressure_numerical" );
      35                 :            : 
      36                 :          0 :   return n;
      37                 :            : }
      38                 :            : 
      39                 :            : std::vector< std::vector< tk::real > > 
      40         [ -  - ]:          0 : CompFlowFieldOutput( ncomp_t system,
      41                 :            :                      ncomp_t offset,
      42                 :            :                      std::size_t nunk,
      43                 :            :                      std::size_t rdof,
      44                 :            :                      const tk::Fields& U )
      45                 :            : // *****************************************************************************
      46                 :            : //  Return field output going to file
      47                 :            : //! \param[in] system Equation system index, i.e., which compressible
      48                 :            : //!   flow equation system we operate on among the systems of PDEs
      49                 :            : //! \param[in] offset System offset specifying the position of the system of
      50                 :            : //!   PDEs among other systems
      51                 :            : //! \param[in] nunk Number of unknowns to extract
      52                 :            : //! \param[in] rdof Number of reconstructed degrees of freedom. This is used as
      53                 :            : //!   the number of scalar components to shift when extracting scalar
      54                 :            : //!   components.
      55                 :            : //! \param[in] U Solution vector at recent time step
      56                 :            : //! \return Vector of vectors to be output to file
      57                 :            : // *****************************************************************************
      58                 :            : {
      59                 :            :   std::vector< std::vector< tk::real > > out;
      60         [ -  - ]:          0 :   const auto r  = U.extract( 0*rdof, offset );
      61         [ -  - ]:          0 :   const auto ru = U.extract( 1*rdof, offset );
      62         [ -  - ]:          0 :   const auto rv = U.extract( 2*rdof, offset );
      63         [ -  - ]:          0 :   const auto rw = U.extract( 3*rdof, offset );
      64         [ -  - ]:          0 :   const auto re = U.extract( 4*rdof, offset );
      65                 :            : 
      66                 :            :   Assert( r.size() >= nunk, "Size mismatch" );
      67                 :            :   Assert( ru.size() >= nunk, "Size mismatch" );
      68                 :            :   Assert( rv.size() >= nunk, "Size mismatch" );
      69                 :            :   Assert( rw.size() >= nunk, "Size mismatch" );
      70                 :            :   Assert( re.size() >= nunk, "Size mismatch" );
      71                 :            : 
      72         [ -  - ]:          0 :   out.push_back( r );
      73                 :            : 
      74         [ -  - ]:          0 :   std::vector< tk::real > u = ru;
      75         [ -  - ]:          0 :   for (std::size_t i=0; i<nunk; ++i) u[i] /= r[i];
      76         [ -  - ]:          0 :   out.push_back( u );
      77                 :            : 
      78         [ -  - ]:          0 :   std::vector< tk::real > v = rv;
      79         [ -  - ]:          0 :   for (std::size_t i=0; i<nunk; ++i) v[i] /= r[i];
      80         [ -  - ]:          0 :   out.push_back( v );
      81                 :            : 
      82         [ -  - ]:          0 :   std::vector< tk::real > w = rw;
      83         [ -  - ]:          0 :   for (std::size_t i=0; i<nunk; ++i) w[i] /= r[i];
      84         [ -  - ]:          0 :   out.push_back( w );
      85                 :            : 
      86         [ -  - ]:          0 :   std::vector< tk::real > E = re;
      87         [ -  - ]:          0 :   for (std::size_t i=0; i<nunk; ++i) E[i] /= r[i];
      88         [ -  - ]:          0 :   out.push_back( E );
      89                 :            : 
      90 [ -  - ][ -  - ]:          0 :   std::vector< tk::real > P( nunk, 0.0 );
      91         [ -  - ]:          0 :   for (std::size_t i=0; i<nunk; ++i) {
      92                 :          0 :     P[i] = eos_pressure< tag::compflow >
      93         [ -  - ]:          0 :              ( system, r[i], u[i], v[i], w[i], r[i]*E[i] );
      94                 :            :   }
      95         [ -  - ]:          0 :   out.push_back( P );
      96                 :            : 
      97                 :          0 :   return out;
      98                 :            : }
      99                 :            : 
     100         [ +  - ]:       2440 : std::vector< std::string > CompFlowSurfNames()
     101                 :            : // *****************************************************************************
     102                 :            : // Return surface field names to be output to file
     103                 :            : //! \note Every surface will output these fields.
     104                 :            : //! \return Vector of strings labelling surface fields output in file
     105                 :            : // *****************************************************************************
     106                 :            : {
     107                 :            :   std::vector< std::string > n;
     108                 :            : 
     109         [ +  - ]:       2440 :   n.push_back( "density_numerical" );
     110         [ +  - ]:       2440 :   n.push_back( "x-velocity_numerical" );
     111         [ +  - ]:       2440 :   n.push_back( "y-velocity_numerical" );
     112         [ +  - ]:       2440 :   n.push_back( "z-velocity_numerical" );
     113         [ +  - ]:       2440 :   n.push_back( "specific_total_energy_numerical" );
     114         [ +  - ]:       2440 :   n.push_back( "pressure_numerical" );
     115                 :            : 
     116                 :       2440 :   return n;
     117                 :            : }
     118                 :            : 
     119                 :            : std::vector< std::vector< tk::real > >
     120         [ +  - ]:       2440 : CompFlowSurfOutput( ncomp_t system,
     121                 :            :                     const std::map< int, std::vector< std::size_t > >& bnd,
     122                 :            :                     const tk::Fields& U )
     123                 :            : // *****************************************************************************
     124                 :            : //  Return surface field output going to file
     125                 :            : //! \param[in] system Equation system index, i.e., which compressible
     126                 :            : //!   flow equation system we operate on among the systems of PDEs
     127                 :            : //! \param[in] bnd Boundary node/elem lists mapped to side set ids
     128                 :            : //! \param[in] U Solution vector at recent time step
     129                 :            : //! \return Vector of vectors of solution along side sets to be output to file
     130                 :            : // *****************************************************************************
     131                 :            : {
     132                 :            :   std::vector< std::vector< tk::real > > out;
     133                 :            : 
     134                 :            :   // extract field output along side sets requested
     135 [ +  - ][ +  + ]:       5028 :   for (auto s : g_inputdeck.outsets()) {
     136                 :            :     // get node list for side set requested
     137                 :            :     auto b = bnd.find(s);
     138         [ +  + ]:        148 :     if (b == end(bnd)) continue;
     139                 :            :     const auto& nodes = b->second;
     140         [ +  - ]:         94 :     std::vector< tk::real > surfaceSol( nodes.size() );
     141         [ +  - ]:         94 :     auto i = out.size();
     142                 :            :     out.insert( end(out), 6, surfaceSol );
     143                 :            :     std::size_t j = 0;
     144         [ +  + ]:       6462 :     for (auto n : nodes) {
     145         [ +  - ]:       6368 :       const auto u = U.extract( n );
     146                 :            :       Assert( u.size() == 5, "Size mismatch" );
     147         [ +  - ]:       6368 :       out[i+0][j] = u[0];
     148                 :       6368 :       out[i+1][j] = u[1]/u[0];
     149                 :       6368 :       out[i+2][j] = u[2]/u[0];
     150                 :       6368 :       out[i+3][j] = u[3]/u[0];
     151                 :       6368 :       out[i+4][j] = u[4]/u[0];
     152         [ +  - ]:       6368 :       out[i+5][j] = eos_pressure< tag::compflow >
     153         [ +  - ]:       6368 :                       ( system, u[0], u[1]/u[0], u[2]/u[0], u[3]/u[0], u[4] );
     154         [ +  - ]:       6368 :       ++j;
     155                 :            :     }
     156                 :            :   }
     157                 :            : 
     158                 :       2440 :   return out;
     159                 :            : }
     160                 :            : 
     161         [ +  - ]:         28 : std::vector< std::string > CompFlowHistNames()
     162                 :            : // *****************************************************************************
     163                 :            : // Return time history field names to be output to file
     164                 :            : //! \note Every time history point will output these fields.
     165                 :            : //! \return Vector of strings labelling time history fields output in file
     166                 :            : // *****************************************************************************
     167                 :            : {
     168                 :            :   std::vector< std::string > n;
     169                 :            : 
     170         [ +  - ]:         28 :   n.push_back( "density" );
     171         [ +  - ]:         28 :   n.push_back( "x-velocity" );
     172         [ +  - ]:         28 :   n.push_back( "y-velocity" );
     173         [ +  - ]:         28 :   n.push_back( "z-velocity" );
     174         [ +  - ]:         28 :   n.push_back( "energy" );
     175         [ +  - ]:         28 :   n.push_back( "pressure" );
     176                 :            : 
     177                 :         28 :   return n;
     178                 :            : }
     179                 :            : 
     180                 :            : std::vector< std::vector< tk::real > >
     181                 :        898 : CompFlowHistOutput( ncomp_t system,
     182                 :            :                     const std::vector< HistData >& h,
     183                 :            :                     const std::vector< std::size_t >& inpoel,
     184                 :            :                     const tk::Fields& U )
     185                 :            : // *****************************************************************************
     186                 :            : //  Return time history field output evaluated at time history points
     187                 :            : //! \param[in] system Equation system index, i.e., which compressible
     188                 :            : //!   flow equation system we operate on among the systems of PDEs
     189                 :            : //! \param[in] h History point data
     190                 :            : //! \param[in] inpoel Mesh element connectivity
     191                 :            : //! \param[in] U Solution vector at recent time step
     192                 :            : //! \return Vector of vectors of solution variables evaluated in all history
     193                 :            : //!   points. Inner vector: variables, outer vector: points.
     194                 :            : // *****************************************************************************
     195                 :            : {
     196                 :        898 :   std::vector< std::vector< tk::real > > out( h.size() );
     197                 :            : 
     198                 :            :   std::size_t j = 0;
     199         [ +  + ]:       1338 :   for (const auto& p : h) {
     200                 :        440 :     auto e = p.get< tag::elem >();        // host element id
     201                 :            :     const auto& n = p.get< tag::fn >();   // shapefunctions evaluated at point
     202         [ +  - ]:        440 :     out[j].resize( 6, 0.0 );
     203         [ +  + ]:       2200 :     for (std::size_t i=0; i<4; ++i) {
     204         [ +  - ]:       1760 :       const auto u = U.extract( inpoel[e*4+i] );
     205                 :            :       Assert( u.size() == 5, "Size mismatch" );
     206         [ +  - ]:       1760 :       out[j][0] += n[i] * u[0];
     207                 :       1760 :       out[j][1] += n[i] * u[1]/u[0];
     208                 :       1760 :       out[j][2] += n[i] * u[2]/u[0];
     209                 :       1760 :       out[j][3] += n[i] * u[3]/u[0];
     210                 :       1760 :       out[j][4] += n[i] * u[4]/u[0];
     211         [ +  - ]:       1760 :       out[j][5] += n[i] *
     212                 :            :         eos_pressure< tag::compflow >
     213         [ +  - ]:       1760 :                     ( system, u[0], u[1]/u[0], u[2]/u[0], u[3]/u[0], u[4] );
     214                 :            :     }
     215                 :        440 :     ++j;
     216                 :            :   }
     217                 :            : 
     218                 :        898 :   return out;
     219                 :            : }
     220                 :            : 
     221                 :            : } //inciter::

Generated by: LCOV version 1.14