350 if (obj.contains(
id)) {
351 const nlohmann::json& entry = obj.at(
id);
352 if (entry.contains(
"type")) {
353 if (entry.contains(
"coeffs")) {
355 if (!type.compare(
"polynomial")) {
359 }
else if (!type.compare(
"exponential")) {
363 }
else if (!type.compare(
"logexponential")) {
367 }
else if (!type.compare(
"exppolynomial")) {
371 }
else if (!type.compare(
"polyoffset")) {
376 throw ValueError(
format(
"The type [%s] is not understood for [%s] of incompressible fluids. Please check your JSON file.",
377 type.c_str(),
id.c_str()));
380 throw ValueError(
format(
"Your file does not have an entry for \"coeffs\" in [%s], which is vital for this function.",
id.c_str()));
383 throw ValueError(
format(
"Your file does not have an entry for \"type\" in [%s], which is vital for this function.",
id.c_str()));
387 throw ValueError(
format(
"Your file does not have information for [%s], which is vital for an incompressible fluid.",
id.c_str()));
395 if (obj.contains(
id)) {
399 throw ValueError(
format(
"Your file does not have information for [%s], which is vital for an incompressible fluid.",
id.c_str()));
415 throw ValueError(
format(
"Cannot recognise the entry for [%s], [%s] is unknown for incompressible fluids.",
id.c_str(), res.c_str()));
421 for (
const auto& fluid_json : listing) {
430 std::size_t index = fluid_map.size();
442 if (
get_debug_level() >= 20) std::cout <<
format(
"Incompressible library: Loading base values for %s ", fluid.
getName().c_str()) <<
'\n';
456 if (
get_debug_level() >= 20) std::cout <<
format(
"Incompressible library: Loading coefficients for %s ", fluid.
getName().c_str()) <<
'\n';
480 string_to_index_map[fluid.
getName()] = index;
484 this->name_vector_pure.push_back(fluid.
getName());
486 this->name_vector_solution.push_back(fluid.
getName());
488 }
catch (std::exception& e) {
489 std::cout <<
format(
"Unable to load fluid: %s; error was %s\n", fluid.
getName().c_str(), e.what());
498 std::size_t index = fluid_map.size();
501 fluid_map[index] = fluid_obj;
510 string_to_index_map[fluid.
getName()] = index;
516 auto it = string_to_index_map.find(key);
518 if (it != string_to_index_map.end()) {
519 return get(it->second);
521 throw ValueError(
format(
"key [%s] was not found in string_to_index_map in JSONIncompressibleLibrary", key.c_str()));
531 auto it = fluid_map.find(key);
533 if (it != fluid_map.end()) {
536 throw ValueError(
format(
"key [%d] was not found in JSONIncompressibleLibrary", key));
546static std::once_flag library_load_flag;
548static void ensure_library_loaded() {
557 }
catch (std::exception& e) {
558 std::cout << e.what() <<
'\n';
565 ensure_library_loaded();
570 ensure_library_loaded();
571 return library.
get(fluid_string);
575 ensure_library_loaded();
579 ensure_library_loaded();