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