1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// *****************************************************************************
/*!
  \file      src/PDE/CompFlow/Problem/FieldOutput.cpp
  \copyright 2012-2015 J. Bakosi,
             2016-2018 Los Alamos National Security, LLC.,
             2019-2021 Triad National Security, LLC.
             All rights reserved. See the LICENSE file for details.
  \brief     Field outputs for single-material equation solver
  \details   This file defines functions for field quantites to be output to
    files for compressible single-material equations.
*/
// *****************************************************************************

#include "FieldOutput.hpp"
#include "EoS/EoS.hpp"
#include "ContainerUtil.hpp"
#include "History.hpp"

namespace inciter {

std::vector< std::string > CompFlowFieldNames()
// *****************************************************************************
// Return field names to be output to file
//! \return Vector of strings labelling fields output in file
// *****************************************************************************
{
  std::vector< std::string > n;

  n.push_back( "density_numerical" );
  n.push_back( "x-velocity_numerical" );
  n.push_back( "y-velocity_numerical" );
  n.push_back( "z-velocity_numerical" );
  n.push_back( "specific_total_energy_numerical" );
  n.push_back( "pressure_numerical" );

  return n;
}

std::vector< std::vector< tk::real > > 
CompFlowFieldOutput( ncomp_t system,
                     ncomp_t offset,
                     std::size_t nunk,
                     std::size_t rdof,
                     const tk::Fields& U )
// *****************************************************************************
//  Return field output going to file
//! \param[in] system Equation system index, i.e., which compressible
//!   flow equation system we operate on among the systems of PDEs
//! \param[in] offset System offset specifying the position of the system of
//!   PDEs among other systems
//! \param[in] nunk Number of unknowns to extract
//! \param[in] rdof Number of reconstructed degrees of freedom. This is used as
//!   the number of scalar components to shift when extracting scalar
//!   components.
//! \param[in] U Solution vector at recent time step
//! \return Vector of vectors to be output to file
// *****************************************************************************
{
  std::vector< std::vector< tk::real > > out;
  const auto r  = U.extract( 0*rdof, offset );
  const auto ru = U.extract( 1*rdof, offset );<--- Variable 'ru' is assigned a value that is never used.
  const auto rv = U.extract( 2*rdof, offset );<--- Variable 'rv' is assigned a value that is never used.
  const auto rw = U.extract( 3*rdof, offset );<--- Variable 'rw' is assigned a value that is never used.
  const auto re = U.extract( 4*rdof, offset );<--- Variable 're' is assigned a value that is never used.

  Assert( r.size() >= nunk, "Size mismatch" );
  Assert( ru.size() >= nunk, "Size mismatch" );
  Assert( rv.size() >= nunk, "Size mismatch" );
  Assert( rw.size() >= nunk, "Size mismatch" );
  Assert( re.size() >= nunk, "Size mismatch" );

  out.push_back( r );

  std::vector< tk::real > u = ru;
  for (std::size_t i=0; i<nunk; ++i) u[i] /= r[i];
  out.push_back( u );

  std::vector< tk::real > v = rv;
  for (std::size_t i=0; i<nunk; ++i) v[i] /= r[i];
  out.push_back( v );

  std::vector< tk::real > w = rw;
  for (std::size_t i=0; i<nunk; ++i) w[i] /= r[i];
  out.push_back( w );

  std::vector< tk::real > E = re;
  for (std::size_t i=0; i<nunk; ++i) E[i] /= r[i];
  out.push_back( E );

  std::vector< tk::real > P( nunk, 0.0 );
  for (std::size_t i=0; i<nunk; ++i) {
    P[i] = eos_pressure< tag::compflow >
             ( system, r[i], u[i], v[i], w[i], r[i]*E[i] );
  }
  out.push_back( P );

  return out;
}

std::vector< std::string > CompFlowSurfNames()
// *****************************************************************************
// Return surface field names to be output to file
//! \note Every surface will output these fields.
//! \return Vector of strings labelling surface fields output in file
// *****************************************************************************
{
  std::vector< std::string > n;

  n.push_back( "density_numerical" );
  n.push_back( "x-velocity_numerical" );
  n.push_back( "y-velocity_numerical" );
  n.push_back( "z-velocity_numerical" );
  n.push_back( "specific_total_energy_numerical" );
  n.push_back( "pressure_numerical" );

  return n;
}

std::vector< std::vector< tk::real > >
CompFlowSurfOutput( ncomp_t system,
                    const std::map< int, std::vector< std::size_t > >& bnd,
                    const tk::Fields& U )
// *****************************************************************************
//  Return surface field output going to file
//! \param[in] system Equation system index, i.e., which compressible
//!   flow equation system we operate on among the systems of PDEs
//! \param[in] bnd Boundary node/elem lists mapped to side set ids
//! \param[in] U Solution vector at recent time step
//! \return Vector of vectors of solution along side sets to be output to file
// *****************************************************************************
{
  std::vector< std::vector< tk::real > > out;

  // extract field output along side sets requested
  for (auto s : g_inputdeck.outsets()) {
    // get node list for side set requested
    auto b = bnd.find(s);
    if (b == end(bnd)) continue;
    const auto& nodes = b->second;
    std::vector< tk::real > surfaceSol( nodes.size() );
    auto i = out.size();
    out.insert( end(out), 6, surfaceSol );
    std::size_t j = 0;
    for (auto n : nodes) {
      const auto u = U.extract( n );
      Assert( u.size() == 5, "Size mismatch" );
      out[i+0][j] = u[0];
      out[i+1][j] = u[1]/u[0];
      out[i+2][j] = u[2]/u[0];
      out[i+3][j] = u[3]/u[0];
      out[i+4][j] = u[4]/u[0];
      out[i+5][j] = eos_pressure< tag::compflow >
                      ( system, u[0], u[1]/u[0], u[2]/u[0], u[3]/u[0], u[4] );
      ++j;
    }
  }

  return out;
}

std::vector< std::string > CompFlowHistNames()
// *****************************************************************************
// Return time history field names to be output to file
//! \note Every time history point will output these fields.
//! \return Vector of strings labelling time history fields output in file
// *****************************************************************************
{
  std::vector< std::string > n;

  n.push_back( "density" );
  n.push_back( "x-velocity" );
  n.push_back( "y-velocity" );
  n.push_back( "z-velocity" );
  n.push_back( "energy" );
  n.push_back( "pressure" );

  return n;
}

std::vector< std::vector< tk::real > >
CompFlowHistOutput( ncomp_t system,
                    const std::vector< HistData >& h,
                    const std::vector< std::size_t >& inpoel,
                    const tk::Fields& U )
// *****************************************************************************
//  Return time history field output evaluated at time history points
//! \param[in] system Equation system index, i.e., which compressible
//!   flow equation system we operate on among the systems of PDEs
//! \param[in] h History point data
//! \param[in] inpoel Mesh element connectivity
//! \param[in] U Solution vector at recent time step
//! \return Vector of vectors of solution variables evaluated in all history
//!   points. Inner vector: variables, outer vector: points.
// *****************************************************************************
{
  std::vector< std::vector< tk::real > > out( h.size() );

  std::size_t j = 0;
  for (const auto& p : h) {
    auto e = p.get< tag::elem >();        // host element id
    const auto& n = p.get< tag::fn >();   // shapefunctions evaluated at point
    out[j].resize( 6, 0.0 );
    for (std::size_t i=0; i<4; ++i) {
      const auto u = U.extract( inpoel[e*4+i] );
      Assert( u.size() == 5, "Size mismatch" );
      out[j][0] += n[i] * u[0];
      out[j][1] += n[i] * u[1]/u[0];
      out[j][2] += n[i] * u[2]/u[0];
      out[j][3] += n[i] * u[3]/u[0];
      out[j][4] += n[i] * u[4]/u[0];
      out[j][5] += n[i] *
        eos_pressure< tag::compflow >
                    ( system, u[0], u[1]/u[0], u[2]/u[0], u[3]/u[0], u[4] );
    }
    ++j;
  }

  return out;
}

} //inciter::