48 #include <boost/iostreams/filtering_streambuf.hpp>
49 #include <boost/iostreams/copy.hpp>
50 #include <boost/iostreams/filter/gzip.hpp>
51 #include <boost/algorithm/string.hpp>
60 #include <boost/program_options.hpp>
61 #include <boost/format.hpp>
63 #ifndef NEKTAR_VERSION
64 #define NEKTAR_VERSION "Unknown"
67 namespace po = boost::program_options;
68 namespace io = boost::iostreams;
72 namespace LibUtilities
128 return solverInfoEnums;
143 return solverInfoMap;
159 return gloSysSolnInfoList;
173 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);
199 if (m_comm->GetSize() > 1)
201 GetSolverInfoDefaults()[
"GLOBALSYSSOLN"] =
202 "IterativeStaticCond";
210 SessionReader::SessionReader(
213 const std::vector<std::string> &pFilenames,
216 ASSERTL0(pFilenames.size() > 0,
"No filenames specified.");
218 ParseCommandLineArguments(argc, argv);
220 m_filenames = pFilenames;
222 m_sessionName = ParseSessionName(m_filenames);
227 CreateComm(argc, argv);
233 if (m_comm->GetSize() > 1)
235 GetSolverInfoDefaults()[
"GLOBALSYSSOLN"] =
236 "IterativeStaticCond";
242 if (m_comm->GetSize() > 1)
244 GetSolverInfoDefaults()[
"GLOBALSYSSOLN"] =
245 "IterativeStaticCond";
253 SessionReader::~SessionReader()
265 void SessionReader::InitSession()
267 m_exprEvaluator.SetRandomSeed((m_comm->GetRank() + 1) * time(NULL));
283 if (m_verbose && m_comm)
285 if (m_comm->GetRank() == 0 && m_parameters.size() > 0)
287 cout <<
"Parameters:" << endl;
289 for (x = m_parameters.begin(); x != m_parameters.end(); ++x)
291 cout <<
"\t" << x->first <<
" = " << x->second << endl;
296 if (m_comm->GetRank() == 0 && m_solverInfo.size() > 0)
298 cout <<
"Solver Info:" << endl;
300 for (x = m_solverInfo.begin(); x != m_solverInfo.end(); ++x)
302 cout <<
"\t" << x->first <<
" = " << x->second << endl;
314 std::vector<std::string> SessionReader::ParseCommandLineArguments(
315 int argc,
char *argv[])
318 po::options_description desc(
"Allowed options");
320 (
"verbose,v",
"be verbose")
321 (
"version,V",
"print version information")
322 (
"help,h",
"print this help message")
323 (
"solverinfo,I", po::value<vector<std::string> >(),
324 "override a SOLVERINFO property")
325 (
"parameter,P", po::value<vector<std::string> >(),
326 "override a parameter")
327 (
"shared-filesystem,s",
"Using shared filesystem.")
328 (
"npx", po::value<int>(),
329 "number of procs in X-dir")
330 (
"npy", po::value<int>(),
331 "number of procs in Y-dir")
332 (
"npz", po::value<int>(),
333 "number of procs in Z-dir")
334 (
"part-only", po::value<int>(),
335 "only partition mesh into N partitions.")
336 (
"part-info",
"Output partition information")
339 CmdLineArgMap::const_iterator cmdIt;
340 for (cmdIt = GetCmdLineArgMap().begin();
341 cmdIt != GetCmdLineArgMap().end(); ++cmdIt)
343 std::string names = cmdIt->first;
344 if (cmdIt->second.shortName !=
"")
346 names +=
"," + cmdIt->second.shortName;
348 if (cmdIt->second.isFlag)
351 (names.c_str(), cmdIt->second.description.c_str())
357 (names.c_str(), po::value<std::string>(),
358 cmdIt->second.description.c_str())
365 po::options_description hidden(
"Hidden options");
367 (
"input-file", po::value< vector<string> >(),
372 po::options_description all(
"All options");
373 all.add(desc).add(hidden);
376 po::positional_options_description p;
377 p.add(
"input-file", -1);
380 po::parsed_options parsed = po::command_line_parser(argc, argv).
383 allow_unregistered().
387 po::store(parsed, m_cmdLineOptions);
388 po::notify(m_cmdLineOptions);
391 if (m_cmdLineOptions.count(
"help"))
398 if (m_cmdLineOptions.count(
"version"))
406 boost::replace_all(branch,
"refs/heads/",
"");
408 cout <<
" (git changeset " << sha1.substr(0, 8) <<
", ";
412 cout <<
"detached head";
416 cout <<
"head " << branch;
427 if (m_cmdLineOptions.count(
"verbose"))
437 std::vector< po::basic_option<char> >
::iterator x;
438 for (x = parsed.options.begin(); x != parsed.options.end(); ++x)
442 cout <<
"Warning: Unknown option: " << x->string_key
448 if (m_cmdLineOptions.count(
"input-file"))
450 return m_cmdLineOptions[
"input-file"].as<
451 std::vector<std::string> >();
455 return std::vector<std::string>();
463 std::string SessionReader::ParseSessionName(
464 std::vector<std::string> &filenames)
467 "At least one filename expected.");
469 std::string retval =
"";
472 std::string fname = filenames[0];
475 if (fname.size() > 4 &&
476 fname.substr(fname.size() - 4, 4) ==
"_xml")
478 retval = fname.substr(0, fname.find_last_of(
"_"));
481 else if (fname.size() > 4 &&
482 fname.substr(fname.size() - 4, 4) ==
".xml")
484 retval = fname.substr(0, fname.find_last_of(
"."));
487 else if (fname.size() > 7 &&
488 fname.substr(fname.size() - 7, 7) ==
".xml.gz")
490 retval = fname.substr(0, fname.find_last_of(
"."));
491 retval = retval.substr(0, retval.find_last_of(
"."));
501 TiXmlDocument& SessionReader::GetDocument()
503 ASSERTL1(m_xmlDoc,
"XML Document not defined.");
530 TiXmlElement* SessionReader::GetElement(
const string& pPath)
532 std::string vPath = boost::to_upper_copy(pPath);
533 std::vector<std::string> st;
534 boost::split(st, vPath, boost::is_any_of(
"\\/ "));
535 ASSERTL0(st.size() > 0,
"No path given in XML element request.");
537 TiXmlElement* vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
538 ASSERTL0(vReturn, std::string(
"Cannot find element '")
539 + st[0] + std::string(
"'."));
540 for (
int i = 1; i < st.size(); ++i)
542 vReturn = vReturn->FirstChildElement(st[i].c_str());
543 ASSERTL0(vReturn, std::string(
"Cannot find element '")
544 + st[i] + std::string(
"'."));
553 bool SessionReader::DefinesElement(
const std::string &pPath)
const
555 std::string vPath = boost::to_upper_copy(pPath);
556 std::vector<std::string> st;
557 boost::split(st, vPath, boost::is_any_of(
"\\/ "));
558 ASSERTL0(st.size() > 0,
"No path given in XML element request.");
560 TiXmlElement* vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
561 ASSERTL0(vReturn, std::string(
"Cannot find element '")
562 + st[0] + std::string(
"'."));
563 for (
int i = 1; i < st.size(); ++i)
565 vReturn = vReturn->FirstChildElement(st[i].c_str());
566 if (!vReturn)
return false;
575 const std::vector<std::string>& SessionReader::GetFilenames()
const
584 const std::string& SessionReader::GetSessionName()
const
586 return m_sessionName;
594 const std::string SessionReader::GetSessionNameRank()
const
596 std::string dirname = m_sessionName +
"_xml";
597 fs::path pdirname(dirname);
599 std::string vFilename =
"P" + boost::lexical_cast<std::string>(m_comm->GetRowComm()->GetRank());
600 fs::path pFilename(vFilename);
602 fs::path fullpath = pdirname / pFilename;
631 bool SessionReader::DefinesParameter(
const std::string& pName)
const
633 std::string vName = boost::to_upper_copy(pName);
634 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
635 return (paramIter != m_parameters.end());
648 const std::string& pName)
const
650 std::string vName = boost::to_upper_copy(pName);
651 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
653 ASSERTL0(paramIter != m_parameters.end(),
654 "Unable to find requested parameter: " + pName);
656 return paramIter->second;
663 void SessionReader::LoadParameter(
664 const std::string &pName,
int &pVar)
const
666 std::string vName = boost::to_upper_copy(pName);
667 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
668 ASSERTL0(paramIter != m_parameters.end(),
"Required parameter '" +
669 pName +
"' not specified in session.");
670 pVar = (int)floor(paramIter->second);
677 void SessionReader::LoadParameter(
678 const std::string &pName,
int &pVar,
const int &pDefault)
const
680 std::string vName = boost::to_upper_copy(pName);
681 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
682 if(paramIter != m_parameters.end())
684 pVar = (int)floor(paramIter->second);
696 void SessionReader::LoadParameter(
697 const std::string &pName,
NekDouble& pVar)
const
699 std::string vName = boost::to_upper_copy(pName);
700 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
701 ASSERTL0(paramIter != m_parameters.end(),
"Required parameter '" +
702 pName +
"' not specified in session.");
703 pVar = paramIter->second;
710 void SessionReader::LoadParameter(
711 const std::string &pName,
715 std::string vName = boost::to_upper_copy(pName);
716 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
717 if(paramIter != m_parameters.end())
719 pVar = paramIter->second;
732 void SessionReader::SetParameter(
const std::string &pName,
int &pVar)
734 std::string vName = boost::to_upper_copy(pName);
735 m_parameters[vName] = pVar;
742 void SessionReader::SetParameter(
743 const std::string &pName,
NekDouble& pVar)
745 std::string vName = boost::to_upper_copy(pName);
746 m_parameters[vName] = pVar;
754 bool SessionReader::DefinesSolverInfo(
const std::string &pName)
const
756 std::string vName = boost::to_upper_copy(pName);
757 SolverInfoMap::const_iterator infoIter = m_solverInfo.find(vName);
758 return (infoIter != m_solverInfo.end());
765 const std::string& SessionReader::GetSolverInfo(
766 const std::string &pProperty)
const
768 std::string vProperty = boost::to_upper_copy(pProperty);
769 SolverInfoMap::const_iterator iter = m_solverInfo.find(vProperty);
771 ASSERTL1(iter != m_solverInfo.end(),
772 "Unable to find requested property: " + pProperty);
780 void SessionReader::SetSolverInfo(
781 const std::string &pProperty,
const std::string &pValue)
783 std::string vProperty = boost::to_upper_copy(pProperty);
786 ASSERTL1(iter != m_solverInfo.end(),
787 "Unable to find requested property: " + pProperty);
789 iter->second = pValue;
795 void SessionReader::LoadSolverInfo(
796 const std::string &pName,
798 const std::string &pDefault)
const
800 std::string vName = boost::to_upper_copy(pName);
801 SolverInfoMap::const_iterator infoIter = m_solverInfo.find(vName);
802 if(infoIter != m_solverInfo.end())
804 pVar = infoIter->second;
816 void SessionReader::MatchSolverInfo(
817 const std::string &pName,
818 const std::string &pTrueVal,
820 const bool &pDefault)
const
822 std::string vName = boost::to_upper_copy(pName);
823 SolverInfoMap::const_iterator infoIter = m_solverInfo.find(vName);
824 if(infoIter != m_solverInfo.end())
826 pVar = boost::iequals(infoIter->second, pTrueVal);
838 bool SessionReader::MatchSolverInfo(
839 const std::string &pName,
840 const std::string &pTrueVal)
const
842 if (DefinesSolverInfo(pName))
844 std::string vName = boost::to_upper_copy(pName);
845 SolverInfoMap::const_iterator iter = m_solverInfo.find(vName);
846 if(iter != m_solverInfo.end())
858 bool SessionReader::DefinesGlobalSysSolnInfo(
const std::string &pVariable,
859 const std::string &pProperty)
const
862 GloSysSolnInfoList::const_iterator iter =
863 GetGloSysSolnList().find(pVariable);
864 if(iter == GetGloSysSolnList().end())
869 std::string vProperty = boost::to_upper_copy(pProperty);
871 GloSysInfoMap::const_iterator iter1 = iter->second.find(vProperty);
872 if(iter1 == iter->second.end())
884 const std::string &SessionReader::GetGlobalSysSolnInfo(
const std::string &pVariable,
const std::string &pProperty)
const
886 GloSysSolnInfoList::const_iterator iter;
888 ASSERTL0( (iter = GetGloSysSolnList().
find(pVariable)) !=
889 GetGloSysSolnList().end(),
890 "Failed to find variable in GlobalSysSolnInfoList");
892 std::string vProperty = boost::to_upper_copy(pProperty);
893 GloSysInfoMap::const_iterator iter1;
895 ASSERTL0( (iter1 = iter->second.find(vProperty)) != iter->second.end(),
896 "Failed to find property: " + vProperty +
" in GlobalSysSolnInfoList");
898 return iter1->second;
904 bool SessionReader::DefinesGeometricInfo(
const std::string &pName)
const
906 std::string vName = boost::to_upper_copy(pName);
907 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
908 return (iter != m_geometricInfo.end());
915 void SessionReader::LoadGeometricInfo(
916 const std::string &pName,
918 const std::string &pDefault)
const
920 std::string vName = boost::to_upper_copy(pName);
921 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
922 if(iter != m_geometricInfo.end())
936 void SessionReader::LoadGeometricInfo(
937 const std::string &pName,
939 const bool &pDefault)
const
941 std::string vName = boost::to_upper_copy(pName);
942 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
943 if(iter != m_geometricInfo.end())
945 if (iter->second ==
"TRUE")
964 void SessionReader::LoadGeometricInfo(
965 const std::string &pName,
969 std::string vName = boost::to_upper_copy(pName);
970 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
971 if(iter != m_geometricInfo.end())
973 pVar = std::atoi(iter->second.c_str());
985 void SessionReader::MatchGeometricInfo(
986 const std::string &pName,
987 const std::string &pTrueVal,
989 const bool &pDefault)
const
991 std::string vName = boost::to_upper_copy(pName);
992 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
993 if(iter != m_geometricInfo.end())
995 pVar = boost::iequals(iter->second, pTrueVal);
1007 const std::string& SessionReader::GetVariable(
1008 const unsigned int &idx)
const
1010 ASSERTL0(idx < m_variables.size(),
"Variable index out of range.");
1011 return m_variables[idx];
1019 void SessionReader::SetVariable(
const unsigned int &idx,
1020 std::string newname)
1022 ASSERTL0(idx < m_variables.size(),
"Variable index out of range.");
1023 m_variables[idx] = newname;
1030 std::vector<std::string> SessionReader::GetVariables()
const
1039 bool SessionReader::DefinesFunction(
const std::string &pName)
const
1041 FunctionMap::const_iterator it1;
1042 std::string vName = boost::to_upper_copy(pName);
1044 if ((it1 = m_functions.find(vName)) != m_functions.end())
1055 bool SessionReader::DefinesFunction(
1056 const std::string &pName,
1057 const std::string &pVariable,
1058 const int pDomain)
const
1060 FunctionMap::const_iterator it1;
1061 FunctionVariableMap::const_iterator it2;
1062 std::string vName = boost::to_upper_copy(pName);
1065 if ((it1 = m_functions.find(vName)) != m_functions.end())
1067 pair<std::string, int> key(pVariable,pDomain);
1068 pair<std::string, int> defkey(
"*",pDomain);
1070 (it2 = it1->second.find(key)) != it1->second.end() ||
1071 (it2 = it1->second.find(defkey)) != it1->second.end();
1082 const std::string &pName,
1083 const std::string &pVariable,
1084 const int pDomain)
const
1086 FunctionMap::const_iterator it1;
1087 FunctionVariableMap::const_iterator it2, it3;
1088 std::string vName = boost::to_upper_copy(pName);
1090 ASSERTL0((it1 = m_functions.find(vName)) != m_functions.end(),
1091 std::string(
"No such function '") + pName
1092 + std::string(
"' has been defined in the session file."));
1095 pair<std::string,int> key(pVariable,pDomain);
1096 pair<std::string,int> defkey(
"*",pDomain);
1097 bool specific = (it2 = it1->second.find(key)) !=
1099 bool wildcard = (it3 = it1->second.find(defkey)) !=
1104 "No such variable " + pVariable
1105 +
" in domain " + boost::lexical_cast<string>(pDomain)
1106 +
" defined for function " + pName
1107 +
" in session file.");
1116 std::string(
"Function is defined by a file."));
1117 return it2->second.m_expression;
1125 const std::string &pName,
1126 const unsigned int &pVar,
1127 const int pDomain)
const
1129 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1130 return GetFunction(pName, m_variables[pVar],pDomain);
1138 const std::string &pName,
1139 const std::string &pVariable,
1140 const int pDomain)
const
1142 FunctionMap::const_iterator it1;
1143 FunctionVariableMap::const_iterator it2, it3;
1144 std::string vName = boost::to_upper_copy(pName);
1146 it1 = m_functions.find(vName);
1147 ASSERTL0 (it1 != m_functions.end(),
1148 std::string(
"Function '") + pName
1149 + std::string(
"' not found."));
1152 pair<std::string,int> key(pVariable,pDomain);
1153 pair<std::string,int> defkey(
"*",pDomain);
1154 bool specific = (it2 = it1->second.find(key)) !=
1156 bool wildcard = (it3 = it1->second.find(defkey)) !=
1161 "No such variable " + pVariable
1162 +
" in domain " + boost::lexical_cast<string>(pDomain)
1163 +
" defined for function " + pName
1164 +
" in session file.");
1172 return it2->second.m_type;
1180 const std::string &pName,
1181 const unsigned int &pVar,
1182 const int pDomain)
const
1184 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1185 return GetFunctionType(pName, m_variables[pVar],pDomain);
1192 std::string SessionReader::GetFunctionFilename(
1193 const std::string &pName,
1194 const std::string &pVariable,
1195 const int pDomain)
const
1197 FunctionMap::const_iterator it1;
1198 FunctionVariableMap::const_iterator it2, it3;
1199 std::string vName = boost::to_upper_copy(pName);
1201 it1 = m_functions.find(vName);
1202 ASSERTL0 (it1 != m_functions.end(),
1203 std::string(
"Function '") + pName
1204 + std::string(
"' not found."));
1207 pair<std::string,int> key(pVariable,pDomain);
1208 pair<std::string,int> defkey(
"*",pDomain);
1209 bool specific = (it2 = it1->second.find(key)) !=
1211 bool wildcard = (it3 = it1->second.find(defkey)) !=
1216 "No such variable " + pVariable
1217 +
" in domain " + boost::lexical_cast<string>(pDomain)
1218 +
" defined for function " + pName
1219 +
" in session file.");
1227 return it2->second.m_filename;
1234 std::string SessionReader::GetFunctionFilename(
1235 const std::string &pName,
1236 const unsigned int &pVar,
1237 const int pDomain)
const
1239 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1240 return GetFunctionFilename(pName, m_variables[pVar],pDomain);
1247 std::string SessionReader::GetFunctionFilenameVariable(
1248 const std::string &pName,
1249 const std::string &pVariable,
1250 const int pDomain)
const
1252 FunctionMap::const_iterator it1;
1253 FunctionVariableMap::const_iterator it2, it3;
1254 std::string vName = boost::to_upper_copy(pName);
1256 it1 = m_functions.find(vName);
1257 ASSERTL0 (it1 != m_functions.end(),
1258 std::string(
"Function '") + pName
1259 + std::string(
"' not found."));
1262 pair<std::string,int> key(pVariable,pDomain);
1263 pair<std::string,int> defkey(
"*",pDomain);
1264 bool specific = (it2 = it1->second.find(key)) !=
1266 bool wildcard = (it3 = it1->second.find(defkey)) !=
1271 "No such variable " + pVariable
1272 +
" in domain " + boost::lexical_cast<string>(pDomain)
1273 +
" defined for function " + pName
1274 +
" in session file.");
1282 return it2->second.m_fileVariable;
1291 return m_exprEvaluator;
1298 bool SessionReader::DefinesTag(
const std::string &pName)
const
1300 std::string vName = boost::to_upper_copy(pName);
1301 TagMap::const_iterator vTagIterator = m_tags.find(vName);
1302 return (vTagIterator != m_tags.end());
1309 void SessionReader::SetTag(
1310 const std::string &pName,
1311 const std::string &pValue)
1313 std::string vName = boost::to_upper_copy(pName);
1314 m_tags[vName] = pValue;
1321 const std::string &SessionReader::GetTag(
const std::string& pName)
const
1323 std::string vName = boost::to_upper_copy(pName);
1324 TagMap::const_iterator vTagIterator = m_tags.find(vName);
1325 ASSERTL0(vTagIterator != m_tags.end(),
1326 "Requested tag does not exist.");
1327 return vTagIterator->second;
1343 bool SessionReader::DefinesCmdLineArgument(
1344 const std::string& pName)
const
1346 return (m_cmdLineOptions.find(pName) != m_cmdLineOptions.end());
1353 void SessionReader::SubstituteExpressions(std::string& pExpr)
1356 for (exprIter = m_expressions.begin();
1357 exprIter != m_expressions.end(); ++exprIter)
1359 boost::replace_all(pExpr, exprIter->first, exprIter->second);
1370 return m_bndRegOrder;
1376 void SessionReader::LoadDoc(
1377 const std::string &pFilename,
1378 TiXmlDocument* pDoc)
const
1380 if (pFilename.size() > 3 &&
1381 pFilename.substr(pFilename.size() - 3, 3) ==
".gz")
1383 ifstream file(pFilename.c_str(),
1384 ios_base::in | ios_base::binary);
1385 ASSERTL0(file.good(),
"Unable to open file: " + pFilename);
1387 io::filtering_streambuf<io::input> in;
1388 in.push(io::gzip_decompressor());
1395 catch (io::gzip_error& e)
1398 "Error: File '" + pFilename +
"' is corrupt.");
1401 else if (pFilename.size() > 4 &&
1402 pFilename.substr(pFilename.size() - 4, 4) ==
"_xml")
1404 fs::path pdirname(pFilename);
1405 boost::format pad(
"P%1$07d.xml");
1406 pad % m_comm->GetRank();
1407 fs::path pRankFilename(pad.str());
1408 fs::path fullpath = pdirname / pRankFilename;
1411 ASSERTL0(file.good(),
"Unable to open file: " + fullpath.string());
1416 ifstream file(pFilename.c_str());
1417 ASSERTL0(file.good(),
"Unable to open file: " + pFilename);
1425 TiXmlDocument *SessionReader::MergeDoc(
1426 const std::vector<std::string> &pFilenames)
const
1428 ASSERTL0(pFilenames.size() > 0,
"No filenames for merging.");
1431 TiXmlDocument *vMainDoc =
new TiXmlDocument;
1432 LoadDoc(pFilenames[0], vMainDoc);
1434 TiXmlHandle vMainHandle(vMainDoc);
1435 TiXmlElement* vMainNektar =
1436 vMainHandle.FirstChildElement(
"NEKTAR").Element();
1441 for (
int i = 1; i < pFilenames.size(); ++i)
1443 if((pFilenames[i].compare(pFilenames[i].size()-3,3,
"xml") == 0)
1444 ||(pFilenames[i].compare(pFilenames[i].size()-6,6,
"xml.gz") == 0))
1446 TiXmlDocument* vTempDoc =
new TiXmlDocument;
1447 LoadDoc(pFilenames[i], vTempDoc);
1449 TiXmlHandle docHandle(vTempDoc);
1450 TiXmlElement* vTempNektar;
1451 vTempNektar = docHandle.FirstChildElement(
"NEKTAR").Element();
1452 ASSERTL0(vTempNektar,
"Unable to find NEKTAR tag in file.");
1453 TiXmlElement* p = vTempNektar->FirstChildElement();
1457 TiXmlElement *vMainEntry =
1458 vMainNektar->FirstChildElement(p->Value());
1459 TiXmlElement *q =
new TiXmlElement(*p);
1462 vMainNektar->RemoveChild(vMainEntry);
1464 vMainNektar->LinkEndChild(q);
1465 p = p->NextSiblingElement();
1478 void SessionReader::ParseDocument()
1481 ASSERTL0(m_xmlDoc,
"No XML document loaded.");
1484 TiXmlHandle docHandle(m_xmlDoc);
1486 e = docHandle.FirstChildElement(
"NEKTAR").
1487 FirstChildElement(
"CONDITIONS").Element();
1492 ReadGlobalSysSolnInfo (e);
1493 ReadExpressions (e);
1497 e = docHandle.FirstChildElement(
"NEKTAR").
1498 FirstChildElement(
"FILTERS").Element();
1507 void SessionReader::CreateComm(
1517 string vCommModule(
"Serial");
1520 vCommModule =
"ParallelMPI";
1531 void SessionReader::PartitionMesh()
1533 ASSERTL0(m_comm.get(),
"Communication not initialised.");
1537 const bool isRoot = (m_comm->GetRank() == 0);
1553 int isPartitioned = 0;
1556 m_xmlDoc = MergeDoc(m_filenames);
1557 if (DefinesElement(
"Nektar/Geometry"))
1559 if (GetElement(
"Nektar/Geometry")->Attribute(
"PARTITION"))
1561 cout <<
"Using pre-partitioned mesh." << endl;
1570 if (isPartitioned) {
1573 m_xmlDoc = MergeDoc(m_filenames);
1581 string vPartitionerName =
"Metis";
1584 vPartitionerName =
"Scotch";
1586 if (DefinesCmdLineArgument(
"use-metis"))
1588 vPartitionerName =
"Metis";
1590 if (DefinesCmdLineArgument(
"use-scotch"))
1592 vPartitionerName =
"Scotch";
1598 if (DefinesCmdLineArgument(
"part-only"))
1603 "The 'part-only' option should be used in serial.");
1606 int nParts = GetCmdLineArgument<int>(
"part-only");
1610 vPartitionerName, vSession);
1611 vPartitioner->PartitionMesh(nParts,
true);
1612 vPartitioner->WriteAllPartitions(vSession);
1613 vPartitioner->GetCompositeOrdering(m_compOrder);
1614 vPartitioner->GetBndRegionOrdering(m_bndRegOrder);
1616 if (isRoot && DefinesCmdLineArgument(
"part-info"))
1618 vPartitioner->PrintPartInfo(std::cout);
1624 else if (vCommMesh->GetSize() > 1)
1627 int nParts = vCommMesh->GetSize();
1628 if (DefinesCmdLineArgument(
"shared-filesystem"))
1631 vector<unsigned int> keys, vals;
1634 if (vComm->GetRank() == 0)
1636 m_xmlDoc = MergeDoc(m_filenames);
1640 vPartitionerName, vSession);
1641 vPartitioner->PartitionMesh(nParts,
true);
1642 vPartitioner->WriteAllPartitions(vSession);
1643 vPartitioner->GetCompositeOrdering(m_compOrder);
1644 vPartitioner->GetBndRegionOrdering(m_bndRegOrder);
1651 keys[0] = m_compOrder.size();
1652 keys[1] = m_bndRegOrder.size();
1654 for (i = 1; i < vComm->GetSize(); ++i)
1656 vComm->Send(i, keys);
1662 keys.resize(m_compOrder.size());
1663 vals.resize(m_compOrder.size());
1665 for (cIt = m_compOrder.begin(), i = 0;
1666 cIt != m_compOrder.end(); ++cIt, ++i)
1668 keys[i] = cIt->first;
1669 vals[i] = cIt->second.size();
1673 for (i = 1; i < vComm->GetSize(); ++i)
1675 vComm->Send(i, keys);
1676 vComm->Send(i, vals);
1678 for (cIt = m_compOrder.begin();
1679 cIt != m_compOrder.end(); ++cIt)
1681 vComm->Send(i, cIt->second);
1688 keys.resize(m_bndRegOrder.size());
1689 vals.resize(m_bndRegOrder.size());
1691 for (bIt = m_bndRegOrder.begin(), i = 0;
1692 bIt != m_bndRegOrder.end(); ++bIt, ++i)
1694 keys[i] = bIt->first;
1695 vals[i] = bIt->second.size();
1699 for (i = 1; i < vComm->GetSize(); ++i)
1701 vComm->Send(i, keys);
1702 vComm->Send(i, vals);
1704 for (bIt = m_bndRegOrder.begin();
1705 bIt != m_bndRegOrder.end(); ++bIt)
1707 vComm->Send(i, bIt->second);
1711 if (DefinesCmdLineArgument(
"part-info"))
1713 vPartitioner->PrintPartInfo(std::cout);
1719 vComm->Recv(0, keys);
1721 int cmpSize = keys[0];
1722 int bndSize = keys[1];
1724 keys.resize(cmpSize);
1725 vals.resize(cmpSize);
1726 vComm->Recv(0, keys);
1727 vComm->Recv(0, vals);
1729 for (
int i = 0; i < keys.size(); ++i)
1731 vector<unsigned int> tmp(vals[i]);
1732 vComm->Recv(0, tmp);
1733 m_compOrder[keys[i]] = tmp;
1736 keys.resize(bndSize);
1737 vals.resize(bndSize);
1738 vComm->Recv(0, keys);
1739 vComm->Recv(0, vals);
1741 for (
int i = 0; i < keys.size(); ++i)
1743 vector<unsigned int> tmp(vals[i]);
1744 vComm->Recv(0, tmp);
1745 m_bndRegOrder[keys[i]] = tmp;
1754 m_xmlDoc = MergeDoc(m_filenames);
1762 vPartitionerName, vSession);
1763 vPartitioner->PartitionMesh(nParts,
false);
1764 vPartitioner->WriteLocalPartition(vSession);
1765 vPartitioner->GetCompositeOrdering(m_compOrder);
1766 vPartitioner->GetBndRegionOrdering(m_bndRegOrder);
1768 if (DefinesCmdLineArgument(
"part-info") && isRoot)
1770 vPartitioner->PrintPartInfo(std::cout);
1775 std::string dirname = GetSessionName() +
"_xml";
1776 fs::path pdirname(dirname);
1777 boost::format pad(
"P%1$07d.xml");
1778 pad % m_comm->GetRowComm()->GetRank();
1779 fs::path pFilename(pad.str());
1780 fs::path fullpath = pdirname / pFilename;
1788 m_xmlDoc =
new TiXmlDocument(vFilename);
1790 ASSERTL0(m_xmlDoc,
"Failed to create XML document object.");
1792 bool loadOkay = m_xmlDoc->LoadFile(vFilename);
1793 ASSERTL0(loadOkay,
"Unable to load file: " + vFilename +
1794 ". Check XML standards compliance. Error on line: " +
1795 boost::lexical_cast<std::string>(m_xmlDoc->Row()));
1799 m_xmlDoc = MergeDoc(m_filenames);
1811 void SessionReader::PartitionComm()
1813 if (m_comm->GetSize() > 1)
1818 if (DefinesCmdLineArgument(
"npx")) {
1819 nProcX = GetCmdLineArgument<int>(
"npx");
1821 if (DefinesCmdLineArgument(
"npy")) {
1822 nProcY = GetCmdLineArgument<int>(
"npy");
1824 if (DefinesCmdLineArgument(
"npz")) {
1825 nProcZ = GetCmdLineArgument<int>(
"npz");
1828 ASSERTL0(m_comm->GetSize() % (nProcZ*nProcY*nProcX) == 0,
1829 "Cannot exactly partition using PROC_Z value.");
1831 "Cannot exactly partition using PROC_Y value.");
1833 "Cannot exactly partition using PROC_X value.");
1836 int nProcSm = nProcZ * nProcY * nProcX;
1840 int nProcSem = m_comm->GetSize() / nProcSm;
1842 m_comm->SplitComm(nProcSm,nProcSem);
1843 m_comm->GetColumnComm()->SplitComm((nProcY*nProcX),nProcZ);
1844 m_comm->GetColumnComm()->GetColumnComm()->SplitComm(
1853 void SessionReader::ReadParameters(TiXmlElement *conditions)
1855 m_parameters.clear();
1862 TiXmlElement *parametersElement = conditions->FirstChildElement(
1867 if (parametersElement)
1869 TiXmlElement *parameter =
1870 parametersElement->FirstChildElement(
"P");
1878 stringstream tagcontent;
1879 tagcontent << *parameter;
1880 TiXmlNode *node = parameter->FirstChild();
1882 while (node && node->Type() != TiXmlNode::TINYXML_TEXT)
1884 node = node->NextSibling();
1890 std::string line = node->ToText()->Value(),
lhs, rhs;
1893 ParseEquals(line,
lhs, rhs);
1897 ASSERTL0(
false,
"Syntax error in parameter "
1898 "expression '" + line
1899 +
"' in XML element: \n\t'"
1900 + tagcontent.str() +
"'");
1906 if (!
lhs.empty() && !rhs.empty())
1912 GetSharedThisPtr(), rhs);
1915 catch (
const std::runtime_error &)
1918 "Error evaluating parameter expression"
1919 " '" + rhs +
"' in XML element: \n\t'"
1920 + tagcontent.str() +
"'");
1922 m_exprEvaluator.SetParameter(
lhs, value);
1923 caseSensitiveParameters[
lhs] = value;
1924 boost::to_upper(
lhs);
1925 m_parameters[
lhs] = value;
1929 parameter = parameter->NextSiblingElement();
1938 void SessionReader::ReadSolverInfo(TiXmlElement *conditions)
1940 m_solverInfo.clear();
1941 m_solverInfo = GetSolverInfoDefaults();
1948 TiXmlElement *solverInfoElement =
1949 conditions->FirstChildElement(
"SOLVERINFO");
1951 if (solverInfoElement)
1953 TiXmlElement *solverInfo =
1954 solverInfoElement->FirstChildElement(
"I");
1958 std::stringstream tagcontent;
1959 tagcontent << *solverInfo;
1961 ASSERTL0(solverInfo->Attribute(
"PROPERTY"),
1962 "Missing PROPERTY attribute in solver info "
1963 "XML element: \n\t'" + tagcontent.str() +
"'");
1964 std::string solverProperty =
1965 solverInfo->Attribute(
"PROPERTY");
1967 "PROPERTY attribute must be non-empty in XML "
1968 "element: \n\t'" + tagcontent.str() +
"'");
1971 std::string solverPropertyUpper =
1972 boost::to_upper_copy(solverProperty);
1975 ASSERTL0(solverInfo->Attribute(
"VALUE"),
1976 "Missing VALUE attribute in solver info "
1977 "XML element: \n\t'" + tagcontent.str() +
"'");
1978 std::string solverValue = solverInfo->Attribute(
"VALUE");
1980 "VALUE attribute must be non-empty in XML "
1981 "element: \n\t'" + tagcontent.str() +
"'");
1983 EnumMapList::const_iterator propIt =
1984 GetSolverInfoEnums().find(solverPropertyUpper);
1985 if (propIt != GetSolverInfoEnums().end())
1987 EnumMap::const_iterator valIt =
1988 propIt->second.find(solverValue);
1989 ASSERTL0(valIt != propIt->second.end(),
1990 "Value '" + solverValue +
"' is not valid for "
1991 "property '" + solverProperty +
"'");
1995 m_solverInfo[solverPropertyUpper] = solverValue;
1996 solverInfo = solverInfo->NextSiblingElement(
"I");
2000 if (m_comm && m_comm->GetRowComm()->GetSize() > 1)
2003 m_solverInfo[
"GLOBALSYSSOLN"] ==
"IterativeFull" ||
2004 m_solverInfo[
"GLOBALSYSSOLN"] ==
"IterativeStaticCond" ||
2005 m_solverInfo[
"GLOBALSYSSOLN"] ==
2006 "IterativeMultiLevelStaticCond" ||
2007 m_solverInfo[
"GLOBALSYSSOLN"] ==
"XxtFull" ||
2008 m_solverInfo[
"GLOBALSYSSOLN"] ==
"XxtStaticCond" ||
2009 m_solverInfo[
"GLOBALSYSSOLN"] ==
2010 "XxtMultiLevelStaticCond" ||
2011 m_solverInfo[
"GLOBALSYSSOLN"] ==
"PETScFull" ||
2012 m_solverInfo[
"GLOBALSYSSOLN"] ==
"PETScStaticCond" ||
2013 m_solverInfo[
"GLOBALSYSSOLN"] ==
2014 "PETScMultiLevelStaticCond",
2015 "A parallel solver must be used when run in parallel.");
2024 void SessionReader::ReadGlobalSysSolnInfo(TiXmlElement *conditions)
2026 GetGloSysSolnList().clear();
2033 TiXmlElement *GlobalSys =
2034 conditions->FirstChildElement(
"GLOBALSYSSOLNINFO");
2041 TiXmlElement *VarInfo = GlobalSys->FirstChildElement(
"V");
2045 std::stringstream tagcontent;
2046 tagcontent << *VarInfo;
2047 ASSERTL0(VarInfo->Attribute(
"VAR"),
2048 "Missing VAR attribute in GobalSysSolnInfo XML "
2049 "element: \n\t'" + tagcontent.str() +
"'");
2051 std::string VarList = VarInfo->Attribute(
"VAR");
2053 "VAR attribute must be non-empty in XML element:\n\t'"
2054 + tagcontent.str() +
"'");
2057 std::vector<std::string> varStrings;
2058 bool valid = ParseUtils::GenerateOrderedStringVector(
2059 VarList.c_str(),varStrings);
2061 ASSERTL0(valid,
"Unable to process list of variable in XML "
2062 "element \n\t'" + tagcontent.str() +
"'");
2064 if(varStrings.size())
2066 TiXmlElement *SysSolnInfo = VarInfo->FirstChildElement(
"I");
2071 tagcontent << *SysSolnInfo;
2073 ASSERTL0(SysSolnInfo->Attribute(
"PROPERTY"),
2074 "Missing PROPERTY attribute in "
2075 "GlobalSysSolnInfo for variable(s) '"
2076 + VarList +
"' in XML element: \n\t'"
2077 + tagcontent.str() +
"'");
2079 std::string SysSolnProperty =
2080 SysSolnInfo->Attribute(
"PROPERTY");
2083 "GlobalSysSolnIno properties must have a "
2084 "non-empty name for variable(s) : '"
2085 + VarList +
"' in XML element: \n\t'"
2086 + tagcontent.str() +
"'");
2089 std::string SysSolnPropertyUpper =
2090 boost::to_upper_copy(SysSolnProperty);
2093 ASSERTL0(SysSolnInfo->Attribute(
"VALUE"),
2094 "Missing VALUE attribute in GlobalSysSolnInfo "
2095 "for variable(s) '" + VarList
2096 +
"' in XML element: \n\t"
2097 + tagcontent.str() +
"'");
2099 std::string SysSolnValue =
2100 SysSolnInfo->Attribute(
"VALUE");
2102 "GlobalSysSolnInfo properties must have a "
2103 "non-empty value for variable(s) '"
2104 + VarList +
"' in XML element: \n\t'"
2105 + tagcontent.str() +
"'");
2108 for(
int i = 0; i < varStrings.size(); ++i)
2111 if ((x = GetGloSysSolnList().
find(varStrings[i])) ==
2112 GetGloSysSolnList().end())
2114 (GetGloSysSolnList()[varStrings[i]])[
2115 SysSolnPropertyUpper] = SysSolnValue;
2119 x->second[SysSolnPropertyUpper] = SysSolnValue;
2123 SysSolnInfo = SysSolnInfo->NextSiblingElement(
"I");
2125 VarInfo = VarInfo->NextSiblingElement(
"V");
2129 if (m_verbose && GetGloSysSolnList().size() > 0 && m_comm)
2131 if(m_comm->GetRank() == 0)
2133 cout <<
"GlobalSysSoln Info:" << endl;
2136 for (x = GetGloSysSolnList().begin();
2137 x != GetGloSysSolnList().end();
2140 cout <<
"\t Variable: " << x->first << endl;
2143 for (y = x->second.begin(); y != x->second.end(); ++y)
2145 cout <<
"\t\t " << y->first <<
" = " << y->second
2158 void SessionReader::ReadExpressions(TiXmlElement *conditions)
2160 m_expressions.clear();
2167 TiXmlElement *expressionsElement =
2168 conditions->FirstChildElement(
"EXPRESSIONS");
2170 if (expressionsElement)
2172 TiXmlElement *expr = expressionsElement->FirstChildElement(
"E");
2176 stringstream tagcontent;
2177 tagcontent << *expr;
2179 "Missing NAME attribute in expression "
2180 "definition: \n\t'" + tagcontent.str() +
"'");
2181 std::string nameString = expr->Attribute(
"NAME");
2183 "Expressions must have a non-empty name: \n\t'"
2184 + tagcontent.str() +
"'");
2187 "Missing VALUE attribute in expression "
2188 "definition: \n\t'" + tagcontent.str() +
"'");
2189 std::string valString = expr->Attribute(
"VALUE");
2191 "Expressions must have a non-empty value: \n\t'"
2192 + tagcontent.str() +
"'");
2195 = m_expressions.find(nameString);
2196 ASSERTL0(exprIter == m_expressions.end(),
2197 std::string(
"Expression '") + nameString
2198 + std::string(
"' already specified."));
2200 m_expressions[nameString] = valString;
2201 expr = expr->NextSiblingElement(
"E");
2210 void SessionReader::ReadVariables(TiXmlElement *conditions)
2212 m_variables.clear();
2219 TiXmlElement *variablesElement =
2220 conditions->FirstChildElement(
"VARIABLES");
2224 if (variablesElement)
2226 TiXmlElement *varElement =
2227 variablesElement->FirstChildElement(
"V");
2230 int nextVariableNumber = -1;
2234 stringstream tagcontent;
2235 tagcontent << *varElement;
2239 nextVariableNumber++;
2242 int err = varElement->QueryIntAttribute(
"ID", &i);
2244 "Variables must have a unique ID number attribute "
2245 "in XML element: \n\t'" + tagcontent.str() +
"'");
2247 "ID numbers for variables must begin with zero and"
2248 " be sequential in XML element: \n\t'"
2249 + tagcontent.str() +
"'");
2251 TiXmlNode* varChild = varElement->FirstChild();
2256 while(varChild && varChild->Type() != TiXmlNode::TINYXML_TEXT)
2258 varChild = varChild->NextSibling();
2262 "Unable to read variable definition body for "
2264 + boost::lexical_cast<string>(i)
2265 +
" in XML element: \n\t'"
2266 + tagcontent.str() +
"'");
2267 std::string variableName = varChild->ToText()->ValueStr();
2269 std::istringstream variableStrm(variableName);
2270 variableStrm >> variableName;
2273 variableName) == m_variables.end(),
2275 + boost::lexical_cast<
string>(i)
2276 +
" in XML element \n\t'" + tagcontent.str()
2277 +
"'\nhas already been defined.");
2279 m_variables.push_back(variableName);
2281 varElement = varElement->NextSiblingElement(
"V");
2285 "Number of variables must be greater than zero.");
2293 void SessionReader::ReadFunctions(TiXmlElement *conditions)
2295 m_functions.clear();
2303 TiXmlElement *
function = conditions->FirstChildElement(
"FUNCTION");
2306 stringstream tagcontent;
2307 tagcontent << *
function;
2310 ASSERTL0(function->Attribute(
"NAME"),
2311 "Functions must have a NAME attribute defined in XML "
2312 "element: \n\t'" + tagcontent.str() +
"'");
2313 std::string functionStr =
function->Attribute(
"NAME");
2315 "Functions must have a non-empty name in XML "
2316 "element: \n\t'" + tagcontent.str() +
"'");
2319 boost::to_upper(functionStr);
2322 TiXmlElement *variable =
function->FirstChildElement();
2331 std::string conditionType = variable->Value();
2334 std::string variableStr;
2335 if (!variable->Attribute(
"VAR"))
2341 variableStr = variable->Attribute(
"VAR");
2345 std::vector<std::string> variableList;
2346 ParseUtils::GenerateOrderedStringVector(variableStr.c_str(),
2350 std::string domainStr;
2351 if (!variable->Attribute(
"DOMAIN"))
2357 domainStr = variable->Attribute(
"DOMAIN");
2361 std::vector<std::string> varSplit;
2362 std::vector<unsigned int> domainList;
2363 ParseUtils::GenerateSeqVector(domainStr.c_str(), domainList);
2366 if (conditionType ==
"E")
2371 ASSERTL0(variable->Attribute(
"VALUE"),
2372 "Attribute VALUE expected for function '"
2373 + functionStr +
"'.");
2374 std::string fcnStr = variable->Attribute(
"VALUE");
2377 (std::string(
"Expression for var: ")
2379 + std::string(
" must be specified.")).c_str());
2381 SubstituteExpressions(fcnStr);
2389 else if (conditionType ==
"F")
2391 if (variable->Attribute(
"TIMEDEPENDENT") &&
2392 boost::lexical_cast<
bool>(variable->Attribute(
"TIMEDEPENDENT")))
2402 ASSERTL0(variable->Attribute(
"FILE"),
2403 "Attribute FILE expected for function '"
2404 + functionStr +
"'.");
2405 std::string filenameStr = variable->Attribute(
"FILE");
2408 "A filename must be specified for the FILE "
2409 "attribute of function '" + functionStr
2412 std::vector<std::string> fSplit;
2413 boost::split(fSplit, filenameStr, boost::is_any_of(
":"));
2415 ASSERTL0(fSplit.size() == 1 || fSplit.size() == 2,
2416 "Incorrect filename specification in function "
2417 + functionStr +
"'. "
2418 "Specify variables inside file as: "
2419 "filename:var1,var2");
2424 if (fSplit.size() == 2)
2427 "Filename variable mapping not valid "
2428 "when using * as a variable inside "
2429 "function '" + functionStr +
"'.");
2432 varSplit, fSplit[1], boost::is_any_of(
","));
2433 ASSERTL0(varSplit.size() == variableList.size(),
2434 "Filename variables should contain the "
2435 "same number of variables defined in "
2436 "VAR in function " + functionStr +
"'.");
2443 stringstream tagcontent;
2444 tagcontent << *variable;
2447 "Identifier " + conditionType +
" in function "
2448 + std::string(function->Attribute(
"NAME"))
2449 +
" is not recognised in XML element: \n\t'"
2450 + tagcontent.str() +
"'");
2456 for (
unsigned int i = 0; i < variableList.size(); ++i)
2458 for(
unsigned int j = 0; j < domainList.size(); ++j)
2461 pair<std::string,int> key(variableList[i],domainList[j]);
2463 = functionVarMap.find(key);
2464 ASSERTL0(fcnsIter == functionVarMap.end(),
2465 "Error setting expression '" + variableList[i]
2467 + boost::lexical_cast<std::string>(domainList[j])
2468 +
"' in function '" + functionStr +
"'. "
2469 "Expression has already been defined.");
2471 if (varSplit.size() > 0)
2475 functionVarMap[key] = funcDef2;
2479 functionVarMap[key] = funcDef;
2484 variable = variable->NextSiblingElement();
2487 m_functions[functionStr] = functionVarMap;
2488 function =
function->NextSiblingElement(
"FUNCTION");
2496 void SessionReader::ReadFilters(TiXmlElement *filters)
2505 TiXmlElement *filter = filters->FirstChildElement(
"FILTER");
2508 ASSERTL0(filter->Attribute(
"TYPE"),
2509 "Missing attribute 'TYPE' for filter.");
2510 std::string typeStr = filter->Attribute(
"TYPE");
2512 std::map<std::string, std::string> vParams;
2514 TiXmlElement *param = filter->FirstChildElement(
"PARAM");
2518 "Missing attribute 'NAME' for parameter in filter "
2520 std::string nameStr = param->Attribute(
"NAME");
2522 ASSERTL0(param->GetText(),
"Empty value string for param.");
2523 std::string valueStr = param->GetText();
2525 vParams[nameStr] = valueStr;
2527 param = param->NextSiblingElement(
"PARAM");
2530 m_filters.push_back(
2531 std::pair<std::string, FilterParams>(typeStr, vParams));
2533 filter = filter->NextSiblingElement(
"FILTER");
2537 void SessionReader::ParseEquals(
2538 const std::string &line,
2543 int beg = line.find_first_not_of(
" ");
2544 int end = line.find_first_of(
"=");
2546 if (beg == end)
throw 1;
2548 if (end != line.find_last_of(
"="))
throw 1;
2550 if (end == std::string::npos)
throw 1;
2552 lhs = line.substr(line.find_first_not_of(
" "),
2554 lhs = lhs .substr(0, lhs.find_last_not_of(
" ")+1);
2555 rhs = line.substr(line.find_last_of(
"=")+1);
2556 rhs = rhs .substr(rhs.find_first_not_of(
" "));
2557 rhs = rhs .substr(0, rhs.find_last_not_of(
" ")+1);
2563 void SessionReader::CmdLineOverride()
2566 if (m_cmdLineOptions.count(
"solverinfo"))
2568 std::vector<std::string> solverInfoList =
2569 m_cmdLineOptions[
"solverinfo"].as<
2570 std::vector<std::string> >();
2572 for (
int i = 0; i < solverInfoList.size(); ++i)
2574 std::string
lhs, rhs;
2578 ParseEquals(solverInfoList[i], lhs, rhs);
2582 ASSERTL0(
false,
"Parse error with command line "
2583 "option: "+solverInfoList[i]);
2586 std::string lhsUpper = boost::to_upper_copy(lhs);
2587 m_solverInfo[lhsUpper] = rhs;
2591 if (m_cmdLineOptions.count(
"parameter"))
2593 std::vector<std::string> parametersList =
2594 m_cmdLineOptions[
"parameter"].as<
2595 std::vector<std::string> >();
2597 for (
int i = 0; i < parametersList.size(); ++i)
2599 std::string
lhs, rhs;
2603 ParseEquals(parametersList[i], lhs, rhs);
2607 ASSERTL0(
false,
"Parse error with command line "
2608 "option: "+parametersList[i]);
2611 std::string lhsUpper = boost::to_upper_copy(lhs);
2615 m_parameters[lhsUpper] =
2620 ASSERTL0(
false,
"Unable to convert string: "+rhs+
2621 "to double value.");
2627 void SessionReader::SetUpXmlDoc(
void)
2629 m_xmlDoc = MergeDoc(m_filenames);