Quinoa all test code coverage report
Current view: top level - PDE - ConfigureMultiMat.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 37 46 80.4 %
Date: 2024-04-29 14:42:33 Functions: 16 25 64.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 22 40 55.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/ConfigureMultiMat.hpp
       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     Register and compile configuration for multi-material compressible
       9                 :            :      flow PDE
      10                 :            :   \details   Register and compile configuration for compressible multi-material
      11                 :            :      flow PDE.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : #ifndef ConfigureMultiMat_h
      15                 :            : #define ConfigureMultiMat_h
      16                 :            : 
      17                 :            : #include <set>
      18                 :            : #include <map>
      19                 :            : #include <vector>
      20                 :            : 
      21                 :            : #include "PDEFactory.hpp"
      22                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      23                 :            : #include "Inciter/Options/PDE.hpp"
      24                 :            : #include "PDE/MultiMat/MultiMatIndexing.hpp"
      25                 :            : #include "ContainerUtil.hpp"
      26                 :            : 
      27                 :            : namespace inciter {
      28                 :            : 
      29                 :            : extern ctr::InputDeck g_inputdeck;
      30                 :            : 
      31                 :            : //! Register compressible flow PDEs into PDE factory
      32                 :            : void
      33                 :            : registerMultiMat( DGFactory& df, FVFactory& ff,
      34                 :            :   std::set< ctr::PDEType >& fvt, std::set< ctr::PDEType >& dgt );
      35                 :            : 
      36                 :            : //! Return information on the multi-material compressible flow PDE
      37                 :            : std::vector< std::pair< std::string, std::string > >
      38                 :            : infoMultiMat( std::map< ctr::PDEType, tk::ncomp_t >& cnt );
      39                 :            : 
      40                 :            : /** @name Functions that compute physics variables from the numerical solution for MultiMat */
      41                 :            : ///@{
      42                 :            : 
      43                 :            : #if defined(__clang__)
      44                 :            :   #pragma clang diagnostic push
      45                 :            :   #pragma clang diagnostic ignored "-Wunused-function"
      46                 :            : #endif
      47                 :            : 
      48                 :            : namespace multimat {
      49                 :            : 
      50                 :            : //! Compute bulk density for output to file
      51                 :            : //! \note Must follow the signature in tk::GetVarFn
      52                 :            : //! \param[in] U Numerical solution
      53                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
      54                 :            : //! \return Bulk density ready to be output to file
      55                 :            : static tk::GetVarFn::result_type
      56                 :        197 : bulkDensityOutVar( const tk::Fields& U, std::size_t rdof )
      57                 :            : {
      58                 :            :   using tk::operator+=;
      59                 :        197 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
      60                 :        197 :   auto r = U.extract_comp( densityDofIdx(nmat,0,rdof,0) );
      61         [ +  + ]:        409 :   for (std::size_t k=1; k<nmat; ++k)
      62 [ +  - ][ +  - ]:        424 :     r += U.extract_comp( densityDofIdx(nmat,k,rdof,0) );
                 [ -  - ]
      63                 :        197 :   return r;
      64                 :            : }
      65                 :            : 
      66                 :            : //! Compute bulk pressure for output to file
      67                 :            : //! \note Must follow the signature in tk::GetVarFn
      68                 :            : //! \param[in] U Numerical solution
      69                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
      70                 :            : //! \return Bulk pressure ready to be output to file
      71                 :            : static tk::GetVarFn::result_type
      72                 :        197 : bulkPressureOutVar( const tk::Fields& U, std::size_t rdof )
      73                 :            : {
      74                 :            :   using tk::operator+=;
      75                 :        197 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
      76                 :        197 :   auto p = U.extract_comp( pressureDofIdx(nmat,0,rdof,0) );
      77         [ +  + ]:        409 :   for (std::size_t k=1; k<nmat; ++k)
      78 [ +  - ][ +  - ]:        424 :     p += U.extract_comp( pressureDofIdx(nmat,k,rdof,0) );
                 [ -  - ]
      79                 :        197 :   return p;
      80                 :            : }
      81                 :            : 
      82                 :            : //! Compute bulk specific total energy (energy per unit mass) for output to file
      83                 :            : //! \note Must follow the signature in tk::GetVarFn
      84                 :            : //! \param[in] U Numerical solution
      85                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
      86                 :            : //! \return Bulk specific total energy ready to be output to file
      87                 :            : static tk::GetVarFn::result_type
      88                 :        195 : bulkSpecificTotalEnergyOutVar( const tk::Fields& U, std::size_t rdof )
      89                 :            : {
      90                 :            :   using tk::operator+=;
      91                 :        195 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
      92                 :        195 :   auto e = U.extract_comp( energyDofIdx(nmat,0,rdof,0) );
      93         [ +  + ]:        405 :   for (std::size_t k=1; k<nmat; ++k)
      94 [ +  - ][ +  - ]:        420 :     e += U.extract_comp( energyDofIdx(nmat,k,rdof,0) );
                 [ -  - ]
      95                 :        195 :   return e;
      96                 :            : }
      97                 :            : 
      98                 :            : //! Compute velocity component for output to file
      99                 :            : //! \note Must follow the signature in tk::GetVarFn
     100                 :            : //! \tparam dir Physical direction, encoded as 0:x, 1:y, 2:z
     101                 :            : //! \param[in] U Numerical solution
     102                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
     103                 :            : //! \return Velocity component ready to be output to file
     104                 :            : template< tk::ncomp_t dir >
     105                 :            : tk::GetVarFn::result_type
     106                 :        587 : velocityOutVar( const tk::Fields& U, std::size_t rdof )
     107                 :            : {
     108                 :        587 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
     109                 :        587 :   return U.extract_comp( velocityDofIdx(nmat,dir,rdof,0) );
     110                 :            : }
     111                 :            : 
     112                 :            : //! Compute material indicator function for output to file
     113                 :            : //! \note Must follow the signature in tk::GetVarFn
     114                 :            : //! \param[in] U Numerical solution
     115                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
     116                 :            : //! \return Material indicator function ready to be output to file
     117                 :            : static tk::GetVarFn::result_type
     118                 :          2 : matIndicatorOutVar( const tk::Fields& U, std::size_t rdof )
     119                 :            : {
     120                 :          2 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
     121                 :          2 :   std::vector< tk::real > m(U.nunk(), 0.0);
     122         [ +  + ]:       3034 :   for (std::size_t i=0; i<U.nunk(); ++i) {
     123         [ +  + ]:       9096 :     for (std::size_t k=0; k<nmat; ++k)
     124                 :       6064 :       m[i] += U(i, volfracDofIdx(nmat,k,rdof,0)) *
     125                 :       6064 :         static_cast< tk::real >(k+1);
     126                 :            :   }
     127                 :          2 :   return m;
     128                 :            : }
     129                 :            : 
     130                 :            : //! Compute Cauchy stress component for output to file
     131                 :            : //! \note Must follow the signature in tk::GetVarFn
     132                 :            : //! \tparam idir Physical direction, encoded as 0:x, 1:y, 2:z
     133                 :            : //! \tparam jdir Physical direction, encoded as 0:x, 1:y, 2:z
     134                 :            : //! \param[in] U Numerical solution
     135                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
     136                 :            : //! \return Cauchy stress component ready to be output to file
     137                 :            : template< tk::ncomp_t idir, tk::ncomp_t jdir >
     138                 :            : tk::GetVarFn::result_type
     139                 :          0 : stressOutVar( const tk::Fields& U, std::size_t rdof )
     140                 :            : {
     141                 :            :   const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >();
     142                 :          0 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
     143                 :            : 
     144                 :          0 :   std::vector< tk::real > cs(U.nunk(), 0.0);
     145         [ -  - ]:          0 :   for (std::size_t e=0; e<cs.size(); ++e) {
     146         [ -  - ]:          0 :     for (std::size_t k=0; k<nmat; ++k) {
     147                 :            :       tk::real asigij(0.0);
     148                 :            : 
     149         [ -  - ]:          0 :       if (solidx[k] > 0) asigij =
     150                 :            :         U(e, stressDofIdx(nmat,solidx[k],stressCmp[idir][jdir],rdof,0));
     151                 :            : 
     152                 :            :       if (idir == jdir)
     153                 :          0 :         asigij -= U(e, pressureDofIdx(nmat,k,rdof,0));
     154                 :            : 
     155                 :          0 :       cs[e] += asigij;
     156                 :            :     }
     157                 :            :   }
     158                 :            : 
     159                 :          0 :   return cs;
     160                 :            : }
     161                 :            : 
     162                 :            : //! Compute inverse deformation gradient tensor component for output to file
     163                 :            : //! \note Must follow the signature in tk::GetVarFn
     164                 :            : //! \tparam idir Physical direction, encoded as 0:x, 1:y, 2:z
     165                 :            : //! \tparam jdir Physical direction, encoded as 0:x, 1:y, 2:z
     166                 :            : //! \param[in] U Numerical solution
     167                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
     168                 :            : //! \return Inverse deformation gradient tensor component to be output to file
     169                 :            : template< tk::ncomp_t idir, tk::ncomp_t jdir >
     170                 :            : tk::GetVarFn::result_type
     171                 :        126 : defGradOutVar( const tk::Fields& U, std::size_t rdof )
     172                 :            : {
     173                 :            :   const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >();
     174                 :        126 :   auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
     175                 :            : 
     176                 :        126 :   std::vector< tk::real > g(U.nunk(), 0.0);
     177         [ +  + ]:      57186 :   for (std::size_t e=0; e<g.size(); ++e) {
     178         [ +  + ]:     171180 :     for (std::size_t k=0; k<nmat; ++k) {
     179                 :            :       tk::real agij(0.0);
     180                 :            : 
     181         [ +  + ]:     114120 :       if (solidx[k] > 0) agij = U(e, volfracDofIdx(nmat,k,rdof,0)) *
     182                 :            :         U(e, deformDofIdx(nmat,solidx[k],idir,jdir,rdof,0));
     183                 :            : 
     184                 :     114120 :       g[e] += agij;
     185                 :            :     }
     186                 :            :   }
     187                 :            : 
     188                 :        126 :   return g;
     189                 :            : }
     190                 :            : 
     191                 :            : } // multimat::
     192                 :            : 
     193                 :            : #if defined(__clang__)
     194                 :            :   #pragma clang diagnostic pop
     195                 :            : #endif
     196                 :            : 
     197                 :            : //@}
     198                 :            : 
     199                 :            : } // inciter::
     200                 :            : 
     201                 :            : #endif // ConfigureMultiMat_h

Generated by: LCOV version 1.14