Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/Control/Inciter/InputDeck/LuaParser.cpp
4 : : \copyright 2019-2021 Triad National Security, LLC.
5 : : All rights reserved. See the LICENSE file for details.
6 : : \brief Inciter's lua input deck file parser
7 : : \details This file defines the input deck, i.e., control file, parser for
8 : : the computational shock hydrodynamics tool, Inciter.
9 : : */
10 : : // *****************************************************************************
11 : :
12 : : #include <ostream>
13 : : #include <type_traits>
14 : :
15 : : #include "QuinoaConfig.hpp"
16 : :
17 : : #include "NoWarning/pegtl.hpp"
18 : :
19 : : #include "Print.hpp"
20 : : #include "Exception.hpp"
21 : : #include "Inciter/InputDeck/InputDeck.hpp"
22 : : #include "Inciter/InputDeck/LuaParser.hpp"
23 : : #include "PDE/MultiMat/MultiMatIndexing.hpp"
24 : : #include "PDE/MultiSpecies/MultiSpeciesIndexing.hpp"
25 : :
26 : : namespace tk {
27 : : namespace grm {
28 : :
29 : : //! \brief Case-insensitive character comparison functor
30 : : struct CaseInsensitiveCharLess {
31 : : //! Function call operator
32 : : //! \param[in] lhs Left character of the comparitor operand
33 : : //! \param[in] rhs Right character of the comparitor operand
34 : : //! \return Boolean indicating the result of the comparison
35 : 3 : bool operator() ( char lhs, char rhs ) const {
36 : 3 : return std::tolower( lhs ) < std::tolower( rhs );
37 : : }
38 : : };
39 : :
40 : : //! \brief Parser-lifetime storage for dependent variables selected.
41 : : //! \details Used to track the dependent variable of differential equations
42 : : //! (i.e., models) assigned during parsing. It needs to be case insensitive
43 : : //! since we only care about whether the variable is selected or not and not
44 : : //! whether it denotes a full variable (upper case) or a fluctuation (lower
45 : : //! case). This is true for both inserting variables into the set as well as
46 : : //! at matching terms of products in parsing requested statistics.
47 : : static std::set< char, CaseInsensitiveCharLess > depvars;
48 : :
49 : : } // grm::
50 : : } // tk::
51 : :
52 : : using inciter::LuaParser;
53 : :
54 : 176 : LuaParser::LuaParser( const tk::Print& /*print*/,
55 : : const ctr::CmdLine& cmdline,
56 : 176 : ctr::InputDeck& inputdeck ) :
57 : 176 : m_filename( cmdline.get< tag::io, tag::control >() )
58 : : // *****************************************************************************
59 : : // Constructor
60 : : // //! \param[in] print Pretty printer
61 : : //! \param[in] cmdline Command line stack
62 : : //! \param[in,out] inputdeck Input deck stack where data is stored during
63 : : //! parsing
64 : : // *****************************************************************************
65 : : {
66 : : // Make sure there is a filename
67 [ - + ][ - - ]: 176 : Assert( !m_filename.empty(), "No filename specified" );
[ - - ][ - - ]
68 : :
69 : : // Local file stream handle
70 [ + - ]: 352 : std::ifstream q;
71 : :
72 : : // Check if file exists, throw exception if it does not
73 [ + - ]: 176 : q.open( m_filename, std::ifstream::in );
74 [ + - ][ - + ]: 176 : ErrChk( q.good(), "Failed to open file: " + m_filename );
[ - - ][ - - ]
[ - - ]
75 : :
76 : : // Attempt to read a character, throw if it fails
77 : : // It is curious that on some systems opening a directory instead of a file
78 : : // with the above ifstream::open() call does not set the failbit. Thus we get
79 : : // here fine, so we try to read a character from it. If it is a directory or
80 : : // an empty file the read will fail, so we throw. Read more at: http://
81 : : // stackoverflow.com/questions/9591036/
82 : : // ifstream-open-doesnt-set-error-bits-when-argument-is-a-directory.
83 [ + - ]: 176 : q.get();
84 [ + - ][ - + ]: 176 : ErrChk( q.good(), "Failed to read from file: " + m_filename );
[ - - ][ - - ]
[ - - ]
85 : :
86 : : // Close it
87 [ + - ]: 176 : q.close();
88 [ + - ][ - + ]: 176 : ErrChk( !q.fail(), "Failed to close file: " + m_filename );
[ - - ][ - - ]
[ - - ]
89 : :
90 : : // Create InputDeck (a tagged tuple) to store parsed input
91 [ + - ]: 352 : ctr::InputDeck ideck( cmdline );
92 : :
93 : : // Read lua file into sol object
94 [ + - ]: 352 : sol::state lua_deck;
95 [ + - ]: 176 : lua_deck.open_libraries(sol::lib::base);
96 [ + - ]: 176 : lua_deck.script_file(m_filename);
97 : :
98 : : // Store inputdeck parameters from sol object into tagged tuple
99 [ + - ][ + - ]: 176 : storeInputDeck(lua_deck["inciter"], ideck);
[ + - ]
100 : :
101 : 176 : inputdeck = std::move( ideck );
102 : 176 : }
103 : :
104 : : void
105 : 176 : LuaParser::storeInputDeck(
106 : : const sol::table& lua_ideck,
107 : : ctr::InputDeck& gideck )
108 : : // *****************************************************************************
109 : : // Store lua inputdeck in custom struct
110 : : //! \param[in] lua_ideck Lua inputdeck parsed by sol2
111 : : //! \param[in,out] gideck Inciter's inputdeck storage
112 : : // *****************************************************************************
113 : : {
114 : : // TODO: explore replacing storeIfSpecd() and storeOptIfSpecd with sol::get_or()
115 : :
116 [ + - ][ + - ]: 176 : storeIfSpecd< std::string >(
[ + - ]
117 : : lua_ideck, "title", gideck.get< tag::title >(), "No title");
118 : :
119 : : // time stepping options
120 : : // ---------------------------------------------------------------------------
121 [ + - ][ + - ]: 176 : storeIfSpecd< uint64_t >(
122 : : lua_ideck, "nstep", gideck.get< tag::nstep >(),
123 : : std::numeric_limits< uint64_t >::max());
124 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
125 : : lua_ideck, "term", gideck.get< tag::term >(),
126 : : std::numeric_limits< tk::real >::max());
127 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
128 : : lua_ideck, "t0", gideck.get< tag::t0 >(), 0.0);
129 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
130 : : lua_ideck, "dt", gideck.get< tag::dt >(), 0.0);
131 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
132 : : lua_ideck, "cfl", gideck.get< tag::cfl >(), 0.0);
133 [ + - ][ + - ]: 176 : storeIfSpecd< uint32_t >(
134 : : lua_ideck, "ttyi", gideck.get< tag::ttyi >(), 1);
135 [ + - ][ + - ]: 176 : storeIfSpecd< bool >(
136 : : lua_ideck, "steady_state", gideck.get< tag::steady_state >(), false);
137 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
138 : : lua_ideck, "residual", gideck.get< tag::residual >(), 1.0e-8);
139 [ + - ][ + - ]: 176 : storeIfSpecd< uint32_t >(
140 : : lua_ideck, "rescomp", gideck.get< tag::rescomp >(), 1);
141 [ + - ][ + - ]: 176 : storeIfSpecd< uint32_t >(
142 : : lua_ideck, "imex_runge_kutta", gideck.get< tag::imex_runge_kutta >(), 0);
143 [ + - ][ + - ]: 176 : storeIfSpecd< uint32_t >(
144 : : lua_ideck, "imex_maxiter", gideck.get< tag::imex_maxiter >(), 50);
145 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
146 : : lua_ideck, "imex_reltol", gideck.get< tag::imex_reltol >(), 1.0e-02);
147 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
148 : : lua_ideck, "imex_abstol", gideck.get< tag::imex_abstol >(), 1.0e-04);
149 : :
150 [ + + ][ - + ]: 176 : if (gideck.get< tag::dt >() < 1e-12 && gideck.get< tag::cfl >() < 1e-12)
[ - + ]
151 [ - - ][ - - ]: 0 : Throw("No time step calculation policy has been selected in the "
[ - - ]
152 : : "preceeding block. Use keyword 'dt' to set a constant or 'cfl' to set an "
153 : : "adaptive time step size calculation policy.");
154 : :
155 : : // partitioning/reordering options
156 : : // ---------------------------------------------------------------------------
157 : : storeOptIfSpecd< tk::ctr::PartitioningAlgorithmType,
158 [ + - ][ + - ]: 176 : tk::ctr::PartitioningAlgorithm >(
159 : : lua_ideck, "partitioning", gideck.get< tag::partitioning >(),
160 : : tk::ctr::PartitioningAlgorithmType::RCB);
161 [ + - ][ + - ]: 176 : storeIfSpecd< bool >(
162 : : lua_ideck, "pelocal_reorder", gideck.get< tag::pelocal_reorder >(),
163 : : false);
164 [ + - ][ + - ]: 176 : storeIfSpecd< bool >(
165 : : lua_ideck, "operator_reorder", gideck.get< tag::operator_reorder >(),
166 : : false);
167 : :
168 : : // discretization scheme options
169 : : // ---------------------------------------------------------------------------
170 : : using inciter::ctr::SchemeType;
171 [ + - ][ + - ]: 176 : storeOptIfSpecd< SchemeType, inciter::ctr::Scheme >(
172 : : lua_ideck, "scheme", gideck.get< tag::scheme >(), SchemeType::ALECG);
173 [ + - ][ + - ]: 176 : storeOptIfSpecd< inciter::ctr::LimiterType, inciter::ctr::Limiter >(
174 : : lua_ideck, "limiter", gideck.get< tag::limiter >(),
175 : : inciter::ctr::LimiterType::NOLIMITER);
176 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
177 : : lua_ideck, "cweight", gideck.get< tag::cweight >(), 1.0);
178 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
179 : : lua_ideck, "shock_detector_coeff",
180 : : gideck.get< tag::shock_detector_coeff >(), 1.0);
181 [ + - ][ + - ]: 176 : storeIfSpecd< bool >(
182 : : lua_ideck, "accuracy_test", gideck.get< tag::accuracy_test >(), false);
183 [ + - ][ + - ]: 176 : storeIfSpecd< bool >(
184 : : lua_ideck, "limsol_projection", gideck.get< tag::limsol_projection >(),
185 : : true);
186 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
187 : : lua_ideck, "lowspeed_kp", gideck.get< tag::lowspeed_kp >(), 0.0);
188 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
189 : : lua_ideck, "lowspeed_ku", gideck.get< tag::lowspeed_ku >(), 1.0);
190 : :
191 : : // configure solutions DOFs
192 : 176 : auto scheme = gideck.get< tag::scheme >();
193 : 176 : auto& ndof = gideck.get< tag::ndof >();
194 : 176 : auto& rdof = gideck.get< tag::rdof >();
195 : 176 : ndof = rdof = 1;
196 [ + + ][ + + ]: 176 : if (scheme == SchemeType::P0P1 || scheme == SchemeType::FV) {
197 : 33 : ndof = 1; rdof = 4;
198 [ + + ]: 143 : } else if (scheme == SchemeType::DGP1) {
199 : 12 : ndof = rdof = 4;
200 [ + + ]: 131 : } else if (scheme == SchemeType::DGP2) {
201 : 6 : ndof = rdof = 10;
202 [ + + ]: 125 : } else if (scheme == SchemeType::PDG) {
203 : 12 : ndof = rdof = 10;
204 : 12 : gideck.get< tag::pref, tag::pref >() = true;
205 [ + + ][ + + ]: 113 : } else if (scheme != SchemeType::DGP0 &&
206 [ - + ]: 20 : scheme != SchemeType::ALECG &&
207 : : scheme != SchemeType::OversetFE) {
208 [ - - ][ - - ]: 0 : Throw("Scheme type not configured in configure_scheme");
[ - - ]
209 : : }
210 : :
211 : : // PDE options
212 : : // ---------------------------------------------------------------------------
213 : :
214 : 176 : char depvar_cnt = 'a';
215 [ + - ]: 176 : gideck.get< tag::depvar >().resize(1);
216 : :
217 : : // check transport
218 [ + - ][ + - ]: 176 : if (lua_ideck["transport"].valid()) {
[ + + ]
219 : :
220 [ + - ][ + - ]: 17 : checkBlock< inciter::ctr::transportList::Keys >(lua_ideck["transport"],
[ + - ][ + - ]
221 : : "transport");
222 : :
223 : 17 : gideck.get< tag::pde >() = inciter::ctr::PDEType::TRANSPORT;
224 [ + - ][ + - ]: 17 : storeIfSpecd< std::size_t >(
[ + - ][ + - ]
225 : : lua_ideck["transport"], "ncomp",
226 : : gideck.get< tag::transport, tag::ncomp >(), 1);
227 [ + - ][ + - ]: 17 : storeIfSpecd< int >(
[ + - ][ + - ]
228 : : lua_ideck["transport"], "intsharp",
229 : : gideck.get< tag::transport, tag::intsharp >(), 0);
230 [ + - ][ + - ]: 17 : storeIfSpecd< tk::real >(
[ + - ][ + - ]
231 : : lua_ideck["transport"], "intsharp_param",
232 : : gideck.get< tag::transport, tag::intsharp_param >(), 1.8);
233 [ + - ][ + - ]: 17 : storeOptIfSpecd< inciter::ctr::ProblemType, inciter::ctr::Problem >(
[ + - ][ + - ]
234 : : lua_ideck["transport"], "problem",
235 : : gideck.get< tag::transport, tag::problem >(),
236 : : inciter::ctr::ProblemType::USER_DEFINED);
237 [ + - ][ + - ]: 17 : storeVecIfSpecd< tk::real >(
[ + - ][ + - ]
[ + - ]
238 : : lua_ideck["transport"], "diffusivity",
239 : : gideck.get< tag::transport, tag::diffusivity >(), {0.0, 0.0, 0.0});
240 [ + - ][ + - ]: 17 : storeVecIfSpecd< tk::real >(
[ + - ][ + - ]
[ + - ]
241 : : lua_ideck["transport"], "u0",
242 : : gideck.get< tag::transport, tag::u0 >(), {0.0, 0.0, 0.0});
243 [ + - ][ + - ]: 17 : storeVecIfSpecd< tk::real >(
[ + - ][ + - ]
[ + - ]
244 : : lua_ideck["transport"], "lambda",
245 : : gideck.get< tag::transport, tag::lambda >(), {0.0, 0.0, 0.0});
246 : 17 : gideck.get< tag::depvar >()[0] = 'c';
247 [ + - ][ + - ]: 17 : storeOptIfSpecd< inciter::ctr::FluxType, inciter::ctr::Flux >(
248 : : lua_ideck, "flux", gideck.get< tag::flux >(),
249 : : inciter::ctr::FluxType::UPWIND);
250 [ + - ][ + - ]: 17 : storeOptIfSpecd< inciter::ctr::PhysicsType, inciter::ctr::Physics >(
[ + - ][ + - ]
251 : : lua_ideck["transport"], "physics",
252 : : gideck.get< tag::transport, tag::physics >(),
253 : : inciter::ctr::PhysicsType::ADVECTION);
254 : :
255 : : // store number of equations in PDE system
256 : 17 : gideck.get< tag::ncomp >() =
257 : 17 : gideck.get< tag::transport, tag::ncomp >();
258 : : }
259 : :
260 : : // check compflow
261 [ + - ][ + - ]: 176 : if (lua_ideck["compflow"].valid()) {
[ + + ]
262 : :
263 [ + - ][ + - ]: 116 : checkBlock< inciter::ctr::compflowList::Keys >(lua_ideck["compflow"],
[ + - ][ + - ]
264 : : "compflow");
265 : :
266 : 116 : gideck.get< tag::pde >() = inciter::ctr::PDEType::COMPFLOW;
267 [ + - ][ + - ]: 116 : storeOptIfSpecd< inciter::ctr::ProblemType, inciter::ctr::Problem >(
[ + - ][ + - ]
268 : : lua_ideck["compflow"], "problem",
269 : : gideck.get< tag::compflow, tag::problem >(),
270 : : inciter::ctr::ProblemType::USER_DEFINED);
271 [ + - ][ + - ]: 116 : storeOptIfSpecd< inciter::ctr::PhysicsType, inciter::ctr::Physics >(
[ + - ][ + - ]
272 : : lua_ideck["compflow"], "physics",
273 : : gideck.get< tag::compflow, tag::physics >(),
274 : : inciter::ctr::PhysicsType::EULER);
275 : :
276 : : // problem parameters for MMS
277 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "alpha",
[ + - ][ + - ]
278 : : gideck.get< tag::compflow, tag::alpha >(), 0.0);
279 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "beta",
[ + - ][ + - ]
280 : : gideck.get< tag::compflow, tag::beta >(), 0.0);
281 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "betax",
[ + - ][ + - ]
282 : : gideck.get< tag::compflow, tag::betax >(), 0.0);
283 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "betay",
[ + - ][ + - ]
284 : : gideck.get< tag::compflow, tag::betay >(), 0.0);
285 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "betaz",
[ + - ][ + - ]
286 : : gideck.get< tag::compflow, tag::betaz >(), 0.0);
287 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "r0",
[ + - ][ + - ]
288 : : gideck.get< tag::compflow, tag::r0 >(), 0.0);
289 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "p0",
[ + - ][ + - ]
290 : : gideck.get< tag::compflow, tag::p0 >(), 0.0);
291 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "ce",
[ + - ][ + - ]
292 : : gideck.get< tag::compflow, tag::ce >(), 0.0);
293 [ + - ][ + - ]: 116 : storeIfSpecd< tk::real >(lua_ideck["compflow"], "kappa",
[ + - ][ + - ]
294 : : gideck.get< tag::compflow, tag::kappa >(), 0.0);
295 : :
296 : 116 : gideck.get< tag::depvar >()[0] = 'a';
297 [ + - ][ + - ]: 116 : storeOptIfSpecd< inciter::ctr::FluxType, inciter::ctr::Flux >(
298 : : lua_ideck, "flux", gideck.get< tag::flux >(),
299 : : inciter::ctr::FluxType::HLLC);
300 : :
301 : : // store number of equations in PDE system
302 : 116 : gideck.get< tag::ncomp >() = 5;
303 : : }
304 : :
305 : : // check multimat
306 [ + - ][ + - ]: 176 : if (lua_ideck["multimat"].valid()) {
[ + + ]
307 : :
308 [ + - ][ + - ]: 37 : checkBlock< inciter::ctr::multimatList::Keys >(lua_ideck["multimat"],
[ + - ][ + - ]
309 : : "multimat");
310 : :
311 : 37 : gideck.get< tag::pde >() = inciter::ctr::PDEType::MULTIMAT;
312 [ + - ][ + - ]: 37 : storeIfSpecd< std::size_t >(
[ + - ][ + - ]
313 : : lua_ideck["multimat"], "nmat",
314 : : gideck.get< tag::multimat, tag::nmat >(), 2);
315 [ + - ][ + - ]: 37 : storeIfSpecd< tk::real >(
[ + - ][ + - ]
316 : : lua_ideck["multimat"], "min_volumefrac",
317 : : gideck.get< tag::multimat, tag::min_volumefrac >(), 1.0e-12);
318 [ + - ][ + - ]: 37 : storeIfSpecd< uint64_t >(
[ + - ][ + - ]
319 : : lua_ideck["multimat"], "prelax",
320 : : gideck.get< tag::multimat, tag::prelax >(), 1);
321 [ + - ][ + - ]: 37 : storeIfSpecd< tk::real >(
[ + - ][ + - ]
322 : : lua_ideck["multimat"], "prelax_timescale",
323 : : gideck.get< tag::multimat, tag::prelax_timescale >(), 0.25);
324 [ + - ][ + - ]: 37 : storeIfSpecd< int >(
[ + - ][ + - ]
325 : : lua_ideck["multimat"], "intsharp",
326 : : gideck.get< tag::multimat, tag::intsharp >(), 0);
327 [ + - ][ + - ]: 37 : storeIfSpecd< tk::real >(
[ + - ][ + - ]
328 : : lua_ideck["multimat"], "intsharp_param",
329 : : gideck.get< tag::multimat, tag::intsharp_param >(), 1.8);
330 [ + - ][ + - ]: 37 : storeIfSpecd< uint64_t >(
[ + - ][ + - ]
331 : : lua_ideck["multimat"], "rho0constraint",
332 : : gideck.get< tag::multimat, tag::rho0constraint >(), 1);
333 [ + - ][ + - ]: 37 : storeIfSpecd< int >(
[ + - ][ + - ]
334 : : lua_ideck["multimat"], "dt_sos_massavg",
335 : : gideck.get< tag::multimat, tag::dt_sos_massavg >(), 0);
336 [ + - ][ + - ]: 37 : storeOptIfSpecd< inciter::ctr::ProblemType, inciter::ctr::Problem >(
[ + - ][ + - ]
337 : : lua_ideck["multimat"], "problem",
338 : : gideck.get< tag::multimat, tag::problem >(),
339 : : inciter::ctr::ProblemType::USER_DEFINED);
340 [ + - ][ + - ]: 37 : storeOptIfSpecd< inciter::ctr::PhysicsType, inciter::ctr::Physics >(
[ + - ][ + - ]
341 : : lua_ideck["multimat"], "physics",
342 : : gideck.get< tag::multimat, tag::physics >(),
343 : : inciter::ctr::PhysicsType::EULER);
344 : 37 : gideck.get< tag::depvar >()[0] = 'a';
345 [ + - ][ + - ]: 37 : storeOptIfSpecd< inciter::ctr::FluxType, inciter::ctr::Flux >(
346 : : lua_ideck, "flux", gideck.get< tag::flux >(),
347 : : inciter::ctr::FluxType::AUSM);
348 : :
349 : : // number of equations in PDE system are determined based on materials
350 : : }
351 : :
352 : : // check multispecies
353 [ + - ][ + - ]: 176 : if (lua_ideck["multispecies"].valid()) {
[ + + ]
354 : :
355 [ + - ][ + - ]: 6 : checkBlock< inciter::ctr::multispeciesList::Keys >(lua_ideck["multispecies"],
[ + - ][ + - ]
356 : : "multispecies");
357 : :
358 : 6 : gideck.get< tag::pde >() = inciter::ctr::PDEType::MULTISPECIES;
359 [ + - ][ + - ]: 6 : storeIfSpecd< std::size_t >(
[ + - ][ + - ]
360 : : lua_ideck["multispecies"], "nspec",
361 : : gideck.get< tag::multispecies, tag::nspec >(), 1);
362 [ + - ][ + - ]: 6 : storeOptIfSpecd< inciter::ctr::ProblemType, inciter::ctr::Problem >(
[ + - ][ + - ]
363 : : lua_ideck["multispecies"], "problem",
364 : : gideck.get< tag::multispecies, tag::problem >(),
365 : : inciter::ctr::ProblemType::USER_DEFINED);
366 [ + - ][ + - ]: 6 : storeOptIfSpecd< inciter::ctr::PhysicsType, inciter::ctr::Physics >(
[ + - ][ + - ]
367 : : lua_ideck["multispecies"], "physics",
368 : : gideck.get< tag::multispecies, tag::physics >(),
369 : : inciter::ctr::PhysicsType::EULER);
370 : 6 : gideck.get< tag::depvar >()[0] = 'a';
371 [ + - ][ + - ]: 6 : storeOptIfSpecd< inciter::ctr::FluxType, inciter::ctr::Flux >(
372 : : lua_ideck, "flux", gideck.get< tag::flux >(),
373 : : inciter::ctr::FluxType::AUSM);
374 : :
375 : : // store number of equations in PDE system
376 : : // nspec: species mass conservation equations,
377 : : // 3: momentum equations,
378 : : // 1: total energy equation.
379 : 6 : gideck.get< tag::ncomp >() =
380 : 6 : gideck.get< tag::multispecies, tag::nspec >() + 3 + 1;
381 : : }
382 : :
383 : : // number of species, for future use
384 : 176 : std::size_t nspec(1);
385 [ + + ]: 176 : if (gideck.get< tag::pde >() == inciter::ctr::PDEType::MULTISPECIES)
386 : 6 : nspec = gideck.get< tag::multispecies, tag::nspec >();
387 : :
388 : : // add depvar to deck::depvars so it can be selected as outvar later
389 [ + - ]: 176 : tk::grm::depvars.insert( gideck.get< tag::depvar >()[0] );
390 : :
391 : : // Assemble material blocks
392 : : // ---------------------------------------------------------------------------
393 : :
394 : : // solid counters
395 : 176 : std::size_t tmat(0), imatcntr(0), mtypei(0), isolcntr(0);
396 : 176 : bool is_solid(false);
397 : 352 : std::set< std::size_t > matidset;
398 : :
399 : : // material vector
400 [ + - ][ + - ]: 176 : if (lua_ideck["material"].valid()) {
[ + + ]
401 : :
402 : : // size material map vectors
403 : 159 : std::size_t nmat(1);
404 [ + + ]: 159 : if (gideck.get< tag::pde >() == inciter::ctr::PDEType::MULTIMAT)
405 : 37 : nmat = gideck.get< tag::multimat, tag::nmat >();
406 [ + - ]: 159 : gideck.get< tag::matidxmap, tag::eosidx >().resize(nmat);
407 [ + - ]: 159 : gideck.get< tag::matidxmap, tag::matidx >().resize(nmat);
408 [ + - ]: 159 : gideck.get< tag::matidxmap, tag::solidx >().resize(nmat);
409 : :
410 : : // size material vector appropriately
411 : : // size of the material vector is the number of distinct types of materials
412 [ + - ][ + - ]: 318 : sol::table sol_mat = lua_ideck["material"];
413 [ + - ][ + - ]: 159 : gideck.get< tag::material >().resize(sol_mat.size());
414 : : // species vector size is one, since all species are only of one type for now
415 [ + - ]: 159 : gideck.get< tag::species >().resize(1);
416 : :
417 : : // store material properties
418 [ + + ]: 318 : for (std::size_t i=0; i<gideck.get< tag::material >().size(); ++i) {
419 : :
420 [ + - ][ + - ]: 159 : checkBlock< inciter::ctr::materialList::Keys >(sol_mat[i+1], "material");
[ + - ][ + - ]
421 : :
422 : 159 : auto& mati_deck = gideck.get< tag::material >()[i];
423 : : // eos
424 [ + - ][ + - ]: 477 : storeOptIfSpecd< inciter::ctr::MaterialType, inciter::ctr::Material >(
[ + - ]
425 [ + - ]: 318 : sol_mat[i+1], "eos", mati_deck.get< tag::eos >(),
426 : : inciter::ctr::MaterialType::STIFFENEDGAS);
427 : :
428 : : // material ids in this eos (default is for compflow i.e. single mat)
429 [ + - ][ + - ]: 477 : storeVecIfSpecd< uint64_t >(
[ + - ]
430 [ + - ]: 318 : sol_mat[i+1], "id", mati_deck.get< tag::id >(),
431 [ + - ]: 318 : std::vector< uint64_t >(1,1));
432 : :
433 : : // Track total number of materials in multiple material blocks (eos's)
434 : 159 : tmat += mati_deck.get< tag::id >().size();
435 : :
436 : : // Check for repeating user specified material ids
437 [ + + ]: 375 : for (auto midx : mati_deck.get< tag::id >()) {
438 [ + - ][ + - ]: 216 : if (!matidset.count(midx))
439 [ + - ]: 216 : matidset.insert(midx);
440 : : else
441 [ - - ][ - - ]: 0 : Throw("Repeating material id specified");
[ - - ]
442 : : }
443 : :
444 : 159 : std::size_t ntype = mati_deck.get< tag::id >().size();
445 : : // cv
446 [ + - ][ + - ]: 159 : if (!sol_mat[i+1]["cv"].valid())
[ + - ][ + + ]
447 [ + - ][ + - ]: 132 : sol_mat[i+1]["cv"] = std::vector< tk::real >(ntype, 717.5);
[ + - ][ + - ]
448 [ + - ][ + - ]: 159 : checkStoreMatProp(sol_mat[i+1], "cv", ntype, mati_deck.get< tag::cv >());
[ + - ][ + - ]
449 : :
450 : : // reset solid-marker
451 : 159 : is_solid = false;
452 : :
453 : : // Stiffened-gas materials
454 [ + + ]: 159 : if (mati_deck.get< tag::eos >() ==
455 : : inciter::ctr::MaterialType::STIFFENEDGAS) {
456 : : // gamma
457 [ + - ][ + - ]: 153 : checkStoreMatProp(sol_mat[i+1], "gamma", ntype,
[ + - ][ + - ]
458 : : mati_deck.get< tag::gamma >());
459 : :
460 : : // pstiff
461 [ + - ][ + - ]: 153 : if (!sol_mat[i+1]["pstiff"].valid())
[ + - ][ + + ]
462 [ + - ][ + - ]: 149 : sol_mat[i+1]["pstiff"] = std::vector< tk::real >(ntype, 0.0);
[ + - ][ + - ]
463 [ + - ][ + - ]: 153 : checkStoreMatProp(sol_mat[i+1], "pstiff", ntype,
[ + - ][ + - ]
464 : : mati_deck.get< tag::pstiff >());
465 : :
466 : : // mu (dynamic viscosity) and 'viscous' keyword
467 [ + - ][ + - ]: 153 : if (!sol_mat[i+1]["mu"].valid())
[ + - ][ + - ]
468 [ + - ][ + - ]: 153 : sol_mat[i+1]["mu"] = std::vector< tk::real >(ntype, 0.0);
[ + - ][ + - ]
469 : 0 : else gideck.get< tag::multimat, tag::viscous >() = true;
470 [ + - ][ + - ]: 153 : checkStoreMatProp(sol_mat[i+1], "mu", ntype, mati_deck.get< tag::mu >());
[ + - ][ + - ]
471 : : }
472 : : // Small-shear solid materials
473 [ - + ]: 6 : else if (mati_deck.get< tag::eos >() ==
474 : : inciter::ctr::MaterialType::SMALLSHEARSOLID) {
475 : : // gamma
476 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "gamma", ntype,
[ - - ][ - - ]
477 : : mati_deck.get< tag::gamma >());
478 : :
479 : : // pstiff
480 [ - - ][ - - ]: 0 : if (!sol_mat[i+1]["pstiff"].valid())
[ - - ][ - - ]
481 [ - - ][ - - ]: 0 : sol_mat[i+1]["pstiff"] = std::vector< tk::real >(ntype, 0.0);
[ - - ][ - - ]
482 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "pstiff", ntype,
[ - - ][ - - ]
483 : : mati_deck.get< tag::pstiff >());
484 : :
485 : : // mu
486 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "mu", ntype,
[ - - ][ - - ]
487 : : mati_deck.get< tag::mu >());
488 : :
489 : : // yield_stress
490 [ - - ][ - - ]: 0 : if (!sol_mat[i+1]["yield_stress"].valid())
[ - - ][ - - ]
491 : 0 : sol_mat[i+1]["yield_stress"] =
492 [ - - ][ - - ]: 0 : std::vector< tk::real >(ntype, 300.0e+06);
[ - - ][ - - ]
493 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "yield_stress", ntype,
[ - - ][ - - ]
494 : : mati_deck.get< tag::yield_stress >());
495 : :
496 : : // assign solid
497 : 0 : is_solid = true;
498 : : }
499 : : // Wilkins aluminum materials
500 [ - + ]: 6 : else if (mati_deck.get< tag::eos >() ==
501 : : inciter::ctr::MaterialType::WILKINSALUMINUM) {
502 : : // gamma
503 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "gamma", ntype,
[ - - ][ - - ]
504 : : mati_deck.get< tag::gamma >());
505 : :
506 : : // mu
507 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "mu", ntype,
[ - - ][ - - ]
508 : : mati_deck.get< tag::mu >());
509 : :
510 : : // yield_stress
511 [ - - ][ - - ]: 0 : if (!sol_mat[i+1]["yield_stress"].valid())
[ - - ][ - - ]
512 : 0 : sol_mat[i+1]["yield_stress"] =
513 [ - - ][ - - ]: 0 : std::vector< tk::real >(ntype, 300.0e+06);
[ - - ][ - - ]
514 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "yield_stress", ntype,
[ - - ][ - - ]
515 : : mati_deck.get< tag::yield_stress >());
516 : :
517 : : // assign solid
518 : 0 : is_solid = true;
519 : : }
520 : : // Godunov-Romenski materials
521 [ - + ]: 6 : else if (mati_deck.get< tag::eos >() ==
522 : : inciter::ctr::MaterialType::GODUNOVROMENSKI) {
523 : : // gamma
524 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "gamma", ntype,
[ - - ][ - - ]
525 : : mati_deck.get< tag::gamma >());
526 : :
527 : : // mu
528 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "mu", ntype,
[ - - ][ - - ]
529 : : mati_deck.get< tag::mu >());
530 : :
531 : : // rho0_jwl
532 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "rho0_jwl", ntype,
[ - - ][ - - ]
533 : : mati_deck.get< tag::rho0_jwl >());
534 : :
535 : : // alpha
536 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "alpha", ntype,
[ - - ][ - - ]
537 : : mati_deck.get< tag::alpha >());
538 : :
539 : : // K0
540 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "K0", ntype,
[ - - ][ - - ]
541 : : mati_deck.get< tag::K0 >());
542 : :
543 : : // yield_stress
544 [ - - ][ - - ]: 0 : if (!sol_mat[i+1]["yield_stress"].valid())
[ - - ][ - - ]
545 : 0 : sol_mat[i+1]["yield_stress"] =
546 [ - - ][ - - ]: 0 : std::vector< tk::real >(ntype, 300.0e+06);
[ - - ][ - - ]
547 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "yield_stress", ntype,
[ - - ][ - - ]
548 : : mati_deck.get< tag::yield_stress >());
549 : :
550 : : // assign solid
551 : 0 : is_solid = true;
552 : : }
553 : : // JWL materials
554 [ - + ]: 6 : else if (mati_deck.get< tag::eos >() == inciter::ctr::MaterialType::JWL) {
555 : : // w_gru
556 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "w_gru", ntype,
[ - - ][ - - ]
557 : : mati_deck.get< tag::w_gru >());
558 : :
559 : : // a_jwl
560 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "A_jwl", ntype,
[ - - ][ - - ]
561 : : mati_deck.get< tag::A_jwl >());
562 : :
563 : : // b_jwl
564 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "B_jwl", ntype,
[ - - ][ - - ]
565 : : mati_deck.get< tag::B_jwl >());
566 : :
567 : : // R1_jwl
568 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "R1_jwl", ntype,
[ - - ][ - - ]
569 : : mati_deck.get< tag::R1_jwl >());
570 : :
571 : : // R2_jwl
572 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "R2_jwl", ntype,
[ - - ][ - - ]
573 : : mati_deck.get< tag::R2_jwl >());
574 : :
575 : : // rho0_jwl
576 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "rho0_jwl", ntype,
[ - - ][ - - ]
577 : : mati_deck.get< tag::rho0_jwl >());
578 : :
579 : : // de_jwl
580 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "de_jwl", ntype,
[ - - ][ - - ]
581 : : mati_deck.get< tag::de_jwl >());
582 : :
583 : : // Pr_jwl
584 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "Pr_jwl", ntype,
[ - - ][ - - ]
585 : : mati_deck.get< tag::Pr_jwl >());
586 : :
587 : : // rhor_jwl
588 [ - - ][ - - ]: 0 : if (sol_mat[i+1]["rhor_jwl"].valid()) {
[ - - ][ - - ]
589 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "rhor_jwl", ntype,
[ - - ][ - - ]
590 : : mati_deck.get< tag::rhor_jwl >());
591 : : }
592 : : // Tr_jwl
593 [ - - ][ - - ]: 0 : else if (sol_mat[i+1]["Tr_jwl"].valid()) {
[ - - ][ - - ]
594 [ - - ][ - - ]: 0 : checkStoreMatProp(sol_mat[i+1], "Tr_jwl", ntype,
[ - - ][ - - ]
595 : : mati_deck.get< tag::Tr_jwl >());
596 : : }
597 : : else
598 [ - - ][ - - ]: 0 : Throw("Either reference density or reference temperature must be "
[ - - ]
599 : : "specified for JWL equation of state (EOS).");
600 : : }
601 : : // Thermally-perfect gas materials
602 [ + - ]: 6 : else if (mati_deck.get< tag::eos >() ==
603 : : inciter::ctr::MaterialType::THERMALLYPERFECTGAS) {
604 : :
605 [ + - ][ + - ]: 6 : if (!lua_ideck["species"].valid())
[ - + ]
606 [ - - ][ - - ]: 0 : Throw("Species block must be specified for thermally perfect gas");
[ - - ]
607 [ + - ][ + - ]: 6 : sol::table sol_spc = lua_ideck["species"];
608 : :
609 : : // We have assumed that nmat == 1 always for multi species, and that
610 : : // all species are of a single type, so that the outer species vector
611 : : // is of size one
612 : 6 : auto& spci_deck = gideck.get< tag::species >()[0];
613 : :
614 : : // species ids (default is for single species)
615 [ + - ][ + - ]: 18 : storeVecIfSpecd< uint64_t >(
[ + - ]
616 [ + - ]: 12 : sol_spc[i+1], "id", spci_deck.get< tag::id >(),
617 [ + - ]: 12 : std::vector< uint64_t >(1,1));
618 : :
619 [ - + ][ - - ]: 6 : Assert(nspec == spci_deck.get< tag::id >().size(),
[ - - ][ - - ]
620 : : "Number of ids in species-block not equal to number of species");
621 : :
622 : : // R
623 [ + - ][ + - ]: 6 : checkStoreMatProp(sol_spc[i+1], "R", nspec,
[ + - ][ + - ]
624 : : spci_deck.get< tag::R >());
625 : : // cp_coeff
626 [ + - ][ + - ]: 6 : checkStoreMatPropVecVec(sol_spc[i+1], "cp_coeff", nspec, 3, 8,
[ + - ][ + - ]
627 : : spci_deck.get< tag::cp_coeff >());
628 : : // t_range
629 [ + - ][ + - ]: 6 : checkStoreMatPropVec(sol_spc[i+1], "t_range", nspec, 4,
[ + - ][ + - ]
630 : : spci_deck.get< tag::t_range >());
631 : : // dH_ref
632 [ + - ][ + - ]: 6 : checkStoreMatProp(sol_spc[i+1], "dH_ref", nspec,
[ + - ][ + - ]
633 : : spci_deck.get< tag::dH_ref >());
634 : : }
635 : :
636 : : // Generate mapping between material index and eos parameter index
637 : 159 : auto& eosmap = gideck.get< tag::matidxmap, tag::eosidx >();
638 : 159 : auto& idxmap = gideck.get< tag::matidxmap, tag::matidx >();
639 : 159 : auto& solidxmap = gideck.get< tag::matidxmap, tag::solidx >();
640 [ + + ]: 375 : for (auto midx : mati_deck.get< tag::id >()) {
641 : 216 : midx -= 1;
642 : 216 : eosmap[midx] = mtypei;
643 : 216 : idxmap[midx] = imatcntr;
644 [ - + ]: 216 : if (is_solid) {
645 : : // add to solid-counter
646 : 0 : ++isolcntr;
647 : 0 : solidxmap[midx] = isolcntr;
648 : : }
649 : 216 : ++imatcntr;
650 : : }
651 : : // end of materials for this eos, thus reset index counter
652 : 159 : imatcntr = 0;
653 : : // increment material-type/eos-type index counter
654 : 159 : ++mtypei;
655 : : }
656 : :
657 : : // Error checking on material ids
658 : : // -------------------------------------------------------------------------
659 : :
660 : : // Total number of materials
661 [ - + ]: 159 : if (tmat != nmat)
662 [ - - ][ - - ]: 0 : Throw("The total number of materials in all the material blocks (" +
[ - - ][ - - ]
[ - - ]
663 : : std::to_string(tmat) +
664 : : ") is not equal to the number of materials specified 'nmat'.");
665 : :
666 : : // Contiguous and 1-based material ids
667 [ - + ]: 159 : if (*matidset.begin() != 1)
668 [ - - ][ - - ]: 0 : Throw("Material ids specified in material blocks not one-based. "
[ - - ]
669 : : "Material ids must begin with one.");
670 : 159 : std::size_t icount(1);
671 [ + + ]: 375 : for (auto midx : matidset) {
672 [ - + ]: 216 : if (midx != icount)
673 [ - - ][ - - ]: 0 : Throw("Material ids specified in material blocks have a gap. "
[ - - ]
674 : : "Material ids must be contiguous.");
675 : 216 : ++icount;
676 : : }
677 : :
678 : : // Set up number of PDEs for multimat
679 [ + + ]: 159 : if (gideck.get< tag::pde >() == inciter::ctr::PDEType::MULTIMAT) {
680 : 37 : auto ntot = nmat + nmat + 3 + nmat;
681 : : // if solid EOS, add components
682 : 37 : const auto& solidx = gideck.get< tag::matidxmap, tag::solidx >();
683 [ + + ]: 131 : for (std::size_t i=0; i<solidx.size(); ++i) {
684 [ - + ]: 94 : if (solidx[i] > 0)
685 : 0 : ntot += 9;
686 : : }
687 : 37 : gideck.get< tag::ncomp >() = ntot;
688 : : }
689 : : }
690 : :
691 : : // Mesh specification block (for overset)
692 : : // ---------------------------------------------------------------------------
693 [ + - ][ + - ]: 176 : if (lua_ideck["mesh"].valid()) {
[ + + ]
694 [ + - ][ + - ]: 22 : const sol::table& lua_mesh = lua_ideck["mesh"];
695 : 11 : auto& mesh_deck = gideck.get< tag::mesh >();
696 [ + - ][ + - ]: 11 : mesh_deck.resize(lua_mesh.size());
697 : :
698 [ + + ]: 23 : for (std::size_t i=0; i<mesh_deck.size(); ++i) {
699 : :
700 [ + - ][ + - ]: 12 : checkBlock< inciter::ctr::meshList::Keys >(lua_mesh[i+1], "mesh");
[ + - ][ + - ]
701 : :
702 : : // filename
703 [ + - ][ + - ]: 24 : storeIfSpecd< std::string >(lua_mesh[i+1], "filename",
[ + - ][ + - ]
[ + - ]
704 : 12 : mesh_deck[i].get< tag::filename >(), "");
705 : :
706 : : // location
707 [ + - ][ + - ]: 24 : storeVecIfSpecd< tk::real >(lua_mesh[i+1], "location",
[ + - ][ + - ]
[ + - ]
708 : 12 : mesh_deck[i].get< tag::location >(), {0.0, 0.0, 0.0});
709 [ - + ]: 12 : if (mesh_deck[i].get< tag::location >().size() != 3)
710 [ - - ][ - - ]: 0 : Throw("Mesh location requires 3 coordinates.");
[ - - ]
711 : :
712 : : // orientation
713 [ + - ][ + - ]: 24 : storeVecIfSpecd< tk::real >(lua_mesh[i+1], "orientation",
[ + - ][ + - ]
[ + - ]
714 : 12 : mesh_deck[i].get< tag::orientation >(), {0.0, 0.0, 0.0});
715 [ - + ]: 12 : if (mesh_deck[i].get< tag::orientation >().size() != 3)
716 [ - - ][ - - ]: 0 : Throw("Mesh orientation requires 3 rotation angles.");
[ - - ]
717 : :
718 : : // mass
719 [ + - ][ + - ]: 12 : storeIfSpecd< tk::real >(lua_mesh[i+1], "mass",
[ + - ][ + - ]
720 : 12 : mesh_deck[i].get< tag::mass >(), 0.0);
721 : :
722 : : // moment of inertia. this is currently only configured for planar motion
723 [ + - ][ + - ]: 12 : storeIfSpecd< tk::real >(lua_mesh[i+1], "moment_of_inertia",
[ + - ][ + - ]
724 : 12 : mesh_deck[i].get< tag::moment_of_inertia >(), 0.0);
725 : :
726 : : // center of mass
727 [ + - ][ + - ]: 24 : storeVecIfSpecd< tk::real >(lua_mesh[i+1], "center_of_mass",
[ + - ][ + - ]
[ + - ]
728 : 12 : mesh_deck[i].get< tag::center_of_mass >(), {0.0, 0.0, 0.0});
729 [ - + ]: 12 : if (mesh_deck[i].get< tag::center_of_mass >().size() != 3)
730 [ - - ][ - - ]: 0 : Throw("Mesh center of mass requires 3 coordinates.");
[ - - ]
731 : :
732 : : // Transfer object
733 [ + + ]: 12 : if (i > 0) {
734 [ + - ]: 1 : gideck.get< tag::transfer >().emplace_back( 0, i );
735 : :
736 : : // assign depvar
737 : 1 : ++depvar_cnt;
738 [ + - ]: 1 : gideck.get< tag::depvar >().push_back(depvar_cnt);
739 : :
740 : : // add depvar to deck::depvars so it can be selected as outvar later
741 [ + - ]: 1 : tk::grm::depvars.insert(depvar_cnt);
742 : : }
743 : : }
744 : : }
745 : : else {
746 : : // TODO: remove double-specification of defaults
747 : 165 : auto& mesh_deck = gideck.get< tag::mesh >();
748 [ + - ]: 165 : mesh_deck.resize(1);
749 : 165 : mesh_deck[0].get< tag::filename >() =
750 [ + - ]: 330 : gideck.get< tag::cmd, tag::io, tag::input >();
751 [ + - ]: 165 : mesh_deck[0].get< tag::location >() = {0.0, 0.0, 0.0};
752 [ + - ]: 165 : mesh_deck[0].get< tag::orientation >() = {0.0, 0.0, 0.0};
753 : 165 : mesh_deck[0].get< tag::mass >() = 0.0;
754 : 165 : mesh_deck[0].get< tag::moment_of_inertia >() = 0.0;
755 [ + - ]: 165 : mesh_deck[0].get< tag::center_of_mass >() = {0.0, 0.0, 0.0};
756 : : }
757 : :
758 [ - + ][ - - ]: 176 : Assert(gideck.get< tag::mesh >().size() == gideck.get< tag::depvar >().size(),
[ - - ][ - - ]
759 : : "Number of depvar not equal to the number of meshes.");
760 : :
761 : : // Rigid body motion block for overset meshes
762 : : // ---------------------------------------------------------------------------
763 [ + - ][ + - ]: 176 : if (lua_ideck["rigid_body_motion"].valid()) {
[ - + ]
764 : :
765 [ - - ][ - - ]: 0 : Assert(gideck.get< tag::mesh >().size() > 1,
[ - - ][ - - ]
766 : : "Multiple meshes (overset) needed for rigid body motion.");
767 : :
768 : : // check that rigid body mass is provided
769 [ - - ]: 0 : const auto mesh_deck = gideck.get< tag::mesh >();
770 [ - - ]: 0 : for (std::size_t i=1; i<mesh_deck.size(); ++i) {
771 [ - - ][ - - ]: 0 : Assert(mesh_deck[i].get< tag::mass >() > 1e-10,
[ - - ][ - - ]
772 : : "Mass of body required for overset meshes with rigid body motion.");
773 : : }
774 : :
775 : 0 : auto& rbm_deck = gideck.get< tag::rigid_body_motion >();
776 : :
777 : 0 : rbm_deck.get< tag::rigid_body_movt >() = true;
778 : :
779 : : // degrees of freedom
780 [ - - ][ - - ]: 0 : storeIfSpecd< std::size_t >(
[ - - ][ - - ]
781 : : lua_ideck["rigid_body_motion"], "rigid_body_dof",
782 : : rbm_deck.get< tag::rigid_body_dof >(), 3);
783 [ - - ][ - - ]: 0 : if (rbm_deck.get< tag::rigid_body_dof >() != 3 &&
784 [ - - ]: 0 : rbm_deck.get< tag::rigid_body_dof >() != 6)
785 [ - - ][ - - ]: 0 : Throw("Only 3 or 6 rigid body DOFs supported.");
[ - - ]
786 : :
787 : : // symmetry plane
788 [ - - ][ - - ]: 0 : storeIfSpecd< std::size_t >(
[ - - ][ - - ]
789 : : lua_ideck["rigid_body_motion"], "symmetry_plane",
790 : : rbm_deck.get< tag::symmetry_plane >(), 0);
791 [ - - ]: 0 : if (rbm_deck.get< tag::symmetry_plane >() > 3)
792 [ - - ][ - - ]: 0 : Throw("Rigid body motion symmetry plane must be 1(x), 2(y), or 3(z).");
[ - - ]
793 [ - - ][ - - ]: 0 : if (rbm_deck.get< tag::symmetry_plane >() == 0 &&
794 [ - - ]: 0 : rbm_deck.get< tag::rigid_body_dof >() == 3)
795 [ - - ][ - - ]: 0 : Throw(
[ - - ]
796 : : "Rigid body motion symmetry plane must be specified for 3 DOF motion.");
797 : : // reset to 0-based indexing
798 : 0 : rbm_deck.get< tag::symmetry_plane >() -= 1;
799 : : }
800 : : else {
801 : : // TODO: remove double-specification of defaults
802 : 176 : auto& rbm_deck = gideck.get< tag::rigid_body_motion >();
803 : 176 : rbm_deck.get< tag::rigid_body_movt >() = false;
804 : 176 : rbm_deck.get< tag::rigid_body_dof >() = 0;
805 : 176 : rbm_deck.get< tag::symmetry_plane >() = 0;
806 : : }
807 : :
808 : : // Field output block
809 : : // ---------------------------------------------------------------------------
810 [ + - ][ + - ]: 176 : if (lua_ideck["field_output"].valid()) {
[ + - ]
811 : :
812 [ + - ][ + - ]: 176 : checkBlock< inciter::ctr::fieldOutputList::Keys >(lua_ideck["field_output"],
[ + - ][ + - ]
813 : : "field_output");
814 : :
815 : 176 : auto& fo_deck = gideck.get< tag::field_output >();
816 : :
817 : : // interval iteration
818 [ + - ][ + - ]: 176 : storeIfSpecd< uint32_t >(
[ + - ][ + - ]
819 : : lua_ideck["field_output"], "interval",
820 : : fo_deck.get< tag::interval >(),
821 : : std::numeric_limits< uint32_t >::max());
822 : :
823 : : // interval physical time
824 [ + - ][ + - ]: 176 : storeIfSpecd< tk::real >(
[ + - ][ + - ]
825 : : lua_ideck["field_output"], "time_interval",
826 : : fo_deck.get< tag::time_interval >(),
827 : : std::numeric_limits< tk::real >::max());
828 : :
829 : : // interval time range
830 [ + - ][ + - ]: 176 : storeVecIfSpecd< tk::real >(
[ + - ][ + - ]
831 : : lua_ideck["field_output"], "time_range",
832 : : fo_deck.get< tag::time_range >(), {});
833 : :
834 : : // refined mesh field output
835 [ + - ][ + - ]: 176 : storeIfSpecd< bool >(
[ + - ][ + - ]
836 : : lua_ideck["field_output"], "refined", fo_deck.get< tag::refined >(),
837 : : false);
838 : 176 : gideck.get< tag::cmd, tag::io, tag::refined >() = fo_deck.get< tag::refined >();
839 : :
840 : : // filetype
841 [ + - ][ + - ]: 176 : storeOptIfSpecd< tk::ctr::FieldFileType, tk::ctr::FieldFile >(
[ + - ][ + - ]
842 : : lua_ideck["field_output"], "filetype", fo_deck.get< tag::filetype >(),
843 : : tk::ctr::FieldFileType::EXODUSII);
844 : :
845 : : // sidesets for field output
846 [ + - ][ + - ]: 176 : storeVecIfSpecd< uint64_t >(
[ + - ][ + - ]
847 : : lua_ideck["field_output"], "sideset", fo_deck.get< tag::sideset >(), {});
848 : :
849 : : // Assign outvar
850 : 176 : auto& foutvar = fo_deck.get< tag::outvar >();
851 : 176 : std::size_t nevar(0), nnvar(0), tensorcompvar(0);
852 : 176 : std::size_t nmat(1);
853 [ + + ]: 176 : if (gideck.get< tag::pde >() == inciter::ctr::PDEType::MULTIMAT)
854 : 37 : nmat = gideck.get< tag::multimat, tag::nmat >();
855 : :
856 : : // elem aliases
857 : 352 : std::vector< std::string > elemalias;
858 [ + - ][ + - ]: 176 : if (lua_ideck["field_output"]["elemvar"].valid())
[ + - ][ + + ]
859 [ + - ][ + - ]: 82 : nevar = sol::table(lua_ideck["field_output"]["elemvar"]).size();
[ + - ][ + - ]
860 [ + - ][ + - ]: 176 : storeVecIfSpecd< std::string >(
[ + - ][ + - ]
861 : : lua_ideck["field_output"], "elemalias", elemalias,
862 [ + - ][ + - ]: 352 : std::vector< std::string >(nevar, ""));
863 : :
864 : : // node aliases
865 : 352 : std::vector< std::string > nodealias;
866 [ + - ][ + - ]: 176 : if (lua_ideck["field_output"]["nodevar"].valid())
[ + - ][ + + ]
867 [ + - ][ + - ]: 30 : nnvar = sol::table(lua_ideck["field_output"]["nodevar"]).size();
[ + - ][ + - ]
868 [ + - ][ + - ]: 176 : storeVecIfSpecd< std::string >(
[ + - ][ + - ]
869 : : lua_ideck["field_output"], "nodealias", nodealias,
870 [ + - ][ + - ]: 352 : std::vector< std::string >(nnvar, ""));
871 : :
872 : : // error check on aliases
873 [ - + ]: 176 : if (elemalias.size() != nevar)
874 [ - - ][ - - ]: 0 : Throw("elemalias should have the same size as elemvar.");
[ - - ]
875 [ - + ]: 176 : if (nodealias.size() != nnvar)
876 [ - - ][ - - ]: 0 : Throw("nodealias should have the same size as nodevar.");
[ - - ]
877 : :
878 : : // element variables
879 [ + - ][ + - ]: 176 : if (lua_ideck["field_output"]["elemvar"].valid()) {
[ + - ][ + + ]
880 [ + + ]: 502 : for (std::size_t i=0; i<nevar; ++i) {
881 [ + - ][ + - ]: 840 : std::string varname(lua_ideck["field_output"]["elemvar"][i+1]);
[ + - ][ + - ]
882 [ + - ]: 840 : std::string alias(elemalias[i]);
883 : : // add extra outvars for tensor components
884 [ - + ]: 420 : if (varname.find("_tensor") != std::string::npos) tensorcompvar += 8;
885 [ + - ]: 420 : addOutVar(varname, alias, gideck.get< tag::depvar >(), nmat,
886 : 420 : nspec, gideck.get< tag::pde >(), tk::Centering::ELEM, foutvar);
887 : : }
888 : : }
889 : :
890 : : // node variables
891 [ + - ][ + - ]: 176 : if (lua_ideck["field_output"]["nodevar"].valid()) {
[ + - ][ + + ]
892 [ + + ]: 220 : for (std::size_t i=0; i<nnvar; ++i) {
893 [ + - ][ + - ]: 380 : std::string varname(lua_ideck["field_output"]["nodevar"][i+1]);
[ + - ][ + - ]
894 [ + - ]: 380 : std::string alias(nodealias[i]);
895 : : // add extra outvars for tensor components
896 [ - + ]: 190 : if (varname.find("_tensor") != std::string::npos) tensorcompvar += 8;
897 [ + - ]: 190 : addOutVar(varname, alias, gideck.get< tag::depvar >(), nmat,
898 : 190 : nspec, gideck.get< tag::pde >(), tk::Centering::NODE, foutvar);
899 : : }
900 : : }
901 : :
902 [ - + ][ - - ]: 176 : Assert(foutvar.size() == (nevar + nnvar + tensorcompvar),
[ - - ][ - - ]
903 : : "Incorrectly sized outvar vector.");
904 : : }
905 : : else {
906 : : // TODO: remove double-specification of defaults
907 : 0 : auto& fo_deck = gideck.get< tag::field_output >();
908 : 0 : fo_deck.get< tag::interval >() =
909 : 0 : std::numeric_limits< uint32_t >::max();
910 : 0 : fo_deck.get< tag::time_interval >() =
911 : 0 : std::numeric_limits< tk::real >::max();
912 [ - - ]: 0 : fo_deck.get< tag::time_range >() = {};
913 : 0 : fo_deck.get< tag::refined >() = false;
914 : 0 : fo_deck.get< tag::filetype >() = tk::ctr::FieldFileType::EXODUSII;
915 [ - - ]: 0 : fo_deck.get< tag::sideset >() = {};
916 : : }
917 : :
918 : : // Diagnostics output block
919 : : // ---------------------------------------------------------------------------
920 [ + - ][ + - ]: 176 : if (lua_ideck["diagnostics"].valid()) {
[ + + ]
921 : :
922 [ + - ][ + - ]: 90 : checkBlock< inciter::ctr::diagnosticsList::Keys >(lua_ideck["diagnostics"],
[ + - ][ + - ]
923 : : "diagnostics");
924 : :
925 : 90 : auto& diag_deck = gideck.get< tag::diagnostics >();
926 : :
927 : : // interval iteration
928 [ + - ][ + - ]: 90 : storeIfSpecd< uint32_t >(
[ + - ][ + - ]
929 : : lua_ideck["diagnostics"], "interval",
930 : : diag_deck.get< tag::interval >(), 1);
931 : :
932 : : // error norm
933 [ + - ][ + - ]: 90 : storeOptIfSpecd< tk::ctr::ErrorType, tk::ctr::Error >(
[ + - ][ + - ]
934 : : lua_ideck["diagnostics"], "error", diag_deck.get< tag::error >(),
935 : : tk::ctr::ErrorType::L2);
936 : :
937 : : // float format
938 [ + - ][ + - ]: 90 : storeOptIfSpecd< tk::ctr::TxtFloatFormatType, tk::ctr::TxtFloatFormat >(
[ + - ][ + - ]
939 : : lua_ideck["diagnostics"], "format", diag_deck.get< tag::format >(),
940 : : tk::ctr::TxtFloatFormatType::DEFAULT);
941 : :
942 : : // precision
943 [ + - ][ + - ]: 90 : storeIfSpecd< std::streamsize >(
[ + - ][ + - ]
944 : : lua_ideck["diagnostics"], "precision",
945 : : diag_deck.get< tag::precision >(), std::cout.precision());
946 : : }
947 : : else {
948 : : // TODO: remove double-specification of defaults
949 : 86 : auto& diag_deck = gideck.get< tag::diagnostics >();
950 : 86 : diag_deck.get< tag::interval >() = 1;
951 : 86 : diag_deck.get< tag::error >() = tk::ctr::ErrorType::L2;
952 : 86 : diag_deck.get< tag::format >() = tk::ctr::TxtFloatFormatType::DEFAULT;
953 : 86 : diag_deck.get< tag::precision >() = std::cout.precision();
954 : : }
955 : :
956 : : // History output block
957 : : // ---------------------------------------------------------------------------
958 [ + - ][ + - ]: 176 : if (lua_ideck["history_output"].valid()) {
[ + + ]
959 : :
960 [ + - ][ + - ]: 4 : checkBlock< inciter::ctr::historyOutputList::Keys >(
[ + - ][ + - ]
961 : : lua_ideck["history_output"], "history_output");
962 : :
963 : 4 : auto& hist_deck = gideck.get< tag::history_output >();
964 : :
965 : : // interval iteration
966 [ + - ][ + - ]: 4 : storeIfSpecd< uint32_t >(
[ + - ][ + - ]
967 : : lua_ideck["history_output"], "interval",
968 : : hist_deck.get< tag::interval >(),
969 : : std::numeric_limits< uint32_t >::max());
970 : :
971 : : // interval time
972 [ + - ][ + - ]: 4 : storeIfSpecd< tk::real >(
[ + - ][ + - ]
973 : : lua_ideck["history_output"], "time_interval",
974 : : hist_deck.get< tag::time_interval >(),
975 : : std::numeric_limits< tk::real >::max());
976 : :
977 : : // interval time range
978 [ + - ][ + - ]: 4 : storeVecIfSpecd< tk::real >(
[ + - ][ + - ]
979 : : lua_ideck["history_output"], "time_range",
980 : : hist_deck.get< tag::time_range >(), {});
981 : :
982 : : // point probes
983 [ + - ][ + - ]: 4 : if (lua_ideck["history_output"]["point"].valid()) {
[ + - ][ + - ]
984 [ + - ][ + - ]: 8 : const sol::table& sol_pt = lua_ideck["history_output"]["point"];
[ + - ]
985 [ + - ][ + - ]: 4 : hist_deck.get< tag::point >().resize(sol_pt.size());
986 : :
987 [ + + ]: 12 : for (std::size_t i=0; i<hist_deck.get< tag::point >().size(); ++i) {
988 : 8 : auto& pti = hist_deck.get< tag::point >()[i];
989 [ + - ][ + - ]: 24 : storeIfSpecd< std::string >(
[ + - ][ + - ]
990 [ + - ]: 16 : sol_pt[i+1], "id", pti.get< tag::id >(), "p");
991 [ + - ][ + - ]: 24 : storeVecIfSpecd< tk::real >(
[ + - ]
992 [ + - ]: 16 : sol_pt[i+1], "coord", pti.get< tag::coord >(), {});
993 : : }
994 : : }
995 : :
996 : : // float format
997 [ + - ][ + - ]: 4 : storeOptIfSpecd< tk::ctr::TxtFloatFormatType, tk::ctr::TxtFloatFormat >(
[ + - ][ + - ]
998 : : lua_ideck["history_output"], "format", hist_deck.get< tag::format >(),
999 : : tk::ctr::TxtFloatFormatType::DEFAULT);
1000 : :
1001 : : // precision
1002 [ + - ][ + - ]: 4 : storeIfSpecd< std::streamsize >(
[ + - ][ + - ]
1003 : : lua_ideck["history_output"], "precision",
1004 : : hist_deck.get< tag::precision >(), std::cout.precision());
1005 : :
1006 : : // error check point
1007 [ + + ]: 12 : for (std::size_t i=0; i<hist_deck.get< tag::point >().size(); ++i) {
1008 [ - + ]: 8 : if (hist_deck.get< tag::point >()[i].get< tag::coord >().size() != 3)
1009 [ - - ][ - - ]: 0 : Throw("Three reals required for point coordinates in history_output.");
[ - - ]
1010 : : }
1011 : : }
1012 : : else {
1013 : : // TODO: remove double-specification of defaults
1014 : 172 : auto& hist_deck = gideck.get< tag::history_output >();
1015 : 172 : hist_deck.get< tag::interval >() =
1016 : 172 : std::numeric_limits< uint32_t >::max();
1017 : 172 : hist_deck.get< tag::time_interval >() =
1018 : 172 : std::numeric_limits< tk::real >::max();
1019 [ + - ]: 172 : hist_deck.get< tag::time_range >() = {};
1020 : 172 : hist_deck.get< tag::precision >() = std::cout.precision();
1021 [ + - ]: 172 : hist_deck.get< tag::point >().resize(0);
1022 : : }
1023 : :
1024 : : // ALE block
1025 : : // ---------------------------------------------------------------------------
1026 : 176 : gideck.get< tag::ale, tag::ale >() = false;
1027 [ + - ][ + - ]: 176 : if (lua_ideck["ale"].valid()) {
[ + + ]
1028 : 10 : auto& ale_deck = gideck.get< tag::ale >();
1029 : 10 : ale_deck.get< tag::ale >() = true;
1030 : :
1031 : : // Mesh velocity smoother
1032 : : storeOptIfSpecd< inciter::ctr::MeshVelocitySmootherType,
1033 [ + - ][ + - ]: 10 : inciter::ctr::MeshVelocitySmoother >(lua_ideck["ale"], "smoother",
[ + - ][ + - ]
1034 : : ale_deck.get< tag::smoother >(), inciter::ctr::MeshVelocitySmootherType::NONE);
1035 : :
1036 : : // Mesh velocity
1037 : : storeOptIfSpecd< inciter::ctr::MeshVelocityType,
1038 [ + - ][ + - ]: 10 : inciter::ctr::MeshVelocity >(lua_ideck["ale"], "mesh_velocity",
[ + - ][ + - ]
1039 : : ale_deck.get< tag::mesh_velocity >(), inciter::ctr::MeshVelocityType::SINE);
1040 : :
1041 : : // Mesh motion direction
1042 [ + - ][ + - ]: 10 : storeVecIfSpecd< std::size_t >(lua_ideck["ale"], "mesh_motion",
[ + - ][ + - ]
[ + - ]
1043 : : ale_deck.get< tag::mesh_motion >(), { 0, 1, 2 });
1044 : :
1045 : : // Mesh force
1046 [ + - ][ + - ]: 10 : storeVecIfSpecd< tk::real >(lua_ideck["ale"], "meshforce",
[ + - ][ + - ]
[ + - ]
1047 : : ale_deck.get< tag::meshforce >(), { 0, 0, 0, 0 });
1048 : :
1049 : : // Dirichlet
1050 [ + - ][ + - ]: 10 : storeVecIfSpecd< std::size_t >(lua_ideck["ale"], "dirichlet",
[ + - ][ + - ]
1051 : : ale_deck.get< tag::dirichlet >(), {});
1052 : :
1053 : : // Symmetry
1054 [ + - ][ + - ]: 10 : storeVecIfSpecd< std::size_t >(lua_ideck["ale"], "symmetry",
[ + - ][ + - ]
1055 : : ale_deck.get< tag::symmetry >(), {});
1056 : :
1057 : : // Move sidesets with user defined function
1058 [ + - ][ + - ]: 10 : if (lua_ideck["ale"]["move"].valid()) {
[ + - ][ + + ]
1059 [ + - ][ + - ]: 4 : const sol::table& sol_mv = lua_ideck["ale"]["move"];
[ + - ]
1060 [ + - ][ + - ]: 2 : ale_deck.get< tag::move >().resize(sol_mv.size());
1061 : :
1062 [ + + ]: 4 : for (std::size_t i=0; i<ale_deck.get< tag::move >().size(); ++i) {
1063 : 2 : auto& mvi = ale_deck.get< tag::move >()[i];
1064 [ + - ][ + - ]: 6 : storeOptIfSpecd< tk::ctr::UserTableType, tk::ctr::UserTable >(
[ + - ]
1065 [ + - ]: 4 : sol_mv[i+1], "fntype", mvi.get< tag::fntype >(),
1066 : : tk::ctr::UserTableType::POSITION);
1067 [ + - ][ + - ]: 6 : storeVecIfSpecd< uint64_t >(
[ + - ]
1068 [ + - ]: 4 : sol_mv[i+1], "sideset", mvi.get< tag::sideset >(), {});
1069 [ + - ][ + - ]: 6 : storeVecIfSpecd< tk::real >(
[ + - ]
1070 [ + - ]: 4 : sol_mv[i+1], "fn", mvi.get< tag::fn >(), {});
1071 : :
1072 : : // error checking on user-def function
1073 [ - + ]: 2 : if (mvi.get< tag::fn >().size() % 4 != 0)
1074 [ - - ][ - - ]: 0 : Throw("Incomplete user-defined function for ALE sideset movement. An "
[ - - ]
1075 : : "R->R^3 function is expected, the number of descrete entries must be "
1076 : : "divisible by 4: one 'column' for the abscissa, and 3 for the "
1077 : : "ordinate.");
1078 : : }
1079 : : }
1080 : :
1081 : : // dv-CFL
1082 [ + - ][ + - ]: 10 : storeIfSpecd< tk::real >(lua_ideck["ale"], "dvcfl", ale_deck.get< tag::dvcfl >(),
[ + - ][ + - ]
1083 : : 0.01);
1084 : :
1085 : : // Vorticity multiplier
1086 [ + - ][ + - ]: 10 : storeIfSpecd< tk::real >(lua_ideck["ale"], "vortmult",
[ + - ][ + - ]
1087 : : ale_deck.get< tag::vortmult >(), 0.0);
1088 : :
1089 : : // Mesh velocity max iterations
1090 [ + - ][ + - ]: 10 : storeIfSpecd< std::size_t >(lua_ideck["ale"], "maxit",
[ + - ][ + - ]
1091 : : ale_deck.get< tag::maxit >(), 5);
1092 : :
1093 : : // Mesh velocity max iterations
1094 [ + - ][ + - ]: 10 : storeIfSpecd< tk::real >(lua_ideck["ale"], "tolerance",
[ + - ][ + - ]
1095 : : ale_deck.get< tag::tolerance >(), 1e-2);
1096 : : }
1097 : :
1098 : : // AMR block
1099 : : // ---------------------------------------------------------------------------
1100 : 176 : gideck.get< tag::amr, tag::amr >() = false;
1101 : 176 : gideck.get< tag::amr, tag::maxlevels >() = 2; // this is needed for outref
1102 [ + - ][ + - ]: 176 : if (lua_ideck["amr"].valid()) {
[ + + ]
1103 : 20 : auto& amr_deck = gideck.get< tag::amr >();
1104 : 20 : amr_deck.get< tag::amr >() = true;
1105 : :
1106 : : // Initial refinement toggle
1107 [ + - ][ + - ]: 20 : storeIfSpecd< bool >(lua_ideck["amr"], "t0ref", amr_deck.get< tag::t0ref >(),
[ + - ][ + - ]
1108 : : false);
1109 : :
1110 : : // Mesh refinement during time-stepping toggle
1111 [ + - ][ + - ]: 20 : storeIfSpecd< bool >(lua_ideck["amr"], "dtref", amr_deck.get< tag::dtref >(),
[ + - ][ + - ]
1112 : : false);
1113 : :
1114 : : // Uniform mesh refinement during time-stepping toggle
1115 [ + - ][ + - ]: 20 : storeIfSpecd< bool >(lua_ideck["amr"], "dtref_uniform",
[ + - ][ + - ]
1116 : : amr_deck.get< tag::dtref_uniform >(), false);
1117 : :
1118 : : // Mesh refinement frequency during time-stepping toggle
1119 [ + - ][ + - ]: 20 : storeIfSpecd< std::size_t >(lua_ideck["amr"], "dtfreq",
[ + - ][ + - ]
1120 : : amr_deck.get< tag::dtfreq >(), 3);
1121 : :
1122 : : // Maximum AMR levels
1123 [ + - ][ + - ]: 20 : storeIfSpecd< std::size_t >(lua_ideck["amr"], "maxlevels",
[ + - ][ + - ]
1124 : : amr_deck.get< tag::maxlevels >(), 2);
1125 : :
1126 : : // Initial AMR steps
1127 [ + - ][ + - ]: 20 : storeOptVecIfSpecd< inciter::ctr::AMRInitialType, inciter::ctr::AMRInitial >(
[ + - ][ + - ]
1128 : : lua_ideck["amr"], "initial", amr_deck.get< tag::initial >(), {});
1129 : :
1130 : : // Initial AMR coordinate based
1131 [ + - ][ + - ]: 20 : if (lua_ideck["amr"]["coords"].valid()) {
[ + - ][ + + ]
1132 : 1 : auto rmax = std::numeric_limits< tk::real >::max() / 100;
1133 : :
1134 [ + - ][ + - ]: 1 : storeIfSpecd< tk::real >(lua_ideck["amr"]["coords"], "xminus",
[ + - ][ + - ]
[ + - ]
1135 : : amr_deck.get< tag::coords, tag::xminus >(), rmax);
1136 [ + - ][ + - ]: 1 : storeIfSpecd< tk::real >(lua_ideck["amr"]["coords"], "xplus",
[ + - ][ + - ]
[ + - ]
1137 : : amr_deck.get< tag::coords, tag::xplus >(), -rmax);
1138 : :
1139 [ + - ][ + - ]: 1 : storeIfSpecd< tk::real >(lua_ideck["amr"]["coords"], "yminus",
[ + - ][ + - ]
[ + - ]
1140 : : amr_deck.get< tag::coords, tag::yminus >(), rmax);
1141 [ + - ][ + - ]: 1 : storeIfSpecd< tk::real >(lua_ideck["amr"]["coords"], "yplus",
[ + - ][ + - ]
[ + - ]
1142 : : amr_deck.get< tag::coords, tag::yplus >(), -rmax);
1143 : :
1144 [ + - ][ + - ]: 1 : storeIfSpecd< tk::real >(lua_ideck["amr"]["coords"], "zminus",
[ + - ][ + - ]
[ + - ]
1145 : : amr_deck.get< tag::coords, tag::zminus >(), rmax);
1146 [ + - ][ + - ]: 1 : storeIfSpecd< tk::real >(lua_ideck["amr"]["coords"], "zplus",
[ + - ][ + - ]
[ + - ]
1147 : : amr_deck.get< tag::coords, tag::zplus >(), -rmax);
1148 : : }
1149 : :
1150 : : // Initial AMR edgelist based
1151 [ + - ][ + - ]: 20 : storeVecIfSpecd< std::size_t >(lua_ideck["amr"], "edgelist",
[ + - ][ + - ]
1152 : : amr_deck.get< tag::edgelist >(), {});
1153 [ - + ]: 20 : if (amr_deck.get< tag::edgelist >().size() % 2 != 0)
1154 [ - - ][ - - ]: 0 : Throw("The number of edge-nodes, marking edges as pairs of nodes, used "
[ - - ]
1155 : : "for explicit tagging of edges for initial mesh refineoment, is odd "
1156 : : "(it must be even).");
1157 : :
1158 : : // Error type for AMR
1159 [ + - ][ + - ]: 20 : storeOptIfSpecd< inciter::ctr::AMRErrorType, inciter::ctr::AMRError >(
[ + - ][ + - ]
1160 : : lua_ideck["amr"], "error", amr_deck.get< tag::error >(),
1161 : : inciter::ctr::AMRErrorType::JUMP);
1162 : :
1163 : : // Tolerances for refine/de-refine
1164 [ + - ][ + - ]: 20 : storeIfSpecd< tk::real >(lua_ideck["amr"], "tol_refine",
[ + - ][ + - ]
1165 : : amr_deck.get< tag::tol_refine >(), 0.2);
1166 [ + - ][ + - ]: 20 : storeIfSpecd< tk::real >(lua_ideck["amr"], "tol_derefine",
[ + - ][ + - ]
1167 : : amr_deck.get< tag::tol_derefine >(), 0.05);
1168 : : }
1169 : :
1170 : : // p-refinement block
1171 : : // ---------------------------------------------------------------------------
1172 : 176 : gideck.get< tag::pref, tag::pref >() = false;
1173 [ + - ][ + - ]: 176 : if (lua_ideck["pref"].valid()) {
[ + + ]
1174 : 12 : auto& pref_deck = gideck.get< tag::pref >();
1175 : 12 : pref_deck.get< tag::pref >() = true;
1176 : :
1177 : : // p-ref indicator type
1178 : : storeOptIfSpecd< inciter::ctr::PrefIndicatorType,
1179 [ + - ][ + - ]: 12 : inciter::ctr::PrefIndicator >(lua_ideck["pref"], "indicator",
[ + - ][ + - ]
1180 : : pref_deck.get< tag::indicator >(),
1181 : : inciter::ctr::PrefIndicatorType::SPECTRAL_DECAY);
1182 : :
1183 : : // p-ref max degrees-of-freedom per cell
1184 [ + - ][ + - ]: 12 : storeIfSpecd< std::size_t >(lua_ideck["pref"], "ndofmax",
[ + - ][ + - ]
1185 : : pref_deck.get< tag::ndofmax >(), 10);
1186 : :
1187 : : // p-ref tolerance
1188 [ + - ][ + - ]: 12 : storeIfSpecd< tk::real >(lua_ideck["pref"], "tolref",
[ + - ][ + - ]
1189 : : pref_deck.get< tag::tolref >(), 0.5);
1190 : :
1191 : : // error checking on the tolerance
1192 [ + - ][ - + ]: 12 : if (pref_deck.get< tag::tolref >() < 0.0 || pref_deck.get< tag::tolref >() > 1.0)
[ - + ]
1193 [ - - ][ - - ]: 0 : Throw("The p-refinement tolerance must be a real number "
[ - - ]
1194 : : "between 0.0 and 1.0, both inclusive.");
1195 : : }
1196 : :
1197 : : // Boundary conditions block
1198 : : // ---------------------------------------------------------------------------
1199 [ + - ][ + - ]: 176 : if (lua_ideck["bc"].valid()) {
[ + + ]
1200 : 332 : std::set< std::size_t > totalmesh;
1201 [ + - ][ + - ]: 332 : const sol::table& sol_bc = lua_ideck["bc"];
1202 : 166 : auto& bc_deck = gideck.get< tag::bc >();
1203 [ + - ][ + - ]: 166 : bc_deck.resize(sol_bc.size());
1204 : :
1205 [ + + ]: 333 : for (std::size_t i=0; i<bc_deck.size(); ++i) {
1206 : :
1207 [ + - ][ + - ]: 167 : checkBlock< inciter::ctr::bcList::Keys >(sol_bc[i+1], "bc");
[ + - ][ + - ]
1208 : :
1209 [ + - ][ + - ]: 334 : storeVecIfSpecd< std::size_t >(sol_bc[i+1], "mesh",
[ + - ][ + - ]
[ + - ]
1210 : 167 : bc_deck[i].get< tag::mesh >(), {1});
1211 : : // collect meshes for error checking
1212 [ + - ]: 167 : totalmesh.insert(bc_deck[i].get< tag::mesh >().begin(),
1213 : 167 : bc_deck[i].get< tag::mesh >().end());
1214 : :
1215 [ + - ][ + - ]: 334 : storeVecIfSpecd< uint64_t >(sol_bc[i+1], "dirichlet",
[ + - ][ + - ]
1216 : 167 : bc_deck[i].get< tag::dirichlet >(), {});
1217 : :
1218 [ + - ][ + - ]: 334 : storeVecIfSpecd< uint64_t >(sol_bc[i+1], "symmetry",
[ + - ][ + - ]
1219 : 167 : bc_deck[i].get< tag::symmetry >(), {});
1220 : :
1221 [ + - ][ + - ]: 167 : if (sol_bc[i+1]["inlet"].valid()) {
[ + - ][ + + ]
1222 [ + - ][ + - ]: 14 : const sol::table& sol_inbc = sol_bc[i+1]["inlet"];
[ + - ]
1223 : 7 : auto& inbc_deck = bc_deck[i].get< tag::inlet >();
1224 [ + - ][ + - ]: 7 : inbc_deck.resize(sol_inbc.size());
1225 : :
1226 [ + + ]: 14 : for (std::size_t j=0; j<inbc_deck.size(); ++j) {
1227 [ + - ][ + - ]: 14 : storeVecIfSpecd< uint64_t >(sol_inbc[j+1], "sideset",
[ + - ][ + - ]
1228 : 7 : inbc_deck[j].get< tag::sideset >(), {});
1229 : :
1230 [ + - ][ + - ]: 14 : storeVecIfSpecd< tk::real >(sol_inbc[j+1], "velocity",
[ + - ][ + - ]
[ + - ]
1231 : 7 : inbc_deck[j].get< tag::velocity >(), {0.0, 0.0, 0.0});
1232 [ - + ]: 7 : if (inbc_deck[j].get< tag::velocity >().size() != 3)
1233 [ - - ][ - - ]: 0 : Throw("Inlet velocity requires 3 components.");
[ - - ]
1234 : :
1235 [ + - ][ + - ]: 7 : storeIfSpecd< tk::real >(sol_inbc[j+1], "pressure",
[ + - ][ + - ]
1236 : 7 : inbc_deck[j].get< tag::pressure >(), 0.0);
1237 : :
1238 [ + - ][ + - ]: 7 : storeIfSpecd< tk::real >(sol_inbc[j+1], "temperature",
[ + - ][ + - ]
1239 : 7 : inbc_deck[j].get< tag::temperature >(), 0.0);
1240 : :
1241 [ + - ][ + - ]: 7 : storeIfSpecd< std::size_t >(sol_inbc[j+1], "materialid",
[ + - ][ + - ]
1242 : 7 : inbc_deck[j].get< tag::materialid >(), 1);
1243 : : }
1244 : : }
1245 : :
1246 [ + - ][ + - ]: 334 : storeVecIfSpecd< uint64_t >(sol_bc[i+1], "outlet",
[ + - ][ + - ]
1247 : 167 : bc_deck[i].get< tag::outlet >(), {});
1248 : :
1249 [ + - ][ + - ]: 334 : storeVecIfSpecd< uint64_t >(sol_bc[i+1], "farfield",
[ + - ][ + - ]
1250 : 167 : bc_deck[i].get< tag::farfield >(), {});
1251 : :
1252 [ + - ][ + - ]: 334 : storeVecIfSpecd< uint64_t >(sol_bc[i+1], "extrapolate",
[ + - ][ + - ]
1253 : 167 : bc_deck[i].get< tag::extrapolate >(), {});
1254 : :
1255 [ + - ][ + - ]: 334 : storeVecIfSpecd< uint64_t >(sol_bc[i+1], "noslipwall",
[ + - ][ + - ]
1256 : 167 : bc_deck[i].get< tag::noslipwall >(), {});
1257 : :
1258 [ + - ][ + - ]: 334 : storeVecIfSpecd< uint64_t >(sol_bc[i+1], "slipwall",
[ + - ][ + - ]
1259 : 167 : bc_deck[i].get< tag::slipwall >(), {});
1260 : :
1261 : : // Time-dependent BC
1262 [ + - ][ + - ]: 167 : if (sol_bc[i+1]["timedep"].valid()) {
[ + - ][ + + ]
1263 [ + - ][ + - ]: 4 : const sol::table& sol_tdbc = sol_bc[i+1]["timedep"];
[ + - ]
1264 : 2 : auto& tdbc_deck = bc_deck[i].get< tag::timedep >();
1265 [ + - ][ + - ]: 2 : tdbc_deck.resize(sol_tdbc.size());
1266 : :
1267 [ + + ]: 4 : for (std::size_t j=0; j<tdbc_deck.size(); ++j) {
1268 [ + - ][ + - ]: 4 : storeVecIfSpecd< uint64_t >(sol_tdbc[j+1], "sideset",
[ + - ][ + - ]
1269 : 2 : tdbc_deck[j].get< tag::sideset >(), {});
1270 [ + - ][ + - ]: 4 : storeVecIfSpecd< tk::real >(sol_tdbc[j+1], "fn",
[ + - ][ + - ]
1271 : 2 : tdbc_deck[j].get< tag::fn >(), {});
1272 : :
1273 : : // error checking on user-def function
1274 [ - + ]: 2 : if (tdbc_deck[j].get< tag::fn >().size() % 6 != 0)
1275 [ - - ][ - - ]: 0 : Throw("Incomplete user-defined function for time-dependent BC. An "
[ - - ]
1276 : : "R->R^5 function is expected, the number of descrete entries must "
1277 : : "be divisible by 6: one 'column' for the abscissa, and 5 for the "
1278 : : "ordinate.");
1279 : : }
1280 : : }
1281 : :
1282 : : // Back pressure BC
1283 [ + - ][ + - ]: 167 : if (sol_bc[i+1]["back_pressure"].valid()) {
[ + - ][ - + ]
1284 [ - - ][ - - ]: 0 : const sol::table& sol_bpbc = sol_bc[i+1]["back_pressure"];
[ - - ]
1285 : 0 : auto& bpbc_deck = bc_deck[i].get< tag::back_pressure >();
1286 : :
1287 [ - - ][ - - ]: 0 : storeVecIfSpecd< uint64_t >(sol_bpbc, "sideset",
1288 : : bpbc_deck.get< tag::sideset >(), {});
1289 : :
1290 [ - - ][ - - ]: 0 : if (!sol_bpbc["pressure"].valid())
[ - - ]
1291 [ - - ][ - - ]: 0 : Throw("Pressure is required for back pressure BC.");
[ - - ]
1292 : :
1293 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(sol_bpbc, "pressure",
1294 : : bpbc_deck.get< tag::pressure >(), 0.0);
1295 : : }
1296 : :
1297 : : // Velocity for inlet/farfield
1298 [ + - ][ + - ]: 334 : storeVecIfSpecd< tk::real >(sol_bc[i+1], "velocity",
[ + - ][ + - ]
[ + - ]
1299 : 167 : bc_deck[i].get< tag::velocity >(), {0.0, 0.0, 0.0});
1300 [ - + ]: 167 : if (bc_deck[i].get< tag::velocity >().size() != 3)
1301 [ - - ][ - - ]: 0 : Throw("BC velocity requires 3 components.");
[ - - ]
1302 : :
1303 : : // Pressure for inlet/outlet/farfield
1304 [ + - ][ + - ]: 167 : storeIfSpecd< tk::real >(sol_bc[i+1], "pressure",
[ + - ][ + - ]
1305 : 167 : bc_deck[i].get< tag::pressure >(), 0.0);
1306 : :
1307 : : // Density for inlet/outlet/farfield
1308 [ + - ][ + - ]: 167 : storeIfSpecd< tk::real >(sol_bc[i+1], "density",
[ + - ][ + - ]
1309 : 167 : bc_deck[i].get< tag::density >(), 0.0);
1310 : :
1311 : : // Temperature for inlet/outlet/farfield
1312 [ + - ][ + - ]: 167 : storeIfSpecd< tk::real >(sol_bc[i+1], "temperature",
[ + - ][ + - ]
1313 : 167 : bc_deck[i].get< tag::temperature >(), 0.0);
1314 : :
1315 : : // Mass fractions for inlet/farfield
1316 [ + - ][ + - ]: 167 : storeVecIfSpecd< tk::real >(sol_bc[i+1], "mass_fractions",
[ + - ][ + - ]
1317 : 167 : bc_deck[i].get< tag::mass_fractions >(),
1318 [ + - ]: 334 : std::vector< tk::real >(nspec, 1.0/static_cast<tk::real>(nspec)));
1319 [ - + ]: 167 : if (bc_deck[i].get< tag::mass_fractions >().size() != nspec)
1320 [ - - ][ - - ]: 0 : Throw("BC mass fraction has incorrect number of species. "
[ - - ][ - - ]
1321 : : "Expected " + std::to_string(nspec));
1322 : :
1323 : : // Material-id for inlet/outlet/farfield
1324 [ + - ][ + - ]: 167 : storeIfSpecd< std::size_t >(sol_bc[i+1], "materialid",
[ + - ][ + - ]
1325 : 167 : bc_deck[i].get< tag::materialid >(), 1);
1326 : : }
1327 : :
1328 : : // error checking on number of meshes
1329 [ - + ]: 166 : if (totalmesh.size() != gideck.get< tag::mesh >().size())
1330 [ - - ][ - - ]: 0 : Throw("Total meshes (" + std::to_string(gideck.get< tag::mesh >().size()) +
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
1331 : : ") not equal to the meshes on which BC's are specified (" +
1332 : : std::to_string(totalmesh.size()));
1333 : :
1334 : : // error checking on mesh ids
1335 : 166 : std::size_t ic(1);
1336 [ + + ]: 333 : for (const auto& im : totalmesh) {
1337 [ - + ][ - - ]: 167 : if (im != ic) Throw("Non-contiguous mesh ids in BC-mesh");
[ - - ][ - - ]
1338 : 167 : ++ic;
1339 : : }
1340 : : }
1341 [ - + ][ + - ]: 10 : else if (gideck.get< tag::scheme >() == inciter::ctr::SchemeType::ALECG ||
1342 [ - - ]: 0 : gideck.get< tag::scheme >() == inciter::ctr::SchemeType::OversetFE)
1343 [ + - ]: 10 : gideck.get< tag::bc >().resize(1);
1344 : : // error checking for unspecified BC's
1345 : : else
1346 [ - - ][ - - ]: 0 : Throw("No boundary conditions specified in input file.");
[ - - ]
1347 : :
1348 : : // Initial condition block
1349 : : // ---------------------------------------------------------------------------
1350 [ + - ][ + - ]: 176 : if (lua_ideck["ic"].valid()) {
[ + + ]
1351 : 20 : auto& ic_deck = gideck.get< tag::ic >();
1352 : :
1353 [ + - ][ + - ]: 20 : checkBlock< inciter::ctr::icList::Keys >(lua_ideck["ic"], "ic");
[ + - ][ + - ]
1354 : :
1355 : : // background IC values
1356 [ + - ][ + - ]: 20 : storeIfSpecd< std::size_t >(lua_ideck["ic"], "materialid",
[ + - ][ + - ]
1357 : : ic_deck.get< tag::materialid >(), 1);
1358 : :
1359 [ + - ][ + - ]: 20 : storeIfSpecd< tk::real >(lua_ideck["ic"], "pressure",
[ + - ][ + - ]
1360 : : ic_deck.get< tag::pressure >(), 0.0);
1361 : :
1362 [ + - ][ + - ]: 20 : storeIfSpecd< tk::real >(lua_ideck["ic"], "temperature",
[ + - ][ + - ]
1363 : : ic_deck.get< tag::temperature >(), 0.0);
1364 : :
1365 [ + - ][ + - ]: 20 : storeVecIfSpecd< tk::real >(lua_ideck["ic"], "mass_fractions",
[ + - ][ + - ]
1366 : : ic_deck.get< tag::mass_fractions >(),
1367 [ + - ]: 40 : std::vector< tk::real >(nspec, 1.0/static_cast<tk::real>(nspec)));
1368 [ - + ]: 20 : if (ic_deck.get< tag::mass_fractions >().size() != nspec)
1369 [ - - ][ - - ]: 0 : Throw("IC mass fraction has incorrect number of species. "
[ - - ][ - - ]
1370 : : "Expected " + std::to_string(nspec));
1371 : :
1372 [ + - ][ + - ]: 20 : storeIfSpecd< tk::real >(lua_ideck["ic"], "density",
[ + - ][ + - ]
1373 : : ic_deck.get< tag::density >(), 0.0);
1374 : :
1375 [ + - ][ + - ]: 20 : storeIfSpecd< tk::real >(lua_ideck["ic"], "energy",
[ + - ][ + - ]
1376 : : ic_deck.get< tag::energy >(), 0.0);
1377 : :
1378 [ + - ][ + - ]: 20 : storeVecIfSpecd< tk::real >(lua_ideck["ic"], "velocity",
[ + - ][ + - ]
[ + - ]
1379 : : ic_deck.get< tag::velocity >(), {0.0, 0.0, 0.0});
1380 [ - + ]: 20 : if (ic_deck.get< tag::velocity >().size() != 3)
1381 [ - - ][ - - ]: 0 : Throw("Velocity in IC requires 3 components.");
[ - - ]
1382 : :
1383 : : // IC box
1384 [ + - ][ + - ]: 20 : if (lua_ideck["ic"]["box"].valid()) {
[ + - ][ + + ]
1385 [ + - ][ + - ]: 26 : const sol::table& lua_box = lua_ideck["ic"]["box"];
[ + - ]
1386 : 13 : auto& box_deck = ic_deck.get< tag::box >();
1387 [ + - ][ + - ]: 13 : box_deck.resize(lua_box.size());
1388 : :
1389 [ + + ]: 27 : for (std::size_t i=0; i<box_deck.size(); ++i) {
1390 : :
1391 [ + - ][ + - ]: 14 : checkBlock< inciter::ctr::boxList::Keys >(lua_box[i+1], "box");
[ + - ][ + - ]
1392 : :
1393 [ + - ][ + - ]: 14 : storeIfSpecd< std::size_t >(lua_box[i+1], "materialid",
[ + - ][ + - ]
1394 : 14 : box_deck[i].get< tag::materialid >(), 1);
1395 : :
1396 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "volume",
[ + - ][ + - ]
1397 : 14 : box_deck[i].get< tag::volume >(), 0.0);
1398 : :
1399 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "mass",
[ + - ][ + - ]
1400 : 14 : box_deck[i].get< tag::mass >(), 0.0);
1401 : :
1402 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "density",
[ + - ][ + - ]
1403 : 14 : box_deck[i].get< tag::density >(), 0.0);
1404 : :
1405 [ + - ][ + - ]: 28 : storeVecIfSpecd< tk::real >(lua_box[i+1], "velocity",
[ + - ][ + - ]
[ + - ]
1406 : 14 : box_deck[i].get< tag::velocity >(), {0.0, 0.0, 0.0});
1407 [ - + ]: 14 : if (box_deck[i].get< tag::velocity >().size() != 3)
1408 [ - - ][ - - ]: 0 : Throw("Velocity in IC box requires 3 components.");
[ - - ]
1409 : :
1410 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "pressure",
[ + - ][ + - ]
1411 : 14 : box_deck[i].get< tag::pressure >(), 0.0);
1412 : :
1413 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "energy",
[ + - ][ + - ]
1414 : 14 : box_deck[i].get< tag::energy >(), 0.0);
1415 : :
1416 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "energy_content",
[ + - ][ + - ]
1417 : 14 : box_deck[i].get< tag::energy_content >(), 0.0);
1418 : :
1419 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "temperature",
[ + - ][ + - ]
1420 : 14 : box_deck[i].get< tag::temperature >(), 0.0);
1421 : :
1422 [ + - ][ + - ]: 14 : storeVecIfSpecd< tk::real >(lua_box[i+1], "mass_fractions",
[ + - ][ + - ]
1423 : 14 : box_deck[i].get< tag::mass_fractions >(),
1424 [ + - ]: 28 : std::vector< tk::real >(nspec, 1.0/static_cast<tk::real>(nspec)));
1425 [ - + ]: 14 : if (box_deck[i].get< tag::mass_fractions >().size() != nspec)
1426 [ - - ][ - - ]: 0 : Throw("IC box mass fraction has incorrect number of species. "
[ - - ][ - - ]
1427 : : "Expected " + std::to_string(nspec));
1428 : :
1429 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "xmin",
[ + - ][ + - ]
1430 : 14 : box_deck[i].get< tag::xmin >(), 0.0);
1431 : :
1432 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "xmax",
[ + - ][ + - ]
1433 : 14 : box_deck[i].get< tag::xmax >(), 0.0);
1434 : :
1435 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "ymin",
[ + - ][ + - ]
1436 : 14 : box_deck[i].get< tag::ymin >(), 0.0);
1437 : :
1438 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "ymax",
[ + - ][ + - ]
1439 : 14 : box_deck[i].get< tag::ymax >(), 0.0);
1440 : :
1441 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "zmin",
[ + - ][ + - ]
1442 : 14 : box_deck[i].get< tag::zmin >(), 0.0);
1443 : :
1444 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "zmax",
[ + - ][ + - ]
1445 : 14 : box_deck[i].get< tag::zmax >(), 0.0);
1446 : :
1447 [ + - ][ + - ]: 28 : storeVecIfSpecd< tk::real >(lua_box[i+1], "orientation",
[ + - ][ + - ]
[ + - ]
1448 : 14 : box_deck[i].get< tag::orientation >(), {0.0, 0.0, 0.0});
1449 [ - + ]: 14 : if (box_deck[i].get< tag::orientation >().size() != 3)
1450 [ - - ][ - - ]: 0 : Throw("Orientation in IC box requires 3 rotation angles.");
[ - - ]
1451 : :
1452 [ + - ][ + - ]: 42 : storeOptIfSpecd< inciter::ctr::InitiateType, inciter::ctr::Initiate >(
[ + - ]
1453 [ + - ]: 42 : lua_box[i+1], "initiate", box_deck[i].get< tag::initiate >(),
1454 : : inciter::ctr::InitiateType::IMPULSE);
1455 : :
1456 [ + - ][ + - ]: 28 : storeVecIfSpecd< tk::real >(lua_box[i+1], "point",
[ + - ][ + - ]
[ + - ]
1457 : 14 : box_deck[i].get< tag::point >(), {0.0, 0.0, 0.0});
1458 [ - + ]: 14 : if (box_deck[i].get< tag::point >().size() != 3)
1459 [ - - ][ - - ]: 0 : Throw("Point in IC box requires 3 coordinates.");
[ - - ]
1460 : :
1461 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "init_time",
[ + - ][ + - ]
1462 : 14 : box_deck[i].get< tag::init_time >(), 0.0);
1463 : :
1464 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "front_width",
[ + - ][ + - ]
1465 : 14 : box_deck[i].get< tag::front_width >(), 0.0);
1466 : :
1467 [ + - ][ + - ]: 14 : storeIfSpecd< tk::real >(lua_box[i+1], "front_speed",
[ + - ][ + - ]
1468 : 14 : box_deck[i].get< tag::front_speed >(), 0.0);
1469 : : }
1470 : : }
1471 : :
1472 : : // IC mesh-block
1473 [ + - ][ + - ]: 20 : if (lua_ideck["ic"]["meshblock"].valid()) {
[ + - ][ - + ]
1474 [ - - ][ - - ]: 0 : const sol::table& lua_meshblock = lua_ideck["ic"]["meshblock"];
[ - - ]
1475 : 0 : auto& mblk_deck = ic_deck.get< tag::meshblock >();
1476 [ - - ][ - - ]: 0 : mblk_deck.resize(lua_meshblock.size());
1477 : :
1478 [ - - ]: 0 : for (std::size_t i=0; i<mblk_deck.size(); ++i) {
1479 : :
1480 [ - - ][ - - ]: 0 : checkBlock< inciter::ctr::meshblockList::Keys >(lua_meshblock[i+1],
[ - - ][ - - ]
1481 : : "meshblock");
1482 : :
1483 [ - - ][ - - ]: 0 : storeIfSpecd< std::size_t >(lua_meshblock[i+1], "blockid",
[ - - ][ - - ]
1484 : 0 : mblk_deck[i].get< tag::blockid >(), 0);
1485 [ - - ]: 0 : if (mblk_deck[i].get< tag::blockid >() == 0)
1486 [ - - ][ - - ]: 0 : Throw("Each IC mesh block must specify the mesh block id.");
[ - - ]
1487 : :
1488 [ - - ][ - - ]: 0 : storeIfSpecd< std::size_t >(lua_meshblock[i+1], "materialid",
[ - - ][ - - ]
1489 : 0 : mblk_deck[i].get< tag::materialid >(), 1);
1490 : :
1491 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "energy_content",
[ - - ][ - - ]
1492 : 0 : mblk_deck[i].get< tag::energy_content >(), 0.0);
1493 : :
1494 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "volume",
[ - - ][ - - ]
1495 : 0 : mblk_deck[i].get< tag::volume >(), 0.0);
1496 [ - - ][ - - ]: 0 : if (mblk_deck[i].get< tag::energy_content >() > 0.0 &&
1497 [ - - ]: 0 : mblk_deck[i].get< tag::volume >() < 1e-12)
1498 [ - - ][ - - ]: 0 : Throw("Mesh block volume must be specified, if energy content is "
[ - - ]
1499 : : "used to initialize block");
1500 : :
1501 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "mass",
[ - - ][ - - ]
1502 : 0 : mblk_deck[i].get< tag::mass >(), 0.0);
1503 : :
1504 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "density",
[ - - ][ - - ]
1505 : 0 : mblk_deck[i].get< tag::density >(), 0.0);
1506 : :
1507 [ - - ][ - - ]: 0 : storeVecIfSpecd< tk::real >(lua_meshblock[i+1], "velocity",
[ - - ][ - - ]
[ - - ]
1508 : 0 : mblk_deck[i].get< tag::velocity >(), {0.0, 0.0, 0.0});
1509 [ - - ]: 0 : if (mblk_deck[i].get< tag::velocity >().size() != 3)
1510 [ - - ][ - - ]: 0 : Throw("Velocity in IC meshblock requires 3 components.");
[ - - ]
1511 : :
1512 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "pressure",
[ - - ][ - - ]
1513 : 0 : mblk_deck[i].get< tag::pressure >(), 0.0);
1514 : :
1515 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "energy",
[ - - ][ - - ]
1516 : 0 : mblk_deck[i].get< tag::energy >(), 0.0);
1517 : :
1518 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "temperature",
[ - - ][ - - ]
1519 : 0 : mblk_deck[i].get< tag::temperature >(), 0.0);
1520 : :
1521 [ - - ][ - - ]: 0 : storeVecIfSpecd< tk::real >(lua_meshblock[i+1], "mass_fractions",
[ - - ][ - - ]
1522 : 0 : mblk_deck[i].get< tag::mass_fractions >(),
1523 [ - - ]: 0 : std::vector< tk::real >(nspec, 1.0/static_cast<tk::real>(nspec)));
1524 [ - - ]: 0 : if (mblk_deck[i].get< tag::mass_fractions >().size() != nspec)
1525 [ - - ][ - - ]: 0 : Throw("IC meshblock mass fraction has incorrect number of species. "
[ - - ][ - - ]
1526 : : "Expected " + std::to_string(nspec));
1527 : :
1528 [ - - ][ - - ]: 0 : storeOptIfSpecd< inciter::ctr::InitiateType, inciter::ctr::Initiate >(
[ - - ]
1529 [ - - ]: 0 : lua_meshblock[i+1], "initiate", mblk_deck[i].get< tag::initiate >(),
1530 : : inciter::ctr::InitiateType::IMPULSE);
1531 : :
1532 [ - - ][ - - ]: 0 : storeVecIfSpecd< tk::real >(lua_meshblock[i+1], "point",
[ - - ][ - - ]
[ - - ]
1533 : 0 : mblk_deck[i].get< tag::point >(), {0.0, 0.0, 0.0});
1534 [ - - ]: 0 : if (mblk_deck[i].get< tag::point >().size() != 3)
1535 [ - - ][ - - ]: 0 : Throw("Point in IC meshblock requires 3 coordinates.");
[ - - ]
1536 : :
1537 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "init_time",
[ - - ][ - - ]
1538 : 0 : mblk_deck[i].get< tag::init_time >(), 0.0);
1539 : :
1540 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "front_width",
[ - - ][ - - ]
1541 : 0 : mblk_deck[i].get< tag::front_width >(), 0.0);
1542 : :
1543 [ - - ][ - - ]: 0 : storeIfSpecd< tk::real >(lua_meshblock[i+1], "front_speed",
[ - - ][ - - ]
1544 : 0 : mblk_deck[i].get< tag::front_speed >(), 0.0);
1545 : : }
1546 : : }
1547 : : }
1548 : : else {
1549 : : // TODO: remove double-specification of defaults
1550 : 156 : auto& ic_deck = gideck.get< tag::ic >();
1551 : 156 : ic_deck.get< tag::materialid >() = 1;
1552 : 156 : ic_deck.get< tag::pressure >() = 0.0;
1553 : 156 : ic_deck.get< tag::temperature >() = 1.0;
1554 : 156 : ic_deck.get< tag::density >() = 0.0;
1555 : 156 : ic_deck.get< tag::energy >() = 0.0;
1556 [ + - ]: 156 : ic_deck.get< tag::velocity >() = {0.0, 0.0, 0.0};
1557 : 156 : ic_deck.get< tag::mass_fractions >() =
1558 [ + - ]: 312 : std::vector< tk::real >(nspec, 1.0/static_cast<tk::real>(nspec));
1559 : : }
1560 : 176 : }
1561 : :
1562 : : void
1563 : 630 : LuaParser::checkStoreMatProp(
1564 : : const sol::table table,
1565 : : const std::string key,
1566 : : std::size_t vecsize,
1567 : : std::vector< tk::real >& storage )
1568 : : // *****************************************************************************
1569 : : // Check and store material property into inpudeck storage
1570 : : //! \param[in] table Sol-table which contains said property
1571 : : //! \param[in] key Key for said property in Sol-table
1572 : : //! \param[in] vecsize Number of said property in Sol-table (based on number of
1573 : : //! materials that are of the same eos type
1574 : : //! \param[in,out] storage Storage space in inputdeck where said property is
1575 : : //! to be stored
1576 : : // *****************************************************************************
1577 : : {
1578 : : // check validity of table
1579 [ + - ][ - + ]: 630 : if (!table[key].valid())
1580 [ - - ][ - - ]: 0 : Throw("Material property '" + key + "' not specified");
[ - - ][ - - ]
1581 [ + - ][ + - ]: 630 : if (sol::table(table[key]).size() != vecsize)
[ - + ]
1582 [ - - ][ - - ]: 0 : Throw("Incorrect number of '" + key + "'s specified. Expected " +
[ - - ][ - - ]
[ - - ][ - - ]
1583 : : std::to_string(vecsize));
1584 : :
1585 : : // store values from table to inputdeck
1586 [ + - ][ + - ]: 630 : storeVecIfSpecd< tk::real >(table, key, storage,
1587 [ + - ]: 1260 : std::vector< tk::real >(vecsize, 0.0));
1588 : 630 : }
1589 : :
1590 : : void
1591 : 6 : LuaParser::checkStoreMatPropVec(
1592 : : const sol::table table,
1593 : : const std::string key,
1594 : : std::size_t nspec,
1595 : : std::size_t vecsize,
1596 : : std::vector<std::vector< tk::real >>& storage )
1597 : : // *****************************************************************************
1598 : : // Check and store material property vector into inpudeck storage
1599 : : //! \param[in] table Sol-table which contains said property
1600 : : //! \param[in] key Key for said property in Sol-table
1601 : : //! \param[in] nspec Number of species
1602 : : //! \param[in] vecsize Number of said property in Sol-table (based on number of
1603 : : //! coefficients for the defined species)
1604 : : //! \param[in,out] storage Storage space in inputdeck where said property is
1605 : : //! to be stored
1606 : : // *****************************************************************************
1607 : : {
1608 : : // check validity of table
1609 [ + - ][ + - ]: 6 : if (!table[key].valid())
[ - + ]
1610 [ - - ][ - - ]: 0 : Throw("Material property '" + key + "' not specified");
[ - - ][ - - ]
1611 [ + - ][ + - ]: 6 : if (sol::table(table[key]).size() != nspec)
[ + - ][ - + ]
1612 [ - - ][ - - ]: 0 : Throw("Incorrect number of '" + key + "' vectors specified. Expected " +
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
1613 : : std::to_string(nspec) + " vectors");
1614 : :
1615 [ + - ]: 6 : storage.resize(nspec);
1616 : :
1617 [ + - ]: 12 : const auto& tableentry = table[key];
1618 [ + + ]: 15 : for (std::size_t k=0; k < nspec; k++) {
1619 [ + - ][ + - ]: 9 : if (sol::table(tableentry[k+1]).size() != vecsize)
[ + - ][ - + ]
1620 [ - - ][ - - ]: 0 : Throw("Incorrect number of '" + key + "' entries in vector of species "
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
1621 : : + std::to_string(k+1) + " specified. Expected " +
1622 : : std::to_string(vecsize));
1623 : :
1624 : : // store values from table to inputdeck
1625 [ + + ]: 45 : for (std::size_t i=0; i<vecsize; ++i)
1626 [ + - ][ + - ]: 36 : storage[k].push_back(tableentry[k+1][i+1]);
[ + - ][ + - ]
1627 : : }
1628 : 6 : }
1629 : :
1630 : : void
1631 : 6 : LuaParser::checkStoreMatPropVecVec(
1632 : : const sol::table table,
1633 : : const std::string key,
1634 : : std::size_t nspec,
1635 : : std::size_t vecsize1,
1636 : : std::size_t vecsize2,
1637 : : std::vector<std::vector<std::vector< tk::real >>>& storage )
1638 : : // *****************************************************************************
1639 : : // Check and store material property vector into inpudeck storage
1640 : : //! \param[in] table Sol-table which contains said property
1641 : : //! \param[in] key Key for said property in Sol-table
1642 : : //! \param[in] nspec Number of species
1643 : : //! \param[in] vecsize1 Outer number of said property in Sol-table (based on
1644 : : //! number of coefficients for the defined species)
1645 : : //! \param[in] vecsize2 Inner number of said property in Sol-table (based on
1646 : : //! number of coefficients for the defined species)
1647 : : //! \param[in,out] storage Storage space in inputdeck where said property is
1648 : : //! to be stored
1649 : : // *****************************************************************************
1650 : : {
1651 : : // check validity of table
1652 [ + - ][ + - ]: 6 : if (!table[key].valid())
[ - + ]
1653 [ - - ][ - - ]: 0 : Throw("Material property '" + key + "' not specified");
[ - - ][ - - ]
1654 [ + - ][ + - ]: 6 : if (sol::table(table[key]).size() != nspec)
[ + - ][ - + ]
1655 [ - - ][ - - ]: 0 : Throw("Incorrect number of '" + key + "' vectors specified. Expected " +
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
1656 : : std::to_string(nspec) + " vectors");
1657 : :
1658 [ + - ]: 6 : storage.resize(nspec);
1659 : :
1660 [ + - ]: 12 : const auto& tableentry = table[key];
1661 [ + + ]: 15 : for (std::size_t k=0; k < nspec; k++) {
1662 [ + - ][ + - ]: 9 : if (sol::table(tableentry[k+1]).size() != vecsize1)
[ + - ][ - + ]
1663 [ - - ][ - - ]: 0 : Throw("Incorrect outer number of '" + key + "' entries in vector of species "
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
1664 : : + std::to_string(k+1) + " specified. Expected " +
1665 : : std::to_string(vecsize1));
1666 : :
1667 : : // store values from table to inputdeck
1668 [ + + ]: 36 : for (std::size_t i=0; i<vecsize1; ++i) {
1669 [ + - ][ + - ]: 27 : if (sol::table(tableentry[k+1][i+1]).size() != vecsize2)
[ + - ][ + - ]
[ - + ]
1670 [ - - ][ - - ]: 0 : Throw("Incorrect inner number of '" + key + "' entries in vector of species "
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
1671 : : + std::to_string(k+1) + " specified. Expected " +
1672 : : std::to_string(vecsize2));
1673 : 54 : std::vector< tk::real > temp_storage;
1674 [ + + ]: 243 : for (std::size_t j=0; j<vecsize2; j++)
1675 [ + - ][ + - ]: 216 : temp_storage.push_back(tableentry[k+1][i+1][j+1]);
[ + - ][ + - ]
[ + - ]
1676 [ + - ]: 27 : storage[k].push_back(temp_storage);
1677 : : }
1678 : : }
1679 : 6 : }
1680 : :
1681 : : void
1682 : 610 : LuaParser::addOutVar(
1683 : : const std::string& varname,
1684 : : const std::string& alias,
1685 : : std::vector< char >& depv,
1686 : : std::size_t nmat,
1687 : : std::size_t nspec,
1688 : : inciter::ctr::PDEType pde,
1689 : : tk::Centering c,
1690 : : std::vector< inciter::ctr::OutVar >& foutvar )
1691 : : // *****************************************************************************
1692 : : // Check and store field output variables
1693 : : //! \param[in] varname Name of variable requested
1694 : : //! \param[in] alias User specified alias for output
1695 : : //! \param[in] depv List of depvars
1696 : : //! \param[in] nmat Number of materials configured
1697 : : //! \param[in] nspec Number of species configured
1698 : : //! \param[in] pde Type of PDE configured
1699 : : //! \param[in] c Variable centering requested
1700 : : //! \param[in,out] foutvar Input deck storage where output vars are stored
1701 : : // *****************************************************************************
1702 : : {
1703 : : // index-based quantity specification
1704 : : // ----------------------------------
1705 [ + + ]: 610 : if (varname.length() == 2) {
1706 : 62 : auto qty = varname.at(0);
1707 [ + - ][ + - ]: 62 : auto j = std::stoul(std::string{varname.at(1)}) - 1;
1708 : :
1709 [ + + ]: 62 : if (pde == inciter::ctr::PDEType::MULTIMAT) {
1710 : : // multimat/matvar quantities
1711 [ - + ]: 33 : if (qty == 'D') { // density
1712 : : foutvar.emplace_back(
1713 [ - - ][ - - ]: 0 : inciter::ctr::OutVar(c, varname, alias, inciter::densityIdx(nmat,j)) );
[ - - ]
1714 : : }
1715 [ + - ]: 33 : else if (qty == 'F') { // volume fraction
1716 : : foutvar.emplace_back(
1717 [ + - ][ + - ]: 33 : inciter::ctr::OutVar(c, varname, alias, inciter::volfracIdx(nmat,j)) );
[ + - ]
1718 : : }
1719 [ - - ]: 0 : else if (qty == 'M') { // momentum
1720 : : foutvar.emplace_back(
1721 [ - - ][ - - ]: 0 : inciter::ctr::OutVar(c, varname, alias, inciter::momentumIdx(nmat,j)) );
[ - - ]
1722 : : }
1723 [ - - ]: 0 : else if (qty == 'E') { // specific total energy
1724 : : foutvar.emplace_back(
1725 [ - - ][ - - ]: 0 : inciter::ctr::OutVar(c, varname, alias, inciter::energyIdx(nmat,j)) );
[ - - ]
1726 : : }
1727 [ - - ]: 0 : else if (qty == 'U') { // velocity (primitive)
1728 : : foutvar.emplace_back(
1729 [ - - ][ - - ]: 0 : inciter::ctr::OutVar(c, varname, alias, inciter::velocityIdx(nmat,j)) );
[ - - ]
1730 : : }
1731 [ - - ]: 0 : else if (qty == 'P') { // material pressure (primitive)
1732 : : foutvar.emplace_back(
1733 [ - - ][ - - ]: 0 : inciter::ctr::OutVar(c, varname, alias, inciter::pressureIdx(nmat,j)) );
[ - - ]
1734 : : }
1735 : : else {
1736 : : // error out if incorrect matvar used
1737 [ - - ][ - - ]: 0 : Throw("field_output: matvar " + varname + " not found");
[ - - ][ - - ]
1738 : : }
1739 : : }
1740 [ + + ]: 29 : else if (pde == inciter::ctr::PDEType::MULTISPECIES) {
1741 : : // multispecies/matvar quantities
1742 [ + - ]: 12 : if (qty == 'D') { // density
1743 : : foutvar.emplace_back(
1744 [ + - ][ + - ]: 24 : inciter::ctr::OutVar(c, varname, alias,
1745 [ + - ]: 12 : inciter::multispecies::densityIdx(nspec,j)) );
1746 : : }
1747 [ - - ]: 0 : else if (qty == 'M') { // momentum
1748 : : foutvar.emplace_back(
1749 [ - - ][ - - ]: 0 : inciter::ctr::OutVar(c, varname, alias,
1750 [ - - ]: 0 : inciter::multispecies::momentumIdx(nspec,j)) );
1751 : : }
1752 [ - - ]: 0 : else if (qty == 'E') { // specific total energy
1753 : : foutvar.emplace_back(
1754 [ - - ][ - - ]: 0 : inciter::ctr::OutVar(c, varname, alias,
1755 [ - - ]: 0 : inciter::multispecies::energyIdx(nspec,j)) );
1756 : : }
1757 : : else {
1758 : : // error out if incorrect matvar used
1759 [ - - ][ - - ]: 0 : Throw("field_output: matvar " + varname + " not found");
[ - - ][ - - ]
1760 : : }
1761 : : }
1762 : : else {
1763 : : // quantities specified by depvar
1764 [ + + ]: 44 : for (const auto& id : depv)
1765 [ + + ]: 27 : if (std::tolower(qty) == id) {
1766 [ + - ][ + - ]: 17 : foutvar.emplace_back( inciter::ctr::OutVar(c, varname, alias, j) );
[ + - ]
1767 : : }
1768 : : }
1769 : : }
1770 : : // analytic quantity specification
1771 : : // -------------------------------
1772 [ + + ]: 548 : else if (varname.find("analytic") != std::string::npos) {
1773 [ + - ][ + - ]: 37 : foutvar.emplace_back( inciter::ctr::OutVar(c, varname, alias, 0) );
[ + - ]
1774 : : }
1775 : : // name-based tensor quantity specification
1776 : : // ----------------------------------------
1777 [ - + ]: 511 : else if (varname.find("_tensor") != std::string::npos) {
1778 [ - - ]: 0 : std::string namet(varname);
1779 : : // remove the "_tensor" from the varname
1780 [ - - ]: 0 : for (std::size_t i=0; i<7; ++i) namet.pop_back();
1781 : :
1782 [ - - ]: 0 : for (std::size_t i=1; i<=3; ++i) {
1783 [ - - ]: 0 : for (std::size_t j=1; j<=3; ++j) {
1784 [ - - ][ - - ]: 0 : std::string tij(namet + std::to_string(i) + std::to_string(j));
[ - - ][ - - ]
1785 [ - - ][ - - ]: 0 : foutvar.emplace_back( inciter::ctr::OutVar(c, tij, alias, 0, tij) );
1786 : : }
1787 : : }
1788 : : }
1789 : : // name-based quantity specification
1790 : : // ---------------------------------
1791 : : else {
1792 [ + - ]: 511 : foutvar.emplace_back( inciter::ctr::OutVar(c, varname, alias, 0, varname) );
1793 : : }
1794 : 610 : }
|