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