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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351 | // *****************************************************************************
/*!
\file src/PDE/ConfigureCompFlow.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 Register and compile configuration for compressible flow PDE
\details Register and compile configuration for compressible flow PDE.
*/
// *****************************************************************************
#include <set>
#include <map>
#include <vector>
#include <string>
#include <limits>
#include <brigand/algorithms/for_each.hpp>
#include "Tags.hpp"
#include "CartesianProduct.hpp"
#include "PDEFactory.hpp"
#include "Inciter/Options/PDE.hpp"
#include "ContainerUtil.hpp"
#include "ConfigureCompFlow.hpp"
#include "CompFlow/Physics/CG.hpp"
#include "CompFlow/Physics/DG.hpp"
#include "CompFlow/CGCompFlow.hpp"
#include "CompFlow/DGCompFlow.hpp"
#include "CompFlow/Problem.hpp"
#include "InfoMesh.hpp"
namespace inciter {
void
registerCompFlow( CGFactory& cf,
DGFactory& df,
std::set< ctr::PDEType >& cgt,
std::set< ctr::PDEType >& dgt )
// *****************************************************************************
// Register compressible flow PDE into PDE factory
//! \param[in,out] cf Continuous Galerkin PDE factory to register to
//! \param[in,out] df Discontinuous Galerkin PDE factory to register to
//! \param[in,out] cgt Counters for equation types registered into CG factory
//! \param[in,out] dgt Counters for equation types registered into DG factory
// *****************************************************************************
{
// Construct vector of vectors for all possible policies
using CGCompFlowPolicies =
tk::cartesian_product< cg::CompFlowPhysics, CompFlowProblems >;
// Register PDEs for all combinations of policies
brigand::for_each< CGCompFlowPolicies >(
registerCG< cg::CompFlow >( cf, cgt, ctr::PDEType::COMPFLOW ) );
// Construct vector of vectors for all possible policies
using DGCompFlowPolicies =
tk::cartesian_product< dg::CompFlowPhysics, CompFlowProblems >;
// Register PDEs for all combinations of policies
brigand::for_each< DGCompFlowPolicies >(
registerDG< dg::CompFlow >( df, dgt, ctr::PDEType::COMPFLOW ) );
}
std::vector< std::pair< std::string, std::string > >
infoCompFlow( std::map< ctr::PDEType, tk::ctr::ncomp_t >& cnt )
// *****************************************************************************
// Return information on the compressible flow system of PDEs
//! \param[inout] cnt std::map of counters for all PDE types
//! \return vector of string pairs describing the PDE configuration
// *****************************************************************************
{
using eq = tag::compflow;
using tk::parameter;
using tk::parameters;
auto c = ++cnt[ ctr::PDEType::COMPFLOW ]; // count eqs
--c; // used to index vectors starting with 0
std::vector< std::pair< std::string, std::string > > nfo;
nfo.emplace_back( ctr::PDE().name( ctr::PDEType::COMPFLOW ), "" );
nfo.emplace_back( "dependent variable", std::string( 1,
g_inputdeck.get< tag::param, eq, tag::depvar >()[c] ) );
infoMesh< eq >( c, nfo );
nfo.emplace_back( "physics", ctr::Physics().name(
g_inputdeck.get< tag::param, eq, tag::physics >()[c] ) );
nfo.emplace_back( "problem", ctr::Problem().name(
g_inputdeck.get< tag::param, eq, tag::problem >()[c] ) );
auto ncomp = g_inputdeck.get< tag::component >().get< eq >()[c];
nfo.emplace_back( "number of components", parameter( ncomp ) );
const auto scheme = g_inputdeck.get< tag::discr, tag::scheme >();
if (scheme != ctr::SchemeType::DiagCG && scheme != ctr::SchemeType::ALECG)
nfo.emplace_back( "flux", ctr::Flux().name(
g_inputdeck.get< tag::param, eq, tag::flux >().at(c) ) );
nfo.emplace_back( "start offset in unknowns array", parameter(
g_inputdeck.get< tag::component >().offset< eq >(c) ) );
// Material property output
const auto& matprop = g_inputdeck.get< tag::param, eq, tag::material >()[c][0];
const auto& m_id = matprop.get< tag::id >();
ctr::Material mopt;
nfo.emplace_back( mopt.name( matprop.get< tag::eos >() ),
std::to_string(m_id.size()) );
nfo.emplace_back( "ratio of specific heats",
parameters(matprop.get< tag::gamma >()) );
const auto& cv = matprop.get< tag::cv >();<--- Shadow variable
if (!cv.empty())
nfo.emplace_back( "specific heat at constant volume",
parameters(cv) );
const auto& pstiff = matprop.get< tag::pstiff >();
if (!pstiff.empty())
nfo.emplace_back( "material stiffness",
parameters(pstiff) );
// Viscosity is optional: vector may be empty
const auto& mu = matprop.get< tag::mu >();<--- Shadow variable
if (!mu.empty())
nfo.emplace_back( "dynamic viscosity", parameters( mu ) );
// Heat conductivity is optional: vector may be empty
const auto& k = matprop.get< tag::k >();<--- Shadow variable
if (!k.empty())
nfo.emplace_back( "heat conductivity", parameters( k ) );
const auto& npar = g_inputdeck.get< tag::param, eq, tag::npar >();
if (!npar.empty())
nfo.emplace_back( "number of tracker particles", parameters( npar ) );
const auto& alpha = g_inputdeck.get< tag::param, eq, tag::alpha >();
if (!alpha.empty()) nfo.emplace_back( "coeff alpha", parameters( alpha ) );
const auto& beta =
g_inputdeck.get< tag::param, eq, tag::beta >();
if (!beta.empty())
nfo.emplace_back( "coeff beta", parameters( beta ) );
const auto& bx = g_inputdeck.get< tag::param, eq, tag::betax >();
if (!bx.empty()) nfo.emplace_back( "coeff betax", parameters( bx ) );
const auto& by = g_inputdeck.get< tag::param, eq, tag::betay >();
if (!by.empty()) nfo.emplace_back( "coeff betay", parameters( by ) );
const auto& bz = g_inputdeck.get< tag::param, eq, tag::betaz >();
if (!bz.empty()) nfo.emplace_back( "coeff betaz", parameters( bz ) );
const auto& r0 = g_inputdeck.get< tag::param, eq, tag::r0 >();
if (!r0.empty()) nfo.emplace_back( "coeff r0", parameters( r0 ) );
const auto& ce = g_inputdeck.get< tag::param, eq, tag::ce >();
if (!ce.empty()) nfo.emplace_back( "coeff ce", parameters( ce ) );
const auto& kappa = g_inputdeck.get< tag::param, eq, tag::kappa >();
if (!kappa.empty()) nfo.emplace_back( "coeff k", parameters( kappa ) );
const auto& p0 = g_inputdeck.get< tag::param, eq, tag::p0 >();
if (!p0.empty()) nfo.emplace_back( "coeff p0", parameters( p0 ) );
// ICs
const auto& ic = g_inputdeck.get< tag::param, eq, tag::ic >();
const auto& bgdensityic = ic.get< tag::density >();
if (bgdensityic.size() > c && !bgdensityic[c].empty())
nfo.emplace_back( "IC background density",
parameter( bgdensityic[c][0] ) );
const auto& bgvelocityic = ic.get< tag::velocity >();
if (bgvelocityic.size() > c && !bgvelocityic[c].empty())
nfo.emplace_back( "IC background velocity",
parameters( bgvelocityic[c] ) );
const auto& bgpressureic = ic.get< tag::pressure >();
if (bgpressureic.size() > c && !bgpressureic[c].empty())
nfo.emplace_back( "IC background pressure",
parameter( bgpressureic[c][0] ) );
const auto& bgenergyic = ic.get< tag::energy >();
if (bgenergyic.size() > c && !bgenergyic[c].empty())
nfo.emplace_back( "IC background energy",
parameter( bgenergyic[c][0] ) );
const auto& bgtemperatureic = ic.get< tag::temperature >();
if (bgtemperatureic.size() > c && !bgtemperatureic[c].empty())
nfo.emplace_back( "IC background temperature",
parameter( bgtemperatureic[c][0] ) );
const auto& icbox = ic.get< tag::box >();
if (icbox.size() > c) {
std::size_t bcnt = 0;
for (const auto& b : icbox[c]) { // for all boxes configured for this eq
std::vector< tk::real > box
{ b.get< tag::xmin >(), b.get< tag::xmax >(),
b.get< tag::ymin >(), b.get< tag::ymax >(),
b.get< tag::zmin >(), b.get< tag::zmax >() };
std::string boxname = "IC box " + parameter(bcnt);
nfo.emplace_back( boxname, parameters( box ) );
nfo.emplace_back( boxname + " density",
parameter( b.get< tag::density >() ) );
nfo.emplace_back( boxname + " velocity",
parameters( b.get< tag::velocity >() ) );
nfo.emplace_back( boxname + " pressure",
parameter( b.get< tag::pressure >() ) );
nfo.emplace_back( boxname + " internal energy per unit mass",
parameter( b.get< tag::energy >() ) );
nfo.emplace_back( boxname + " mass",
parameter( b.get< tag::mass >() ) );
nfo.emplace_back( boxname + " internal energy per unit volume",
parameter( b.get< tag::energy_content >() ) );
nfo.emplace_back( boxname + " temperature",
parameter( b.get< tag::temperature >() ) );
const auto& initiate = b.get< tag::initiate >();
const auto& inittype = initiate.get< tag::init >();
auto opt = ctr::Initiate();
nfo.emplace_back( boxname + ' ' + opt.group(), opt.name(inittype) );
if (inittype == ctr::InitiateType::LINEAR) {
nfo.emplace_back( boxname + " initiate linear point(s)",
parameters( initiate.get< tag::point >() ) );
nfo.emplace_back( boxname + " initiate linear radius",
parameter( initiate.get< tag::radius >() ) );
nfo.emplace_back( boxname + " initiate linear velocity",
parameter( initiate.get< tag::velocity >() ) );
}
++bcnt;
}
}
// BCs
const auto& stag = g_inputdeck.get< tag::param, eq, tag::stag >();
const auto& spoint = stag.get< tag::point >();
if (spoint.size() > c)
nfo.emplace_back( "Stagnation point(s)", parameters( spoint[c] ) );
const auto& sradius = stag.get< tag::radius >();
if (sradius.size() > c)
nfo.emplace_back( "Stagnation point(s) radii", parameters( sradius[c] ) );
const auto& skip = g_inputdeck.get< tag::param, eq, tag::skip >();
const auto& kpoint = skip.get< tag::point >();
if (kpoint.size() > c)
nfo.emplace_back( "Skip point(s)", parameters( kpoint[c] ) );
const auto& kradius = skip.get< tag::radius >();
if (kradius.size() > c)
nfo.emplace_back( "Skip point(s) radii", parameters( kradius[c] ) );
const auto& fs =
g_inputdeck.get< tag::param, eq, tag::bc, tag::bcfarfield >();
if (fs.size() > c) {
nfo.emplace_back( "Farfield BC sideset(s)", parameters( fs[c] ) );
const auto& fr =
g_inputdeck.get< tag::param, eq, tag::farfield_density >();
if (fr.size() > c)
nfo.emplace_back( "Farfield BC density", std::to_string(fr[c]) );
const auto& fu =
g_inputdeck.get< tag::param, eq, tag::farfield_velocity >();
if (fu.size() > c)
nfo.emplace_back( "Farfield BC velocity", parameters( fu[c] ) );
const auto& fp =
g_inputdeck.get< tag::param, eq, tag::farfield_pressure >();
if (fp.size() > c)
nfo.emplace_back( "Farfield BC pressure", std::to_string(fp[c]) );
}
const auto& sym =
g_inputdeck.get< tag::param, eq, tag::bc, tag::bcsym >();
if (sym.size() > c) {
nfo.emplace_back( "Symmetry BC sideset(s)", parameters( sym[c] ) );
const auto& sponge = g_inputdeck.get< tag::param, eq, tag::sponge >();
const auto& ss = sponge.get< tag::sideset >();
if (ss.size() > c)
nfo.emplace_back( "Sponge sideset(s)", parameters( ss[c] ) );
const auto& spvel = sponge.get< tag::velocity >();
if (spvel.size() > c)
nfo.emplace_back( "Sponge velocity parameters", parameters( spvel[c] ) );
const auto& sppre = sponge.get< tag::pressure >();
if (sppre.size() > c)
nfo.emplace_back( "Sponge pressure parameters", parameters( sppre[c] ) );
}
const auto& dir =
g_inputdeck.get< tag::param, eq, tag::bc, tag::bcdir >();
if (dir.size() > c)
nfo.emplace_back( "Dirichlet BC sideset(s)", parameters( dir[c] ) );
const auto& timedep = g_inputdeck.get< tag::param, eq, tag::bctimedep >();
if (timedep.size() > c) {
for (const auto& bndry : timedep[c]) {
nfo.emplace_back( "Time dependent BC sideset(s)",<--- Consider using std::transform algorithm instead of a raw loop.
parameters(bndry.get< tag::sideset >()) );
}
}
// FCT
auto bool_to_string = [](bool B) -> std::string {
return B ? "true" : "false";
};
const auto fct = g_inputdeck.get< tag::discr, tag::fct >();
if (scheme == ctr::SchemeType::DiagCG && fct) {
const auto& sys = g_inputdeck.get< tag::param, eq, tag::sysfct >();
if (sys.size() > c) {
nfo.emplace_back( "FCT system character", bool_to_string( sys[c] ) );
if (sys[c]) { // if system FCT is enabled for this system
const auto& sv = g_inputdeck.get< tag::param, eq, tag::sysfctvar >();
if (sv.size() > c) {
nfo.emplace_back( "System-FCT variables", parameters( sv[c] ) );
}
}
}
}
return nfo;
}
void
assignCompFlowGetVars( const std::string& name, tk::GetVarFn& f )
// *****************************************************************************
// Assign functions that compute physics variables from the numerical solution
// for CompFlow
//! \param[in] name Name of variable whose tk::GetVarFn is to be assigned
//! \param[in,out] f Function assigned
// *****************************************************************************
{
using namespace kw;
using namespace compflow;
assign< outvar_density >( name, densityOutVar, f );
assign< outvar_xvelocity >( name, velocityOutVar<0>, f );
assign< outvar_yvelocity >( name, velocityOutVar<1>, f );
assign< outvar_zvelocity >( name, velocityOutVar<2>, f );
assign< outvar_specific_total_energy >( name, specificTotalEnergyOutVar, f );
assign< outvar_volumetric_total_energy >
( name, volumetricTotalEnergyOutVar, f );
assign< outvar_xmomentum >( name, momentumOutVar<0>, f );
assign< outvar_ymomentum >( name, momentumOutVar<1>, f );
assign< outvar_zmomentum >( name, momentumOutVar<2>, f );
assign< outvar_pressure >( name, pressureOutVar, f );
}
} // inciter::
|