Branch data Line data Source code
1 : : // ***************************************************************************** 2 : : /*! 3 : : \file src/PDE/MultiSpecies/Problem/FieldOutput.cpp 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 Field outputs for multi-species equation solver 9 : : \details This file defines functions for field quantites to be output to 10 : : files for compressible multi-species equations. 11 : : */ 12 : : // ***************************************************************************** 13 : : #include "FieldOutput.hpp" 14 : : #include "MultiSpecies/MultiSpeciesIndexing.hpp" 15 : : #include "Vector.hpp" 16 : : #include "Inciter/InputDeck/InputDeck.hpp" 17 : : #include "ConfigureMultiSpecies.hpp" 18 : : 19 : : namespace inciter { 20 : : 21 : : extern ctr::InputDeck g_inputdeck; 22 : : 23 : 352 : std::map< std::string, tk::GetVarFn > MultiSpeciesOutVarFn() 24 : : // ***************************************************************************** 25 : : // Return a map that associates user-specified strings to functions 26 : : //! \return Map that associates user-specified strings to functions that compute 27 : : //! relevant quantities to be output to file 28 : : // ***************************************************************************** 29 : : { 30 : 352 : std::map< std::string, tk::GetVarFn > OutFnMap; 31 : : 32 : : // Allowed strings for user-def field output vars 33 [ + - ][ + - ]: 352 : OutFnMap["density"] = multispecies::mixDensityOutVar; [ + - ] 34 [ + - ][ + - ]: 352 : OutFnMap["temperature"] = multispecies::temperatureOutVar; [ + - ] 35 : : //OutFnMap["pressure"] = multispecies::pressureOutVar; 36 [ + - ][ + - ]: 352 : OutFnMap["specific_total_energy"] = multispecies::specificTotalEnergyOutVar; [ + - ] 37 [ + - ][ + - ]: 352 : OutFnMap["x-velocity"] = multispecies::velocityOutVar<0>; [ + - ] 38 [ + - ][ + - ]: 352 : OutFnMap["y-velocity"] = multispecies::velocityOutVar<1>; [ + - ] 39 [ + - ][ + - ]: 352 : OutFnMap["z-velocity"] = multispecies::velocityOutVar<2>; [ + - ] 40 : : 41 : 352 : return OutFnMap; 42 : : } 43 : : 44 : : std::vector< std::string > 45 : 0 : MultiSpeciesFieldNames( std::size_t nspec ) 46 : : // ***************************************************************************** 47 : : // Return multi-species field names to be output to file 48 : : //! \param[in] nspec Number of species in system 49 : : //! \return Vector of strings labelling fields output in file 50 : : // ***************************************************************************** 51 : : { 52 : 0 : std::vector< std::string > n; 53 : : 54 [ - - ]: 0 : for (std::size_t k=0; k<nspec; ++k) 55 [ - - ][ - - ]: 0 : n.push_back( "density"+std::to_string(k+1)+"_numerical" ); [ - - ][ - - ] 56 [ - - ][ - - ]: 0 : n.push_back( "x-velocity_numerical" ); 57 [ - - ][ - - ]: 0 : n.push_back( "y-velocity_numerical" ); 58 [ - - ][ - - ]: 0 : n.push_back( "z-velocity_numerical" ); 59 [ - - ][ - - ]: 0 : n.push_back( "pressure_numerical" ); 60 [ - - ][ - - ]: 0 : n.push_back( "soundspeed" ); 61 [ - - ][ - - ]: 0 : n.push_back( "total_energy_density_numerical" ); 62 [ - - ][ - - ]: 0 : n.push_back( "timestep" ); 63 : : 64 : 0 : return n; 65 : : } 66 : : 67 : 0 : std::vector< std::string > MultiSpeciesSurfNames() 68 : : // ***************************************************************************** 69 : : // Return surface field names to be output to file 70 : : //! \note Every surface will output these fields. 71 : : //! \return Vector of strings labelling surface fields output in file 72 : : // ***************************************************************************** 73 : : { 74 : 0 : std::vector< std::string > n; 75 : : 76 [ - - ][ - - ]: 0 : n.push_back( "density" ); 77 [ - - ][ - - ]: 0 : n.push_back( "x-velocity" ); 78 [ - - ][ - - ]: 0 : n.push_back( "y-velocity" ); 79 [ - - ][ - - ]: 0 : n.push_back( "z-velocity" ); 80 [ - - ][ - - ]: 0 : n.push_back( "specific_total_energy" ); 81 : : 82 : 0 : return n; 83 : : } 84 : : 85 : : std::vector< std::vector< tk::real > > 86 : 0 : MultiSpeciesSurfOutput( 87 : : const std::size_t nspec, 88 : : const std::size_t rdof, 89 : : const FaceData& fd, 90 : : const tk::Fields& U, 91 : : const tk::Fields& /*P*/ ) 92 : : // ***************************************************************************** 93 : : // Return element surface field output (on triangle faces) going to file 94 : : //! \param[in] nspec Number of species in this PDE system 95 : : //! \param[in] rdof Maximum number of reconstructed degrees of freedom 96 : : //! \param[in] fd Face connectivity and boundary conditions object 97 : : //! \param[in] U Solution vector at recent time step 98 : : // //! \param[in] P Vector of primitives at recent time step 99 : : //! \return Vector of vectors of solution on side set faces to be output to file 100 : : // ***************************************************************************** 101 : : { 102 : 0 : std::vector< std::vector< tk::real > > out; 103 : : 104 : 0 : const auto& bface = fd.Bface(); 105 : 0 : const auto& esuf = fd.Esuf(); 106 : : 107 : : // extract field output along side sets requested 108 [ - - ]: 0 : for (auto s : g_inputdeck.get< tag::field_output, tag::sideset >()) { 109 : : // get face list for side set requested 110 [ - - ]: 0 : auto b = bface.find(static_cast<int>(s)); 111 [ - - ]: 0 : if (b == end(bface)) continue; 112 : 0 : const auto& faces = b->second; 113 [ - - ]: 0 : std::vector< tk::real > surfaceSol( faces.size() ); 114 : 0 : auto i = out.size(); 115 [ - - ]: 0 : out.insert( end(out), 6, surfaceSol ); 116 : 0 : std::size_t j = 0; 117 [ - - ]: 0 : for (auto f : faces) { 118 [ - - ][ - - ]: 0 : Assert( esuf[2*f+1] == -1, "outside boundary element not -1" ); [ - - ][ - - ] 119 : 0 : std::size_t el = static_cast< std::size_t >(esuf[2*f]); 120 : : 121 : : // access solutions at boundary element 122 : 0 : tk::real rhob(0.0), rhoE(0.0); 123 [ - - ]: 0 : for (std::size_t k=0; k<nspec; ++k) { 124 [ - - ]: 0 : rhob += U(el, multispecies::densityDofIdx(nspec,k,rdof,0)); 125 : : } 126 [ - - ]: 0 : rhoE = U(el, multispecies::energyDofIdx(nspec,0,rdof,0)); 127 : : 128 : 0 : out[i+0][j] = rhob; 129 [ - - ]: 0 : out[i+1][j] = U(el, multispecies::momentumDofIdx(nspec,0,rdof,0))/rhob; 130 [ - - ]: 0 : out[i+2][j] = U(el, multispecies::momentumDofIdx(nspec,1,rdof,0))/rhob; 131 [ - - ]: 0 : out[i+3][j] = U(el, multispecies::momentumDofIdx(nspec,2,rdof,0))/rhob; 132 : 0 : out[i+4][j] = rhoE; 133 : 0 : ++j; 134 : : } 135 : : } 136 : : 137 : 0 : return out; 138 : : } 139 : : 140 : 0 : std::vector< std::string > MultiSpeciesHistNames() 141 : : // ***************************************************************************** 142 : : // Return time history field names to be output to file 143 : : //! \note Every time history point will output these fields. 144 : : //! \return Vector of strings labelling time history fields output in file 145 : : // ***************************************************************************** 146 : : { 147 : 0 : std::vector< std::string > n; 148 : 0 : auto nspec = g_inputdeck.get< tag::multispecies, tag::nspec >(); 149 : : 150 [ - - ][ - - ]: 0 : n.push_back( "density" ); 151 [ - - ][ - - ]: 0 : n.push_back( "x-velocity" ); 152 [ - - ][ - - ]: 0 : n.push_back( "y-velocity" ); 153 [ - - ][ - - ]: 0 : n.push_back( "z-velocity" ); 154 [ - - ][ - - ]: 0 : n.push_back( "energy" ); 155 [ - - ][ - - ]: 0 : n.push_back( "pressure" ); 156 [ - - ]: 0 : for (std::size_t k=0; k<nspec; ++k) 157 [ - - ][ - - ]: 0 : n.push_back( "massfrac"+std::to_string(k+1) ); [ - - ] 158 : : 159 : 0 : return n; 160 : : } 161 : : 162 : 6 : std::vector< std::string > MultiSpeciesDiagNames(std::size_t nspec) 163 : : // ***************************************************************************** 164 : : // Return diagnostic var names to be output to file 165 : : //! \param[in] nspec Number of species in systen 166 : : //! \return Vector of strings labelling diagnostic fields output in file 167 : : // ***************************************************************************** 168 : : { 169 : 6 : std::vector< std::string > n; 170 : : 171 [ + + ]: 15 : for (std::size_t k=0; k<nspec; ++k) 172 [ + - ][ + - ]: 9 : n.push_back( "fr"+std::to_string(k+1) ); [ + - ] 173 [ + - ][ + - ]: 6 : n.push_back( "ru" ); 174 [ + - ][ + - ]: 6 : n.push_back( "rv" ); 175 [ + - ][ + - ]: 6 : n.push_back( "rw" ); 176 [ + - ][ + - ]: 6 : n.push_back( "re0" ); 177 : : 178 : 6 : return n; 179 : : } 180 : : 181 : : } //inciter::