Quinoa all test code coverage report
Current view: top level - PDE/CompFlow/Problem - NLEnergyGrowth.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 31 31 100.0 %
Date: 2024-04-29 14:42:33 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/CompFlow/Problem/NLEnergyGrowth.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     Problem configuration for the compressible flow equations
       9                 :            :   \details   This file declares a problem policy class for the compressible flow
      10                 :            :     equations, defined in PDE/CompFlow/CompFlow.h. See PDE/CompFlow/Problem.h
      11                 :            :     for general requirements on Problem policy classes for CompFlow.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : #ifndef CompFlowProblemNLEnergyGrowth_h
      15                 :            : #define CompFlowProblemNLEnergyGrowth_h
      16                 :            : 
      17                 :            : #include <string>
      18                 :            : #include <unordered_set>
      19                 :            : 
      20                 :            : #include "Types.hpp"
      21                 :            : #include "Fields.hpp"
      22                 :            : #include "FunctionPrototypes.hpp"
      23                 :            : #include "Inciter/Options/Problem.hpp"
      24                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      25                 :            : #include "EoS/GetMatProp.hpp"
      26                 :            : 
      27                 :            : namespace inciter {
      28                 :            : 
      29                 :            : extern ctr::InputDeck g_inputdeck;
      30                 :            : 
      31                 :            : //! CompFlow system of PDEs problem: nonlinear energy growth (NLEG)
      32                 :            : //! \see Waltz, et. al, "Manufactured solutions for the three-dimensional Euler
      33                 :            : //!   equations with relevance to Inertial Confinement Fusion", Journal of
      34                 :            : //!   Computational Physics 267 (2014) 196-209.
      35                 :            : class CompFlowProblemNLEnergyGrowth {
      36                 :            : 
      37                 :            :   private:
      38                 :            :     using ncomp_t = tk::ncomp_t;
      39                 :            :     using eq = tag::compflow;
      40                 :            : 
      41                 :            :     //! Compute internal energy parameter
      42                 :            :     static tk::real hx( tk::real bx, tk::real by, tk::real bz,
      43                 :            :                         tk::real x, tk::real y, tk::real z );
      44                 :            : 
      45                 :            :     //! Compute a power of the internal energy
      46                 :            :     static tk::real ec( tk::real ce, tk::real kappa, tk::real t, tk::real h,
      47                 :            :                         tk::real p );
      48                 :            : 
      49                 :            :   public:
      50                 :            :     //! Initialize numerical solution
      51                 :            :     static tk::InitializeFn::result_type
      52                 :            :     initialize( ncomp_t, const std::vector< EOS >&,
      53                 :            :                 tk::real x, tk::real y, tk::real z, tk::real t );
      54                 :            : 
      55                 :            :     //! Evaluate analytical solution at (x,y,z,t) for all components
      56                 :            :     static tk::InitializeFn::result_type
      57                 :            :     analyticSolution( ncomp_t, const std::vector< EOS >&, tk::real x, tk::real y,
      58                 :            :                       tk::real z, tk::real t );
      59                 :            : 
      60                 :            :     //! Compute and return source term for NLEG manufactured solution
      61                 :            :     //! \param[in] x X coordinate where to evaluate the solution
      62                 :            :     //! \param[in] y Y coordinate where to evaluate the solution
      63                 :            :     //! \param[in] z Z coordinate where to evaluate the solution
      64                 :            :     //! \param[in] t Physical time at which to evaluate the source
      65                 :            :     //! \param[in,out] sv Source term vector
      66                 :            :     //! \note The function signature must follow tk::SrcFn
      67                 :            :     static tk::SrcFn::result_type
      68                 :    2242560 :     src( ncomp_t, const std::vector< EOS >&, tk::real x,
      69                 :            :          tk::real y, tk::real z, tk::real t, std::vector< tk::real >& sv )
      70                 :            :     {
      71                 :            :       Assert(sv.size() == 5, "Incorrect source vector size");
      72                 :            :       using std::sin; using std::cos;
      73                 :            :       // manufactured solution parameters
      74                 :    2242560 :       const auto a = g_inputdeck.get< eq, tag::alpha >();
      75                 :    2242560 :       const auto bx = g_inputdeck.get< eq, tag::betax >();
      76                 :    2242560 :       const auto by = g_inputdeck.get< eq, tag::betay >();
      77                 :    2242560 :       const auto bz = g_inputdeck.get< eq, tag::betaz >();
      78                 :    2242560 :       const auto ce = g_inputdeck.get< eq, tag::ce >();
      79                 :    2242560 :       const auto kappa = g_inputdeck.get< eq, tag::kappa >();
      80                 :    2242560 :       const auto r0 = g_inputdeck.get< eq, tag::r0 >();
      81                 :            :       // ratio of specific heats
      82                 :    2242560 :       const auto g = getmatprop< tag::gamma >();
      83                 :            :       // spatial component of density field
      84                 :    2242560 :       const auto gx = 1.0 - x*x - y*y - z*z;
      85                 :            :       // derivative of spatial component of density field
      86                 :    2242560 :       const std::array< tk::real, 3 > dg{{ -2.0*x, -2.0*y, -2.0*z }};
      87                 :            :       // spatial component of energy field
      88                 :    2242560 :       const auto h = hx( bx, by, bz, x, y, z );
      89                 :            :       // derivative of spatial component of energy field
      90                 :            :       std::array< tk::real, 3 >
      91                 :    2242560 :         dh{{ -bx*M_PI*sin(bx*M_PI*x)*cos(by*M_PI*y)*cos(bz*M_PI*z),
      92                 :    2242560 :              -by*M_PI*cos(bx*M_PI*x)*sin(by*M_PI*y)*cos(bz*M_PI*z),
      93                 :    2242560 :              -bz*M_PI*cos(bx*M_PI*x)*cos(by*M_PI*y)*sin(bz*M_PI*z) }};
      94                 :            :       // temporal function f and its derivative
      95                 :    2242560 :       const auto ft = std::exp(-a*t);
      96                 :    2242560 :       const auto dfdt = -a*ft;
      97                 :            :       // density and its derivatives
      98                 :    2242560 :       const auto rho = r0 + ft*gx;
      99                 :    2242560 :       const std::array< tk::real, 3 > drdx{{ ft*dg[0], ft*dg[1], ft*dg[2] }};
     100                 :    2242560 :       const auto drdt = gx*dfdt;
     101                 :            :       // internal energy and its derivatives
     102                 :    2242560 :       const auto ie = ec( ce, kappa, t, h, -1.0/3.0 );
     103                 :            :       const std::array< tk::real, 3 > dedx{{
     104                 :    2242560 :         2.0*std::pow(ie,4.0)*kappa*h*dh[0]*t,
     105                 :    2242560 :         2.0*std::pow(ie,4.0)*kappa*h*dh[1]*t,
     106                 :    2242560 :         2.0*std::pow(ie,4.0)*kappa*h*dh[2]*t }};
     107                 :    2242560 :       const auto dedt = kappa*h*h*std::pow(ie,4.0);
     108                 :            :       // density source
     109                 :    2242560 :       sv[0] = drdt;
     110                 :            :       // momentum source
     111                 :    2242560 :       sv[1] = (g-1.0)*(rho*dedx[0] + ie*drdx[0]);
     112                 :    2242560 :       sv[2] = (g-1.0)*(rho*dedx[1] + ie*drdx[1]);
     113                 :    2242560 :       sv[3] = (g-1.0)*(rho*dedx[2] + ie*drdx[2]);
     114                 :            :       // energy source
     115                 :    2242560 :       sv[4] = rho*dedt + ie*drdt;
     116                 :    2242560 :     }
     117                 :            : 
     118                 :            :     //! Return analytic field names to be output to file
     119                 :            :     std::vector< std::string > analyticFieldNames( ncomp_t ) const;
     120                 :            : 
     121                 :            :     //! Return names of integral variables to be output to diagnostics file
     122                 :            :     std::vector< std::string > names( ncomp_t ) const;
     123                 :            : 
     124                 :            :     //! Return problem type
     125                 :            :     static ctr::ProblemType type() noexcept
     126                 :            :     { return ctr::ProblemType::NL_ENERGY_GROWTH; }
     127                 :            : };
     128                 :            : 
     129                 :            : } // inciter::
     130                 :            : 
     131                 :            : #endif // CompFlowProblemNLEnergyGrowth_h

Generated by: LCOV version 1.14