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));
286 if (m_verbose && m_comm)
288 if (m_comm->GetRank() == 0 && m_parameters.size() > 0)
290 cout <<
"Parameters:" << endl;
292 for (x = m_parameters.begin(); x != m_parameters.end(); ++x)
294 cout <<
"\t" << x->first <<
" = " << x->second << endl;
299 if (m_comm->GetRank() == 0 && m_solverInfo.size() > 0)
301 cout <<
"Solver Info:" << endl;
303 for (x = m_solverInfo.begin(); x != m_solverInfo.end(); ++x)
305 cout <<
"\t" << x->first <<
" = " << x->second << endl;
317 std::vector<std::string> SessionReader::ParseCommandLineArguments(
318 int argc,
char *argv[])
321 po::options_description desc(
"Allowed options");
323 (
"verbose,v",
"be verbose")
324 (
"version,V",
"print version information")
325 (
"help,h",
"print this help message")
326 (
"solverinfo,I", po::value<vector<std::string> >(),
327 "override a SOLVERINFO property")
328 (
"parameter,P", po::value<vector<std::string> >(),
329 "override a parameter")
330 (
"shared-filesystem,s",
"Using shared filesystem.")
331 (
"npx", po::value<int>(),
332 "number of procs in X-dir")
333 (
"npy", po::value<int>(),
334 "number of procs in Y-dir")
335 (
"npz", po::value<int>(),
336 "number of procs in Z-dir")
337 (
"nsz", po::value<int>(),
338 "number of slices in Z-dir")
339 (
"part-only", po::value<int>(),
340 "only partition mesh into N partitions.")
341 (
"part-info",
"Output partition information")
344 CmdLineArgMap::const_iterator cmdIt;
345 for (cmdIt = GetCmdLineArgMap().begin();
346 cmdIt != GetCmdLineArgMap().end(); ++cmdIt)
348 std::string names = cmdIt->first;
349 if (cmdIt->second.shortName !=
"")
351 names +=
"," + cmdIt->second.shortName;
353 if (cmdIt->second.isFlag)
356 (names.c_str(), cmdIt->second.description.c_str())
362 (names.c_str(), po::value<std::string>(),
363 cmdIt->second.description.c_str())
370 po::options_description hidden(
"Hidden options");
372 (
"input-file", po::value< vector<string> >(),
377 po::options_description all(
"All options");
378 all.add(desc).add(hidden);
381 po::positional_options_description p;
382 p.add(
"input-file", -1);
385 po::parsed_options parsed = po::command_line_parser(argc, argv).
388 allow_unregistered().
392 po::store(parsed, m_cmdLineOptions);
393 po::notify(m_cmdLineOptions);
396 if (m_cmdLineOptions.count(
"help"))
403 if (m_cmdLineOptions.count(
"version"))
411 boost::replace_all(branch,
"refs/heads/",
"");
413 cout <<
" (git changeset " << sha1.substr(0, 8) <<
", ";
417 cout <<
"detached head";
421 cout <<
"head " << branch;
432 if (m_cmdLineOptions.count(
"verbose"))
442 std::vector< po::basic_option<char> >
::iterator x;
443 for (x = parsed.options.begin(); x != parsed.options.end(); ++x)
447 cout <<
"Warning: Unknown option: " << x->string_key
453 if (m_cmdLineOptions.count(
"input-file"))
455 return m_cmdLineOptions[
"input-file"].as<
456 std::vector<std::string> >();
460 return std::vector<std::string>();
468 std::string SessionReader::ParseSessionName(
469 std::vector<std::string> &filenames)
472 "At least one filename expected.");
474 std::string retval =
"";
477 std::string fname = filenames[0];
480 if (fname.size() > 4 &&
481 fname.substr(fname.size() - 4, 4) ==
"_xml")
483 retval = fname.substr(0, fname.find_last_of(
"_"));
486 else if (fname.size() > 4 &&
487 fname.substr(fname.size() - 4, 4) ==
".xml")
489 retval = fname.substr(0, fname.find_last_of(
"."));
492 else if (fname.size() > 7 &&
493 fname.substr(fname.size() - 7, 7) ==
".xml.gz")
495 retval = fname.substr(0, fname.find_last_of(
"."));
496 retval = retval.substr(0, retval.find_last_of(
"."));
506 TiXmlDocument& SessionReader::GetDocument()
508 ASSERTL1(m_xmlDoc,
"XML Document not defined.");
535 TiXmlElement* SessionReader::GetElement(
const string& pPath)
537 std::string vPath = boost::to_upper_copy(pPath);
538 std::vector<std::string> st;
539 boost::split(st, vPath, boost::is_any_of(
"\\/ "));
540 ASSERTL0(st.size() > 0,
"No path given in XML element request.");
542 TiXmlElement* vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
543 ASSERTL0(vReturn, std::string(
"Cannot find element '")
544 + st[0] + std::string(
"'."));
545 for (
int i = 1; i < st.size(); ++i)
547 vReturn = vReturn->FirstChildElement(st[i].c_str());
548 ASSERTL0(vReturn, std::string(
"Cannot find element '")
549 + st[i] + std::string(
"'."));
558 bool SessionReader::DefinesElement(
const std::string &pPath)
const
560 std::string vPath = boost::to_upper_copy(pPath);
561 std::vector<std::string> st;
562 boost::split(st, vPath, boost::is_any_of(
"\\/ "));
563 ASSERTL0(st.size() > 0,
"No path given in XML element request.");
565 TiXmlElement* vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
566 ASSERTL0(vReturn, std::string(
"Cannot find element '")
567 + st[0] + std::string(
"'."));
568 for (
int i = 1; i < st.size(); ++i)
570 vReturn = vReturn->FirstChildElement(st[i].c_str());
571 if (!vReturn)
return false;
580 const std::vector<std::string>& SessionReader::GetFilenames()
const
589 const std::string& SessionReader::GetSessionName()
const
591 return m_sessionName;
599 const std::string SessionReader::GetSessionNameRank()
const
601 std::string dirname = m_sessionName +
"_xml";
602 fs::path pdirname(dirname);
604 std::string vFilename =
"P" + boost::lexical_cast<std::string>(m_comm->GetRowComm()->GetRank());
605 fs::path pFilename(vFilename);
607 fs::path fullpath = pdirname / pFilename;
636 bool SessionReader::DefinesParameter(
const std::string& pName)
const
638 std::string vName = boost::to_upper_copy(pName);
639 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
640 return (paramIter != m_parameters.end());
653 const std::string& pName)
const
655 std::string vName = boost::to_upper_copy(pName);
656 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
658 ASSERTL0(paramIter != m_parameters.end(),
659 "Unable to find requested parameter: " + pName);
661 return paramIter->second;
668 void SessionReader::LoadParameter(
669 const std::string &pName,
int &pVar)
const
671 std::string vName = boost::to_upper_copy(pName);
672 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
673 ASSERTL0(paramIter != m_parameters.end(),
"Required parameter '" +
674 pName +
"' not specified in session.");
675 pVar = (int)floor(paramIter->second);
682 void SessionReader::LoadParameter(
683 const std::string &pName,
int &pVar,
const int &pDefault)
const
685 std::string vName = boost::to_upper_copy(pName);
686 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
687 if(paramIter != m_parameters.end())
689 pVar = (int)floor(paramIter->second);
701 void SessionReader::LoadParameter(
702 const std::string &pName,
NekDouble& pVar)
const
704 std::string vName = boost::to_upper_copy(pName);
705 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
706 ASSERTL0(paramIter != m_parameters.end(),
"Required parameter '" +
707 pName +
"' not specified in session.");
708 pVar = paramIter->second;
715 void SessionReader::LoadParameter(
716 const std::string &pName,
720 std::string vName = boost::to_upper_copy(pName);
721 ParameterMap::const_iterator paramIter = m_parameters.find(vName);
722 if(paramIter != m_parameters.end())
724 pVar = paramIter->second;
737 void SessionReader::SetParameter(
const std::string &pName,
int &pVar)
739 std::string vName = boost::to_upper_copy(pName);
740 m_parameters[vName] = pVar;
747 void SessionReader::SetParameter(
748 const std::string &pName,
NekDouble& pVar)
750 std::string vName = boost::to_upper_copy(pName);
751 m_parameters[vName] = pVar;
759 bool SessionReader::DefinesSolverInfo(
const std::string &pName)
const
761 std::string vName = boost::to_upper_copy(pName);
762 SolverInfoMap::const_iterator infoIter = m_solverInfo.find(vName);
763 return (infoIter != m_solverInfo.end());
770 const std::string& SessionReader::GetSolverInfo(
771 const std::string &pProperty)
const
773 std::string vProperty = boost::to_upper_copy(pProperty);
774 SolverInfoMap::const_iterator iter = m_solverInfo.find(vProperty);
776 ASSERTL1(iter != m_solverInfo.end(),
777 "Unable to find requested property: " + pProperty);
785 void SessionReader::SetSolverInfo(
786 const std::string &pProperty,
const std::string &pValue)
788 std::string vProperty = boost::to_upper_copy(pProperty);
791 ASSERTL1(iter != m_solverInfo.end(),
792 "Unable to find requested property: " + pProperty);
794 iter->second = pValue;
800 void SessionReader::LoadSolverInfo(
801 const std::string &pName,
803 const std::string &pDefault)
const
805 std::string vName = boost::to_upper_copy(pName);
806 SolverInfoMap::const_iterator infoIter = m_solverInfo.find(vName);
807 if(infoIter != m_solverInfo.end())
809 pVar = infoIter->second;
821 void SessionReader::MatchSolverInfo(
822 const std::string &pName,
823 const std::string &pTrueVal,
825 const bool &pDefault)
const
827 std::string vName = boost::to_upper_copy(pName);
828 SolverInfoMap::const_iterator infoIter = m_solverInfo.find(vName);
829 if(infoIter != m_solverInfo.end())
831 pVar = boost::iequals(infoIter->second, pTrueVal);
843 bool SessionReader::MatchSolverInfo(
844 const std::string &pName,
845 const std::string &pTrueVal)
const
847 if (DefinesSolverInfo(pName))
849 std::string vName = boost::to_upper_copy(pName);
850 SolverInfoMap::const_iterator iter = m_solverInfo.find(vName);
851 if(iter != m_solverInfo.end())
863 bool SessionReader::DefinesGlobalSysSolnInfo(
const std::string &pVariable,
864 const std::string &pProperty)
const
867 GloSysSolnInfoList::const_iterator iter =
868 GetGloSysSolnList().find(pVariable);
869 if(iter == GetGloSysSolnList().end())
874 std::string vProperty = boost::to_upper_copy(pProperty);
876 GloSysInfoMap::const_iterator iter1 = iter->second.find(vProperty);
877 if(iter1 == iter->second.end())
889 const std::string &SessionReader::GetGlobalSysSolnInfo(
const std::string &pVariable,
const std::string &pProperty)
const
891 GloSysSolnInfoList::const_iterator iter;
893 ASSERTL0( (iter = GetGloSysSolnList().
find(pVariable)) !=
894 GetGloSysSolnList().end(),
895 "Failed to find variable in GlobalSysSolnInfoList");
897 std::string vProperty = boost::to_upper_copy(pProperty);
898 GloSysInfoMap::const_iterator iter1;
900 ASSERTL0( (iter1 = iter->second.find(vProperty)) != iter->second.end(),
901 "Failed to find property: " + vProperty +
" in GlobalSysSolnInfoList");
903 return iter1->second;
909 bool SessionReader::DefinesGeometricInfo(
const std::string &pName)
const
911 std::string vName = boost::to_upper_copy(pName);
912 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
913 return (iter != m_geometricInfo.end());
920 void SessionReader::LoadGeometricInfo(
921 const std::string &pName,
923 const std::string &pDefault)
const
925 std::string vName = boost::to_upper_copy(pName);
926 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
927 if(iter != m_geometricInfo.end())
941 void SessionReader::LoadGeometricInfo(
942 const std::string &pName,
944 const bool &pDefault)
const
946 std::string vName = boost::to_upper_copy(pName);
947 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
948 if(iter != m_geometricInfo.end())
950 if (iter->second ==
"TRUE")
969 void SessionReader::LoadGeometricInfo(
970 const std::string &pName,
974 std::string vName = boost::to_upper_copy(pName);
975 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
976 if(iter != m_geometricInfo.end())
978 pVar = std::atoi(iter->second.c_str());
990 void SessionReader::MatchGeometricInfo(
991 const std::string &pName,
992 const std::string &pTrueVal,
994 const bool &pDefault)
const
996 std::string vName = boost::to_upper_copy(pName);
997 GeometricInfoMap::const_iterator iter = m_geometricInfo.find(vName);
998 if(iter != m_geometricInfo.end())
1000 pVar = boost::iequals(iter->second, pTrueVal);
1012 const std::string& SessionReader::GetVariable(
1013 const unsigned int &idx)
const
1015 ASSERTL0(idx < m_variables.size(),
"Variable index out of range.");
1016 return m_variables[idx];
1024 void SessionReader::SetVariable(
const unsigned int &idx,
1025 std::string newname)
1027 ASSERTL0(idx < m_variables.size(),
"Variable index out of range.");
1028 m_variables[idx] = newname;
1035 std::vector<std::string> SessionReader::GetVariables()
const
1044 bool SessionReader::DefinesFunction(
const std::string &pName)
const
1046 FunctionMap::const_iterator it1;
1047 std::string vName = boost::to_upper_copy(pName);
1049 if ((it1 = m_functions.find(vName)) != m_functions.end())
1060 bool SessionReader::DefinesFunction(
1061 const std::string &pName,
1062 const std::string &pVariable,
1063 const int pDomain)
const
1065 FunctionMap::const_iterator it1;
1066 FunctionVariableMap::const_iterator it2;
1067 std::string vName = boost::to_upper_copy(pName);
1070 if ((it1 = m_functions.find(vName)) != m_functions.end())
1072 pair<std::string, int> key(pVariable,pDomain);
1073 pair<std::string, int> defkey(
"*",pDomain);
1075 (it2 = it1->second.find(key)) != it1->second.end() ||
1076 (it2 = it1->second.find(defkey)) != it1->second.end();
1087 const std::string &pName,
1088 const std::string &pVariable,
1089 const int pDomain)
const
1091 FunctionMap::const_iterator it1;
1092 FunctionVariableMap::const_iterator it2, it3;
1093 std::string vName = boost::to_upper_copy(pName);
1095 ASSERTL0((it1 = m_functions.find(vName)) != m_functions.end(),
1096 std::string(
"No such function '") + pName
1097 + std::string(
"' has been defined in the session file."));
1100 pair<std::string,int> key(pVariable,pDomain);
1101 pair<std::string,int> defkey(
"*",pDomain);
1102 bool specific = (it2 = it1->second.find(key)) !=
1104 bool wildcard = (it3 = it1->second.find(defkey)) !=
1109 "No such variable " + pVariable
1110 +
" in domain " + boost::lexical_cast<string>(pDomain)
1111 +
" defined for function " + pName
1112 +
" in session file.");
1121 std::string(
"Function is defined by a file."));
1122 return it2->second.m_expression;
1130 const std::string &pName,
1131 const unsigned int &pVar,
1132 const int pDomain)
const
1134 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1135 return GetFunction(pName, m_variables[pVar],pDomain);
1143 const std::string &pName,
1144 const std::string &pVariable,
1145 const int pDomain)
const
1147 FunctionMap::const_iterator it1;
1148 FunctionVariableMap::const_iterator it2, it3;
1149 std::string vName = boost::to_upper_copy(pName);
1151 it1 = m_functions.find(vName);
1152 ASSERTL0 (it1 != m_functions.end(),
1153 std::string(
"Function '") + pName
1154 + std::string(
"' not found."));
1157 pair<std::string,int> key(pVariable,pDomain);
1158 pair<std::string,int> defkey(
"*",pDomain);
1159 bool specific = (it2 = it1->second.find(key)) !=
1161 bool wildcard = (it3 = it1->second.find(defkey)) !=
1166 "No such variable " + pVariable
1167 +
" in domain " + boost::lexical_cast<string>(pDomain)
1168 +
" defined for function " + pName
1169 +
" in session file.");
1177 return it2->second.m_type;
1185 const std::string &pName,
1186 const unsigned int &pVar,
1187 const int pDomain)
const
1189 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1190 return GetFunctionType(pName, m_variables[pVar],pDomain);
1197 std::string SessionReader::GetFunctionFilename(
1198 const std::string &pName,
1199 const std::string &pVariable,
1200 const int pDomain)
const
1202 FunctionMap::const_iterator it1;
1203 FunctionVariableMap::const_iterator it2, it3;
1204 std::string vName = boost::to_upper_copy(pName);
1206 it1 = m_functions.find(vName);
1207 ASSERTL0 (it1 != m_functions.end(),
1208 std::string(
"Function '") + pName
1209 + std::string(
"' not found."));
1212 pair<std::string,int> key(pVariable,pDomain);
1213 pair<std::string,int> defkey(
"*",pDomain);
1214 bool specific = (it2 = it1->second.find(key)) !=
1216 bool wildcard = (it3 = it1->second.find(defkey)) !=
1221 "No such variable " + pVariable
1222 +
" in domain " + boost::lexical_cast<string>(pDomain)
1223 +
" defined for function " + pName
1224 +
" in session file.");
1232 return it2->second.m_filename;
1239 std::string SessionReader::GetFunctionFilename(
1240 const std::string &pName,
1241 const unsigned int &pVar,
1242 const int pDomain)
const
1244 ASSERTL0(pVar < m_variables.size(),
"Variable index out of range.");
1245 return GetFunctionFilename(pName, m_variables[pVar],pDomain);
1252 std::string SessionReader::GetFunctionFilenameVariable(
1253 const std::string &pName,
1254 const std::string &pVariable,
1255 const int pDomain)
const
1257 FunctionMap::const_iterator it1;
1258 FunctionVariableMap::const_iterator it2, it3;
1259 std::string vName = boost::to_upper_copy(pName);
1261 it1 = m_functions.find(vName);
1262 ASSERTL0 (it1 != m_functions.end(),
1263 std::string(
"Function '") + pName
1264 + std::string(
"' not found."));
1267 pair<std::string,int> key(pVariable,pDomain);
1268 pair<std::string,int> defkey(
"*",pDomain);
1269 bool specific = (it2 = it1->second.find(key)) !=
1271 bool wildcard = (it3 = it1->second.find(defkey)) !=
1276 "No such variable " + pVariable
1277 +
" in domain " + boost::lexical_cast<string>(pDomain)
1278 +
" defined for function " + pName
1279 +
" in session file.");
1287 return it2->second.m_fileVariable;
1296 return m_exprEvaluator;
1303 bool SessionReader::DefinesTag(
const std::string &pName)
const
1305 std::string vName = boost::to_upper_copy(pName);
1306 TagMap::const_iterator vTagIterator = m_tags.find(vName);
1307 return (vTagIterator != m_tags.end());
1314 void SessionReader::SetTag(
1315 const std::string &pName,
1316 const std::string &pValue)
1318 std::string vName = boost::to_upper_copy(pName);
1319 m_tags[vName] = pValue;
1326 const std::string &SessionReader::GetTag(
const std::string& pName)
const
1328 std::string vName = boost::to_upper_copy(pName);
1329 TagMap::const_iterator vTagIterator = m_tags.find(vName);
1330 ASSERTL0(vTagIterator != m_tags.end(),
1331 "Requested tag does not exist.");
1332 return vTagIterator->second;
1348 bool SessionReader::DefinesCmdLineArgument(
1349 const std::string& pName)
const
1351 return (m_cmdLineOptions.find(pName) != m_cmdLineOptions.end());
1358 void SessionReader::SubstituteExpressions(std::string& pExpr)
1361 for (exprIter = m_expressions.begin();
1362 exprIter != m_expressions.end(); ++exprIter)
1364 boost::replace_all(pExpr, exprIter->first, exprIter->second);
1375 return m_bndRegOrder;
1381 void SessionReader::LoadDoc(
1382 const std::string &pFilename,
1383 TiXmlDocument* pDoc)
const
1385 if (pFilename.size() > 3 &&
1386 pFilename.substr(pFilename.size() - 3, 3) ==
".gz")
1388 ifstream file(pFilename.c_str(),
1389 ios_base::in | ios_base::binary);
1390 ASSERTL0(file.good(),
"Unable to open file: " + pFilename);
1392 io::filtering_streambuf<io::input> in;
1393 in.push(io::gzip_decompressor());
1400 catch (io::gzip_error& e)
1403 "Error: File '" + pFilename +
"' is corrupt.");
1406 else if (pFilename.size() > 4 &&
1407 pFilename.substr(pFilename.size() - 4, 4) ==
"_xml")
1409 fs::path pdirname(pFilename);
1410 boost::format pad(
"P%1$07d.xml");
1411 pad % m_comm->GetRank();
1412 fs::path pRankFilename(pad.str());
1413 fs::path fullpath = pdirname / pRankFilename;
1416 ASSERTL0(file.good(),
"Unable to open file: " + fullpath.string());
1421 ifstream file(pFilename.c_str());
1422 ASSERTL0(file.good(),
"Unable to open file: " + pFilename);
1430 TiXmlDocument *SessionReader::MergeDoc(
1431 const std::vector<std::string> &pFilenames)
const
1433 ASSERTL0(pFilenames.size() > 0,
"No filenames for merging.");
1436 TiXmlDocument *vMainDoc =
new TiXmlDocument;
1437 LoadDoc(pFilenames[0], vMainDoc);
1439 TiXmlHandle vMainHandle(vMainDoc);
1440 TiXmlElement* vMainNektar =
1441 vMainHandle.FirstChildElement(
"NEKTAR").Element();
1446 for (
int i = 1; i < pFilenames.size(); ++i)
1448 if((pFilenames[i].compare(pFilenames[i].size()-3,3,
"xml") == 0)
1449 ||(pFilenames[i].compare(pFilenames[i].size()-6,6,
"xml.gz") == 0))
1451 TiXmlDocument* vTempDoc =
new TiXmlDocument;
1452 LoadDoc(pFilenames[i], vTempDoc);
1454 TiXmlHandle docHandle(vTempDoc);
1455 TiXmlElement* vTempNektar;
1456 vTempNektar = docHandle.FirstChildElement(
"NEKTAR").Element();
1457 ASSERTL0(vTempNektar,
"Unable to find NEKTAR tag in file.");
1458 TiXmlElement* p = vTempNektar->FirstChildElement();
1462 TiXmlElement *vMainEntry =
1463 vMainNektar->FirstChildElement(p->Value());
1464 TiXmlElement *q =
new TiXmlElement(*p);
1467 vMainNektar->RemoveChild(vMainEntry);
1469 vMainNektar->LinkEndChild(q);
1470 p = p->NextSiblingElement();
1483 void SessionReader::ParseDocument()
1486 ASSERTL0(m_xmlDoc,
"No XML document loaded.");
1489 TiXmlHandle docHandle(m_xmlDoc);
1491 e = docHandle.FirstChildElement(
"NEKTAR").
1492 FirstChildElement(
"CONDITIONS").Element();
1497 ReadGlobalSysSolnInfo (e);
1498 ReadExpressions (e);
1502 e = docHandle.FirstChildElement(
"NEKTAR").
1503 FirstChildElement(
"FILTERS").Element();
1512 void SessionReader::CreateComm(
1522 string vCommModule(
"Serial");
1525 vCommModule =
"ParallelMPI";
1536 void SessionReader::PartitionMesh()
1538 ASSERTL0(m_comm.get(),
"Communication not initialised.");
1542 const bool isRoot = (m_comm->GetRank() == 0);
1558 int isPartitioned = 0;
1561 m_xmlDoc = MergeDoc(m_filenames);
1562 if (DefinesElement(
"Nektar/Geometry"))
1564 if (GetElement(
"Nektar/Geometry")->Attribute(
"PARTITION"))
1566 cout <<
"Using pre-partitioned mesh." << endl;
1575 if (isPartitioned) {
1578 m_xmlDoc = MergeDoc(m_filenames);
1586 string vPartitionerName =
"Metis";
1589 vPartitionerName =
"Scotch";
1591 if (DefinesCmdLineArgument(
"use-metis"))
1593 vPartitionerName =
"Metis";
1595 if (DefinesCmdLineArgument(
"use-scotch"))
1597 vPartitionerName =
"Scotch";
1603 if (DefinesCmdLineArgument(
"part-only"))
1608 "The 'part-only' option should be used in serial.");
1611 int nParts = GetCmdLineArgument<int>(
"part-only");
1615 vPartitionerName, vSession);
1616 vPartitioner->PartitionMesh(nParts,
true);
1617 vPartitioner->WriteAllPartitions(vSession);
1618 vPartitioner->GetCompositeOrdering(m_compOrder);
1619 vPartitioner->GetBndRegionOrdering(m_bndRegOrder);
1621 if (isRoot && DefinesCmdLineArgument(
"part-info"))
1623 vPartitioner->PrintPartInfo(std::cout);
1629 else if (vCommMesh->GetSize() > 1)
1632 int nParts = vCommMesh->GetSize();
1633 if (DefinesCmdLineArgument(
"shared-filesystem"))
1636 vector<unsigned int> keys, vals;
1639 if (vComm->GetRank() == 0)
1641 m_xmlDoc = MergeDoc(m_filenames);
1645 vPartitionerName, vSession);
1646 vPartitioner->PartitionMesh(nParts,
true);
1647 vPartitioner->WriteAllPartitions(vSession);
1648 vPartitioner->GetCompositeOrdering(m_compOrder);
1649 vPartitioner->GetBndRegionOrdering(m_bndRegOrder);
1656 keys[0] = m_compOrder.size();
1657 keys[1] = m_bndRegOrder.size();
1659 for (i = 1; i < vComm->GetSize(); ++i)
1661 vComm->Send(i, keys);
1667 keys.resize(m_compOrder.size());
1668 vals.resize(m_compOrder.size());
1670 for (cIt = m_compOrder.begin(), i = 0;
1671 cIt != m_compOrder.end(); ++cIt, ++i)
1673 keys[i] = cIt->first;
1674 vals[i] = cIt->second.size();
1678 for (i = 1; i < vComm->GetSize(); ++i)
1680 vComm->Send(i, keys);
1681 vComm->Send(i, vals);
1683 for (cIt = m_compOrder.begin();
1684 cIt != m_compOrder.end(); ++cIt)
1686 vComm->Send(i, cIt->second);
1693 keys.resize(m_bndRegOrder.size());
1694 vals.resize(m_bndRegOrder.size());
1696 for (bIt = m_bndRegOrder.begin(), i = 0;
1697 bIt != m_bndRegOrder.end(); ++bIt, ++i)
1699 keys[i] = bIt->first;
1700 vals[i] = bIt->second.size();
1704 for (i = 1; i < vComm->GetSize(); ++i)
1706 vComm->Send(i, keys);
1707 vComm->Send(i, vals);
1709 for (bIt = m_bndRegOrder.begin();
1710 bIt != m_bndRegOrder.end(); ++bIt)
1712 vComm->Send(i, bIt->second);
1716 if (DefinesCmdLineArgument(
"part-info"))
1718 vPartitioner->PrintPartInfo(std::cout);
1724 vComm->Recv(0, keys);
1726 int cmpSize = keys[0];
1727 int bndSize = keys[1];
1729 keys.resize(cmpSize);
1730 vals.resize(cmpSize);
1731 vComm->Recv(0, keys);
1732 vComm->Recv(0, vals);
1734 for (
int i = 0; i < keys.size(); ++i)
1736 vector<unsigned int> tmp(vals[i]);
1737 vComm->Recv(0, tmp);
1738 m_compOrder[keys[i]] = tmp;
1741 keys.resize(bndSize);
1742 vals.resize(bndSize);
1743 vComm->Recv(0, keys);
1744 vComm->Recv(0, vals);
1746 for (
int i = 0; i < keys.size(); ++i)
1748 vector<unsigned int> tmp(vals[i]);
1749 vComm->Recv(0, tmp);
1750 m_bndRegOrder[keys[i]] = tmp;
1759 m_xmlDoc = MergeDoc(m_filenames);
1767 vPartitionerName, vSession);
1768 vPartitioner->PartitionMesh(nParts,
false);
1769 vPartitioner->WriteLocalPartition(vSession);
1770 vPartitioner->GetCompositeOrdering(m_compOrder);
1771 vPartitioner->GetBndRegionOrdering(m_bndRegOrder);
1773 if (DefinesCmdLineArgument(
"part-info") && isRoot)
1775 vPartitioner->PrintPartInfo(std::cout);
1780 std::string dirname = GetSessionName() +
"_xml";
1781 fs::path pdirname(dirname);
1782 boost::format pad(
"P%1$07d.xml");
1783 pad % m_comm->GetRowComm()->GetRank();
1784 fs::path pFilename(pad.str());
1785 fs::path fullpath = pdirname / pFilename;
1793 m_xmlDoc =
new TiXmlDocument(vFilename);
1795 ASSERTL0(m_xmlDoc,
"Failed to create XML document object.");
1797 bool loadOkay = m_xmlDoc->LoadFile(vFilename);
1798 ASSERTL0(loadOkay,
"Unable to load file: " + vFilename +
1799 ". Check XML standards compliance. Error on line: " +
1800 boost::lexical_cast<std::string>(m_xmlDoc->Row()));
1804 m_xmlDoc = MergeDoc(m_filenames);
1816 void SessionReader::PartitionComm()
1818 if (m_comm->GetSize() > 1)
1824 if (DefinesCmdLineArgument(
"npx")) {
1825 nProcX = GetCmdLineArgument<int>(
"npx");
1827 if (DefinesCmdLineArgument(
"npy")) {
1828 nProcY = GetCmdLineArgument<int>(
"npy");
1830 if (DefinesCmdLineArgument(
"npz")) {
1831 nProcZ = GetCmdLineArgument<int>(
"npz");
1833 if (DefinesCmdLineArgument(
"nsz")) {
1834 nStripZ = GetCmdLineArgument<int>(
"nsz");
1836 ASSERTL0(m_comm->GetSize() % (nProcZ*nProcY*nProcX) == 0,
1837 "Cannot exactly partition using PROC_Z value.");
1839 "Cannot exactly partition using PROC_Y value.");
1841 "Cannot exactly partition using PROC_X value.");
1844 int nProcSm = nProcZ * nProcY * nProcX;
1848 int nProcSem = m_comm->GetSize() / nProcSm;
1850 m_comm->SplitComm(nProcSm,nProcSem);
1851 m_comm->GetColumnComm()->SplitComm(nProcZ/nStripZ,nStripZ);
1852 m_comm->GetColumnComm()->GetColumnComm()->SplitComm(
1853 (nProcY*nProcX),nProcZ/nStripZ);
1854 m_comm->GetColumnComm()->GetColumnComm()->GetColumnComm()
1855 ->SplitComm(nProcX,nProcY);
1863 void SessionReader::ReadParameters(TiXmlElement *conditions)
1865 m_parameters.clear();
1872 TiXmlElement *parametersElement = conditions->FirstChildElement(
1877 if (parametersElement)
1879 TiXmlElement *parameter =
1880 parametersElement->FirstChildElement(
"P");
1888 stringstream tagcontent;
1889 tagcontent << *parameter;
1890 TiXmlNode *node = parameter->FirstChild();
1892 while (node && node->Type() != TiXmlNode::TINYXML_TEXT)
1894 node = node->NextSibling();
1900 std::string line = node->ToText()->Value(),
lhs, rhs;
1903 ParseEquals(line,
lhs, rhs);
1907 ASSERTL0(
false,
"Syntax error in parameter "
1908 "expression '" + line
1909 +
"' in XML element: \n\t'"
1910 + tagcontent.str() +
"'");
1916 if (!
lhs.empty() && !rhs.empty())
1922 GetSharedThisPtr(), rhs);
1925 catch (
const std::runtime_error &)
1928 "Error evaluating parameter expression"
1929 " '" + rhs +
"' in XML element: \n\t'"
1930 + tagcontent.str() +
"'");
1932 m_exprEvaluator.SetParameter(
lhs, value);
1933 caseSensitiveParameters[
lhs] = value;
1934 boost::to_upper(
lhs);
1935 m_parameters[
lhs] = value;
1939 parameter = parameter->NextSiblingElement();
1948 void SessionReader::ReadSolverInfo(TiXmlElement *conditions)
1950 m_solverInfo.clear();
1951 m_solverInfo = GetSolverInfoDefaults();
1958 TiXmlElement *solverInfoElement =
1959 conditions->FirstChildElement(
"SOLVERINFO");
1961 if (solverInfoElement)
1963 TiXmlElement *solverInfo =
1964 solverInfoElement->FirstChildElement(
"I");
1968 std::stringstream tagcontent;
1969 tagcontent << *solverInfo;
1971 ASSERTL0(solverInfo->Attribute(
"PROPERTY"),
1972 "Missing PROPERTY attribute in solver info "
1973 "XML element: \n\t'" + tagcontent.str() +
"'");
1974 std::string solverProperty =
1975 solverInfo->Attribute(
"PROPERTY");
1977 "PROPERTY attribute must be non-empty in XML "
1978 "element: \n\t'" + tagcontent.str() +
"'");
1981 std::string solverPropertyUpper =
1982 boost::to_upper_copy(solverProperty);
1985 ASSERTL0(solverInfo->Attribute(
"VALUE"),
1986 "Missing VALUE attribute in solver info "
1987 "XML element: \n\t'" + tagcontent.str() +
"'");
1988 std::string solverValue = solverInfo->Attribute(
"VALUE");
1990 "VALUE attribute must be non-empty in XML "
1991 "element: \n\t'" + tagcontent.str() +
"'");
1994 m_solverInfo[solverPropertyUpper] = solverValue;
1995 solverInfo = solverInfo->NextSiblingElement(
"I");
1999 if (m_comm && m_comm->GetRowComm()->GetSize() > 1)
2002 m_solverInfo[
"GLOBALSYSSOLN"] ==
"IterativeFull" ||
2003 m_solverInfo[
"GLOBALSYSSOLN"] ==
"IterativeStaticCond" ||
2004 m_solverInfo[
"GLOBALSYSSOLN"] ==
2005 "IterativeMultiLevelStaticCond" ||
2006 m_solverInfo[
"GLOBALSYSSOLN"] ==
"XxtFull" ||
2007 m_solverInfo[
"GLOBALSYSSOLN"] ==
"XxtStaticCond" ||
2008 m_solverInfo[
"GLOBALSYSSOLN"] ==
2009 "XxtMultiLevelStaticCond" ||
2010 m_solverInfo[
"GLOBALSYSSOLN"] ==
"PETScFull" ||
2011 m_solverInfo[
"GLOBALSYSSOLN"] ==
"PETScStaticCond" ||
2012 m_solverInfo[
"GLOBALSYSSOLN"] ==
2013 "PETScMultiLevelStaticCond",
2014 "A parallel solver must be used when run in parallel.");
2023 void SessionReader::ReadGlobalSysSolnInfo(TiXmlElement *conditions)
2025 GetGloSysSolnList().clear();
2032 TiXmlElement *GlobalSys =
2033 conditions->FirstChildElement(
"GLOBALSYSSOLNINFO");
2040 TiXmlElement *VarInfo = GlobalSys->FirstChildElement(
"V");
2044 std::stringstream tagcontent;
2045 tagcontent << *VarInfo;
2046 ASSERTL0(VarInfo->Attribute(
"VAR"),
2047 "Missing VAR attribute in GobalSysSolnInfo XML "
2048 "element: \n\t'" + tagcontent.str() +
"'");
2050 std::string VarList = VarInfo->Attribute(
"VAR");
2052 "VAR attribute must be non-empty in XML element:\n\t'"
2053 + tagcontent.str() +
"'");
2056 std::vector<std::string> varStrings;
2057 bool valid = ParseUtils::GenerateOrderedStringVector(
2058 VarList.c_str(),varStrings);
2060 ASSERTL0(valid,
"Unable to process list of variable in XML "
2061 "element \n\t'" + tagcontent.str() +
"'");
2063 if(varStrings.size())
2065 TiXmlElement *SysSolnInfo = VarInfo->FirstChildElement(
"I");
2070 tagcontent << *SysSolnInfo;
2072 ASSERTL0(SysSolnInfo->Attribute(
"PROPERTY"),
2073 "Missing PROPERTY attribute in "
2074 "GlobalSysSolnInfo for variable(s) '"
2075 + VarList +
"' in XML element: \n\t'"
2076 + tagcontent.str() +
"'");
2078 std::string SysSolnProperty =
2079 SysSolnInfo->Attribute(
"PROPERTY");
2082 "GlobalSysSolnIno properties must have a "
2083 "non-empty name for variable(s) : '"
2084 + VarList +
"' in XML element: \n\t'"
2085 + tagcontent.str() +
"'");
2088 std::string SysSolnPropertyUpper =
2089 boost::to_upper_copy(SysSolnProperty);
2092 ASSERTL0(SysSolnInfo->Attribute(
"VALUE"),
2093 "Missing VALUE attribute in GlobalSysSolnInfo "
2094 "for variable(s) '" + VarList
2095 +
"' in XML element: \n\t"
2096 + tagcontent.str() +
"'");
2098 std::string SysSolnValue =
2099 SysSolnInfo->Attribute(
"VALUE");
2101 "GlobalSysSolnInfo properties must have a "
2102 "non-empty value for variable(s) '"
2103 + VarList +
"' in XML element: \n\t'"
2104 + tagcontent.str() +
"'");
2107 for(
int i = 0; i < varStrings.size(); ++i)
2110 if ((x = GetGloSysSolnList().
find(varStrings[i])) ==
2111 GetGloSysSolnList().end())
2113 (GetGloSysSolnList()[varStrings[i]])[
2114 SysSolnPropertyUpper] = SysSolnValue;
2118 x->second[SysSolnPropertyUpper] = SysSolnValue;
2122 SysSolnInfo = SysSolnInfo->NextSiblingElement(
"I");
2124 VarInfo = VarInfo->NextSiblingElement(
"V");
2128 if (m_verbose && GetGloSysSolnList().size() > 0 && m_comm)
2130 if(m_comm->GetRank() == 0)
2132 cout <<
"GlobalSysSoln Info:" << endl;
2135 for (x = GetGloSysSolnList().begin();
2136 x != GetGloSysSolnList().end();
2139 cout <<
"\t Variable: " << x->first << endl;
2142 for (y = x->second.begin(); y != x->second.end(); ++y)
2144 cout <<
"\t\t " << y->first <<
" = " << y->second
2157 void SessionReader::ReadExpressions(TiXmlElement *conditions)
2159 m_expressions.clear();
2166 TiXmlElement *expressionsElement =
2167 conditions->FirstChildElement(
"EXPRESSIONS");
2169 if (expressionsElement)
2171 TiXmlElement *expr = expressionsElement->FirstChildElement(
"E");
2175 stringstream tagcontent;
2176 tagcontent << *expr;
2178 "Missing NAME attribute in expression "
2179 "definition: \n\t'" + tagcontent.str() +
"'");
2180 std::string nameString = expr->Attribute(
"NAME");
2182 "Expressions must have a non-empty name: \n\t'"
2183 + tagcontent.str() +
"'");
2186 "Missing VALUE attribute in expression "
2187 "definition: \n\t'" + tagcontent.str() +
"'");
2188 std::string valString = expr->Attribute(
"VALUE");
2190 "Expressions must have a non-empty value: \n\t'"
2191 + tagcontent.str() +
"'");
2194 = m_expressions.find(nameString);
2195 ASSERTL0(exprIter == m_expressions.end(),
2196 std::string(
"Expression '") + nameString
2197 + std::string(
"' already specified."));
2199 m_expressions[nameString] = valString;
2200 expr = expr->NextSiblingElement(
"E");
2209 void SessionReader::ReadVariables(TiXmlElement *conditions)
2211 m_variables.clear();
2218 TiXmlElement *variablesElement =
2219 conditions->FirstChildElement(
"VARIABLES");
2223 if (variablesElement)
2225 TiXmlElement *varElement =
2226 variablesElement->FirstChildElement(
"V");
2229 int nextVariableNumber = -1;
2233 stringstream tagcontent;
2234 tagcontent << *varElement;
2238 nextVariableNumber++;
2241 int err = varElement->QueryIntAttribute(
"ID", &i);
2243 "Variables must have a unique ID number attribute "
2244 "in XML element: \n\t'" + tagcontent.str() +
"'");
2246 "ID numbers for variables must begin with zero and"
2247 " be sequential in XML element: \n\t'"
2248 + tagcontent.str() +
"'");
2250 TiXmlNode* varChild = varElement->FirstChild();
2255 while(varChild && varChild->Type() != TiXmlNode::TINYXML_TEXT)
2257 varChild = varChild->NextSibling();
2261 "Unable to read variable definition body for "
2263 + boost::lexical_cast<string>(i)
2264 +
" in XML element: \n\t'"
2265 + tagcontent.str() +
"'");
2266 std::string variableName = varChild->ToText()->ValueStr();
2268 std::istringstream variableStrm(variableName);
2269 variableStrm >> variableName;
2272 variableName) == m_variables.end(),
2274 + boost::lexical_cast<
string>(i)
2275 +
" in XML element \n\t'" + tagcontent.str()
2276 +
"'\nhas already been defined.");
2278 m_variables.push_back(variableName);
2280 varElement = varElement->NextSiblingElement(
"V");
2284 "Number of variables must be greater than zero.");
2292 void SessionReader::ReadFunctions(TiXmlElement *conditions)
2294 m_functions.clear();
2302 TiXmlElement *
function = conditions->FirstChildElement(
"FUNCTION");
2305 stringstream tagcontent;
2306 tagcontent << *
function;
2309 ASSERTL0(function->Attribute(
"NAME"),
2310 "Functions must have a NAME attribute defined in XML "
2311 "element: \n\t'" + tagcontent.str() +
"'");
2312 std::string functionStr =
function->Attribute(
"NAME");
2314 "Functions must have a non-empty name in XML "
2315 "element: \n\t'" + tagcontent.str() +
"'");
2318 boost::to_upper(functionStr);
2321 TiXmlElement *variable =
function->FirstChildElement();
2330 std::string conditionType = variable->Value();
2333 std::string variableStr;
2334 if (!variable->Attribute(
"VAR"))
2340 variableStr = variable->Attribute(
"VAR");
2344 std::vector<std::string> variableList;
2345 ParseUtils::GenerateOrderedStringVector(variableStr.c_str(),
2349 std::string domainStr;
2350 if (!variable->Attribute(
"DOMAIN"))
2356 domainStr = variable->Attribute(
"DOMAIN");
2360 std::vector<std::string> varSplit;
2361 std::vector<unsigned int> domainList;
2362 ParseUtils::GenerateSeqVector(domainStr.c_str(), domainList);
2365 if (conditionType ==
"E")
2370 ASSERTL0(variable->Attribute(
"VALUE"),
2371 "Attribute VALUE expected for function '"
2372 + functionStr +
"'.");
2373 std::string fcnStr = variable->Attribute(
"VALUE");
2376 (std::string(
"Expression for var: ")
2378 + std::string(
" must be specified.")).c_str());
2380 SubstituteExpressions(fcnStr);
2388 else if (conditionType ==
"F")
2390 if (variable->Attribute(
"TIMEDEPENDENT") &&
2391 boost::lexical_cast<
bool>(variable->Attribute(
"TIMEDEPENDENT")))
2401 ASSERTL0(variable->Attribute(
"FILE"),
2402 "Attribute FILE expected for function '"
2403 + functionStr +
"'.");
2404 std::string filenameStr = variable->Attribute(
"FILE");
2407 "A filename must be specified for the FILE "
2408 "attribute of function '" + functionStr
2411 std::vector<std::string> fSplit;
2412 boost::split(fSplit, filenameStr, boost::is_any_of(
":"));
2414 ASSERTL0(fSplit.size() == 1 || fSplit.size() == 2,
2415 "Incorrect filename specification in function "
2416 + functionStr +
"'. "
2417 "Specify variables inside file as: "
2418 "filename:var1,var2");
2423 if (fSplit.size() == 2)
2426 "Filename variable mapping not valid "
2427 "when using * as a variable inside "
2428 "function '" + functionStr +
"'.");
2431 varSplit, fSplit[1], boost::is_any_of(
","));
2432 ASSERTL0(varSplit.size() == variableList.size(),
2433 "Filename variables should contain the "
2434 "same number of variables defined in "
2435 "VAR in function " + functionStr +
"'.");
2442 stringstream tagcontent;
2443 tagcontent << *variable;
2446 "Identifier " + conditionType +
" in function "
2447 + std::string(function->Attribute(
"NAME"))
2448 +
" is not recognised in XML element: \n\t'"
2449 + tagcontent.str() +
"'");
2455 for (
unsigned int i = 0; i < variableList.size(); ++i)
2457 for(
unsigned int j = 0; j < domainList.size(); ++j)
2460 pair<std::string,int> key(variableList[i],domainList[j]);
2462 = functionVarMap.find(key);
2463 ASSERTL0(fcnsIter == functionVarMap.end(),
2464 "Error setting expression '" + variableList[i]
2466 + boost::lexical_cast<std::string>(domainList[j])
2467 +
"' in function '" + functionStr +
"'. "
2468 "Expression has already been defined.");
2470 if (varSplit.size() > 0)
2474 functionVarMap[key] = funcDef2;
2478 functionVarMap[key] = funcDef;
2483 variable = variable->NextSiblingElement();
2486 m_functions[functionStr] = functionVarMap;
2487 function =
function->NextSiblingElement(
"FUNCTION");
2495 void SessionReader::ReadFilters(TiXmlElement *filters)
2504 TiXmlElement *filter = filters->FirstChildElement(
"FILTER");
2507 ASSERTL0(filter->Attribute(
"TYPE"),
2508 "Missing attribute 'TYPE' for filter.");
2509 std::string typeStr = filter->Attribute(
"TYPE");
2511 std::map<std::string, std::string> vParams;
2513 TiXmlElement *param = filter->FirstChildElement(
"PARAM");
2517 "Missing attribute 'NAME' for parameter in filter "
2519 std::string nameStr = param->Attribute(
"NAME");
2521 ASSERTL0(param->GetText(),
"Empty value string for param.");
2522 std::string valueStr = param->GetText();
2524 vParams[nameStr] = valueStr;
2526 param = param->NextSiblingElement(
"PARAM");
2529 m_filters.push_back(
2530 std::pair<std::string, FilterParams>(typeStr, vParams));
2532 filter = filter->NextSiblingElement(
"FILTER");
2536 void SessionReader::ParseEquals(
2537 const std::string &line,
2542 int beg = line.find_first_not_of(
" ");
2543 int end = line.find_first_of(
"=");
2545 if (beg == end)
throw 1;
2547 if (end != line.find_last_of(
"="))
throw 1;
2549 if (end == std::string::npos)
throw 1;
2551 lhs = line.substr(line.find_first_not_of(
" "),
2553 lhs = lhs .substr(0, lhs.find_last_not_of(
" ")+1);
2554 rhs = line.substr(line.find_last_of(
"=")+1);
2555 rhs = rhs .substr(rhs.find_first_not_of(
" "));
2556 rhs = rhs .substr(0, rhs.find_last_not_of(
" ")+1);
2562 void SessionReader::CmdLineOverride()
2565 if (m_cmdLineOptions.count(
"solverinfo"))
2567 std::vector<std::string> solverInfoList =
2568 m_cmdLineOptions[
"solverinfo"].as<
2569 std::vector<std::string> >();
2571 for (
int i = 0; i < solverInfoList.size(); ++i)
2573 std::string
lhs, rhs;
2577 ParseEquals(solverInfoList[i], lhs, rhs);
2581 ASSERTL0(
false,
"Parse error with command line "
2582 "option: "+solverInfoList[i]);
2585 std::string lhsUpper = boost::to_upper_copy(lhs);
2586 m_solverInfo[lhsUpper] = rhs;
2590 if (m_cmdLineOptions.count(
"parameter"))
2592 std::vector<std::string> parametersList =
2593 m_cmdLineOptions[
"parameter"].as<
2594 std::vector<std::string> >();
2596 for (
int i = 0; i < parametersList.size(); ++i)
2598 std::string
lhs, rhs;
2602 ParseEquals(parametersList[i], lhs, rhs);
2606 ASSERTL0(
false,
"Parse error with command line "
2607 "option: "+parametersList[i]);
2610 std::string lhsUpper = boost::to_upper_copy(lhs);
2614 m_parameters[lhsUpper] =
2619 ASSERTL0(
false,
"Unable to convert string: "+rhs+
2620 "to double value.");
2626 void SessionReader::VerifySolverInfo()
2628 SolverInfoMap::const_iterator x;
2629 for (x = m_solverInfo.begin(); x != m_solverInfo.end(); ++x)
2631 std::string solverProperty = x->first;
2632 std::string solverValue = x->second;
2634 EnumMapList::const_iterator propIt =
2635 GetSolverInfoEnums().find(solverProperty);
2636 if (propIt != GetSolverInfoEnums().end())
2638 EnumMap::const_iterator valIt =
2639 propIt->second.find(solverValue);
2640 ASSERTL0(valIt != propIt->second.end(),
2641 "Value '" + solverValue +
"' is not valid for "
2642 "property '" + solverProperty +
"'");
2648 void SessionReader::SetUpXmlDoc(
void)
2650 m_xmlDoc = MergeDoc(m_filenames);
std::map< std::string, std::string > SolverInfoMap
#define ASSERTL0(condition, msg)
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
static void Finalise(gs_data *pGsh)
Deallocates the GSLib mapping data.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::map< std::pair< std::string, int >, FunctionVariableDefinition > FunctionVariableMap
boost::shared_ptr< MeshPartition > MeshPartitionSharedPtr
std::map< int, std::vector< unsigned int > > BndRegionOrdering
std::map< int, std::vector< unsigned int > > CompositeOrdering
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
CommFactory & GetCommFactory()
EquationSharedPtr m_expression
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
const std::string kGitSha1
std::map< std::string, GloSysInfoMap > GloSysSolnInfoList
int GetSize(const Array< OneD, const NekDouble > &x)
NekDouble Evaluate() const
std::vector< std::pair< std::string, FilterParams > > FilterMap
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
const std::string kGitBranch
boost::shared_ptr< Equation > EquationSharedPtr
This class defines evaluator of analytic (symbolic) mathematical expressions. Expressions are allowed...
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::map< std::string, NekDouble > ParameterMap
std::map< std::string, EnumMap > EnumMapList
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
std::string m_fileVariable
std::map< std::string, CmdLineArg > CmdLineArgMap
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
MeshPartitionFactory & GetMeshPartitionFactory()