Nektar++
Loading...
Searching...
No Matches
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 <memory>
40#include <string>
41
46
47#include <boost/algorithm/string/case_conv.hpp>
48#include <boost/program_options/variables_map.hpp>
49
50class TiXmlElement;
51class TiXmlDocument;
52class TiXmlHandle;
53
55{
56typedef std::map<std::string, std::string> SolverInfoMap;
57typedef std::map<std::string, NekDouble> ParameterMap;
58typedef std::map<std::string, std::string> GeometricInfoMap;
59typedef std::vector<std::string> VariableList;
60typedef std::map<std::string, std::string> TagMap;
61typedef std::map<std::string, std::string> FilterParams;
63{
64 std::string name;
65 int domain;
67};
68typedef std::vector<FilterDefinition> FilterMap;
69
71{
72 std::string shortName;
73 std::string description;
74 bool isFlag;
75};
76
77typedef std::map<std::string, CmdLineArg> CmdLineArgMap;
78
79typedef std::map<std::string, int> EnumMap;
80typedef std::map<std::string, EnumMap> EnumMapList;
81
82typedef std::map<std::string, std::string> GloSysInfoMap;
83typedef std::map<std::string, GloSysInfoMap> GloSysSolnInfoList;
84
85typedef std::map<std::string, std::string> GloSysInfoMap;
86typedef std::map<std::string, GloSysInfoMap> GloSysSolnInfoList;
87
89{
90 std::string method = "";
91 std::string variant = "";
92 unsigned int order = 1;
93 std::vector<NekDouble> freeParams;
94};
95
103const char *const FunctionTypeMap[] = {"No Function type", "Expression",
104 "File"};
105
113
114typedef std::map<std::pair<std::string, int>, FunctionVariableDefinition>
116typedef std::map<std::string, FunctionVariableMap> FunctionMap;
117
118class SessionReader;
119typedef std::shared_ptr<SessionReader> SessionReaderSharedPtr;
120
121/// Reads and parses information from a Nektar++ XML session file.
123{
124public:
125 /// Support creation through MemoryManager.
126 friend class MemoryManager<SessionReader>;
127
128 /**
129 * @brief Creates an instance of the SessionReader class.
130 *
131 * This function should be used by an application to instantiate the
132 * session reader. It should be called at the very beginning of the
133 * application before any other processing of command-line
134 * arguments. After instantiating the class and setting up any
135 * parallel communication, it also calls the main initialisation
136 * of the object.
137 */
139 int argc, char *argv[])
140 {
143 argv);
144 return p;
145 }
146
147 /**
148 * @brief Creates an instance of the SessionReader class initialised
149 * using a separate list of XML documents.
150 *
151 * This function should be used by an application to instantiate the
152 * session reader. It may be called after processing of command-line
153 * arguments. After instantiating the class and setting up any
154 * parallel communication, it also calls the main initialisation
155 * of the object.
156 */
158 int argc, char *argv[], std::vector<std::string> &pFilenames,
159 const CommSharedPtr &pComm = CommSharedPtr(), const int &timelevel = 0)
160 {
163 argc, argv, pFilenames, pComm, timelevel);
164 return p;
165 }
166
168 int argc, char *argv[], const std::vector<std::string> &pFilenames,
169 const CommSharedPtr &pComm, const int &timelevel);
170
171 /// Destructor
173
175 const std::vector<std::string> &filenames = std::vector<std::string>());
176
177 /// Provides direct access to the TiXmlDocument object.
178 LIB_UTILITIES_EXPORT TiXmlDocument &GetDocument();
179 /// Provides direct access to the TiXmlElement specified.
180 LIB_UTILITIES_EXPORT TiXmlElement *GetElement(const std::string &pPath);
181 /// Tests if a specified element is defined in the XML document.
182 LIB_UTILITIES_EXPORT bool DefinesElement(const std::string &pPath) const;
183 /// Returns the filename of the loaded XML document.
184 LIB_UTILITIES_EXPORT const std::vector<std::string> &GetFilenames() const;
185 /// Returns the session name of the loaded XML document.
186 LIB_UTILITIES_EXPORT const std::string &GetSessionName() const;
187 /// Returns the communication object.
189 /// Returns if file system shared
191 /// Finalises the session.
193
194 /* ------ PARAMETERS --------*/
195 /// Checks if a parameter is specified in the XML document.
196 LIB_UTILITIES_EXPORT bool DefinesParameter(const std::string &name) const;
197 /// Returns the value of the specified parameter.
199 const std::string &pName) const;
201 /// Load an integer parameter
202 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name,
203 int &var) const;
204 /// Load an unsigned integer parameter
205 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name,
206 unsigned int &var) const;
207 /// Load an size_t parameter
208 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name,
209 size_t &var) const;
210 /// Check for and load an integer parameter.
211 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name, int &var,
212 const int &def) const;
213 /// Check for and load an unsigned integer parameter.
214 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name,
215 unsigned int &var,
216 const unsigned int &def) const;
217 /// Check for and load an size_t parameter.
218 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name,
219 size_t &var,
220 const size_t &def) const;
221 /// Load a double precision parameter
222 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name,
223 NekDouble &var) const;
224 /// Check for and load a double-precision parameter.
225 LIB_UTILITIES_EXPORT void LoadParameter(const std::string &name,
226 NekDouble &var,
227 const NekDouble &def) const;
228 /// Set an integer parameter
229 LIB_UTILITIES_EXPORT void SetParameter(const std::string &name, int &var);
230 /// Set an unsigned integer parameter
231 LIB_UTILITIES_EXPORT void SetParameter(const std::string &name,
232 unsigned int &var);
233 /// Set an size_t parameter
234 LIB_UTILITIES_EXPORT void SetParameter(const std::string &name,
235 size_t &var);
236 /// Set a double precision parameter
237 LIB_UTILITIES_EXPORT void SetParameter(const std::string &name,
238 NekDouble &var);
239
240 /* ------ SOLVER INFO ------ */
241 /// Checks if a solver info property is specified.
242 LIB_UTILITIES_EXPORT bool DefinesSolverInfo(const std::string &name) const;
243 /// Returns the value of the specified solver info property.
244 LIB_UTILITIES_EXPORT const std::string &GetSolverInfo(
245 const std::string &pProperty) const;
246 /// Sets the value of the specified solver info property.
247 LIB_UTILITIES_EXPORT void SetSolverInfo(const std::string &pProperty,
248 const std::string &pValue);
249 /// Returns the value of the specified solver info property as enum
250 template <typename T>
251 inline const T GetSolverInfoAsEnum(const std::string &pName) const;
252 /// Returns the value of the specified property and value as enum
253 template <typename T>
254 inline const T GetValueAsEnum(const std::string &pName,
255 const std::string &vValue) const;
256 /// Check for and load a solver info property.
257 LIB_UTILITIES_EXPORT void LoadSolverInfo(const std::string &name,
258 std::string &var,
259 const std::string &def = "") const;
260 /// Check if the value of a solver info property matches.
261 LIB_UTILITIES_EXPORT void MatchSolverInfo(const std::string &name,
262 const std::string &trueval,
263 bool &var,
264 const bool &def = false) const;
265 /// Check if the value of a solver info property matches.
266 LIB_UTILITIES_EXPORT bool MatchSolverInfo(const std::string &name,
267 const std::string &trueval) const;
268 /// Check if the value of a solver info property matches.
269 template <typename T>
270 inline bool MatchSolverInfoAsEnum(const std::string &name,
271 const T &trueval) const;
272 /// Registers an enumeration value.
273 LIB_UTILITIES_EXPORT inline static std::string RegisterEnumValue(
274 std::string pEnum, std::string pString, int pEnumValue);
275 /// Registers the default string value of a solver info property.
276 LIB_UTILITIES_EXPORT inline static std::string RegisterDefaultSolverInfo(
277 const std::string &pName, const std::string &pValue);
278 /// Returns the backups.
279 LIB_UTILITIES_EXPORT bool GetBackups() const;
280
281 /* ----GlobalSysSolnInfo ----- */
283 const std::string &variable, const std::string &property) const;
284
286 const std::string &variable, const std::string &property) const;
287
288 LIB_UTILITIES_EXPORT void SetGlobalSysSolnInfo(const std::string &variable,
289 const std::string &property,
290 const std::string &value);
291
292 /* ------ TIME INTEGRATION INFORMATION ----- */
295
296 /* ------ GEOMETRIC INFO ------ */
297 LIB_UTILITIES_EXPORT std::string GetGeometryType() const;
298
299 /* ------ VARIABLES ------ */
300 /// Returns the name of the variable specified by the given index.
301 LIB_UTILITIES_EXPORT const std::string &GetVariable(
302 const unsigned int &idx) const;
303 LIB_UTILITIES_EXPORT void SetVariable(const unsigned int &idx,
304 std::string newname);
305
306 /// Returns the names of all variables.
307 LIB_UTILITIES_EXPORT std::vector<std::string> GetVariables() const;
308
309 /* ------ FUNCTIONS ------*/
310 /// Checks if a specified function is defined in the XML document.
311 LIB_UTILITIES_EXPORT bool DefinesFunction(const std::string &name) const;
312 /// Checks if a specified function has a given variable defined.
313 LIB_UTILITIES_EXPORT bool DefinesFunction(const std::string &name,
314 const std::string &variable,
315 const int pDomain = 0) const;
316 /// Returns an EquationSharedPtr to a given function variable.
318 GetFunction(const std::string &name, const std::string &variable,
319 const int pDomain = 0) const;
320 /// Returns an EquationSharedPtr to a given function variable index.
322 GetFunction(const std::string &name, const unsigned int &var,
323 const int pDomain = 0) const;
324 /// Returns the type of a given function variable.
326 const std::string &name, const std::string &variable,
327 const int pDomain = 0) const;
328 /// Returns the type of a given function variable index.
330 const std::string &pName, const unsigned int &pVar,
331 const int pDomain = 0) const;
332 /// Returns the filename to be loaded for a given variable.
334 const std::string &name, const std::string &variable,
335 const int pDomain = 0) const;
336 /// Returns the filename to be loaded for a given variable index.
338 const std::string &name, const unsigned int &var,
339 const int pDomain = 0) const;
340 /// Returns the filename variable to be loaded for a given variable
341 /// index.
343 const std::string &name, const std::string &variable,
344 const int pDomain = 0) const;
345
346 /// Returns the instance of the Interpreter specific to this
347 /// session.
349
350 /* ------ TAGS ------ */
351 /// Checks if a specified tag is defined.
352 LIB_UTILITIES_EXPORT bool DefinesTag(const std::string &pName) const;
353 /// Sets a specified tag.
354 LIB_UTILITIES_EXPORT void SetTag(const std::string &pName,
355 const std::string &pValue);
356 /// Returns the value of a specified tag.
357 LIB_UTILITIES_EXPORT const std::string &GetTag(
358 const std::string &pName) const;
359
360 /* ------ FILTERS ------ */
362
363 /* ------ CMDLINE ARGUMENTS ------- */
364 /// Checks if a specified cmdline argument has been given.
366 const std::string &pName) const;
367 /// Retrieves a command-line argument value.
368 template <typename T> T GetCmdLineArgument(const std::string &pName) const
369 {
370 return m_cmdLineOptions.find(pName)->second.as<T>();
371 }
372 /// Registers a command-line argument with the session reader.
373 LIB_UTILITIES_EXPORT inline static std::string RegisterCmdLineArgument(
374 const std::string &pName, const std::string &pShortName,
375 const std::string &pDescription);
376 /// Registers a command-line flag with the session reader.
377 LIB_UTILITIES_EXPORT inline static std::string RegisterCmdLineFlag(
378 const std::string &pName, const std::string &pShortName,
379 const std::string &pDescription);
380
381 /// Get bool to update optimisation file
383 {
384 return m_updateOptFile;
385 }
386
387 /// Set bool to update optimisation file
389 {
390 m_updateOptFile = flag;
391 }
392
393 /// Get time level (Parallel-in-Time)
395 {
396 return m_timeLevel;
397 }
398
399 /// Get XML elment time level (Parallel-in-Time)
401 TiXmlElement *&element, const size_t timeLevel,
402 const bool enableCheck = true);
403
404private:
405 boost::program_options::variables_map m_cmdLineOptions;
406
407 /// Communication object.
409 /// Filenames
410 std::vector<std::string> m_filenames;
411 /// Session name of the loaded XML document (filename minus ext).
412 std::string m_sessionName;
413 /// Pointer to the loaded XML document.
414 TiXmlDocument *m_xmlDoc;
415 /// Parameters.
417 /// Solver information properties.
419 /// Geometric information properties.
421 /// Interpreter instance.
423 /// Functions.
425 /// Variables.
427 /// Custom tags.
429 /// Filters map.
431 /// Time integration scheme information.
433 /// Time level.
434 size_t m_timeLevel = 0;
435 /// Be verbose
437 /// Running on a shared filesystem
439 /// Backups
440 bool m_backups = true;
441 /// Update optimisation file
443
444 /// String to enumeration map for Solver Info parameters.
446 /// Default solver info options.
448 /// GlobalSysSoln Info map.
450 /// CmdLine argument map.
452
453 /// Main constructor
454 LIB_UTILITIES_EXPORT SessionReader(int argc, char *argv[]);
455
457
458 /// Parse the program arguments and fill #m_cmdLineOptions
459 std::vector<std::string> ParseCommandLineArguments(int argc, char *argv[]);
460
461 /// Parse the session name.
462 std::string ParseSessionName(std::vector<std::string> &filenames);
463
464 /// Loads an xml file into a tinyxml doc and decompresses if needed
465 LIB_UTILITIES_EXPORT void LoadDoc(const std::string &pFilename,
466 TiXmlDocument *pDoc) const;
467 /// Creates an XML document from a list of input files.
468 LIB_UTILITIES_EXPORT TiXmlDocument *MergeDoc(
469 const std::vector<std::string> &pFilenames) const;
470 /// Loads and parses the specified file.
472
473 /// Loads the given XML document and instantiates an appropriate
474 /// communication object.
475 LIB_UTILITIES_EXPORT void CreateComm(int &argc, char *argv[]);
476 /// Partitions the comm object based on session parameters.
478
479 /// Reads the PARAMETERS section of the XML document.
480 LIB_UTILITIES_EXPORT void ReadParameters(TiXmlElement *conditions);
481 /// Reads the SOLVERINFO section of the XML document.
482 LIB_UTILITIES_EXPORT void ReadSolverInfo(TiXmlElement *conditions);
483 /// Reads the GLOBALSYSSOLNINFO section of the XML document.
484 LIB_UTILITIES_EXPORT void ReadGlobalSysSolnInfo(TiXmlElement *conditions);
485 /// Reads the TIMEINTEGRATIONSCHEME section of the XML document.
486 LIB_UTILITIES_EXPORT void ReadTimeIntScheme(TiXmlElement *conditions);
487 /// Reads the VARIABLES section of the XML document.
488 LIB_UTILITIES_EXPORT void ReadVariables(TiXmlElement *conditions);
489 /// Reads the FUNCTIONS section of the XML document.
490 LIB_UTILITIES_EXPORT void ReadFunctions(TiXmlElement *conditions);
491 /// Reads the FILTERS section of the XML document.
492 LIB_UTILITIES_EXPORT void ReadFilters(TiXmlElement *filters);
493 /// Enforce parameters from command line arguments.
495 /// Check values of solver info options are valid.
497
498 /// Parse a string in the form lhs = rhs.
499 LIB_UTILITIES_EXPORT void ParseEquals(const std::string &line,
500 std::string &lhs, std::string &rhs);
501};
502
503/**
504 *
505 */
506template <typename T>
507inline bool SessionReader::MatchSolverInfoAsEnum(const std::string &name,
508 const T &trueval) const
509{
510 return (GetSolverInfoAsEnum<T>(name) == trueval);
511}
512
513/**
514 *
515 */
516template <typename T>
518 const std::string &pName) const
519{
520 std::string vName = boost::to_upper_copy(pName);
522 "Solver info '" + pName + "' not defined.");
523
524 std::string vValue = GetSolverInfo(vName);
525 auto x = GetSolverInfoEnums().find(vName);
526 ASSERTL0(x != GetSolverInfoEnums().end(),
527 "Enum for SolverInfo property '" + pName + "' not found.");
528
529 auto y = x->second.find(vValue);
530 ASSERTL0(y != x->second.end(),
531 "Value of SolverInfo property '" + pName + "' is invalid.");
532
533 return T(y->second);
534}
535
536/**
537 *
538 */
539template <typename T>
540inline const T SessionReader::GetValueAsEnum(const std::string &pName,
541 const std::string &pValue) const
542{
543 std::string vName = boost::to_upper_copy(pName);
544
545 auto x = GetSolverInfoEnums().find(vName);
546 ASSERTL0(x != GetSolverInfoEnums().end(),
547 "Enum for property '" + pName + "' not found.");
548
549 auto y = x->second.find(pValue);
550 ASSERTL0(y != x->second.end(),
551 "Value of property '" + pValue + "' is invalid.");
552 return T(y->second);
553}
554
555/**
556 * A set of valid values for a given solver info property may be
557 * registered using this function. It must be called statically during
558 * the initialisation of a static variable. For example:
559 *
560 * @code
561 * std::string GlobalLinSys::lookupIds[2] = {
562 * LibUtilities::SessionReader::RegisterEnumValue(
563 * "GlobalSysSoln",
564 * "DirectFull",
565 * MultiRegions::eDirectFullMatrix),
566 * LibUtilities::SessionReader::RegisterEnumValue(
567 * "GlobalSysSoln",
568 * "DirectStaticCond",
569 * MultiRegions::eDirectStaticCond)
570 * }
571 * @endcode
572 *
573 * @param pEnum The name of the property.
574 * @param pString A valid value for the property.
575 * @param pEnumValue An enumeration value corresponding to this
576 * value.
577 *
578 * @return The value for the property provided by #pString.
579 */
580inline std::string SessionReader::RegisterEnumValue(std::string pEnum,
581 std::string pString,
582 int pEnumValue)
583{
584 std::string vEnum = boost::to_upper_copy(pEnum);
585 auto x = GetSolverInfoEnums().find(vEnum);
586
587 if (x == GetSolverInfoEnums().end())
588 {
589 GetSolverInfoEnums()[vEnum] = EnumMap();
590 x = GetSolverInfoEnums().find(vEnum);
591 }
592
593 x->second[pString] = pEnumValue;
594 return pString;
595}
596
597/**
598 * A default value for a given solver info property may be registered
599 * using this function. The property will take this value until it is
600 * overwritten by a value specified in the XML document, or specified
601 * as a command-line argument. Usage has the form:
602 *
603 * @code
604 * std::string GlobalLinSys::def
605 * = LibUtilities::SessionReader::RegisterDefaultSolverInfo(
606 * "GlobalSysSoln","DirectMultiLevelStaticCond");
607 * @endcode
608 *
609 * @param pName The name of the property.
610 * @param pValue The default value of the property.
611 *
612 * @return The default value of the property provided by #pValue.
613 */
615 const std::string &pName, const std::string &pValue)
616{
617 std::string vName = boost::to_upper_copy(pName);
618 GetSolverInfoDefaults()[vName] = pValue;
619 return pValue;
620}
621
622/**
623 *
624 */
626 const std::string &pName, const std::string &pShortName,
627 const std::string &pDescription)
628{
629 ASSERTL0(!pName.empty(), "Empty name for cmdline argument.");
630 CmdLineArg x;
631 x.shortName = pShortName;
632 x.description = pDescription;
633 x.isFlag = false;
634 GetCmdLineArgMap()[pName] = x;
635 return pName;
636}
637
638/**
639 *
640 */
642 const std::string &pName, const std::string &pShortName,
643 const std::string &pDescription)
644{
645 ASSERTL0(!pName.empty(), "Empty name for cmdline argument.");
646 CmdLineArg x;
647 x.shortName = pShortName;
648 x.description = pDescription;
649 x.isFlag = true;
650 GetCmdLineArgMap()[pName] = x;
651 return pName;
652}
653
654/**
655 *
656 */
657TiXmlElement *GetChildElementOrThrow(const std::string &filename,
658 std::string childElementName,
659 const TiXmlHandle &docHandle);
660
661} // namespace Nektar::LibUtilities
662
663#endif
#define ASSERTL0(condition, msg)
#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.
void SetUpdateOptFile(bool flag)
Set bool to update optimisation file.
bool DefinesFunction(const std::string &name) const
Checks if a specified function is defined in the XML document.
void SetGlobalSysSolnInfo(const std::string &variable, const std::string &property, const std::string &value)
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.
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 ReadFilters(TiXmlElement *filters)
Reads the FILTERS section of the XML document.
void ReadGlobalSysSolnInfo(TiXmlElement *conditions)
Reads the GLOBALSYSSOLNINFO section of the XML document.
bool GetBackups() const
Returns the backups.
void InitSession(const std::vector< std::string > &filenames=std::vector< std::string >())
VariableList m_variables
Variables.
SolverInfoMap m_solverInfo
Solver information properties.
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.
static void GetXMLElementTimeLevel(TiXmlElement *&element, const size_t timeLevel, const bool enableCheck=true)
Get XML elment time level (Parallel-in-Time)
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.
bool GetUpdateOptFile() const
Get bool to update optimisation file.
bool m_updateOptFile
Update optimisation file.
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.
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.
size_t GetTimeLevel(void) const
Get time level (Parallel-in-Time)
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 SetTag(const std::string &pName, const std::string &pValue)
Sets a specified tag.
boost::program_options::variables_map m_cmdLineOptions
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[], std::vector< std::string > &pFilenames, const CommSharedPtr &pComm=CommSharedPtr(), const int &timelevel=0)
Creates an instance of the SessionReader class initialised using a separate list of XML documents.
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.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Interpreter > InterpreterSharedPtr
std::map< std::string, FunctionVariableMap > FunctionMap
std::map< std::string, std::string > FilterParams
std::map< std::string, std::string > SolverInfoMap
std::map< std::string, GloSysInfoMap > GloSysSolnInfoList
const char *const FunctionTypeMap[]
std::map< std::pair< std::string, int >, FunctionVariableDefinition > FunctionVariableMap
std::map< std::string, NekDouble > ParameterMap
std::map< std::string, int > EnumMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
Definition Equation.h:131
std::vector< std::string > VariableList
std::map< std::string, std::string > GloSysInfoMap
TiXmlElement * GetChildElementOrThrow(const std::string &filename, std::string elementName, const TiXmlHandle &docHandle)
std::map< std::string, EnumMap > EnumMapList
std::vector< FilterDefinition > FilterMap
std::map< std::string, CmdLineArg > CmdLineArgMap
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition Comm.h:55
std::map< std::string, std::string > GeometricInfoMap
std::map< std::string, std::string > TagMap
std::vector< NekDouble > freeParams