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