Quinoa all test code coverage report
Current view: top level - PDE/MultiMat/Problem - FieldOutput.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 51 86 59.3 %
Date: 2025-12-15 14:04:59 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 74 190 38.9 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/MultiMat/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 multi-material equation solver
       9                 :            :   \details   This file defines functions for field quantites to be output to
      10                 :            :     files for compressible multi-material equations.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #include "FieldOutput.hpp"
      14                 :            : #include "MultiMat/MultiMatIndexing.hpp"
      15                 :            : #include "Vector.hpp"
      16                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      17                 :            : #include "ConfigureMultiMat.hpp"
      18                 :            : 
      19                 :            : namespace inciter {
      20                 :            : 
      21                 :            : extern ctr::InputDeck g_inputdeck;
      22                 :            : 
      23         [ +  - ]:        472 : std::map< std::string, tk::GetVarFn > MultiMatOutVarFn()
      24                 :            : // *****************************************************************************
      25                 :            : // Return a map that associates user-specified strings to functions
      26                 :            : //! \return Map that associates user-specified strings to functions that compute
      27                 :            : //!   relevant quantities to be output to file
      28                 :            : // *****************************************************************************
      29                 :            : {
      30                 :            :   std::map< std::string, tk::GetVarFn > OutFnMap;
      31                 :            : 
      32                 :            :   // Allowed strings for user-def field output vars
      33 [ +  - ][ +  - ]:        472 :   OutFnMap["density"] = multimat::bulkDensityOutVar;
      34 [ +  - ][ +  - ]:        472 :   OutFnMap["pressure"] = multimat::bulkPressureOutVar;
      35 [ +  - ][ +  - ]:        472 :   OutFnMap["specific_total_energy"] = multimat::bulkSpecificTotalEnergyOutVar;
      36 [ +  - ][ +  - ]:        472 :   OutFnMap["x-velocity"] = multimat::velocityOutVar<0>;
      37 [ +  - ][ +  - ]:        472 :   OutFnMap["y-velocity"] = multimat::velocityOutVar<1>;
      38 [ +  - ][ +  - ]:        472 :   OutFnMap["z-velocity"] = multimat::velocityOutVar<2>;
      39 [ +  - ][ +  - ]:        472 :   OutFnMap["material_indicator"] = multimat::matIndicatorOutVar;
      40                 :            :   // Cauchy stress tensor
      41 [ +  - ][ +  - ]:        472 :   OutFnMap["stress11"] = multimat::stressOutVar<0,0>;
      42 [ +  - ][ +  - ]:        472 :   OutFnMap["stress12"] = multimat::stressOutVar<0,1>;
      43 [ +  - ][ +  - ]:        472 :   OutFnMap["stress13"] = multimat::stressOutVar<0,2>;
      44 [ +  - ][ +  - ]:        472 :   OutFnMap["stress21"] = multimat::stressOutVar<1,0>;
      45 [ +  - ][ +  - ]:        472 :   OutFnMap["stress22"] = multimat::stressOutVar<1,1>;
      46 [ +  - ][ +  - ]:        472 :   OutFnMap["stress23"] = multimat::stressOutVar<1,2>;
      47 [ +  - ][ +  - ]:        472 :   OutFnMap["stress31"] = multimat::stressOutVar<2,0>;
      48 [ +  - ][ +  - ]:        472 :   OutFnMap["stress32"] = multimat::stressOutVar<2,1>;
      49 [ +  - ][ +  - ]:        472 :   OutFnMap["stress33"] = multimat::stressOutVar<2,2>;
      50                 :            :   // Inverse deformation gradient tensor
      51 [ +  - ][ +  - ]:        472 :   OutFnMap["g11"] = multimat::defGradOutVar<0,0>;
      52 [ +  - ][ +  - ]:        472 :   OutFnMap["g12"] = multimat::defGradOutVar<0,1>;
      53 [ +  - ][ +  - ]:        472 :   OutFnMap["g13"] = multimat::defGradOutVar<0,2>;
      54 [ +  - ][ +  - ]:        472 :   OutFnMap["g21"] = multimat::defGradOutVar<1,0>;
      55 [ +  - ][ +  - ]:        472 :   OutFnMap["g22"] = multimat::defGradOutVar<1,1>;
      56 [ +  - ][ +  - ]:        472 :   OutFnMap["g23"] = multimat::defGradOutVar<1,2>;
      57 [ +  - ][ +  - ]:        472 :   OutFnMap["g31"] = multimat::defGradOutVar<2,0>;
      58 [ +  - ][ +  - ]:        472 :   OutFnMap["g32"] = multimat::defGradOutVar<2,1>;
      59 [ +  - ][ +  - ]:        472 :   OutFnMap["g33"] = multimat::defGradOutVar<2,2>;
      60                 :            : 
      61                 :        472 :   return OutFnMap;
      62                 :            : }
      63                 :            : 
      64         [ +  - ]:        236 : std::vector< std::string > MultiMatSurfNames()
      65                 :            : // *****************************************************************************
      66                 :            : //  Return surface field names to be output to file
      67                 :            : //! \note Every surface will output these fields.
      68                 :            : //! \return Vector of strings labelling surface fields output in file
      69                 :            : // *****************************************************************************
      70                 :            : {
      71                 :            :   std::vector< std::string > n;
      72                 :            : 
      73         [ +  - ]:        236 :   n.push_back( "density" );
      74         [ +  - ]:        236 :   n.push_back( "x-velocity" );
      75         [ +  - ]:        236 :   n.push_back( "y-velocity" );
      76         [ +  - ]:        236 :   n.push_back( "z-velocity" );
      77         [ +  - ]:        236 :   n.push_back( "specific_total_energy" );
      78         [ +  - ]:        236 :   n.push_back( "pressure" );
      79                 :            : 
      80                 :        236 :   return n;
      81                 :          0 : }
      82                 :            : 
      83                 :            : std::vector< std::vector< tk::real > >
      84                 :        236 : MultiMatSurfOutput(
      85                 :            :   const std::size_t nmat,
      86                 :            :   const std::size_t rdof,
      87                 :            :   const FaceData& fd,
      88                 :            :   const tk::Fields& U,
      89                 :            :   const tk::Fields& P )
      90                 :            : // *****************************************************************************
      91                 :            : //  Return element surface field output (on triangle faces) going to file
      92                 :            : //! \param[in] nmat Number of materials in this PDE system
      93                 :            : //! \param[in] rdof Maximum number of reconstructed degrees of freedom
      94                 :            : //! \param[in] fd Face connectivity and boundary conditions object
      95                 :            : //! \param[in] U Solution vector at recent time step
      96                 :            : //! \param[in] P Vector of primitives at recent time step
      97                 :            : //! \return Vector of vectors of solution on side set faces to be output to file
      98                 :            : // *****************************************************************************
      99                 :            : {
     100                 :            :   std::vector< std::vector< tk::real > > out;
     101                 :            : 
     102                 :            :   const auto& bface = fd.Bface();
     103                 :            :   const auto& esuf = fd.Esuf();
     104                 :            : 
     105                 :            :   // extract field output along side sets requested
     106         [ -  + ]:        236 :   for (auto s : g_inputdeck.get< tag::field_output, tag::sideset >()) {
     107                 :            :     // get face list for side set requested
     108                 :          0 :     auto b = bface.find(static_cast<int>(s));
     109         [ -  - ]:          0 :     if (b == end(bface)) continue;
     110                 :            :     const auto& faces = b->second;
     111 [ -  - ][ -  - ]:          0 :     std::vector< tk::real > surfaceSol( faces.size() );
     112                 :            :     auto i = out.size();
     113                 :            :     out.insert( end(out), 6, surfaceSol );
     114                 :            :     std::size_t j = 0;
     115         [ -  - ]:          0 :     for (auto f : faces) {
     116                 :            :       Assert( esuf[2*f+1] == -1, "outside boundary element not -1" );
     117                 :          0 :       std::size_t el = static_cast< std::size_t >(esuf[2*f]);
     118                 :            : 
     119                 :            :       // access solutions at boundary element
     120                 :            :       tk::real rhob(0.0), rhoE(0.0), pb(0.0);
     121         [ -  - ]:          0 :       for (std::size_t k=0; k<nmat; ++k) {
     122                 :          0 :         rhob += U(el, densityDofIdx(nmat,k,rdof,0));
     123                 :          0 :         rhoE += U(el, energyDofIdx(nmat,k,rdof,0));
     124                 :          0 :         pb += P(el, pressureDofIdx(nmat,k,rdof,0));
     125                 :            :       }
     126                 :            : 
     127                 :          0 :       out[i+0][j] = rhob;
     128                 :          0 :       out[i+1][j] = P(el, velocityDofIdx(nmat,0,rdof,0));
     129                 :          0 :       out[i+2][j] = P(el, velocityDofIdx(nmat,1,rdof,0));
     130                 :          0 :       out[i+3][j] = P(el, velocityDofIdx(nmat,2,rdof,0));
     131                 :          0 :       out[i+4][j] = rhoE;
     132                 :          0 :       out[i+5][j] = pb;
     133                 :          0 :       ++j;
     134                 :            :     }
     135                 :            :   }
     136                 :            : 
     137                 :        236 :   return out;
     138                 :          0 : }
     139                 :            : 
     140         [ -  - ]:          0 : std::vector< std::string > MultiMatHistNames()
     141                 :            : // *****************************************************************************
     142                 :            : // Return time history field names to be output to file
     143                 :            : //! \note Every time history point will output these fields.
     144                 :            : //! \return Vector of strings labelling time history fields output in file
     145                 :            : // *****************************************************************************
     146                 :            : {
     147                 :            :   std::vector< std::string > n;
     148                 :          0 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
     149                 :            : 
     150         [ -  - ]:          0 :   n.push_back( "density" );
     151         [ -  - ]:          0 :   n.push_back( "x-velocity" );
     152         [ -  - ]:          0 :   n.push_back( "y-velocity" );
     153         [ -  - ]:          0 :   n.push_back( "z-velocity" );
     154         [ -  - ]:          0 :   n.push_back( "energy" );
     155         [ -  - ]:          0 :   n.push_back( "pressure" );
     156         [ -  - ]:          0 :   for (std::size_t k=0; k<nmat; ++k)
     157         [ -  - ]:          0 :     n.push_back( "volfrac"+std::to_string(k+1) );
     158                 :            : 
     159                 :          0 :   return n;
     160                 :          0 : }
     161                 :            : 
     162                 :         34 : std::vector< std::string > MultiMatDiagNames(std::size_t nmat)
     163                 :            : // *****************************************************************************
     164                 :            : // Return diagnostic var names to be output to file
     165                 :            : //! \param[in] nmat Number of materials in systen
     166                 :            : //! \return Vector of strings labelling diagnostic fields output in file
     167                 :            : // *****************************************************************************
     168                 :            : {
     169                 :            :   std::vector< std::string > n;
     170                 :            :   const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >();
     171                 :            : 
     172         [ +  + ]:        122 :   for (std::size_t k=0; k<nmat; ++k)
     173         [ +  - ]:        176 :     n.push_back( "f"+std::to_string(k+1) );
     174         [ +  + ]:        122 :   for (std::size_t k=0; k<nmat; ++k)
     175         [ +  - ]:        176 :     n.push_back( "fr"+std::to_string(k+1) );
     176         [ +  - ]:         34 :   n.push_back( "fru" );
     177         [ +  - ]:         34 :   n.push_back( "frv" );
     178         [ +  - ]:         34 :   n.push_back( "frw" );
     179         [ +  + ]:        122 :   for (std::size_t k=0; k<nmat; ++k)
     180         [ +  - ]:        176 :     n.push_back( "fre"+std::to_string(k+1) );
     181         [ +  + ]:        122 :   for (std::size_t k=0; k<nmat; ++k) {
     182         [ -  + ]:         88 :     if (solidx[k]) {
     183         [ -  - ]:          0 :       for (std::size_t i=1; i<=3; ++i)
     184         [ -  - ]:          0 :         for (std::size_t j=1; j<=3; ++j)
     185 [ -  - ][ -  - ]:          0 :           n.push_back( "g"+std::to_string(k+1)+
                 [ -  - ]
     186 [ -  - ][ -  - ]:          0 :             "_"+std::to_string(i)+std::to_string(j) );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     187                 :            :     }
     188                 :            :   }
     189                 :            : 
     190                 :         34 :   return n;
     191                 :          0 : }
     192                 :            : 
     193                 :            : } //inciter::

Generated by: LCOV version 1.16