Use FieldFactory to evaluate expression
| 346 | namespace { |
| 347 | /// Use FieldFactory to evaluate expression |
| 348 | double parseExpression(const Options::ValueType& value, const Options* options, |
| 349 | const std::string& type, const std::string& full_name) { |
| 350 | try { |
| 351 | // Parse the string, giving this Option pointer for the context |
| 352 | // then generate a value at t,x,y,z = 0,0,0,0 |
| 353 | auto gen = FieldFactory::get()->parse(bout::utils::get<std::string>(value), options); |
| 354 | if (!gen) { |
| 355 | throw ParseException("FieldFactory did not return a generator for '{}'", |
| 356 | bout::utils::variantToString(value)); |
| 357 | } |
| 358 | return gen->generate({}); |
| 359 | } catch (ParseException& error) { |
| 360 | // Convert any exceptions to something a bit more useful |
| 361 | throw BoutException(_("Couldn't get {} from option {:s} = '{:s}': {}"), type, |
| 362 | full_name, bout::utils::variantToString(value), error.what()); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /// Helper function to print `key = value` with optional source |
| 367 | template <class T> |
no test coverage detected