46 #include <boost/algorithm/string.hpp>
47 #include <boost/iostreams/copy.hpp>
48 #include <boost/iostreams/filter/gzip.hpp>
49 #include <boost/iostreams/filtering_streambuf.hpp>
61 #include <boost/format.hpp>
62 #include <boost/program_options.hpp>
64 #ifndef NEKTAR_VERSION
65 #define NEKTAR_VERSION "Unknown"
70 namespace po = boost::program_options;
71 namespace io = boost::iostreams;
75 namespace LibUtilities
131 return solverInfoEnums;
145 return solverInfoMap;
160 return gloSysSolnInfoList;
174 return cmdLineArguments;
185 SessionReader::SessionReader(
int argc,
char *argv[])
188 m_filenames = ParseCommandLineArguments(argc, argv);
190 ASSERTL0(m_filenames.size() > 0,
"No session file(s) given.");
192 m_sessionName = ParseSessionName(m_filenames);
195 CreateComm(argc, argv);
197 TestSharedFilesystem();
201 if (m_comm->GetSize() > 1)
203 GetSolverInfoDefaults()[
"GLOBALSYSSOLN"] =
"IterativeStaticCond";
207 m_interpreter->SetRandomSeed((m_comm->GetRank() + 1) *
208 (
unsigned int)time(NULL));
217 SessionReader::SessionReader(
int argc,
char *argv[],
218 const std::vector<std::string> &pFilenames,
221 ASSERTL0(pFilenames.size() > 0,
"No filenames specified.");
223 ParseCommandLineArguments(argc, argv);
225 m_filenames = pFilenames;
227 m_sessionName = ParseSessionName(m_filenames);
232 CreateComm(argc, argv);
239 TestSharedFilesystem();
243 if (m_comm->GetSize() > 1)
245 GetSolverInfoDefaults()[
"GLOBALSYSSOLN"] =
"IterativeStaticCond";
249 m_interpreter->SetRandomSeed((m_comm->GetRank() + 1) *
250 (
unsigned int)time(NULL));
259 SessionReader::~SessionReader()
273 void SessionReader::InitSession(
const std::vector<std::string> &filenames)
276 if (filenames.size() > 0)
278 m_filenames = filenames;
285 if (DefinesCmdLineArgument(
"useoptfile"))
287 optfile = m_cmdLineOptions.find(
"useoptfile")->second.as<std::string>();
288 exists = (bool)boost::filesystem::exists(optfile.c_str());
289 ASSERTL0(exists,
"A valid .opt file was not specified "
290 "with the --useoptfile command line option");
292 m_filenames.push_back(optfile);
295 std::rotate(m_filenames.rbegin(), m_filenames.rbegin() + 1,
301 optfile = m_sessionName +
".opt";
302 exists = (bool)boost::filesystem::exists(optfile.c_str());
305 m_filenames.push_back(optfile);
308 std::rotate(m_filenames.rbegin(), m_filenames.rbegin() + 1,
313 m_updateOptFile =
true;
323 m_xmlDoc = MergeDoc(m_filenames);
336 if (m_verbose && m_comm)
338 if (m_comm->TreatAsRankZero() && m_parameters.size() > 0)
340 cout <<
"Parameters:" << endl;
341 for (
auto &x : m_parameters)
343 cout <<
"\t" << x.first <<
" = " << x.second << endl;
348 if (m_comm->TreatAsRankZero() && m_solverInfo.size() > 0)
350 cout <<
"Solver Info:" << endl;
351 for (
auto &x : m_solverInfo)
353 cout <<
"\t" << x.first <<
" = " << x.second << endl;
360 void SessionReader::TestSharedFilesystem()
362 m_sharedFilesystem =
false;
364 if (m_comm->GetSize() > 1)
366 if (m_comm->GetRank() == 0)
368 std::ofstream testfile(
"shared-fs-testfile");
369 testfile <<
"" << std::endl;
370 ASSERTL1(!testfile.fail(),
"Test file creation failed");
375 int exists = (bool)boost::filesystem::exists(
"shared-fs-testfile");
378 m_sharedFilesystem = (exists == m_comm->GetSize());
380 if ((m_sharedFilesystem && m_comm->GetRank() == 0) ||
383 std::remove(
"shared-fs-testfile");
388 m_sharedFilesystem =
false;
391 if (m_verbose && m_comm->GetRank() == 0 && m_sharedFilesystem)
393 cout <<
"Shared filesystem detected" << endl;
401 std::vector<std::string> SessionReader::ParseCommandLineArguments(
int argc,
405 po::options_description desc(
"Allowed options");
409 (
"verbose,v",
"be verbose")
410 (
"version,V",
"print version information")
411 (
"help,h",
"print this help message")
412 (
"solverinfo,I", po::value<vector<std::string> >(),
413 "override a SOLVERINFO property")
414 (
"parameter,P", po::value<vector<std::string> >(),
415 "override a parameter")
416 (
"npx", po::value<int>(),
417 "number of procs in X-dir")
418 (
"npy", po::value<int>(),
419 "number of procs in Y-dir")
420 (
"npz", po::value<int>(),
421 "number of procs in Z-dir")
422 (
"nsz", po::value<int>(),
423 "number of slices in Z-dir")
424 (
"part-only", po::value<int>(),
425 "only partition mesh into N partitions.")
426 (
"part-only-overlapping", po::value<int>(),
427 "only partition mesh into N overlapping partitions.")
428 (
"part-info",
"Output partition information")
429 #ifdef NEKTAR_USE_CWIPI
430 (
"cwipi", po::value<std::string>(),
433 (
"writeoptfile",
"write an optimisation file")
434 (
"useoptfile", po::value<std::string>(),
435 "use an optimisation file")
439 for (
auto &cmdIt : GetCmdLineArgMap())
441 std::string names = cmdIt.first;
442 if (cmdIt.second.shortName !=
"")
444 names +=
"," + cmdIt.second.shortName;
446 if (cmdIt.second.isFlag)
448 desc.add_options()(names.c_str(), cmdIt.second.description.c_str());
452 desc.add_options()(names.c_str(), po::value<std::string>(),
453 cmdIt.second.description.c_str());
459 po::options_description hidden(
"Hidden options");
463 (
"input-file", po::value< vector<string> >(),
469 po::options_description all(
"All options");
470 all.add(desc).add(hidden);
473 po::positional_options_description
p;
474 p.add(
"input-file", -1);
477 po::parsed_options parsed = po::command_line_parser(argc, argv)
480 .allow_unregistered()
484 po::store(parsed, m_cmdLineOptions);
485 po::notify(m_cmdLineOptions);
488 if (m_cmdLineOptions.count(
"help"))
495 if (m_cmdLineOptions.count(
"version"))
503 boost::replace_all(branch,
"refs/heads/",
"");
505 cout <<
" (git changeset " << sha1.substr(0, 8) <<
", ";
509 cout <<
"detached head";
513 cout <<
"head " << branch;
524 if (m_cmdLineOptions.count(
"verbose"))
534 if (m_cmdLineOptions.count(
"writeoptfile"))
536 m_updateOptFile =
true;
540 m_updateOptFile =
false;
544 for (
auto &x : parsed.options)
548 cout <<
"Warning: Unknown option: " << x.string_key << endl;
553 if (m_cmdLineOptions.count(
"input-file"))
555 return m_cmdLineOptions[
"input-file"].as<std::vector<std::string>>();
559 return std::vector<std::string>();
566 std::string SessionReader::ParseSessionName(std::vector<std::string> &filenames)
568 ASSERTL0(!filenames.empty(),
"At least one filename expected.");
570 std::string retval =
"";
573 std::string fname = filenames[0];
576 if (fname.size() > 4 && fname.substr(fname.size() - 4, 4) ==
"_xml")
578 retval = fname.substr(0, fname.find_last_of(
"_"));
581 else if (fname.size() > 4 && fname.substr(fname.size() - 4, 4) ==
".xml")
583 retval = fname.substr(0, fname.find_last_of(
"."));
586 else if (fname.size() > 7 && fname.substr(fname.size() - 7, 7) ==
".xml.gz")
588 retval = fname.substr(0, fname.find_last_of(
"."));
589 retval = retval.substr(0, retval.find_last_of(
"."));
598 TiXmlDocument &SessionReader::GetDocument()
600 ASSERTL1(m_xmlDoc,
"XML Document not defined.");
626 TiXmlElement *SessionReader::GetElement(
const string &pPath)
628 std::string vPath = boost::to_upper_copy(pPath);
629 std::vector<std::string> st;
630 boost::split(st, vPath, boost::is_any_of(
"\\/ "));
631 ASSERTL0(st.size() > 0,
"No path given in XML element request.");
633 TiXmlElement *vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
635 std::string(
"Cannot find element '") + st[0] + std::string(
"'."));
636 for (
int i = 1; i < st.size(); ++i)
638 vReturn = vReturn->FirstChildElement(st[i].c_str());
639 ASSERTL0(vReturn, std::string(
"Cannot find element '") + st[i] +
648 bool SessionReader::DefinesElement(
const std::string &pPath)
const
650 std::string vPath = boost::to_upper_copy(pPath);
651 std::vector<std::string> st;
652 boost::split(st, vPath, boost::is_any_of(
"\\/ "));
653 ASSERTL0(st.size() > 0,
"No path given in XML element request.");
655 TiXmlElement *vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
657 std::string(
"Cannot find element '") + st[0] + std::string(
"'."));
658 for (
int i = 1; i < st.size(); ++i)
660 vReturn = vReturn->FirstChildElement(st[i].c_str());
670 const std::vector<std::string> &SessionReader::GetFilenames()
const
678 const std::string &SessionReader::GetSessionName()
const
680 return m_sessionName;
687 const std::string SessionReader::GetSessionNameRank()
const
689 std::string dirname = m_sessionName +
"_xml";
690 fs::path pdirname(dirname);
692 std::string vFilename =
693 "P" + boost::lexical_cast<std::string>(m_comm->GetRowComm()->GetRank());
694 fs::path pFilename(vFilename);
696 fs::path fullpath = pdirname / pFilename;
709 bool SessionReader::GetSharedFilesystem()
711 return m_sharedFilesystem;
728 bool SessionReader::DefinesParameter(
const std::string &pName)
const
730 std::string vName = boost::to_upper_copy(pName);
731 return m_parameters.find(vName) != m_parameters.end();
742 const NekDouble &SessionReader::GetParameter(
const std::string &pName)
const
744 std::string vName = boost::to_upper_copy(pName);
745 auto paramIter = m_parameters.find(vName);
747 ASSERTL0(paramIter != m_parameters.end(),
748 "Unable to find requested parameter: " + pName);
750 return paramIter->second;
756 void SessionReader::LoadParameter(
const std::string &pName,
int &pVar)
const
758 std::string vName = boost::to_upper_copy(pName);
759 auto paramIter = m_parameters.find(vName);
760 ASSERTL0(paramIter != m_parameters.end(),
761 "Required parameter '" + pName +
"' not specified in session.");
762 NekDouble param = round(paramIter->second);
763 pVar = checked_cast<int>(param);
769 void SessionReader::LoadParameter(
const std::string &pName,
int &pVar,
770 const int &pDefault)
const
772 std::string vName = boost::to_upper_copy(pName);
773 auto paramIter = m_parameters.find(vName);
774 if (paramIter != m_parameters.end())
776 NekDouble param = round(paramIter->second);
777 pVar = checked_cast<int>(param);
788 void SessionReader::LoadParameter(
const std::string &pName,
791 std::string vName = boost::to_upper_copy(pName);
792 auto paramIter = m_parameters.find(vName);
793 ASSERTL0(paramIter != m_parameters.end(),
794 "Required parameter '" + pName +
"' not specified in session.");
795 pVar = paramIter->second;
801 void SessionReader::LoadParameter(
const std::string &pName,
NekDouble &pVar,
804 std::string vName = boost::to_upper_copy(pName);
805 auto paramIter = m_parameters.find(vName);
806 if (paramIter != m_parameters.end())
808 pVar = paramIter->second;
819 void SessionReader::SetParameter(
const std::string &pName,
int &pVar)
821 std::string vName = boost::to_upper_copy(pName);
822 m_parameters[vName] = pVar;
828 void SessionReader::SetParameter(
const std::string &pName,
NekDouble &pVar)
830 std::string vName = boost::to_upper_copy(pName);
831 m_parameters[vName] = pVar;
837 bool SessionReader::DefinesSolverInfo(
const std::string &pName)
const
839 std::string vName = boost::to_upper_copy(pName);
840 auto infoIter = m_solverInfo.find(vName);
841 return (infoIter != m_solverInfo.end());
847 const std::string &SessionReader::GetSolverInfo(
848 const std::string &pProperty)
const
850 std::string vProperty = boost::to_upper_copy(pProperty);
851 auto iter = m_solverInfo.find(vProperty);
853 ASSERTL1(iter != m_solverInfo.end(),
854 "Unable to find requested property: " + pProperty);
862 void SessionReader::SetSolverInfo(
const std::string &pProperty,
863 const std::string &pValue)
865 std::string vProperty = boost::to_upper_copy(pProperty);
866 auto iter = m_solverInfo.find(vProperty);
868 ASSERTL1(iter != m_solverInfo.end(),
869 "Unable to find requested property: " + pProperty);
871 iter->second = pValue;
877 void SessionReader::LoadSolverInfo(
const std::string &pName, std::string &pVar,
878 const std::string &pDefault)
const
880 std::string vName = boost::to_upper_copy(pName);
881 auto infoIter = m_solverInfo.find(vName);
882 if (infoIter != m_solverInfo.end())
884 pVar = infoIter->second;
895 void SessionReader::MatchSolverInfo(
const std::string &pName,
896 const std::string &pTrueVal,
bool &pVar,
897 const bool &pDefault)
const
899 std::string vName = boost::to_upper_copy(pName);
900 auto infoIter = m_solverInfo.find(vName);
901 if (infoIter != m_solverInfo.end())
903 pVar = boost::iequals(infoIter->second, pTrueVal);
914 bool SessionReader::MatchSolverInfo(
const std::string &pName,
915 const std::string &pTrueVal)
const
917 if (DefinesSolverInfo(pName))
919 std::string vName = boost::to_upper_copy(pName);
920 auto iter = m_solverInfo.find(vName);
921 if (iter != m_solverInfo.end())
923 return boost::iequals(iter->second, pTrueVal);
932 bool SessionReader::DefinesGlobalSysSolnInfo(
const std::string &pVariable,
933 const std::string &pProperty)
const
935 auto iter = GetGloSysSolnList().find(pVariable);
936 if (iter == GetGloSysSolnList().end())
941 std::string vProperty = boost::to_upper_copy(pProperty);
943 auto iter1 = iter->second.find(vProperty);
944 if (iter1 == iter->second.end())
955 const std::string &SessionReader::GetGlobalSysSolnInfo(
956 const std::string &pVariable,
const std::string &pProperty)
const
958 auto iter = GetGloSysSolnList().find(pVariable);
959 ASSERTL0(iter != GetGloSysSolnList().end(),
960 "Failed to find variable in GlobalSysSolnInfoList");
962 std::string vProperty = boost::to_upper_copy(pProperty);
963 auto iter1 = iter->second.find(vProperty);
965 ASSERTL0(iter1 != iter->second.end(),
966 "Failed to find property: " + vProperty +
967 " in GlobalSysSolnInfoList");
969 return iter1->second;
976 bool SessionReader::DefinesTimeIntScheme()
const
978 return m_timeIntScheme.method !=
"";
987 return m_timeIntScheme;
990 std::string SessionReader::GetGeometryType()
const
992 TiXmlElement *xmlGeom =
993 m_xmlDoc->FirstChildElement(
"NEKTAR")->FirstChildElement(
"GEOMETRY");
994 ASSERTL1(xmlGeom,
"Failed to find a GEOMETRY section in m_xmlDoc");
996 TiXmlAttribute *attr = xmlGeom->FirstAttribute();
999 std::string attrName(attr->Name());
1000 if (attrName ==
"HDF5FILE")
1006 attr = attr->Next();
1011 TiXmlElement *element = xmlGeom->FirstChildElement(
"VERTEX");
1012 string IsCompressed;
1013 element->QueryStringAttribute(
"COMPRESSED", &IsCompressed);
1015 if (IsCompressed.size() > 0)
1017 return "XmlCompressed";
1027 bool SessionReader::DefinesGeometricInfo(
const std::string &pName)
const
1029 std::string vName = boost::to_upper_copy(pName);
1030 return m_geometricInfo.find(vName) != m_geometricInfo.end();
1036 void SessionReader::LoadGeometricInfo(
const std::string &pName,
1038 const std::string &pDefault)
const
1040 std::string vName = boost::to_upper_copy(pName);
1041 auto iter = m_geometricInfo.find(vName);
1042 if (iter != m_geometricInfo.end())
1044 pVar = iter->second;
1055 void SessionReader::LoadGeometricInfo(
const std::string &pName,
bool &pVar,
1056 const bool &pDefault)
const
1058 std::string vName = boost::to_upper_copy(pName);
1059 auto iter = m_geometricInfo.find(vName);
1060 if (iter != m_geometricInfo.end())
1062 if (iter->second ==
"TRUE")
1080 void SessionReader::LoadGeometricInfo(
const std::string &pName,
NekDouble &pVar,
1083 std::string vName = boost::to_upper_copy(pName);
1084 auto iter = m_geometricInfo.find(vName);
1085 if (iter != m_geometricInfo.end())
1087 pVar = std::atoi(iter->second.c_str());
1098 void SessionReader::MatchGeometricInfo(
const std::string &pName,
1099 const std::string &pTrueVal,
bool &pVar,
1100 const bool &pDefault)
const
1102 std::string vName = boost::to_upper_copy(pName);
1103 auto iter = m_geometricInfo.find(vName);
1104 if (iter != m_geometricInfo.end())
1106 pVar = boost::iequals(iter->second, pTrueVal);
1117 const std::string &SessionReader::GetVariable(
const unsigned int &idx)
const
1119 ASSERTL0(idx < m_variables.size(),
"Variable index out of range.");
1120 return m_variables[idx];
1126 void SessionReader::SetVariable(
const unsigned int &idx, std::string newname)
1128 ASSERTL0(idx < m_variables.size(),
"Variable index out of range.");
1129 m_variables[idx] = newname;
1135 std::vector<std::string> SessionReader::GetVariables()
const
1143 bool SessionReader::DefinesFunction(
const std::string &pName)
const
1145 std::string vName = boost::to_upper_copy(pName);
1146 return m_functions.find(vName) != m_functions.end();
1152 bool SessionReader::DefinesFunction(
const std::string &pName,
1153 const std::string &pVariable,
1154 const int pDomain)
const
1156 std::string vName = boost::to_upper_copy(pName);
1159 auto it1 = m_functions.find(vName);
1160 if (it1 != m_functions.end())
1162 pair<std::string, int> key(pVariable, pDomain);
1163 pair<std::string, int> defkey(
"*", pDomain);
1164 bool varExists = it1->second.find(key) != it1->second.end() ||
1165 it1->second.find(defkey) != it1->second.end();
1175 const std::string &pVariable,
1176 const int pDomain)
const
1178 std::string vName = boost::to_upper_copy(pName);
1179 auto it1 = m_functions.find(vName);
1182 std::string(
"No such function '") + pName +
1183 std::string(
"' has been defined in the session file."));
1186 pair<std::string, int> key(pVariable, pDomain);
1187 pair<std::string, int> defkey(
"*", pDomain);
1189 auto it2 = it1->second.find(key);
1190 auto it3 = it1->second.find(defkey);
1191 bool specific = it2 != it1->second.end();
1192 bool wildcard = it3 != it1->second.end();
1196 "No such variable " + pVariable +
" in domain " +
1197 boost::lexical_cast<string>(pDomain) +
1198 " defined for function " + pName +
" in session file.");
1207 std::string(
"Function is defined by a file."));
1208 return it2->second.m_expression;
1215 const unsigned int &pVar,
1216 const int pDomain)
const
1218 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1219 return GetFunction(pName, m_variables[pVar], pDomain);
1225 enum FunctionType SessionReader::GetFunctionType(
const std::string &pName,
1226 const std::string &pVariable,
1227 const int pDomain)
const
1229 std::string vName = boost::to_upper_copy(pName);
1230 auto it1 = m_functions.find(vName);
1233 std::string(
"Function '") + pName + std::string(
"' not found."));
1236 pair<std::string, int> key(pVariable, pDomain);
1237 pair<std::string, int> defkey(
"*", pDomain);
1239 auto it2 = it1->second.find(key);
1240 auto it3 = it1->second.find(defkey);
1241 bool specific = it2 != it1->second.end();
1242 bool wildcard = it3 != it1->second.end();
1246 "No such variable " + pVariable +
" in domain " +
1247 boost::lexical_cast<string>(pDomain) +
1248 " defined for function " + pName +
" in session file.");
1256 return it2->second.m_type;
1262 enum FunctionType SessionReader::GetFunctionType(
const std::string &pName,
1263 const unsigned int &pVar,
1264 const int pDomain)
const
1266 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1267 return GetFunctionType(pName, m_variables[pVar], pDomain);
1273 std::string SessionReader::GetFunctionFilename(
const std::string &pName,
1274 const std::string &pVariable,
1275 const int pDomain)
const
1277 std::string vName = boost::to_upper_copy(pName);
1278 auto it1 = m_functions.find(vName);
1281 std::string(
"Function '") + pName + std::string(
"' not found."));
1284 pair<std::string, int> key(pVariable, pDomain);
1285 pair<std::string, int> defkey(
"*", pDomain);
1287 auto it2 = it1->second.find(key);
1288 auto it3 = it1->second.find(defkey);
1289 bool specific = it2 != it1->second.end();
1290 bool wildcard = it3 != it1->second.end();
1294 "No such variable " + pVariable +
" in domain " +
1295 boost::lexical_cast<string>(pDomain) +
1296 " defined for function " + pName +
" in session file.");
1304 return it2->second.m_filename;
1310 std::string SessionReader::GetFunctionFilename(
const std::string &pName,
1311 const unsigned int &pVar,
1312 const int pDomain)
const
1314 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1315 return GetFunctionFilename(pName, m_variables[pVar], pDomain);
1321 std::string SessionReader::GetFunctionFilenameVariable(
1322 const std::string &pName,
const std::string &pVariable,
1323 const int pDomain)
const
1325 std::string vName = boost::to_upper_copy(pName);
1326 auto it1 = m_functions.find(vName);
1329 std::string(
"Function '") + pName + std::string(
"' not found."));
1332 pair<std::string, int> key(pVariable, pDomain);
1333 pair<std::string, int> defkey(
"*", pDomain);
1335 auto it2 = it1->second.find(key);
1336 auto it3 = it1->second.find(defkey);
1337 bool specific = it2 != it1->second.end();
1338 bool wildcard = it3 != it1->second.end();
1342 "No such variable " + pVariable +
" in domain " +
1343 boost::lexical_cast<string>(pDomain) +
1344 " defined for function " + pName +
" in session file.");
1352 return it2->second.m_fileVariable;
1358 bool SessionReader::DefinesTag(
const std::string &pName)
const
1360 std::string vName = boost::to_upper_copy(pName);
1361 return m_tags.find(vName) != m_tags.end();
1367 void SessionReader::SetTag(
const std::string &pName,
const std::string &pValue)
1369 std::string vName = boost::to_upper_copy(pName);
1370 m_tags[vName] = pValue;
1376 const std::string &SessionReader::GetTag(
const std::string &pName)
const
1378 std::string vName = boost::to_upper_copy(pName);
1379 auto vTagIterator = m_tags.find(vName);
1380 ASSERTL0(vTagIterator != m_tags.end(),
"Requested tag does not exist.");
1381 return vTagIterator->second;
1395 bool SessionReader::DefinesCmdLineArgument(
const std::string &pName)
const
1397 return (m_cmdLineOptions.find(pName) != m_cmdLineOptions.end());
1403 void SessionReader::SubstituteExpressions(std::string &pExpr)
1405 for (
auto &exprIter : m_expressions)
1407 boost::replace_all(pExpr, exprIter.first, exprIter.second);
1414 void SessionReader::LoadDoc(
const std::string &pFilename,
1415 TiXmlDocument *pDoc)
const
1417 if (pFilename.size() > 3 &&
1418 pFilename.substr(pFilename.size() - 3, 3) ==
".gz")
1420 ifstream file(pFilename.c_str(), ios_base::in | ios_base::binary);
1421 ASSERTL0(file.good(),
"Unable to open file: " + pFilename);
1423 io::filtering_streambuf<io::input> in;
1424 in.push(io::gzip_decompressor());
1431 catch (io::gzip_error &)
1434 "Error: File '" + pFilename +
"' is corrupt.");
1437 else if (pFilename.size() > 4 &&
1438 pFilename.substr(pFilename.size() - 4, 4) ==
"_xml")
1440 fs::path pdirname(pFilename);
1442 pad % m_comm->GetRank();
1443 fs::path pRankFilename(pad.str());
1444 fs::path fullpath = pdirname / pRankFilename;
1447 ASSERTL0(file.good(),
"Unable to open file: " + fullpath.string());
1452 ifstream file(pFilename.c_str());
1453 ASSERTL0(file.good(),
"Unable to open file: " + pFilename);
1461 TiXmlDocument *SessionReader::MergeDoc(
1462 const std::vector<std::string> &pFilenames)
const
1464 ASSERTL0(pFilenames.size() > 0,
"No filenames for merging.");
1467 TiXmlDocument *vMainDoc =
new TiXmlDocument;
1468 LoadDoc(pFilenames[0], vMainDoc);
1470 TiXmlHandle vMainHandle(vMainDoc);
1471 TiXmlElement *vMainNektar =
1477 for (
int i = 1; i < pFilenames.size(); ++i)
1479 if ((pFilenames[i].compare(pFilenames[i].size() - 3, 3,
"xml") == 0) ||
1480 (pFilenames[i].compare(pFilenames[i].size() - 6, 6,
"xml.gz") ==
1482 (pFilenames[i].compare(pFilenames[i].size() - 3, 3,
"opt") == 0))
1484 TiXmlDocument *vTempDoc =
new TiXmlDocument;
1485 LoadDoc(pFilenames[i], vTempDoc);
1487 TiXmlHandle docHandle(vTempDoc);
1488 TiXmlElement *vTempNektar =
1490 TiXmlElement *
p = vTempNektar->FirstChildElement();
1494 TiXmlElement *vMainEntry =
1495 vMainNektar->FirstChildElement(
p->Value());
1500 if (!
p->FirstChild() && vMainEntry &&
1501 !boost::iequals(
p->Value(),
"COLLECTIONS"))
1503 std::string warningmsg =
1504 "File " + pFilenames[i] +
" contains " +
1505 "an empty XML element " + std::string(
p->Value()) +
1506 " which will be ignored.";
1507 NEKERROR(ErrorUtil::ewarning, warningmsg.c_str());
1513 vMainNektar->RemoveChild(vMainEntry);
1515 TiXmlElement *q =
new TiXmlElement(*
p);
1516 vMainNektar->LinkEndChild(q);
1518 p =
p->NextSiblingElement();
1530 void SessionReader::ParseDocument()
1533 ASSERTL0(m_xmlDoc,
"No XML document loaded.");
1536 TiXmlHandle docHandle(m_xmlDoc);
1538 e = docHandle.FirstChildElement(
"NEKTAR")
1539 .FirstChildElement(
"CONDITIONS")
1545 ReadGlobalSysSolnInfo(e);
1546 ReadTimeIntScheme(e);
1551 e = docHandle.FirstChildElement(
"NEKTAR")
1552 .FirstChildElement(
"FILTERS")
1561 void SessionReader::CreateComm(
int &argc,
char *argv[])
1569 string vCommModule(
"Serial");
1572 vCommModule =
"ParallelMPI";
1574 if (m_cmdLineOptions.count(
"cwipi") &&
1577 vCommModule =
"CWIPI";
1591 void SessionReader::PartitionComm()
1593 if (m_comm->GetSize() > 1)
1599 if (DefinesCmdLineArgument(
"npx"))
1601 nProcX = GetCmdLineArgument<int>(
"npx");
1603 if (DefinesCmdLineArgument(
"npy"))
1605 nProcY = GetCmdLineArgument<int>(
"npy");
1607 if (DefinesCmdLineArgument(
"npz"))
1609 nProcZ = GetCmdLineArgument<int>(
"npz");
1611 if (DefinesCmdLineArgument(
"nsz"))
1613 nStripZ = GetCmdLineArgument<int>(
"nsz");
1615 ASSERTL0(m_comm->GetSize() % (nProcZ * nProcY * nProcX) == 0,
1616 "Cannot exactly partition using PROC_Z value.");
1618 "Cannot exactly partition using PROC_Y value.");
1620 "Cannot exactly partition using PROC_X value.");
1623 int nProcSm = nProcZ * nProcY * nProcX;
1627 int nProcSem = m_comm->GetSize() / nProcSm;
1629 m_comm->SplitComm(nProcSm, nProcSem);
1630 m_comm->GetColumnComm()->SplitComm(nProcZ / nStripZ, nStripZ);
1631 m_comm->GetColumnComm()->GetColumnComm()->SplitComm((nProcY * nProcX),
1633 m_comm->GetColumnComm()->GetColumnComm()->GetColumnComm()->SplitComm(
1641 void SessionReader::ReadParameters(TiXmlElement *conditions)
1643 m_parameters.clear();
1650 TiXmlElement *parametersElement =
1651 conditions->FirstChildElement(
"PARAMETERS");
1655 if (parametersElement)
1657 TiXmlElement *parameter = parametersElement->FirstChildElement(
"P");
1665 stringstream tagcontent;
1666 tagcontent << *parameter;
1667 TiXmlNode *node = parameter->FirstChild();
1669 while (node && node->Type() != TiXmlNode::TINYXML_TEXT)
1671 node = node->NextSibling();
1677 std::string line = node->ToText()->Value(), lhs, rhs;
1681 ParseEquals(line, lhs, rhs);
1686 "Syntax error in parameter expression '" + line +
1687 "' in XML element: \n\t'" + tagcontent.str() +
1694 if (!lhs.empty() && !rhs.empty())
1702 catch (
const std::runtime_error &)
1705 "Error evaluating parameter expression"
1707 rhs +
"' in XML element: \n\t'" +
1708 tagcontent.str() +
"'");
1710 m_interpreter->SetParameter(lhs, value);
1711 caseSensitiveParameters[lhs] = value;
1712 boost::to_upper(lhs);
1713 m_parameters[lhs] = value;
1717 parameter = parameter->NextSiblingElement();
1725 void SessionReader::ReadSolverInfo(TiXmlElement *conditions)
1727 m_solverInfo.clear();
1728 m_solverInfo = GetSolverInfoDefaults();
1735 TiXmlElement *solverInfoElement =
1736 conditions->FirstChildElement(
"SOLVERINFO");
1738 if (solverInfoElement)
1740 TiXmlElement *solverInfo = solverInfoElement->FirstChildElement(
"I");
1744 std::stringstream tagcontent;
1745 tagcontent << *solverInfo;
1747 ASSERTL0(solverInfo->Attribute(
"PROPERTY"),
1748 "Missing PROPERTY attribute in solver info "
1749 "XML element: \n\t'" +
1750 tagcontent.str() +
"'");
1751 std::string solverProperty = solverInfo->Attribute(
"PROPERTY");
1753 "PROPERTY attribute must be non-empty in XML "
1755 tagcontent.str() +
"'");
1758 std::string solverPropertyUpper =
1759 boost::to_upper_copy(solverProperty);
1762 ASSERTL0(solverInfo->Attribute(
"VALUE"),
1763 "Missing VALUE attribute in solver info "
1764 "XML element: \n\t'" +
1765 tagcontent.str() +
"'");
1766 std::string solverValue = solverInfo->Attribute(
"VALUE");
1768 "VALUE attribute must be non-empty in XML "
1770 tagcontent.str() +
"'");
1773 m_solverInfo[solverPropertyUpper] = solverValue;
1774 solverInfo = solverInfo->NextSiblingElement(
"I");
1778 if (m_comm && m_comm->GetRowComm()->GetSize() > 1)
1781 m_solverInfo[
"GLOBALSYSSOLN"] ==
"IterativeFull" ||
1782 m_solverInfo[
"GLOBALSYSSOLN"] ==
"IterativeStaticCond" ||
1783 m_solverInfo[
"GLOBALSYSSOLN"] ==
1784 "IterativeMultiLevelStaticCond" ||
1785 m_solverInfo[
"GLOBALSYSSOLN"] ==
"XxtFull" ||
1786 m_solverInfo[
"GLOBALSYSSOLN"] ==
"XxtStaticCond" ||
1787 m_solverInfo[
"GLOBALSYSSOLN"] ==
"XxtMultiLevelStaticCond" ||
1788 m_solverInfo[
"GLOBALSYSSOLN"] ==
"PETScFull" ||
1789 m_solverInfo[
"GLOBALSYSSOLN"] ==
"PETScStaticCond" ||
1790 m_solverInfo[
"GLOBALSYSSOLN"] ==
"PETScMultiLevelStaticCond",
1791 "A parallel solver must be used when run in parallel.");
1798 void SessionReader::ReadGlobalSysSolnInfo(TiXmlElement *conditions)
1800 GetGloSysSolnList().clear();
1807 TiXmlElement *GlobalSys =
1808 conditions->FirstChildElement(
"GLOBALSYSSOLNINFO");
1815 TiXmlElement *VarInfo = GlobalSys->FirstChildElement(
"V");
1819 std::stringstream tagcontent;
1820 tagcontent << *VarInfo;
1821 ASSERTL0(VarInfo->Attribute(
"VAR"),
1822 "Missing VAR attribute in GobalSysSolnInfo XML "
1824 tagcontent.str() +
"'");
1826 std::string VarList = VarInfo->Attribute(
"VAR");
1828 "VAR attribute must be non-empty in XML element:\n\t'" +
1829 tagcontent.str() +
"'");
1832 std::vector<std::string> varStrings;
1833 bool valid = ParseUtils::GenerateVector(VarList, varStrings);
1835 ASSERTL0(valid,
"Unable to process list of variable in XML "
1837 tagcontent.str() +
"'");
1839 if (varStrings.size())
1841 TiXmlElement *SysSolnInfo = VarInfo->FirstChildElement(
"I");
1846 tagcontent << *SysSolnInfo;
1848 ASSERTL0(SysSolnInfo->Attribute(
"PROPERTY"),
1849 "Missing PROPERTY attribute in "
1850 "GlobalSysSolnInfo for variable(s) '" +
1851 VarList +
"' in XML element: \n\t'" +
1852 tagcontent.str() +
"'");
1854 std::string SysSolnProperty =
1855 SysSolnInfo->Attribute(
"PROPERTY");
1858 "GlobalSysSolnIno properties must have a "
1859 "non-empty name for variable(s) : '" +
1860 VarList +
"' in XML element: \n\t'" +
1861 tagcontent.str() +
"'");
1864 std::string SysSolnPropertyUpper =
1865 boost::to_upper_copy(SysSolnProperty);
1868 ASSERTL0(SysSolnInfo->Attribute(
"VALUE"),
1869 "Missing VALUE attribute in GlobalSysSolnInfo "
1870 "for variable(s) '" +
1871 VarList +
"' in XML element: \n\t" +
1872 tagcontent.str() +
"'");
1874 std::string SysSolnValue = SysSolnInfo->Attribute(
"VALUE");
1876 "GlobalSysSolnInfo properties must have a "
1877 "non-empty value for variable(s) '" +
1878 VarList +
"' in XML element: \n\t'" +
1879 tagcontent.str() +
"'");
1882 for (
int i = 0; i < varStrings.size(); ++i)
1884 auto x = GetGloSysSolnList().find(varStrings[i]);
1885 if (x == GetGloSysSolnList().end())
1887 (GetGloSysSolnList()[varStrings[i]])
1888 [SysSolnPropertyUpper] = SysSolnValue;
1892 x->second[SysSolnPropertyUpper] = SysSolnValue;
1896 SysSolnInfo = SysSolnInfo->NextSiblingElement(
"I");
1898 VarInfo = VarInfo->NextSiblingElement(
"V");
1902 if (m_verbose && GetGloSysSolnList().size() > 0 && m_comm)
1904 if (m_comm->GetRank() == 0)
1906 cout <<
"GlobalSysSoln Info:" << endl;
1908 for (
auto &x : GetGloSysSolnList())
1910 cout <<
"\t Variable: " << x.first << endl;
1912 for (
auto &y : x.second)
1914 cout <<
"\t\t " << y.first <<
" = " << y.second << endl;
1925 void SessionReader::ReadTimeIntScheme(TiXmlElement *conditions)
1932 TiXmlElement *timeInt =
1933 conditions->FirstChildElement(
"TIMEINTEGRATIONSCHEME");
1940 TiXmlElement *method = timeInt->FirstChildElement(
"METHOD");
1941 TiXmlElement *variant = timeInt->FirstChildElement(
"VARIANT");
1942 TiXmlElement *order = timeInt->FirstChildElement(
"ORDER");
1943 TiXmlElement *params = timeInt->FirstChildElement(
"FREEPARAMETERS");
1946 ASSERTL0(method,
"Missing METHOD tag inside "
1947 "TIMEINTEGRATIONSCHEME.");
1948 ASSERTL0(order,
"Missing ORDER tag inside "
1949 "TIMEINTEGRATIONSCHEME.");
1951 m_timeIntScheme.method = method->GetText();
1953 std::string orderStr = order->GetText();
1956 ASSERTL0(m_timeIntScheme.method.size() > 0,
1957 "Empty text inside METHOD tag in TIMEINTEGRATIONSCHEME.");
1959 "Empty text inside ORDER tag in TIMEINTEGRATIONSCHEME.");
1962 m_timeIntScheme.order = boost::lexical_cast<unsigned int>(orderStr);
1966 NEKERROR(ErrorUtil::efatal,
"In ORDER tag, unable to convert "
1968 orderStr +
"' to an unsigned integer.");
1973 m_timeIntScheme.variant = variant->GetText();
1978 std::string paramsStr = params->GetText();
1980 "Empty text inside FREEPARAMETERS tag in "
1981 "TIMEINTEGRATIONSCHEME.");
1983 std::vector<std::string> pSplit;
1984 boost::split(pSplit, paramsStr, boost::is_any_of(
" "));
1986 m_timeIntScheme.freeParams.resize(pSplit.size());
1987 for (
size_t i = 0; i < pSplit.size(); ++i)
1991 m_timeIntScheme.freeParams[i] =
1992 boost::lexical_cast<NekDouble>(pSplit[i]);
1996 NEKERROR(ErrorUtil::efatal,
"In FREEPARAMETERS tag, "
1997 "unable to convert string '" +
2000 "to a floating-point value.");
2005 if (m_verbose && m_comm)
2007 if (m_comm->GetRank() == 0)
2009 cout <<
"Trying to use time integration scheme:" << endl;
2010 cout <<
"\t Method : " << m_timeIntScheme.method << endl;
2011 cout <<
"\t Variant: " << m_timeIntScheme.variant << endl;
2012 cout <<
"\t Order : " << m_timeIntScheme.order << endl;
2014 if (m_timeIntScheme.freeParams.size() > 0)
2016 cout <<
"\t Params :";
2017 for (
auto &x : m_timeIntScheme.freeParams)
2030 void SessionReader::ReadExpressions(TiXmlElement *conditions)
2032 m_expressions.clear();
2039 TiXmlElement *expressionsElement =
2040 conditions->FirstChildElement(
"EXPRESSIONS");
2042 if (expressionsElement)
2044 TiXmlElement *expr = expressionsElement->FirstChildElement(
"E");
2048 stringstream tagcontent;
2049 tagcontent << *expr;
2051 "Missing NAME attribute in expression "
2052 "definition: \n\t'" +
2053 tagcontent.str() +
"'");
2054 std::string nameString = expr->Attribute(
"NAME");
2056 "Expressions must have a non-empty name: \n\t'" +
2057 tagcontent.str() +
"'");
2060 "Missing VALUE attribute in expression "
2061 "definition: \n\t'" +
2062 tagcontent.str() +
"'");
2063 std::string valString = expr->Attribute(
"VALUE");
2065 "Expressions must have a non-empty value: \n\t'" +
2066 tagcontent.str() +
"'");
2068 auto exprIter = m_expressions.find(nameString);
2069 ASSERTL0(exprIter == m_expressions.end(),
2070 std::string(
"Expression '") + nameString +
2071 std::string(
"' already specified."));
2073 m_expressions[nameString] = valString;
2074 expr = expr->NextSiblingElement(
"E");
2082 void SessionReader::ReadVariables(TiXmlElement *conditions)
2084 m_variables.clear();
2091 TiXmlElement *variablesElement = conditions->FirstChildElement(
"VARIABLES");
2095 if (variablesElement)
2097 TiXmlElement *varElement = variablesElement->FirstChildElement(
"V");
2100 int nextVariableNumber = -1;
2104 stringstream tagcontent;
2105 tagcontent << *varElement;
2109 nextVariableNumber++;
2112 int err = varElement->QueryIntAttribute(
"ID", &i);
2114 "Variables must have a unique ID number attribute "
2115 "in XML element: \n\t'" +
2116 tagcontent.str() +
"'");
2118 "ID numbers for variables must begin with zero and"
2119 " be sequential in XML element: \n\t'" +
2120 tagcontent.str() +
"'");
2122 TiXmlNode *varChild = varElement->FirstChild();
2127 while (varChild && varChild->Type() != TiXmlNode::TINYXML_TEXT)
2129 varChild = varChild->NextSibling();
2132 ASSERTL0(varChild,
"Unable to read variable definition body for "
2133 "variable with ID " +
2134 boost::lexical_cast<string>(i) +
2135 " in XML element: \n\t'" + tagcontent.str() +
2137 std::string variableName = varChild->ToText()->ValueStr();
2139 std::istringstream variableStrm(variableName);
2140 variableStrm >> variableName;
2143 variableName) == m_variables.end(),
2144 "Variable with ID " + boost::lexical_cast<string>(i) +
2145 " in XML element \n\t'" + tagcontent.str() +
2146 "'\nhas already been defined.");
2148 m_variables.push_back(variableName);
2150 varElement = varElement->NextSiblingElement(
"V");
2154 "Number of variables must be greater than zero.");
2161 void SessionReader::ReadFunctions(TiXmlElement *conditions)
2163 m_functions.clear();
2171 TiXmlElement *
function = conditions->FirstChildElement(
"FUNCTION");
2174 stringstream tagcontent;
2175 tagcontent << *
function;
2178 ASSERTL0(function->Attribute(
"NAME"),
2179 "Functions must have a NAME attribute defined in XML "
2181 tagcontent.str() +
"'");
2182 std::string functionStr =
function->Attribute(
"NAME");
2184 "Functions must have a non-empty name in XML "
2186 tagcontent.str() +
"'");
2189 boost::to_upper(functionStr);
2192 TiXmlElement *variable =
function->FirstChildElement();
2201 std::string conditionType = variable->Value();
2204 std::string variableStr;
2205 if (!variable->Attribute(
"VAR"))
2211 variableStr = variable->Attribute(
"VAR");
2215 std::vector<std::string> variableList;
2216 ParseUtils::GenerateVector(variableStr, variableList);
2219 std::string domainStr;
2220 if (!variable->Attribute(
"DOMAIN"))
2226 domainStr = variable->Attribute(
"DOMAIN");
2230 std::string evarsStr =
"x y z t";
2231 if (variable->Attribute(
"EVARS"))
2234 evarsStr + std::string(
" ") + variable->Attribute(
"EVARS");
2238 std::vector<std::string> varSplit;
2239 std::vector<unsigned int> domainList;
2240 ParseUtils::GenerateSeqVector(domainStr, domainList);
2243 if (conditionType ==
"E")
2248 ASSERTL0(variable->Attribute(
"VALUE"),
2249 "Attribute VALUE expected for function '" +
2250 functionStr +
"'.");
2251 std::string fcnStr = variable->Attribute(
"VALUE");
2254 (std::string(
"Expression for var: ") + variableStr +
2255 std::string(
" must be specified."))
2258 SubstituteExpressions(fcnStr);
2263 m_interpreter, fcnStr, evarsStr);
2267 else if (conditionType ==
"F")
2269 if (variable->Attribute(
"TIMEDEPENDENT") &&
2270 boost::lexical_cast<bool>(
2271 variable->Attribute(
"TIMEDEPENDENT")))
2281 ASSERTL0(variable->Attribute(
"FILE"),
2282 "Attribute FILE expected for function '" +
2283 functionStr +
"'.");
2284 std::string filenameStr = variable->Attribute(
"FILE");
2287 "A filename must be specified for the FILE "
2288 "attribute of function '" +
2289 functionStr +
"'.");
2291 std::vector<std::string> fSplit;
2292 boost::split(fSplit, filenameStr, boost::is_any_of(
":"));
2294 ASSERTL0(fSplit.size() == 1 || fSplit.size() == 2,
2295 "Incorrect filename specification in function " +
2298 "Specify variables inside file as: "
2299 "filename:var1,var2");
2304 if (fSplit.size() == 2)
2307 "Filename variable mapping not valid "
2308 "when using * as a variable inside "
2310 functionStr +
"'.");
2312 boost::split(varSplit, fSplit[1], boost::is_any_of(
","));
2313 ASSERTL0(varSplit.size() == variableList.size(),
2314 "Filename variables should contain the "
2315 "same number of variables defined in "
2316 "VAR in function " +
2317 functionStr +
"'.");
2324 stringstream tagcontent;
2325 tagcontent << *variable;
2328 "Identifier " + conditionType +
" in function " +
2329 std::string(function->Attribute(
"NAME")) +
2330 " is not recognised in XML element: \n\t'" +
2331 tagcontent.str() +
"'");
2335 for (
unsigned int i = 0; i < variableList.size(); ++i)
2337 for (
unsigned int j = 0; j < domainList.size(); ++j)
2340 pair<std::string, int> key(variableList[i], domainList[j]);
2341 auto fcnsIter = functionVarMap.find(key);
2343 fcnsIter == functionVarMap.end(),
2344 "Error setting expression '" + variableList[i] +
2346 boost::lexical_cast<std::string>(domainList[j]) +
2347 "' in function '" + functionStr +
2349 "Expression has already been defined.");
2351 if (varSplit.size() > 0)
2355 functionVarMap[key] = funcDef2;
2359 functionVarMap[key] = funcDef;
2364 variable = variable->NextSiblingElement();
2367 m_functions[functionStr] = functionVarMap;
2368 function =
function->NextSiblingElement(
"FUNCTION");
2375 void SessionReader::ReadFilters(TiXmlElement *filters)
2384 TiXmlElement *filter = filters->FirstChildElement(
"FILTER");
2387 ASSERTL0(filter->Attribute(
"TYPE"),
2388 "Missing attribute 'TYPE' for filter.");
2389 std::string typeStr = filter->Attribute(
"TYPE");
2391 std::map<std::string, std::string> vParams;
2393 TiXmlElement *param = filter->FirstChildElement(
"PARAM");
2397 "Missing attribute 'NAME' for parameter in filter " +
2399 std::string nameStr = param->Attribute(
"NAME");
2401 ASSERTL0(param->GetText(),
"Empty value string for param.");
2402 std::string valueStr = param->GetText();
2404 vParams[nameStr] = valueStr;
2406 param = param->NextSiblingElement(
"PARAM");
2409 m_filters.push_back(
2410 std::pair<std::string, FilterParams>(typeStr, vParams));
2412 filter = filter->NextSiblingElement(
"FILTER");
2416 void SessionReader::ParseEquals(
const std::string &line, std::string &lhs,
2420 size_t beg = line.find_first_not_of(
" ");
2421 size_t end = line.find_first_of(
"=");
2426 if (end != line.find_last_of(
"="))
2429 if (end == std::string::npos)
2432 lhs = line.substr(line.find_first_not_of(
" "), end - beg);
2433 lhs = lhs.substr(0, lhs.find_last_not_of(
" ") + 1);
2434 rhs = line.substr(line.find_last_of(
"=") + 1);
2435 rhs = rhs.substr(rhs.find_first_not_of(
" "));
2436 rhs = rhs.substr(0, rhs.find_last_not_of(
" ") + 1);
2442 void SessionReader::CmdLineOverride()
2445 if (m_cmdLineOptions.count(
"solverinfo"))
2447 std::vector<std::string> solverInfoList =
2448 m_cmdLineOptions[
"solverinfo"].as<std::vector<std::string>>();
2450 for (
size_t i = 0; i < solverInfoList.size(); ++i)
2452 std::string lhs, rhs;
2456 ParseEquals(solverInfoList[i], lhs, rhs);
2460 NEKERROR(ErrorUtil::efatal,
"Parse error with command line "
2465 std::string lhsUpper = boost::to_upper_copy(lhs);
2466 m_solverInfo[lhsUpper] = rhs;
2470 if (m_cmdLineOptions.count(
"parameter"))
2472 std::vector<std::string> parametersList =
2473 m_cmdLineOptions[
"parameter"].as<std::vector<std::string>>();
2475 for (
size_t i = 0; i < parametersList.size(); ++i)
2477 std::string lhs, rhs;
2481 ParseEquals(parametersList[i], lhs, rhs);
2485 NEKERROR(ErrorUtil::efatal,
"Parse error with command line "
2490 std::string lhsUpper = boost::to_upper_copy(lhs);
2494 m_parameters[lhsUpper] = boost::lexical_cast<NekDouble>(rhs);
2498 NEKERROR(ErrorUtil::efatal,
"Unable to convert string: " + rhs +
2499 "to double value.");
2505 void SessionReader::VerifySolverInfo()
2507 for (
auto &x : m_solverInfo)
2509 std::string solverProperty = x.first;
2510 std::string solverValue = x.second;
2512 auto propIt = GetSolverInfoEnums().find(solverProperty);
2513 if (propIt != GetSolverInfoEnums().end())
2515 auto valIt = propIt->second.find(solverValue);
2516 ASSERTL0(valIt != propIt->second.end(),
"Value '" + solverValue +
2517 "' is not valid for "
2519 solverProperty +
"'");
2524 void SessionReader::SetUpXmlDoc(
void)
2526 m_xmlDoc = MergeDoc(m_filenames);
2531 return m_interpreter;
2539 std::string elementName,
2540 const TiXmlHandle &docHandle)
2542 TiXmlElement *element = docHandle.FirstChildElement(elementName).Element();
2549 NEKERROR(ErrorUtil::efatal,
"Unable to find '" + elementName +
2550 "' XML node in " + filename);
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
NekDouble Evaluate() const
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static void Finalise(gs_data *pGsh)
Deallocates the GSLib mapping data.
std::shared_ptr< Interpreter > InterpreterSharedPtr
std::map< std::string, std::string > SolverInfoMap
std::map< std::string, GloSysInfoMap > GloSysSolnInfoList
std::map< std::pair< std::string, int >, FunctionVariableDefinition > FunctionVariableMap
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
std::map< std::string, NekDouble > ParameterMap
std::shared_ptr< Equation > EquationSharedPtr
TiXmlElement * GetChildElementOrThrow(const std::string &filename, std::string elementName, const TiXmlHandle &docHandle)
std::map< std::string, EnumMap > EnumMapList
std::vector< std::pair< std::string, FilterParams > > FilterMap
CommFactory & GetCommFactory()
std::map< std::string, CmdLineArg > CmdLineArgMap
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
@ eFunctionTypeExpression
@ eFunctionTypeTransientFile
const std::string kGitBranch
const std::string kGitSha1
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
The above copyright notice and this permission notice shall be included.
EquationSharedPtr m_expression
std::string m_fileVariable