Quinoa all test code coverage report
Current view: top level - Inciter - FieldOutput.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 14 14 100.0 %
Date: 2024-11-22 08:51:48 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 26 32 81.2 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Inciter/FieldOutput.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     Extract field output for inciter
       9                 :            :   \details   Extract field output for inciter.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef FieldOutput_h
      13                 :            : #define FieldOutput_h
      14                 :            : 
      15                 :            : #include "Types.hpp"
      16                 :            : #include "Fields.hpp"
      17                 :            : #include "Centering.hpp"
      18                 :            : #include "ContainerUtil.hpp"
      19                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      20                 :            : #include "UnsMesh.hpp"
      21                 :            : #include "Discretization.hpp"
      22                 :            : #include "FunctionPrototypes.hpp"
      23                 :            : 
      24                 :            : namespace inciter {
      25                 :            : 
      26                 :            : extern ctr::InputDeck g_inputdeck;
      27                 :            : 
      28                 :            : //! Collect field output names from numerical solution based on user input
      29                 :            : std::vector< std::string >
      30                 :            : numericFieldNames( tk::Centering c );
      31                 :            : 
      32                 :            : //! Collect field output from numerical solution based on user input
      33                 :            : std::vector< std::vector< tk::real > >
      34                 :            : numericFieldOutput( const tk::Fields& U, tk::Centering c,
      35                 :            :                     const std::map< std::string, tk::GetVarFn >& outvarfn,
      36                 :            :                     const tk::Fields& P = tk::Fields() );
      37                 :            : 
      38                 :            : //! Evaluate solution on incoming (a potentially refined) mesh
      39                 :            : void
      40                 :            : evalSolution(
      41                 :            :   const Discretization& D,
      42                 :            :   const std::vector< std::size_t >& inpoel,
      43                 :            :   const tk::UnsMesh::Coords& coord,
      44                 :            :   const std::unordered_map< std::size_t, std::size_t >& addedTets,
      45                 :            :   const std::vector< std::size_t >& ndofel,
      46                 :            :   const tk::Fields& U,
      47                 :            :   const tk::Fields& P,
      48                 :            :   tk::Fields& uElemfields,
      49                 :            :   tk::Fields& pElemfields,
      50                 :            :   tk::Fields& uNodefields,
      51                 :            :   tk::Fields& pNodefields );
      52                 :            : 
      53                 :            : //! Collect field output names from analytic solutions based on user input
      54                 :            : //! \tparam PDE Partial differential equation type
      55                 :            : //! \param[in] eq PDE whose analytic solution field names to query
      56                 :            : //! \param[in] c Extract variables only with this centering
      57                 :            : //! \param[in,out] f Output field names augmented
      58                 :            : template< class PDE >
      59                 :            : void
      60                 :       5607 : analyticFieldNames( const PDE& eq,
      61                 :            :                     tk::Centering c,
      62                 :            :                     std::vector< std::string >& f )
      63                 :            : {
      64         [ +  + ]:      31145 :   for (const auto& v : g_inputdeck.get< tag::field_output, tag::outvar >())
      65 [ +  + ][ +  + ]:      25538 :     if (v.centering == c && v.analytic())
                 [ +  + ]
      66 [ +  - ][ +  - ]:       2780 :       tk::concat( eq.analyticFieldNames(), f );
      67                 :       5607 : }
      68                 :            : 
      69                 :            : //! Collect field output from analytic solutions based on user input
      70                 :            : //! \tparam PDE Partial differential equation type
      71                 :            : //! \param[in] eq PDE whose analytic solution to output
      72                 :            : //! \param[in] c Extract variables only with this centering
      73                 :            : //! \param[in] x x coordinates at which to evaluate the analytic solution
      74                 :            : //! \param[in] y y coordinates at which to evaluate the analytic solution
      75                 :            : //! \param[in] z z coordinates at which to evaluate the analytic solution
      76                 :            : //! \param[in] t Physical time at which to evaluate the analytic solution
      77                 :            : //! \param[in,out] f Output fields augmented by analytic solutions requested
      78                 :            : template< class PDE >
      79                 :            : void
      80                 :       5607 : analyticFieldOutput( const PDE& eq,
      81                 :            :                      tk::Centering c,
      82                 :            :                      const std::vector< tk::real >& x,
      83                 :            :                      const std::vector< tk::real >& y,
      84                 :            :                      const std::vector< tk::real >& z,
      85                 :            :                      tk::real t,
      86                 :            :                      std::vector< std::vector< tk::real > >& f )
      87                 :            : {
      88         [ +  + ]:      31145 :   for (const auto& v : g_inputdeck.get< tag::field_output, tag::outvar >()) {
      89 [ +  + ][ +  + ]:      25538 :     if (v.centering == c && v.analytic()) {
                 [ +  + ]
      90         [ +  - ]:       2780 :       auto ncomp = eq.analyticSolution( x[0], y[0], z[0], t ).size();
      91 [ +  - ][ +  - ]:       2780 :       f.resize( f.size() + ncomp, std::vector< tk::real >( x.size() ) );
      92         [ +  + ]:    1302885 :       for (std::size_t i=0; i<x.size(); ++i) {
      93         [ +  - ]:    2600210 :         auto s = eq.analyticSolution( x[i], y[i], z[i], t );
      94         [ +  + ]:    4480075 :         for (std::size_t j=0; j<ncomp; ++j) f[f.size()-ncomp+j][i] = s[j];
      95                 :            :       }
      96                 :            :     }
      97                 :            :   }
      98                 :       5607 : }
      99                 :            : 
     100                 :            : } // inciter::
     101                 :            : 
     102                 :            : #endif // FieldOutput_h

Generated by: LCOV version 1.14