347 if (obj.HasMember(
id.c_str())) {
349 if (obj[
id.c_str()].HasMember(
"type")) {
350 if (obj[
id.c_str()].HasMember(
"coeffs")) {
352 if (!type.compare(
"polynomial")) {
356 }
else if (!type.compare(
"exponential")) {
360 }
else if (!type.compare(
"logexponential")) {
364 }
else if (!type.compare(
"exppolynomial")) {
368 }
else if (!type.compare(
"polyoffset")) {
373 throw ValueError(
format(
"The type [%s] is not understood for [%s] of incompressible fluids. Please check your JSON file.",
374 type.c_str(),
id.c_str()));
379 throw ValueError(
format(
"Your file does not have an entry for \"coeffs\" in [%s], which is vital for this function.",
id.c_str()));
382 throw ValueError(
format(
"Your file does not have an entry for \"type\" in [%s], which is vital for this function.",
id.c_str()));
386 throw ValueError(
format(
"Your file does not have information for [%s], which is vital for an incompressible fluid.",
id.c_str()));
394 if (obj.HasMember(
id.c_str())) {
398 throw ValueError(
format(
"Your file does not have information for [%s], which is vital for an incompressible fluid.",
id.c_str()));
414 throw ValueError(
format(
"Cannot recognise the entry for [%s], [%s] is unknown for incompressible fluids.",
id.c_str(), res.c_str()));
420 for (rapidjson::Value::ValueIterator itr = listing.Begin(); itr != listing.End(); ++itr) {
429 std::size_t index = fluid_map.size();
441 if (
get_debug_level() >= 20) std::cout <<
format(
"Incompressible library: Loading base values for %s ", fluid.
getName().c_str()) << std::endl;
456 std::cout <<
format(
"Incompressible library: Loading coefficients for %s ", fluid.
getName().c_str()) << std::endl;
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 std::map<std::string, std::size_t>::const_iterator 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 std::map<std::size_t, IncompressibleFluid>::iterator it = fluid_map.find(key);
533 if (it != fluid_map.end()) {
536 throw ValueError(
format(
"key [%d] was not found in JSONIncompressibleLibrary", key));
543 rapidjson::Document dd;
546 if (dd.HasParseError()) {
547 throw ValueError(
"Unable to load all_incompressibles_JSON.json");
551 }
catch (std::exception& e) {
552 std::cout << e.what() << std::endl;
570 return library.
get(fluid_string);