Quinoa all test code coverage report
Current view: top level - PDE/CompFlow/Problem - RayleighTaylor.hpp (source / functions) Hit Total Coverage
Commit: Quinoa_v0.3-957-gb4f0efae0 Lines: 45 45 100.0 %
Date: 2021-11-11 18:25:50 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/CompFlow/Problem/RayleighTaylor.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 defines a 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 CompFlowProblemRayleighTaylor_h
      15                 :            : #define CompFlowProblemRayleighTaylor_h
      16                 :            : 
      17                 :            : #include <string>
      18                 :            : #include <unordered_set>
      19                 :            : 
      20                 :            : #include "Types.hpp"
      21                 :            : #include "Fields.hpp"
      22                 :            : #include "FunctionPrototypes.hpp"
      23                 :            : #include "SystemComponents.hpp"
      24                 :            : #include "Inciter/Options/Problem.hpp"
      25                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      26                 :            : #include "EoS/EoS.hpp"
      27                 :            : 
      28                 :            : namespace inciter {
      29                 :            : 
      30                 :            : extern ctr::InputDeck g_inputdeck;
      31                 :            : 
      32                 :            : //! CompFlow system of PDEs problem: Rayleigh-Taylor
      33                 :            : //! \see Waltz, et. al, "Manufactured solutions for the three-dimensional Euler
      34                 :            : //!   equations with relevance to Inertial Confinement Fusion", Journal of
      35                 :            : //!   Computational Physics 267 (2014) 196-209.
      36                 :            : class CompFlowProblemRayleighTaylor {
      37                 :            : 
      38                 :            :   private:
      39                 :            :     using ncomp_t = tk::ctr::ncomp_t;
      40                 :            :     using eq = tag::compflow;
      41                 :            : 
      42                 :            :   public:
      43                 :            :     //! Initialize numerical solution
      44                 :            :     static tk::InitializeFn::result_type
      45                 :            :     initialize( ncomp_t system, ncomp_t, tk::real x, tk::real y,
      46                 :            :                 tk::real z, tk::real t );
      47                 :            : 
      48                 :            :     //! Evaluate analytical solution at (x,y,z,t) for all components
      49                 :            :     static tk::InitializeFn::result_type
      50                 :            :     analyticSolution( ncomp_t system, ncomp_t, tk::real x, tk::real y,
      51                 :            :                       tk::real z, tk::real t );
      52                 :            : 
      53                 :            :     //! Compute and return source term for Rayleigh-Taylor manufactured solution
      54                 :            :     //! \param[in] system Equation system index, i.e., which compressible
      55                 :            :     //!   flow equation system we operate on among the systems of PDEs
      56                 :            :     //! \param[in] x X coordinate where to evaluate the solution
      57                 :            :     //! \param[in] y Y coordinate where to evaluate the solution
      58                 :            :     //! \param[in] z Z coordinate where to evaluate the solution
      59                 :            :     //! \param[in] t Physical time at which to evaluate the source
      60                 :            :     //! \param[in,out] r Density source
      61                 :            :     //! \param[in,out] ru X momentum source
      62                 :            :     //! \param[in,out] rv Y momentum source
      63                 :            :     //! \param[in,out] rw Z momentum source
      64                 :            :     //! \param[in,out] re Specific total energy source
      65                 :            :     //! \note The function signature must follow tk::SrcFn
      66                 :            :     static tk::CompFlowSrcFn::result_type
      67                 :     438000 :     src( ncomp_t system, tk::real x, tk::real y, tk::real z, tk::real t,
      68                 :            :          tk::real& r, tk::real& ru, tk::real& rv, tk::real& rw, tk::real& re )
      69                 :            :     {
      70                 :            :       using tag::param; using std::sin; using std::cos;
      71                 :            : 
      72                 :            :       // manufactured solution parameters
      73                 :     438000 :       auto a = g_inputdeck.get< param, eq, tag::alpha >()[system];
      74                 :     438000 :       auto bx = g_inputdeck.get< param, eq, tag::betax >()[system];
      75                 :     438000 :       auto by = g_inputdeck.get< param, eq, tag::betay >()[system];
      76                 :     438000 :       auto bz = g_inputdeck.get< param, eq, tag::betaz >()[system];
      77                 :     438000 :       auto k = g_inputdeck.get< param, eq, tag::kappa >()[system];
      78                 :     438000 :       auto p0 = g_inputdeck.get< param, eq, tag::p0 >()[system];
      79                 :            :       // ratio of specific heats
      80         [ +  - ]:     438000 :       auto g = gamma< tag::compflow >(system);
      81                 :            : 
      82                 :            :       // evaluate solution at x,y,z,t
      83         [ +  - ]:     438000 :       auto s = initialize( system, 5, x, y, z, t );
      84                 :            : 
      85                 :            :       // density, velocity, energy, pressure
      86                 :     438000 :       auto rho = s[0];
      87                 :     438000 :       auto u = s[1]/s[0];
      88                 :     438000 :       auto v = s[2]/s[0];
      89                 :     438000 :       auto w = s[3]/s[0];
      90                 :     438000 :       auto E = s[4]/s[0];
      91                 :     438000 :       auto p = p0 + a*(bx*x*x + by*y*y + bz*z*z);
      92                 :            : 
      93                 :            :       // spatial gradients
      94                 :     438000 :       std::array< tk::real, 3 > drdx{{ -2.0*bx*x, -2.0*by*y, -2.0*bz*z }};
      95                 :     438000 :       std::array< tk::real, 3 > dpdx{{ 2.0*a*bx*x, 2.0*a*by*y, 2.0*a*bz*z }};
      96                 :     438000 :       tk::real ft = cos(k*M_PI*t);
      97                 :     438000 :       std::array< tk::real, 3 > dudx{{ ft*M_PI*z*cos(M_PI*x),
      98                 :            :                                        0.0,
      99                 :     438000 :                                        ft*sin(M_PI*x) }};
     100                 :     438000 :       std::array< tk::real, 3 > dvdx{{ 0.0,
     101                 :     438000 :                                        -ft*M_PI*z*sin(M_PI*y),
     102                 :     438000 :                                        ft*cos(M_PI*y) }};
     103                 :     438000 :       std::array< tk::real, 3 > dwdx{{ ft*M_PI*0.5*M_PI*z*z*sin(M_PI*x),
     104                 :     438000 :                                        ft*M_PI*0.5*M_PI*z*z*cos(M_PI*y),
     105                 :     438000 :                                       -ft*M_PI*z*(cos(M_PI*x) - sin(M_PI*y)) }};
     106                 :            :       std::array< tk::real, 3 > dedx{{
     107                 :     438000 :         dpdx[0]/rho/(g-1.0) - p/(g-1.0)/rho/rho*drdx[0]
     108                 :     438000 :         + u*dudx[0] + v*dvdx[0] + w*dwdx[0],
     109                 :     438000 :         dpdx[1]/rho/(g-1.0) - p/(g-1.0)/rho/rho*drdx[1]
     110                 :     438000 :         + u*dudx[1] + v*dvdx[1] + w*dwdx[1],
     111                 :     438000 :         dpdx[2]/rho/(g-1.0) - p/(g-1.0)/rho/rho*drdx[2]
     112                 :    1314000 :         + u*dudx[2] + v*dvdx[2] + w*dwdx[2] }};
     113                 :            : 
     114                 :            :       // time derivatives
     115                 :     438000 :       auto dudt = -k*M_PI*sin(k*M_PI*t)*z*sin(M_PI*x);
     116                 :     438000 :       auto dvdt = -k*M_PI*sin(k*M_PI*t)*z*cos(M_PI*y);
     117                 :     438000 :       auto dwdt =  k*M_PI*sin(k*M_PI*t)/2*M_PI*z*z*(cos(M_PI*x) - sin(M_PI*y));
     118                 :     438000 :       auto dedt = u*dudt + v*dvdt + w*dwdt;
     119                 :            : 
     120                 :            :       // density source
     121                 :     438000 :       r = u*drdx[0] + v*drdx[1] + w*drdx[2];
     122                 :            :       // momentum source
     123                 :     438000 :       ru = rho*dudt+u*r+dpdx[0] + s[1]*dudx[0]+s[2]*dudx[1]+s[3]*dudx[2];
     124                 :     438000 :       rv = rho*dvdt+v*r+dpdx[1] + s[1]*dvdx[0]+s[2]*dvdx[1]+s[3]*dvdx[2];
     125                 :     438000 :       rw = rho*dwdt+w*r+dpdx[2] + s[1]*dwdx[0]+s[2]*dwdx[1]+s[3]*dwdx[2];
     126                 :            :       // energy source
     127                 :     438000 :       re = rho*dedt + E*r + s[1]*dedx[0]+s[2]*dedx[1]+s[3]*dedx[2]
     128                 :     438000 :            + u*dpdx[0]+v*dpdx[1]+w*dpdx[2];
     129                 :     438000 :     }
     130                 :            : 
     131                 :            :     //! Return field names to be output to file
     132                 :            :     std::vector< std::string > analyticFieldNames( ncomp_t ) const;
     133                 :            : 
     134                 :            :     //! Return names of integral variables to be output to diagnostics file
     135                 :            :     std::vector< std::string > names( ncomp_t /*ncomp*/ ) const;
     136                 :            : 
     137                 :            :     //! Return problem type
     138                 :       4695 :     static ctr::ProblemType type() noexcept
     139                 :       4695 :     { return ctr::ProblemType::RAYLEIGH_TAYLOR; }
     140                 :            : };
     141                 :            : 
     142                 :            : } // inciter::
     143                 :            : 
     144                 :            : #endif // CompFlowProblemRayleighTaylor_h

Generated by: LCOV version 1.14