Nektar++
SessionReader.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File SessionReader.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description:
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIB_UTILITIES_SESSIONREADER_H
36 #define NEKTAR_LIB_UTILITIES_SESSIONREADER_H
37 
38 #include <map>
39 #include <string>
40 #include <memory>
41 
46 
47 #include <boost/algorithm/string/case_conv.hpp>
48 #include <boost/program_options/variables_map.hpp>
49 
50 class TiXmlElement;
51 class TiXmlDocument;
52 
53 namespace Nektar
54 {
55  namespace LibUtilities
56  {
57  typedef std::map<std::string, std::string> SolverInfoMap;
58  typedef std::map<std::string, NekDouble> ParameterMap;
59  typedef std::map<std::string, std::string> GeometricInfoMap;
60  typedef std::map<std::string, std::string> ExpressionMap;
61  typedef std::vector<std::string> VariableList;
62  typedef std::map<std::string, std::string> TagMap;
63  typedef std::map<std::string, std::string> FilterParams;
64  typedef std::vector<
65  std::pair<std::string, FilterParams> > FilterMap;
66 
67  struct CmdLineArg
68  {
69  std::string shortName;
70  std::string description;
71  bool isFlag;
72  };
73 
74  typedef std::map<std::string, CmdLineArg> CmdLineArgMap;
75 
76  typedef std::map<std::string, int> EnumMap;
77  typedef std::map<std::string, EnumMap> EnumMapList;
78 
79  typedef std::map<std::string, std::string> GloSysInfoMap;
80  typedef std::map<std::string, GloSysInfoMap> GloSysSolnInfoList;
81 
82  typedef std::map<std::string, std::string> GloSysInfoMap;
83  typedef std::map<std::string, GloSysInfoMap> GloSysSolnInfoList;
84 
86  {
87  std::string method = "";
88  std::string variant = "";
89  unsigned int order = 1;
90  std::vector<NekDouble> freeParams;
91  };
92 
94  {
99  };
100  const char* const FunctionTypeMap[] =
101  {
102  "No Function type",
103  "Expression",
104  "File"
105  };
106 
108  {
109  enum FunctionType m_type;
110  std::string m_filename;
112  std::string m_fileVariable;
113  };
114 
115  typedef std::map<std::pair<std::string,int>, FunctionVariableDefinition>
117  typedef std::map<std::string, FunctionVariableMap >
119 
120  class SessionReader;
121  typedef std::shared_ptr<SessionReader> SessionReaderSharedPtr;
122 
123  /// Reads and parses information from a Nektar++ XML session file.
125  {
126  public:
127  /// Support creation through MemoryManager.
128  friend class MemoryManager<SessionReader>;
129 
130  /**
131  * @brief Creates an instance of the SessionReader class.
132  *
133  * This function should be used by an application to instantiate the
134  * session reader. It should be called at the very beginning of the
135  * application before any other processing of command-line
136  * arguments. After instantiating the class and setting up any
137  * parallel communication, it also calls the main initialisation
138  * of the object.
139  */
141  int argc, char *argv[])
142  {
144  LibUtilities::SessionReader>::AllocateSharedPtr(argc, argv);
145  return p;
146  }
147 
148  /**
149  * @brief Creates an instance of the SessionReader class initialised
150  * using a separate list of XML documents.
151  *
152  * This function should be used by an application to instantiate the
153  * session reader. It may be called after processing of command-line
154  * arguments. After instantiating the class and setting up any
155  * parallel communication, it also calls the main initialisation
156  * of the object.
157  */
159  int argc,
160  char *argv[],
161  std::vector<std::string> &pFilenames,
162  const CommSharedPtr &pComm = CommSharedPtr())
163  {
166  ::AllocateSharedPtr(argc, argv, pFilenames, pComm);
167  return p;
168  }
169 
171  int argc,
172  char *argv[],
173  const std::vector<std::string> &pFilenames,
174  const CommSharedPtr &pComm);
175 
176  /// Destructor
178 
180  const std::vector<std::string> &filenames =
181  std::vector<std::string>());
182 
183  /// Provides direct access to the TiXmlDocument object.
184  LIB_UTILITIES_EXPORT TiXmlDocument &GetDocument();
185  /// Provides direct access to the TiXmlElement specified.
186  LIB_UTILITIES_EXPORT TiXmlElement *GetElement(
187  const std::string& pPath);
188  /// Tests if a specified element is defined in the XML document.
190  const std::string& pPath) const;
191  /// Returns the filename of the loaded XML document.
192  LIB_UTILITIES_EXPORT const std::vector<std::string>
193  &GetFilenames() const;
194  /// Returns the session name of the loaded XML document.
195  LIB_UTILITIES_EXPORT const std::string &GetSessionName() const;
196  /// Returns the session name with process rank
197  LIB_UTILITIES_EXPORT const std::string GetSessionNameRank() const;
198  /// Returns the communication object.
200  /// Returns if file system shared
202  /// Finalises the session.
204 
205  /* ------ PARAMETERS --------*/
206  /// Checks if a parameter is specified in the XML document.
208  const std::string &name) const;
209  /// Returns the value of the specified parameter.
211  const std::string &pName) const;
212  /// Load an integer parameter
214  const std::string &name,
215  int &var) const;
216  /// Check for and load an integer parameter.
218  const std::string &name,
219  int &var,
220  const int &def) const;
221  /// Load a double precision parameter
223  const std::string &name,
224  NekDouble &var) const;
225  /// Check for and load a double-precision parameter.
227  const std::string &name,
228  NekDouble &var,
229  const NekDouble &def) const;
230  /// Set an integer parameter
232  const std::string &name,
233  int &var);
234  /// Set a double precision parameter
236  const std::string &name,
237  NekDouble &var);
238 
239 
240  /* ------ SOLVER INFO ------ */
241  /// Checks if a solver info property is specified.
243  const std::string &name) const;
244  /// Returns the value of the specified solver info property.
245  LIB_UTILITIES_EXPORT const std::string& GetSolverInfo(
246  const std::string &pProperty) const;
247  /// Sets the value of the specified solver info property.
249  const std::string &pProperty, const std::string &pValue);
250  /// Returns the value of the specified solver info property as enum
251  template<typename T>
252  inline const T GetSolverInfoAsEnum(const std::string &pName) const;
253  /// Returns the value of the specified property and value as enum
254  template<typename T>
255  inline const T GetValueAsEnum(const std::string &pName,
256  const std::string &vValue) const;
257  /// Check for and load a solver info property.
259  const std::string &name,
260  std::string &var,
261  const std::string &def = "") const;
262  /// Check if the value of a solver info property matches.
264  const std::string &name,
265  const std::string &trueval,
266  bool &var,
267  const bool &def = false) const;
268  /// Check if the value of a solver info property matches.
270  const std::string &name,
271  const std::string &trueval) const;
272  /// Check if the value of a solver info property matches.
273  template<typename T>
274  inline bool MatchSolverInfoAsEnum(
275  const std::string &name,
276  const T &trueval) const;
277  /// Registers an enumeration value.
278  LIB_UTILITIES_EXPORT inline static std::string RegisterEnumValue(
279  std::string pEnum,
280  std::string pString,
281  int pEnumValue);
282  /// Registers the default string value of a solver info property.
283  LIB_UTILITIES_EXPORT inline static std::string
285  const std::string &pName,
286  const std::string &pValue);
287 
288  /* ----GlobalSysSolnInfo ----- */
289 
291  const std::string &variable,
292  const std::string &property) const;
293 
294  LIB_UTILITIES_EXPORT const std::string& GetGlobalSysSolnInfo(
295  const std::string &variable,
296  const std::string &property) const;
297 
298  /* ------ TIME INTEGRATION INFORMATION ----- */
301 
302  /* ------ GEOMETRIC INFO ------ */
303  LIB_UTILITIES_EXPORT std::string GetGeometryType() const;
304  /// Checks if a geometric info property is defined.
306  const std::string &name) const;
307  /// Checks for and load a geometric info string property.
309  const std::string &name,
310  std::string &var,
311  const std::string &def = "") const;
312  /// Checks for and loads a geometric info boolean property.
314  const std::string &name,
315  bool &var,
316  const bool &def = false) const;
317  /// Checks for and loads a geometric info double-precision property.
319  const std::string &name,
320  NekDouble &var,
321  const NekDouble &def = 0.0) const;
322  /// Check if the value of a geometric info string property matches.
324  const std::string &name,
325  const std::string &trueval,
326  bool &var,
327  const bool &def = false) const;
328 
329  /* ------ VARIABLES ------ */
330  /// Returns the name of the variable specified by the given index.
331  LIB_UTILITIES_EXPORT const std::string& GetVariable(
332  const unsigned int &idx) const;
334  const unsigned int &idx,
335  std::string newname);
336 
337  /// Returns the names of all variables.
338  LIB_UTILITIES_EXPORT std::vector<std::string> GetVariables() const;
339 
340  /* ------ FUNCTIONS ------*/
341  /// Checks if a specified function is defined in the XML document.
343  const std::string &name) const;
344  /// Checks if a specified function has a given variable defined.
346  const std::string &name,
347  const std::string &variable,
348  const int pDomain = 0) const;
349  /// Returns an EquationSharedPtr to a given function variable.
351  const std::string &name,
352  const std::string &variable,
353  const int pDomain = 0) const;
354  /// Returns an EquationSharedPtr to a given function variable index.
356  const std::string &name,
357  const unsigned int &var,
358  const int pDomain = 0) const;
359  /// Returns the type of a given function variable.
361  const std::string &name,
362  const std::string &variable,
363  const int pDomain = 0) const;
364  /// Returns the type of a given function variable index.
366  const std::string &pName,
367  const unsigned int &pVar,
368  const int pDomain = 0) const;
369  /// Returns the filename to be loaded for a given variable.
371  const std::string &name,
372  const std::string &variable,
373  const int pDomain = 0) const;
374  /// Returns the filename to be loaded for a given variable index.
376  const std::string &name,
377  const unsigned int &var,
378  const int pDomain = 0) const;
379  /// Returns the filename variable to be loaded for a given variable
380  /// index.
382  const std::string &name,
383  const std::string &variable,
384  const int pDomain = 0) const;
385 
386  /// Returns the instance of the Interpreter specific to this
387  /// session.
389 
390  /* ------ TAGS ------ */
391  /// Checks if a specified tag is defined.
393  const std::string& pName) const;
394  /// Sets a specified tag.
396  const std::string& pName,
397  const std::string& pValue);
398  /// Returns the value of a specified tag.
399  LIB_UTILITIES_EXPORT const std::string &GetTag(
400  const std::string& pName) const;
401 
402  /* ------ FILTERS ------ */
404 
405  /* ------ CMDLINE ARGUMENTS ------- */
406  /// Checks if a specified cmdline argument has been given.
408  const std::string& pName) const;
409  /// Retrieves a command-line argument value.
410  template <typename T>
412  const std::string& pName) const
413  {
414  return m_cmdLineOptions.find(pName)->second.as<T>();
415  }
416  /// Registers a command-line argument with the session reader.
417  LIB_UTILITIES_EXPORT inline static std::string
419  const std::string &pName,
420  const std::string &pShortName,
421  const std::string &pDescription);
422  /// Registers a command-line flag with the session reader.
423  LIB_UTILITIES_EXPORT inline static std::string
425  const std::string &pName,
426  const std::string &pShortName,
427  const std::string &pDescription);
428 
429  /// Substitutes expressions defined in the XML document.
430  LIB_UTILITIES_EXPORT void SubstituteExpressions(std::string &expr);
431 
433 
434  private:
435  boost::program_options::variables_map m_cmdLineOptions;
436 
437  /// Communication object.
439  /// Filenames
440  std::vector<std::string> m_filenames;
441  /// Session name of the loaded XML document (filename minus ext).
442  std::string m_sessionName;
443  /// Pointer to the loaded XML document.
444  TiXmlDocument* m_xmlDoc;
445  /// Parameters.
447  /// Solver information properties.
449  /// Geometric information properties.
451  /// Expressions.
453  /// Interpreter instance.
455  /// Functions.
457  /// Variables.
459  /// Custom tags.
461  /// Filters map.
463  /// Time integration scheme information.
465  /// Be verbose
466  bool m_verbose;
467  /// Running on a shared filesystem
469  /// String to enumeration map for Solver Info parameters.
471  /// Default solver info options.
473  /// GlobalSysSoln Info map.
475  /// CmdLine argument map.
477 
478  /// Main constructor
480  int argc,
481  char *argv[]);
482 
484 
485  /// Parse the program arguments and fill #m_cmdLineOptions
486  std::vector<std::string> ParseCommandLineArguments(
487  int argc, char *argv[]);
488 
489  /// Parse the session name.
490  std::string ParseSessionName(std::vector<std::string> &filenames);
491 
492  /// Loads an xml file into a tinyxml doc and decompresses if needed
494  const std::string &pFilename,
495  TiXmlDocument* pDoc) const;
496  /// Creates an XML document from a list of input files.
497  LIB_UTILITIES_EXPORT TiXmlDocument *MergeDoc(
498  const std::vector<std::string> &pFilenames) const;
499  /// Loads and parses the specified file.
501  /// Loads the given XML document and instantiates an appropriate
502  /// communication object.
504  int &argc,
505  char* argv[]);
506 
507  /// Partitions the comm object based on session parameters.
509 
510  /// Reads the PARAMETERS section of the XML document.
511  LIB_UTILITIES_EXPORT void ReadParameters(TiXmlElement *conditions);
512  /// Reads the SOLVERINFO section of the XML document.
513  LIB_UTILITIES_EXPORT void ReadSolverInfo(TiXmlElement *conditions);
514  /// Reads the GLOBALSYSSOLNINFO section of the XML document.
516  TiXmlElement *conditions);
517  /// Reads the TIMEINTEGRATIONSCHEME section of the XML document.
519  TiXmlElement *conditions);
520  /// Reads the EXPRESSIONS section of the XML document.
521  LIB_UTILITIES_EXPORT void ReadExpressions(TiXmlElement *conditions);
522  /// Reads the VARIABLES section of the XML document.
523  LIB_UTILITIES_EXPORT void ReadVariables(TiXmlElement *conditions);
524  /// Reads the FUNCTIONS section of the XML document.
525  LIB_UTILITIES_EXPORT void ReadFunctions(TiXmlElement *conditions);
526  /// Reads the FILTERS section of the XML document.
527  LIB_UTILITIES_EXPORT void ReadFilters(TiXmlElement *filters);
528  /// Enforce parameters from command line arguments.
530  /// Check values of solver info options are valid.
532 
533  /// Parse a string in the form lhs = rhs.
535  const std::string &line,
536  std::string &lhs,
537  std::string &rhs);
538  };
539 
540 
541  /**
542  *
543  */
544  template<typename T>
546  const std::string &name, const T &trueval) const
547  {
548  return (GetSolverInfoAsEnum<T>(name) == trueval);
549  }
550 
551 
552  /**
553  *
554  */
555  template<typename T>
557  const std::string &pName) const
558  {
559  std::string vName = boost::to_upper_copy(pName);
561  "Solver info '" + pName + "' not defined.");
562 
563  std::string vValue = GetSolverInfo(vName);
564  auto x = GetSolverInfoEnums().find(vName);
565  ASSERTL0(x != GetSolverInfoEnums().end(),
566  "Enum for SolverInfo property '" + pName + "' not found.");
567 
568  auto y = x->second.find(vValue);
569  ASSERTL0(y != x->second.end(),
570  "Value of SolverInfo property '" + pName +
571  "' is invalid.");
572 
573  return T(y->second);
574  }
575 
576 
577 
578  /**
579  *
580  */
581  template<typename T>
583  const std::string &pName,
584  const std::string &pValue) const
585  {
586  std::string vName = boost::to_upper_copy(pName);
587 
588  auto x = GetSolverInfoEnums().find(vName);
589  ASSERTL0(x != GetSolverInfoEnums().end(),
590  "Enum for property '" + pName + "' not found.");
591 
592  auto y = x->second.find(pValue);
593  ASSERTL0(y != x->second.end(),
594  "Value of property '" + pValue + "' is invalid.");
595  return T(y->second);
596  }
597 
598 
599 
600  /**
601  * A set of valid values for a given solver info property may be
602  * registered using this function. It must be called statically during
603  * the initialisation of a static variable. For example:
604  *
605  * @code
606  * std::string GlobalLinSys::lookupIds[2] = {
607  * LibUtilities::SessionReader::RegisterEnumValue(
608  * "GlobalSysSoln",
609  * "DirectFull",
610  * MultiRegions::eDirectFullMatrix),
611  * LibUtilities::SessionReader::RegisterEnumValue(
612  * "GlobalSysSoln",
613  * "DirectStaticCond",
614  * MultiRegions::eDirectStaticCond)
615  * }
616  * @endcode
617  *
618  * @param pEnum The name of the property.
619  * @param pString A valid value for the property.
620  * @param pEnumValue An enumeration value corresponding to this
621  * value.
622  *
623  * @return The value for the property provided by #pString.
624  */
626  std::string pEnum, std::string pString, int pEnumValue)
627  {
628  std::string vEnum = boost::to_upper_copy(pEnum);
629  auto x = GetSolverInfoEnums().find(vEnum);
630 
631  if (x == GetSolverInfoEnums().end())
632  {
633  GetSolverInfoEnums()[vEnum] = EnumMap();
634  x = GetSolverInfoEnums().find(vEnum);
635  }
636 
637  x->second[pString] = pEnumValue;
638  return pString;
639  }
640 
641 
642  /**
643  * A default value for a given solver info property may be registered
644  * using this function. The property will take this value until it is
645  * overwritten by a value specified in the XML document, or specified
646  * as a command-line argument. Usage has the form:
647  *
648  * @code
649  * std::string GlobalLinSys::def
650  * = LibUtilities::SessionReader::RegisterDefaultSolverInfo(
651  * "GlobalSysSoln","DirectMultiLevelStaticCond");
652  * @endcode
653  *
654  * @param pName The name of the property.
655  * @param pValue The default value of the property.
656  *
657  * @return The default value of the property provided by #pValue.
658  */
660  const std::string &pName,
661  const std::string &pValue)
662  {
663  std::string vName = boost::to_upper_copy(pName);
664  GetSolverInfoDefaults()[vName] = pValue;
665  return pValue;
666  }
667 
668 
669  /**
670  *
671  */
673  const std::string &pName,
674  const std::string &pShortName,
675  const std::string &pDescription)
676  {
677  ASSERTL0(!pName.empty(), "Empty name for cmdline argument.");
678  CmdLineArg x;
679  x.shortName = pShortName;
680  x.description = pDescription;
681  x.isFlag = false;
682  GetCmdLineArgMap()[pName] = x;
683  return pName;
684  }
685 
686 
687  /**
688  *
689  */
691  const std::string &pName,
692  const std::string &pShortName,
693  const std::string &pDescription)
694  {
695  ASSERTL0(!pName.empty(), "Empty name for cmdline argument.");
696  CmdLineArg x;
697  x.shortName = pShortName;
698  x.description = pDescription;
699  x.isFlag = true;
700  GetCmdLineArgMap()[pName] = x;
701  return pName;
702  }
703  }
704 }
705 
706 #endif
707 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
#define LIB_UTILITIES_EXPORT
Reads and parses information from a Nektar++ XML session file.
const std::string & GetGlobalSysSolnInfo(const std::string &variable, const std::string &property) const
void ReadSolverInfo(TiXmlElement *conditions)
Reads the SOLVERINFO section of the XML document.
GeometricInfoMap m_geometricInfo
Geometric information properties.
bool DefinesFunction(const std::string &name) const
Checks if a specified function is defined in the XML document.
std::string GetFunctionFilenameVariable(const std::string &name, const std::string &variable, const int pDomain=0) const
Returns the filename variable to be loaded for a given variable index.
bool DefinesGeometricInfo(const std::string &name) const
Checks if a geometric info property is defined.
std::vector< std::string > ParseCommandLineArguments(int argc, char *argv[])
Parse the program arguments and fill m_cmdLineOptions.
static SolverInfoMap & GetSolverInfoDefaults()
Default solver info options.
static std::string RegisterCmdLineArgument(const std::string &pName, const std::string &pShortName, const std::string &pDescription)
Registers a command-line argument with the session reader.
TimeIntScheme m_timeIntScheme
Time integration scheme information.
InterpreterSharedPtr GetInterpreter()
Returns the instance of the Interpreter specific to this session.
TiXmlElement * GetElement(const std::string &pPath)
Provides direct access to the TiXmlElement specified.
void ReadVariables(TiXmlElement *conditions)
Reads the VARIABLES section of the XML document.
bool DefinesSolverInfo(const std::string &name) const
Checks if a solver info property is specified.
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
const std::string & GetSessionName() const
Returns the session name of the loaded XML document.
void ReadTimeIntScheme(TiXmlElement *conditions)
Reads the TIMEINTEGRATIONSCHEME section of the XML document.
void MatchGeometricInfo(const std::string &name, const std::string &trueval, bool &var, const bool &def=false) const
Check if the value of a geometric info string property matches.
void ReadFilters(TiXmlElement *filters)
Reads the FILTERS section of the XML document.
void ReadGlobalSysSolnInfo(TiXmlElement *conditions)
Reads the GLOBALSYSSOLNINFO section of the XML document.
void InitSession(const std::vector< std::string > &filenames=std::vector< std::string >())
VariableList m_variables
Variables.
SolverInfoMap m_solverInfo
Solver information properties.
void SubstituteExpressions(std::string &expr)
Substitutes expressions defined in the XML document.
std::vector< std::string > GetVariables() const
Returns the names of all variables.
static CmdLineArgMap & GetCmdLineArgMap()
CmdLine argument map.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
TiXmlDocument * MergeDoc(const std::vector< std::string > &pFilenames) const
Creates an XML document from a list of input files.
void SetVariable(const unsigned int &idx, std::string newname)
T GetCmdLineArgument(const std::string &pName) const
Retrieves a command-line argument value.
void CmdLineOverride()
Enforce parameters from command line arguments.
void ParseDocument()
Loads and parses the specified file.
bool m_sharedFilesystem
Running on a shared filesystem.
static std::string RegisterDefaultSolverInfo(const std::string &pName, const std::string &pValue)
Registers the default string value of a solver info property.
std::string ParseSessionName(std::vector< std::string > &filenames)
Parse the session name.
std::string GetFunctionFilename(const std::string &name, const std::string &variable, const int pDomain=0) const
Returns the filename to be loaded for a given variable.
enum FunctionType GetFunctionType(const std::string &name, const std::string &variable, const int pDomain=0) const
Returns the type of a given function variable.
bool DefinesTag(const std::string &pName) const
Checks if a specified tag is defined.
void LoadParameter(const std::string &name, int &var) const
Load an integer parameter.
CommSharedPtr GetComm()
Returns the communication object.
const NekDouble & GetParameter(const std::string &pName) const
Returns the value of the specified parameter.
const T GetSolverInfoAsEnum(const std::string &pName) const
Returns the value of the specified solver info property as enum.
ParameterMap m_parameters
Parameters.
void SetParameter(const std::string &name, int &var)
Set an integer parameter.
InterpreterSharedPtr m_interpreter
Interpreter instance.
static EnumMapList & GetSolverInfoEnums()
String to enumeration map for Solver Info parameters.
void VerifySolverInfo()
Check values of solver info options are valid.
void SetSolverInfo(const std::string &pProperty, const std::string &pValue)
Sets the value of the specified solver info property.
const std::string & GetVariable(const unsigned int &idx) const
Returns the name of the variable specified by the given index.
EquationSharedPtr GetFunction(const std::string &name, const std::string &variable, const int pDomain=0) const
Returns an EquationSharedPtr to a given function variable.
const std::string & GetTag(const std::string &pName) const
Returns the value of a specified tag.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[], std::vector< std::string > &pFilenames, const CommSharedPtr &pComm=CommSharedPtr())
Creates an instance of the SessionReader class initialised using a separate list of XML documents.
ExpressionMap m_expressions
Expressions.
FunctionMap m_functions
Functions.
TiXmlDocument & GetDocument()
Provides direct access to the TiXmlDocument object.
bool DefinesElement(const std::string &pPath) const
Tests if a specified element is defined in the XML document.
std::vector< std::string > m_filenames
Filenames.
bool DefinesGlobalSysSolnInfo(const std::string &variable, const std::string &property) const
void ReadFunctions(TiXmlElement *conditions)
Reads the FUNCTIONS section of the XML document.
void LoadDoc(const std::string &pFilename, TiXmlDocument *pDoc) const
Loads an xml file into a tinyxml doc and decompresses if needed.
bool DefinesParameter(const std::string &name) const
Checks if a parameter is specified in the XML document.
SessionReader(int argc, char *argv[], const std::vector< std::string > &pFilenames, const CommSharedPtr &pComm)
const std::string GetSessionNameRank() const
Returns the session name with process rank.
const TimeIntScheme & GetTimeIntScheme() const
Returns the time integration scheme structure m_timeIntScheme from the session file.
bool MatchSolverInfoAsEnum(const std::string &name, const T &trueval) const
Check if the value of a solver info property matches.
void LoadGeometricInfo(const std::string &name, std::string &var, const std::string &def="") const
Checks for and load a geometric info string property.
void SetTag(const std::string &pName, const std::string &pValue)
Sets a specified tag.
boost::program_options::variables_map m_cmdLineOptions
std::string m_sessionName
Session name of the loaded XML document (filename minus ext).
CommSharedPtr m_comm
Communication object.
static std::string RegisterCmdLineFlag(const std::string &pName, const std::string &pShortName, const std::string &pDescription)
Registers a command-line flag with the session reader.
const T GetValueAsEnum(const std::string &pName, const std::string &vValue) const
Returns the value of the specified property and value as enum.
void MatchSolverInfo(const std::string &name, const std::string &trueval, bool &var, const bool &def=false) const
Check if the value of a solver info property matches.
void CreateComm(int &argc, char *argv[])
Loads the given XML document and instantiates an appropriate communication object.
const std::string & GetSolverInfo(const std::string &pProperty) const
Returns the value of the specified solver info property.
void ParseEquals(const std::string &line, std::string &lhs, std::string &rhs)
Parse a string in the form lhs = rhs.
bool DefinesTimeIntScheme() const
Returns true if the TIMEINTEGRATIONSCHEME section is defined in the session file.
const std::vector< std::string > & GetFilenames() const
Returns the filename of the loaded XML document.
bool GetSharedFilesystem()
Returns if file system shared.
static GloSysSolnInfoList & GetGloSysSolnList()
GlobalSysSoln Info map.
void PartitionComm()
Partitions the comm object based on session parameters.
bool DefinesCmdLineArgument(const std::string &pName) const
Checks if a specified cmdline argument has been given.
TiXmlDocument * m_xmlDoc
Pointer to the loaded XML document.
void ReadParameters(TiXmlElement *conditions)
Reads the PARAMETERS section of the XML document.
void LoadSolverInfo(const std::string &name, std::string &var, const std::string &def="") const
Check for and load a solver info property.
void ReadExpressions(TiXmlElement *conditions)
Reads the EXPRESSIONS section of the XML document.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< Interpreter > InterpreterSharedPtr
Definition: Interpreter.h:325
std::map< std::string, std::string > FilterParams
Definition: SessionReader.h:63
std::map< std::string, std::string > SolverInfoMap
Definition: SessionReader.h:57
std::map< std::string, GloSysInfoMap > GloSysSolnInfoList
Definition: SessionReader.h:80
std::map< std::string, FunctionVariableMap > FunctionMap
const char *const FunctionTypeMap[]
std::map< std::string, NekDouble > ParameterMap
Definition: SessionReader.h:58
std::map< std::string, int > EnumMap
Definition: SessionReader.h:76
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:131
std::vector< std::pair< std::string, FilterParams > > FilterMap
Definition: SessionReader.h:65
std::vector< std::string > VariableList
Definition: SessionReader.h:61
std::map< std::string, std::string > GloSysInfoMap
Definition: SessionReader.h:79
std::map< std::string, EnumMap > EnumMapList
Definition: SessionReader.h:77
std::map< std::string, std::string > ExpressionMap
Definition: SessionReader.h:60
std::map< std::string, CmdLineArg > CmdLineArgMap
Definition: SessionReader.h:74
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:54
std::map< std::string, std::string > GeometricInfoMap
Definition: SessionReader.h:59
std::map< std::pair< std::string, int >, FunctionVariableDefinition > FunctionVariableMap
std::map< std::string, std::string > TagMap
Definition: SessionReader.h:62
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble
std::vector< NekDouble > freeParams
Definition: SessionReader.h:90