Branch data Line data Source code
1 : : // ***************************************************************************** 2 : : /*! 3 : : \file src/PDE/ConfigureMultiSpecies.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-species compressible 9 : : flow PDE 10 : : */ 11 : : // ***************************************************************************** 12 : : #ifndef ConfigureMultiSpecies_h 13 : : #define ConfigureMultiSpecies_h 14 : : 15 : : #include <set> 16 : : #include <map> 17 : : #include <vector> 18 : : 19 : : #include "PDEFactory.hpp" 20 : : #include "Inciter/InputDeck/InputDeck.hpp" 21 : : #include "Inciter/Options/PDE.hpp" 22 : : #include "PDE/MultiSpecies/MultiSpeciesIndexing.hpp" 23 : : #include "ContainerUtil.hpp" 24 : : 25 : : namespace inciter { 26 : : 27 : : extern ctr::InputDeck g_inputdeck; 28 : : 29 : : //! Register compressible flow PDEs into PDE factory 30 : : void 31 : : registerMultiSpecies( DGFactory& df, FVFactory& ff, 32 : : std::set< ctr::PDEType >& fvt, std::set< ctr::PDEType >& dgt ); 33 : : 34 : : //! Return information on the multi-species compressible flow PDE 35 : : std::vector< std::pair< std::string, std::string > > 36 : : infoMultiSpecies( std::map< ctr::PDEType, tk::ncomp_t >& cnt ); 37 : : 38 : : /** @name Functions that compute physics variables from the numerical solution for MultiSpecies */ 39 : : ///@{ 40 : : 41 : : #if defined(__clang__) 42 : : #pragma clang diagnostic push 43 : : #pragma clang diagnostic ignored "-Wunused-function" 44 : : #endif 45 : : 46 : : namespace multispecies { 47 : : 48 : : //! Compute mixture density for output to file 49 : : //! \note Must follow the signature in tk::GetVarFn 50 : : //! \param[in] U Numerical solution 51 : : //! \param[in] rdof Number of reconstructed solution DOFs 52 : : //! \return Bulk density ready to be output to file 53 : : static tk::GetVarFn::result_type 54 : 176 : mixDensityOutVar( const tk::Fields& U, std::size_t rdof ) 55 : : { 56 : : using tk::operator+=; 57 : 176 : auto nspec = g_inputdeck.get< tag::multispecies, tag::nspec >(); 58 : 176 : auto r = U.extract_comp( densityDofIdx(nspec,0,rdof,0) ); 59 [ + + ]: 264 : for (std::size_t k=1; k<nspec; ++k) 60 [ + - ][ + - ]: 88 : r += U.extract_comp( densityDofIdx(nspec,k,rdof,0) ); 61 : 176 : return r; 62 : : } 63 : : 64 : : ////! Compute pressure for output to file 65 : : ////! \note Must follow the signature in tk::GetVarFn 66 : : ////! \param[in] U Numerical solution 67 : : ////! \param[in] rdof Number of reconstructed solution DOFs 68 : : ////! \return Pressure ready to be output to file 69 : : //static tk::GetVarFn::result_type 70 : : //pressureOutVar( const tk::Fields& U, std::size_t rdof ) 71 : : //{ 72 : : // using tk::operator+=; 73 : : // auto nspec = g_inputdeck.get< tag::multispecies, tag::nspec >(); 74 : : // auto p = U.extract_comp( pressureDofIdx(nspec,0,rdof,0) ); 75 : : // for (std::size_t k=1; k<nspec; ++k) 76 : : // p += U.extract_comp( pressureDofIdx(nspec,k,rdof,0) ); 77 : : // return p; 78 : : //} 79 : : 80 : : //! Compute specific total energy (energy per unit volume) for output to file 81 : : //! \note Must follow the signature in tk::GetVarFn 82 : : //! \param[in] U Numerical solution 83 : : //! \param[in] rdof Number of reconstructed solution DOFs 84 : : //! \return Specific total energy ready to be output to file 85 : : static tk::GetVarFn::result_type 86 : 176 : specificTotalEnergyOutVar( const tk::Fields& U, std::size_t rdof ) 87 : : { 88 : 176 : auto nspec = g_inputdeck.get< tag::multispecies, tag::nspec >(); 89 : 176 : return U.extract_comp( energyDofIdx(nspec,0,rdof,0) ); 90 : : } 91 : : 92 : : //! Compute velocity component for output to file 93 : : //! \note Must follow the signature in tk::GetVarFn 94 : : //! \tparam dir Physical direction, encoded as 0:x, 1:y, 2:z 95 : : //! \param[in] U Numerical solution 96 : : //! \param[in] rdof Number of reconstructed solution DOFs 97 : : //! \return Velocity component ready to be output to file 98 : : template< tk::ncomp_t dir > 99 : : tk::GetVarFn::result_type 100 : 528 : velocityOutVar( const tk::Fields& U, std::size_t rdof ) 101 : : { 102 : : using tk::operator/=; 103 : : using tk::operator+=; 104 : 528 : auto nspec = g_inputdeck.get< tag::multispecies, tag::nspec >(); 105 : : 106 : : // mixture density 107 [ + - ]: 1056 : auto r = U.extract_comp( densityDofIdx(nspec,0,rdof,0) ); 108 [ + + ]: 792 : for (std::size_t k=1; k<nspec; ++k) 109 [ + - ][ + - ]: 264 : r += U.extract_comp( densityDofIdx(nspec,k,rdof,0) ); 110 : : 111 : : // momentum 112 [ + - ]: 528 : auto u = U.extract_comp( momentumDofIdx(nspec,dir,rdof,0) ); 113 : : 114 : : // velocity 115 [ + - ]: 528 : u /= r; 116 : : 117 : 1056 : return u; 118 : : } 119 : : 120 : : } // multispecies:: 121 : : 122 : : #if defined(__clang__) 123 : : #pragma clang diagnostic pop 124 : : #endif 125 : : 126 : : //@} 127 : : 128 : : } // inciter:: 129 : : 130 : : #endif // ConfigureMultiSpecies_h