Nektar++
|
Reads and parses information from a Nektar++ XML session file. More...
#include <SessionReader.h>
Public Member Functions | |
SessionReader (int argc, char *argv[], const std::vector< std::string > &pFilenames, const CommSharedPtr &pComm, const int &timelevel) | |
~SessionReader () | |
Destructor. More... | |
void | InitSession (const std::vector< std::string > &filenames=std::vector< std::string >()) |
TiXmlDocument & | GetDocument () |
Provides direct access to the TiXmlDocument object. More... | |
TiXmlElement * | GetElement (const std::string &pPath) |
Provides direct access to the TiXmlElement specified. More... | |
bool | DefinesElement (const std::string &pPath) const |
Tests if a specified element is defined in the XML document. More... | |
const std::vector< std::string > & | GetFilenames () const |
Returns the filename of the loaded XML document. More... | |
const std::string & | GetSessionName () const |
Returns the session name of the loaded XML document. More... | |
const std::string | GetSessionNameRank () const |
Returns the session name with process rank. More... | |
CommSharedPtr | GetComm () |
Returns the communication object. More... | |
bool | GetSharedFilesystem () |
Returns if file system shared. More... | |
void | Finalise () |
Finalises the session. More... | |
bool | DefinesParameter (const std::string &name) const |
Checks if a parameter is specified in the XML document. More... | |
const NekDouble & | GetParameter (const std::string &pName) const |
Returns the value of the specified parameter. More... | |
void | LoadParameter (const std::string &name, int &var) const |
Load an integer parameter. More... | |
void | LoadParameter (const std::string &name, size_t &var) const |
Load an size_t parameter. More... | |
void | LoadParameter (const std::string &name, int &var, const int &def) const |
Check for and load an integer parameter. More... | |
void | LoadParameter (const std::string &name, size_t &var, const size_t &def) const |
Check for and load an size_t parameter. More... | |
void | LoadParameter (const std::string &name, NekDouble &var) const |
Load a double precision parameter. More... | |
void | LoadParameter (const std::string &name, NekDouble &var, const NekDouble &def) const |
Check for and load a double-precision parameter. More... | |
void | SetParameter (const std::string &name, int &var) |
Set an integer parameter. More... | |
void | SetParameter (const std::string &name, size_t &var) |
Set an size_t parameter. More... | |
void | SetParameter (const std::string &name, NekDouble &var) |
Set a double precision parameter. More... | |
bool | DefinesSolverInfo (const std::string &name) const |
Checks if a solver info property is specified. More... | |
const std::string & | GetSolverInfo (const std::string &pProperty) const |
Returns the value of the specified solver info property. More... | |
void | SetSolverInfo (const std::string &pProperty, const std::string &pValue) |
Sets the value of the specified solver info property. More... | |
template<typename T > | |
const T | GetSolverInfoAsEnum (const std::string &pName) const |
Returns the value of the specified solver info property as enum. More... | |
template<typename T > | |
const T | GetValueAsEnum (const std::string &pName, const std::string &vValue) const |
Returns the value of the specified property and value as enum. More... | |
void | LoadSolverInfo (const std::string &name, std::string &var, const std::string &def="") const |
Check for and load a solver info property. More... | |
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. More... | |
bool | MatchSolverInfo (const std::string &name, const std::string &trueval) const |
Check if the value of a solver info property matches. More... | |
template<typename T > | |
bool | MatchSolverInfoAsEnum (const std::string &name, const T &trueval) const |
Check if the value of a solver info property matches. More... | |
bool | GetBackups () const |
Returns the backups. More... | |
bool | DefinesGlobalSysSolnInfo (const std::string &variable, const std::string &property) const |
const std::string & | GetGlobalSysSolnInfo (const std::string &variable, const std::string &property) const |
bool | DefinesTimeIntScheme () const |
Returns true if the TIMEINTEGRATIONSCHEME section is defined in the session file. More... | |
const TimeIntScheme & | GetTimeIntScheme () const |
Returns the time integration scheme structure m_timeIntScheme from the session file. More... | |
std::string | GetGeometryType () const |
bool | DefinesGeometricInfo (const std::string &name) const |
Checks if a geometric info property is defined. More... | |
void | LoadGeometricInfo (const std::string &name, std::string &var, const std::string &def="") const |
Checks for and load a geometric info string property. More... | |
void | LoadGeometricInfo (const std::string &name, bool &var, const bool &def=false) const |
Checks for and loads a geometric info boolean property. More... | |
void | LoadGeometricInfo (const std::string &name, NekDouble &var, const NekDouble &def=0.0) const |
Checks for and loads a geometric info double-precision property. More... | |
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. More... | |
const std::string & | GetVariable (const unsigned int &idx) const |
Returns the name of the variable specified by the given index. More... | |
void | SetVariable (const unsigned int &idx, std::string newname) |
std::vector< std::string > | GetVariables () const |
Returns the names of all variables. More... | |
bool | DefinesFunction (const std::string &name) const |
Checks if a specified function is defined in the XML document. More... | |
bool | DefinesFunction (const std::string &name, const std::string &variable, const int pDomain=0) const |
Checks if a specified function has a given variable defined. More... | |
EquationSharedPtr | GetFunction (const std::string &name, const std::string &variable, const int pDomain=0) const |
Returns an EquationSharedPtr to a given function variable. More... | |
EquationSharedPtr | GetFunction (const std::string &name, const unsigned int &var, const int pDomain=0) const |
Returns an EquationSharedPtr to a given function variable index. More... | |
enum FunctionType | GetFunctionType (const std::string &name, const std::string &variable, const int pDomain=0) const |
Returns the type of a given function variable. More... | |
enum FunctionType | GetFunctionType (const std::string &pName, const unsigned int &pVar, const int pDomain=0) const |
Returns the type of a given function variable index. More... | |
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. More... | |
std::string | GetFunctionFilename (const std::string &name, const unsigned int &var, const int pDomain=0) const |
Returns the filename to be loaded for a given variable index. More... | |
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. More... | |
InterpreterSharedPtr | GetInterpreter () |
Returns the instance of the Interpreter specific to this session. More... | |
bool | DefinesTag (const std::string &pName) const |
Checks if a specified tag is defined. More... | |
void | SetTag (const std::string &pName, const std::string &pValue) |
Sets a specified tag. More... | |
const std::string & | GetTag (const std::string &pName) const |
Returns the value of a specified tag. More... | |
const FilterMap & | GetFilters () const |
bool | DefinesCmdLineArgument (const std::string &pName) const |
Checks if a specified cmdline argument has been given. More... | |
template<typename T > | |
T | GetCmdLineArgument (const std::string &pName) const |
Retrieves a command-line argument value. More... | |
bool | GetUpdateOptFile () const |
Get bool to update optimisation file. More... | |
void | SetUpdateOptFile (bool flag) |
Set bool to update optimisation file. More... | |
size_t | GetTimeLevel (void) const |
Get time level (Parallel-in-Time) More... | |
Static Public Member Functions | |
static SessionReaderSharedPtr | CreateInstance (int argc, char *argv[]) |
Creates an instance of the SessionReader class. More... | |
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. More... | |
static std::string | RegisterEnumValue (std::string pEnum, std::string pString, int pEnumValue) |
Registers an enumeration value. More... | |
static std::string | RegisterDefaultSolverInfo (const std::string &pName, const std::string &pValue) |
Registers the default string value of a solver info property. More... | |
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. More... | |
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. More... | |
static void | GetXMLElementTimeLevel (TiXmlElement *&element, const size_t timeLevel, const bool disableCheck=true) |
Get XML elment time level (Parallel-in-Time) More... | |
Private Member Functions | |
SessionReader (int argc, char *argv[]) | |
Main constructor. More... | |
void | TestSharedFilesystem () |
std::vector< std::string > | ParseCommandLineArguments (int argc, char *argv[]) |
Parse the program arguments and fill m_cmdLineOptions. More... | |
std::string | ParseSessionName (std::vector< std::string > &filenames) |
Parse the session name. More... | |
void | LoadDoc (const std::string &pFilename, TiXmlDocument *pDoc) const |
Loads an xml file into a tinyxml doc and decompresses if needed. More... | |
TiXmlDocument * | MergeDoc (const std::vector< std::string > &pFilenames) const |
Creates an XML document from a list of input files. More... | |
void | ParseDocument () |
Loads and parses the specified file. More... | |
void | CreateComm (int &argc, char *argv[]) |
Loads the given XML document and instantiates an appropriate communication object. More... | |
void | PartitionComm () |
Partitions the comm object based on session parameters. More... | |
void | ReadParameters (TiXmlElement *conditions) |
Reads the PARAMETERS section of the XML document. More... | |
void | ReadSolverInfo (TiXmlElement *conditions) |
Reads the SOLVERINFO section of the XML document. More... | |
void | ReadGlobalSysSolnInfo (TiXmlElement *conditions) |
Reads the GLOBALSYSSOLNINFO section of the XML document. More... | |
void | ReadTimeIntScheme (TiXmlElement *conditions) |
Reads the TIMEINTEGRATIONSCHEME section of the XML document. More... | |
void | ReadVariables (TiXmlElement *conditions) |
Reads the VARIABLES section of the XML document. More... | |
void | ReadFunctions (TiXmlElement *conditions) |
Reads the FUNCTIONS section of the XML document. More... | |
void | ReadFilters (TiXmlElement *filters) |
Reads the FILTERS section of the XML document. More... | |
void | CmdLineOverride () |
Enforce parameters from command line arguments. More... | |
void | VerifySolverInfo () |
Check values of solver info options are valid. More... | |
void | ParseEquals (const std::string &line, std::string &lhs, std::string &rhs) |
Parse a string in the form lhs = rhs. More... | |
Static Private Member Functions | |
static EnumMapList & | GetSolverInfoEnums () |
String to enumeration map for Solver Info parameters. More... | |
static SolverInfoMap & | GetSolverInfoDefaults () |
Default solver info options. More... | |
static GloSysSolnInfoList & | GetGloSysSolnList () |
GlobalSysSoln Info map. More... | |
static CmdLineArgMap & | GetCmdLineArgMap () |
CmdLine argument map. More... | |
Private Attributes | |
boost::program_options::variables_map | m_cmdLineOptions |
CommSharedPtr | m_comm |
Communication object. More... | |
std::vector< std::string > | m_filenames |
Filenames. More... | |
std::string | m_sessionName |
Session name of the loaded XML document (filename minus ext). More... | |
TiXmlDocument * | m_xmlDoc |
Pointer to the loaded XML document. More... | |
ParameterMap | m_parameters |
Parameters. More... | |
SolverInfoMap | m_solverInfo |
Solver information properties. More... | |
GeometricInfoMap | m_geometricInfo |
Geometric information properties. More... | |
InterpreterSharedPtr | m_interpreter |
Interpreter instance. More... | |
FunctionMap | m_functions |
Functions. More... | |
VariableList | m_variables |
Variables. More... | |
TagMap | m_tags |
Custom tags. More... | |
FilterMap | m_filters |
Filters map. More... | |
TimeIntScheme | m_timeIntScheme |
Time integration scheme information. More... | |
size_t | m_timeLevel = 0 |
Time level. More... | |
bool | m_verbose |
Be verbose. More... | |
bool | m_sharedFilesystem |
Running on a shared filesystem. More... | |
bool | m_backups = true |
Backups. More... | |
bool | m_updateOptFile |
Update optimisation file. More... | |
Friends | |
class | MemoryManager< SessionReader > |
Support creation through MemoryManager. More... | |
Reads and parses information from a Nektar++ XML session file.
This class provides an interface to Nektar++-specific content in a supplied XML document. It also initialises a Nektar++ session including setting up communication for parallel execution and where necessary partitioning the supplied mesh for running across multiple processes.
A session should be initialised at the beginning of a user's application by passing the command-line arguments. This not only allows the SessionReader to extract the name of the XML document to load containing Nektar++ session information, but also supplies the MPI arguments necessary for setting up parallel communication. The SessionReader should be initialised using the CreateInstance function:
The instance vSession
can now be passed to other key Nektar++ components during their construction.
The SessionReader class provides streamlined, validated access to session parameters, solver information and functions defined within a Nektar++ XML document. The available routines and their usage is documented below.
In the case of solver information properties, the classes to which these parameters are pertinent may register with the SessionReader class the set of valid values for a given property. Such values may also be associated with an enumeration value for more transparent use of the property values in code.
Definition at line 118 of file SessionReader.h.
Nektar::LibUtilities::SessionReader::SessionReader | ( | int | argc, |
char * | argv[], | ||
const std::vector< std::string > & | pFilenames, | ||
const CommSharedPtr & | pComm, | ||
const int & | timelevel | ||
) |
Definition at line 217 of file BasicUtils/SessionReader.cpp.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, CreateComm(), GetSolverInfoDefaults(), m_comm, m_filenames, m_interpreter, m_sessionName, m_timeLevel, m_xmlDoc, ParseCommandLineArguments(), ParseSessionName(), PartitionComm(), and TestSharedFilesystem().
Nektar::LibUtilities::SessionReader::~SessionReader | ( | ) |
|
private |
Main constructor.
This constructor parses the command-line arguments given to the user application to set up any MPI communication, read supplied XML session files, and partition meshes where necessary.
argc | Number of command-line arguments |
argv | Array of command-line arguments |
Definition at line 185 of file BasicUtils/SessionReader.cpp.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, CreateComm(), GetSolverInfoDefaults(), m_comm, m_filenames, m_interpreter, m_sessionName, m_xmlDoc, ParseCommandLineArguments(), ParseSessionName(), PartitionComm(), and TestSharedFilesystem().
|
private |
Enforce parameters from command line arguments.
Definition at line 2544 of file BasicUtils/SessionReader.cpp.
References Nektar::ErrorUtil::efatal, m_cmdLineOptions, m_parameters, m_solverInfo, NEKERROR, and ParseEquals().
Referenced by InitSession().
|
private |
Loads the given XML document and instantiates an appropriate communication object.
Definition at line 1685 of file BasicUtils/SessionReader.cpp.
References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::GetCommFactory(), m_cmdLineOptions, and m_comm.
Referenced by SessionReader().
|
inlinestatic |
Creates an instance of the SessionReader class.
This function should be used by an application to instantiate the session reader. It should be called at the very beginning of the application before any other processing of command-line arguments. After instantiating the class and setting up any parallel communication, it also calls the main initialisation of the object.
Definition at line 134 of file SessionReader.h.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.
Referenced by Diffusion::Diffusion(), Nektar::SolverUtils::DriverParallelInTime::SetParallelInTimeEquationSystem(), Nektar::VarcoeffHashingTest::setupContFieldSolve(), Nektar::SolverUtils::Driver::v_InitObject(), Nektar::FieldUtils::InputXml::v_Process(), Nektar::FieldUtils::ProcessDisplacement::v_Process(), Nektar::FieldUtils::ProcessHomogeneousPlane::v_Process(), Nektar::FieldUtils::ProcessInterpField::v_Process(), Nektar::FieldUtils::ProcessInterpPoints::v_Process(), and Nektar::VortexWaveInteraction::VortexWaveInteraction().
|
inlinestatic |
Creates an instance of the SessionReader class initialised using a separate list of XML documents.
This function should be used by an application to instantiate the session reader. It may be called after processing of command-line arguments. After instantiating the class and setting up any parallel communication, it also calls the main initialisation of the object.
Definition at line 153 of file SessionReader.h.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.
bool Nektar::LibUtilities::SessionReader::DefinesCmdLineArgument | ( | const std::string & | pName | ) | const |
Checks if a specified cmdline argument has been given.
Definition at line 1491 of file BasicUtils/SessionReader.cpp.
References m_cmdLineOptions.
Referenced by InitSession(), and PartitionComm().
bool Nektar::LibUtilities::SessionReader::DefinesElement | ( | const std::string & | pPath | ) | const |
Tests if a specified element is defined in the XML document.
Definition at line 695 of file BasicUtils/SessionReader.cpp.
bool Nektar::LibUtilities::SessionReader::DefinesFunction | ( | const std::string & | name | ) | const |
Checks if a specified function is defined in the XML document.
Definition at line 1239 of file BasicUtils/SessionReader.cpp.
References m_functions.
bool Nektar::LibUtilities::SessionReader::DefinesFunction | ( | const std::string & | name, |
const std::string & | variable, | ||
const int | pDomain = 0 |
||
) | const |
Checks if a specified function has a given variable defined.
Definition at line 1248 of file BasicUtils/SessionReader.cpp.
References m_functions.
bool Nektar::LibUtilities::SessionReader::DefinesGeometricInfo | ( | const std::string & | name | ) | const |
Checks if a geometric info property is defined.
Definition at line 1115 of file BasicUtils/SessionReader.cpp.
References m_geometricInfo.
bool Nektar::LibUtilities::SessionReader::DefinesGlobalSysSolnInfo | ( | const std::string & | variable, |
const std::string & | property | ||
) | const |
Definition at line 1020 of file BasicUtils/SessionReader.cpp.
References GetGloSysSolnList().
bool Nektar::LibUtilities::SessionReader::DefinesParameter | ( | const std::string & | name | ) | const |
Checks if a parameter is specified in the XML document.
Definition at line 775 of file BasicUtils/SessionReader.cpp.
References m_parameters.
bool Nektar::LibUtilities::SessionReader::DefinesSolverInfo | ( | const std::string & | name | ) | const |
Checks if a solver info property is specified.
Definition at line 925 of file BasicUtils/SessionReader.cpp.
References m_solverInfo.
Referenced by GetSolverInfoAsEnum(), and MatchSolverInfo().
bool Nektar::LibUtilities::SessionReader::DefinesTag | ( | const std::string & | pName | ) | const |
Checks if a specified tag is defined.
Definition at line 1454 of file BasicUtils/SessionReader.cpp.
References m_tags.
bool Nektar::LibUtilities::SessionReader::DefinesTimeIntScheme | ( | ) | const |
Returns true if the TIMEINTEGRATIONSCHEME section is defined in the session file.
Definition at line 1064 of file BasicUtils/SessionReader.cpp.
References m_timeIntScheme, and Nektar::LibUtilities::TimeIntScheme::method.
void Nektar::LibUtilities::SessionReader::Finalise | ( | ) |
Finalises the session.
This routine finalises any parallel communication.
Definition at line 767 of file BasicUtils/SessionReader.cpp.
References m_comm.
bool Nektar::LibUtilities::SessionReader::GetBackups | ( | ) | const |
Returns the backups.
Definition at line 1231 of file BasicUtils/SessionReader.cpp.
References m_backups.
|
staticprivate |
CmdLine argument map.
Lists the possible command-line argument which can be specified for this executable.
This list is populated through the RegisterCmdLineArgument static member function which is called statically from various classes to register command-line arguments they need.
Definition at line 171 of file BasicUtils/SessionReader.cpp.
Referenced by ParseCommandLineArguments(), RegisterCmdLineArgument(), and RegisterCmdLineFlag().
|
inline |
Retrieves a command-line argument value.
Definition at line 372 of file SessionReader.h.
References m_cmdLineOptions.
CommSharedPtr Nektar::LibUtilities::SessionReader::GetComm | ( | ) |
Returns the communication object.
Definition at line 751 of file BasicUtils/SessionReader.cpp.
References m_comm.
TiXmlDocument & Nektar::LibUtilities::SessionReader::GetDocument | ( | ) |
Provides direct access to the TiXmlDocument object.
Definition at line 645 of file BasicUtils/SessionReader.cpp.
TiXmlElement * Nektar::LibUtilities::SessionReader::GetElement | ( | const std::string & | pPath | ) |
Provides direct access to the TiXmlElement specified.
The single parameter specifies a path to the requested element in a similar format to the filesystem path. Given the following XML:
the PARAMETERS element would be retrieved by requesting the path:
pPath | Path to requested element. |
Definition at line 673 of file BasicUtils/SessionReader.cpp.
const std::vector< std::string > & Nektar::LibUtilities::SessionReader::GetFilenames | ( | ) | const |
Returns the filename of the loaded XML document.
Definition at line 717 of file BasicUtils/SessionReader.cpp.
References m_filenames.
const FilterMap & Nektar::LibUtilities::SessionReader::GetFilters | ( | ) | const |
Definition at line 1483 of file BasicUtils/SessionReader.cpp.
References m_filters.
EquationSharedPtr Nektar::LibUtilities::SessionReader::GetFunction | ( | const std::string & | name, |
const std::string & | variable, | ||
const int | pDomain = 0 |
||
) | const |
Returns an EquationSharedPtr to a given function variable.
Definition at line 1270 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, Nektar::LibUtilities::eFunctionTypeExpression, and m_functions.
Referenced by GetFunction().
EquationSharedPtr Nektar::LibUtilities::SessionReader::GetFunction | ( | const std::string & | name, |
const unsigned int & | var, | ||
const int | pDomain = 0 |
||
) | const |
Returns an EquationSharedPtr to a given function variable index.
Definition at line 1310 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, GetFunction(), and m_variables.
std::string Nektar::LibUtilities::SessionReader::GetFunctionFilename | ( | const std::string & | name, |
const std::string & | variable, | ||
const int | pDomain = 0 |
||
) | const |
Returns the filename to be loaded for a given variable.
Definition at line 1369 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_functions.
Referenced by GetFunctionFilename().
std::string Nektar::LibUtilities::SessionReader::GetFunctionFilename | ( | const std::string & | name, |
const unsigned int & | var, | ||
const int | pDomain = 0 |
||
) | const |
Returns the filename to be loaded for a given variable index.
Definition at line 1406 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, GetFunctionFilename(), and m_variables.
std::string Nektar::LibUtilities::SessionReader::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.
Definition at line 1417 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_functions.
enum FunctionType Nektar::LibUtilities::SessionReader::GetFunctionType | ( | const std::string & | name, |
const std::string & | variable, | ||
const int | pDomain = 0 |
||
) | const |
Returns the type of a given function variable.
Definition at line 1321 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_functions.
Referenced by GetFunctionType().
enum FunctionType Nektar::LibUtilities::SessionReader::GetFunctionType | ( | const std::string & | pName, |
const unsigned int & | pVar, | ||
const int | pDomain = 0 |
||
) | const |
Returns the type of a given function variable index.
Definition at line 1358 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, GetFunctionType(), and m_variables.
std::string Nektar::LibUtilities::SessionReader::GetGeometryType | ( | ) | const |
Definition at line 1078 of file BasicUtils/SessionReader.cpp.
const std::string & Nektar::LibUtilities::SessionReader::GetGlobalSysSolnInfo | ( | const std::string & | variable, |
const std::string & | property | ||
) | const |
Definition at line 1043 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and GetGloSysSolnList().
|
staticprivate |
GlobalSysSoln Info map.
List of values for GlobalSysSoln parameters to be used to override details given in SolverInfo
This list is populated by ReadGlobalSysSoln if the GLOBALSYSSOLNINFO section is defined in the input file. This List allows for details to define for the Global Sys solver for each variable.
Definition at line 157 of file BasicUtils/SessionReader.cpp.
Referenced by DefinesGlobalSysSolnInfo(), GetGlobalSysSolnInfo(), and ReadGlobalSysSolnInfo().
InterpreterSharedPtr Nektar::LibUtilities::SessionReader::GetInterpreter | ( | ) |
Returns the instance of the Interpreter specific to this session.
Definition at line 2626 of file BasicUtils/SessionReader.cpp.
References m_interpreter.
const NekDouble & Nektar::LibUtilities::SessionReader::GetParameter | ( | const std::string & | pName | ) | const |
Returns the value of the specified parameter.
If the parameter is not defined, termination occurs. Therefore, the parameters existence should be tested for using DefinesParameter before calling this function.
pName | The name of a floating-point parameter. |
Definition at line 789 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_parameters.
const std::string & Nektar::LibUtilities::SessionReader::GetSessionName | ( | ) | const |
Returns the session name of the loaded XML document.
Definition at line 725 of file BasicUtils/SessionReader.cpp.
References m_sessionName.
const std::string Nektar::LibUtilities::SessionReader::GetSessionNameRank | ( | ) | const |
Returns the session name with process rank.
Output is of the form [sessionName]_P[idx] where idx is the rank of the process.
Definition at line 734 of file BasicUtils/SessionReader.cpp.
References m_comm, m_sessionName, and Nektar::LibUtilities::PortablePath().
bool Nektar::LibUtilities::SessionReader::GetSharedFilesystem | ( | ) |
Returns if file system shared.
Definition at line 756 of file BasicUtils/SessionReader.cpp.
References m_sharedFilesystem.
const std::string & Nektar::LibUtilities::SessionReader::GetSolverInfo | ( | const std::string & | pProperty | ) | const |
Returns the value of the specified solver info property.
Definition at line 935 of file BasicUtils/SessionReader.cpp.
References ASSERTL1, and m_solverInfo.
Referenced by GetSolverInfoAsEnum().
|
inline |
Returns the value of the specified solver info property as enum.
Definition at line 520 of file SessionReader.h.
References ASSERTL0, DefinesSolverInfo(), GetSolverInfo(), and GetSolverInfoEnums().
|
staticprivate |
Default solver info options.
List of default values for solver information parameters to be used in the case of them not being provided.
This list is populated through the RegisterDefaultSolverInfo static member variable which is called statically from various classes to register the default value for a given parameter.
Definition at line 142 of file BasicUtils/SessionReader.cpp.
Referenced by ReadSolverInfo(), RegisterDefaultSolverInfo(), and SessionReader().
|
staticprivate |
String to enumeration map for Solver Info parameters.
This map of maps stores the list of valid string values for a number of solver information parameters. The top level map connects different parameter names to their list of possible values. The list of possible values is also a map, mapping a valid string to a corresponding enum value.
This list is populated through the RegisterEnumValue static member function which is called statically from various classes to register the valid values for solver info parameters associated with them. The map is therefore fully populated before the SessionReader class is instantiated and a file is read in and parsed.
Definition at line 128 of file BasicUtils/SessionReader.cpp.
Referenced by GetSolverInfoAsEnum(), GetValueAsEnum(), RegisterEnumValue(), and VerifySolverInfo().
const std::string & Nektar::LibUtilities::SessionReader::GetTag | ( | const std::string & | pName | ) | const |
Returns the value of a specified tag.
Definition at line 1472 of file BasicUtils/SessionReader.cpp.
const TimeIntScheme & Nektar::LibUtilities::SessionReader::GetTimeIntScheme | ( | ) | const |
Returns the time integration scheme structure m_timeIntScheme from the session file.
Definition at line 1073 of file BasicUtils/SessionReader.cpp.
References m_timeIntScheme.
|
inline |
Get time level (Parallel-in-Time)
Definition at line 398 of file SessionReader.h.
References m_timeLevel.
|
inline |
Get bool to update optimisation file.
Definition at line 386 of file SessionReader.h.
References m_updateOptFile.
|
inline |
Returns the value of the specified property and value as enum.
Definition at line 543 of file SessionReader.h.
References ASSERTL0, and GetSolverInfoEnums().
const std::string & Nektar::LibUtilities::SessionReader::GetVariable | ( | const unsigned int & | idx | ) | const |
Returns the name of the variable specified by the given index.
Definition at line 1205 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_variables.
std::vector< std::string > Nektar::LibUtilities::SessionReader::GetVariables | ( | ) | const |
Returns the names of all variables.
Definition at line 1223 of file BasicUtils/SessionReader.cpp.
References m_variables.
|
static |
Get XML elment time level (Parallel-in-Time)
Definition at line 1499 of file BasicUtils/SessionReader.cpp.
References ASSERTL0.
Referenced by Nektar::Collections::CollectionOptimisation::CollectionOptimisation(), Nektar::GlobalMapping::Mapping::Load(), Nektar::SolverUtils::Forcing::Load(), Nektar::SpatialDomains::BoundaryConditions::ReadBoundaryConditions(), Nektar::SpatialDomains::BoundaryConditions::ReadBoundaryRegions(), Nektar::SpatialDomains::MeshPartition::ReadConditions(), Nektar::SpatialDomains::MeshGraph::ReadExpansionInfo(), Nektar::SpatialDomains::MeshPartition::ReadExpansions(), ReadFilters(), ReadFunctions(), ReadGlobalSysSolnInfo(), ReadParameters(), ReadSolverInfo(), ReadTimeIntScheme(), ReadVariables(), Nektar::GlobalMapping::Mapping::ReplaceField(), Nektar::Collections::CollectionOptimisation::UpdateOptFile(), Nektar::SpatialDomains::MeshGraphHDF5::v_PartitionMesh(), and Nektar::SpatialDomains::MeshGraphXml::WriteXMLGeometry().
void Nektar::LibUtilities::SessionReader::InitSession | ( | const std::vector< std::string > & | filenames = std::vector<std::string>() | ) |
Performs the main initialisation of the object. The XML file provided on the command-line is loaded and any mesh partitioning is done. The resulting process-specific XML file (containing the process's geometry partition) is then reloaded and parsed.
Definition at line 276 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, CmdLineOverride(), DefinesCmdLineArgument(), m_backups, m_cmdLineOptions, m_comm, m_filenames, m_parameters, m_sessionName, m_solverInfo, m_timeLevel, m_updateOptFile, m_verbose, m_xmlDoc, MergeDoc(), ParseDocument(), and VerifySolverInfo().
|
private |
Loads an xml file into a tinyxml doc and decompresses if needed.
Definition at line 1539 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, CellMLToNektar.pycml::copy(), Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::format, m_comm, NEKERROR, and Nektar::LibUtilities::PortablePath().
Referenced by MergeDoc().
void Nektar::LibUtilities::SessionReader::LoadGeometricInfo | ( | const std::string & | name, |
bool & | var, | ||
const bool & | def = false |
||
) | const |
Checks for and loads a geometric info boolean property.
Definition at line 1143 of file BasicUtils/SessionReader.cpp.
References m_geometricInfo.
void Nektar::LibUtilities::SessionReader::LoadGeometricInfo | ( | const std::string & | name, |
NekDouble & | var, | ||
const NekDouble & | def = 0.0 |
||
) | const |
Checks for and loads a geometric info double-precision property.
Definition at line 1168 of file BasicUtils/SessionReader.cpp.
References m_geometricInfo.
void Nektar::LibUtilities::SessionReader::LoadGeometricInfo | ( | const std::string & | name, |
std::string & | var, | ||
const std::string & | def = "" |
||
) | const |
Checks for and load a geometric info string property.
Definition at line 1124 of file BasicUtils/SessionReader.cpp.
References m_geometricInfo.
void Nektar::LibUtilities::SessionReader::LoadParameter | ( | const std::string & | name, |
int & | var | ||
) | const |
Load an integer parameter.
Definition at line 803 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_parameters.
void Nektar::LibUtilities::SessionReader::LoadParameter | ( | const std::string & | name, |
int & | var, | ||
const int & | def | ||
) | const |
Check for and load an integer parameter.
Definition at line 816 of file BasicUtils/SessionReader.cpp.
References m_parameters.
void Nektar::LibUtilities::SessionReader::LoadParameter | ( | const std::string & | name, |
NekDouble & | var | ||
) | const |
Load a double precision parameter.
Definition at line 867 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_parameters.
void Nektar::LibUtilities::SessionReader::LoadParameter | ( | const std::string & | name, |
NekDouble & | var, | ||
const NekDouble & | def | ||
) | const |
Check for and load a double-precision parameter.
Definition at line 880 of file BasicUtils/SessionReader.cpp.
References m_parameters.
void Nektar::LibUtilities::SessionReader::LoadParameter | ( | const std::string & | name, |
size_t & | var | ||
) | const |
Load an size_t parameter.
Definition at line 835 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_parameters.
void Nektar::LibUtilities::SessionReader::LoadParameter | ( | const std::string & | name, |
size_t & | var, | ||
const size_t & | def | ||
) | const |
Check for and load an size_t parameter.
Definition at line 848 of file BasicUtils/SessionReader.cpp.
References m_parameters.
void Nektar::LibUtilities::SessionReader::LoadSolverInfo | ( | const std::string & | name, |
std::string & | var, | ||
const std::string & | def = "" |
||
) | const |
Check for and load a solver info property.
Definition at line 965 of file BasicUtils/SessionReader.cpp.
References m_solverInfo.
void Nektar::LibUtilities::SessionReader::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.
Definition at line 1186 of file BasicUtils/SessionReader.cpp.
References m_geometricInfo.
bool Nektar::LibUtilities::SessionReader::MatchSolverInfo | ( | const std::string & | name, |
const std::string & | trueval | ||
) | const |
Check if the value of a solver info property matches.
Definition at line 1002 of file BasicUtils/SessionReader.cpp.
References DefinesSolverInfo(), and m_solverInfo.
void Nektar::LibUtilities::SessionReader::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.
Definition at line 983 of file BasicUtils/SessionReader.cpp.
References m_solverInfo.
|
inline |
Check if the value of a solver info property matches.
Definition at line 510 of file SessionReader.h.
References CellMLToNektar.pycml::name.
|
private |
Creates an XML document from a list of input files.
Definition at line 1586 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, Nektar::ErrorUtil::ewarning, Nektar::LibUtilities::GetChildElementOrThrow(), LoadDoc(), NEKERROR, CellMLToNektar.cellml_metadata::p, and Nektar::UnitTests::q().
Referenced by InitSession().
|
private |
Parse the program arguments and fill m_cmdLineOptions.
Parses the command-line arguments for known options and filenames.
Definition at line 440 of file BasicUtils/SessionReader.cpp.
References GetCmdLineArgMap(), Nektar::NekConstants::kGitBranch, Nektar::NekConstants::kGitSha1, m_backups, m_cmdLineOptions, m_updateOptFile, m_verbose, NEKTAR_VERSION, and CellMLToNektar.cellml_metadata::p.
Referenced by SessionReader().
|
private |
Loads and parses the specified file.
Definition at line 1655 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, m_xmlDoc, ReadFilters(), ReadFunctions(), ReadGlobalSysSolnInfo(), ReadParameters(), ReadSolverInfo(), ReadTimeIntScheme(), and ReadVariables().
Referenced by InitSession().
|
private |
Parse a string in the form lhs = rhs.
Pull out lhs and rhs and eliminate any spaces.
Definition at line 2518 of file BasicUtils/SessionReader.cpp.
Referenced by CmdLineOverride(), and ReadParameters().
|
private |
Parse the session name.
Definition at line 613 of file BasicUtils/SessionReader.cpp.
References ASSERTL0.
Referenced by SessionReader().
|
private |
Partitions the comm object based on session parameters.
Splits the processes into a cartesian grid and creates communicators for each row and column of the grid. The grid is defined by the PROC_X parameter which, if specified, gives the number of processes spanned by the Fourier direction. PROC_X must exactly divide the total number of processes or an error is thrown.
Definition at line 1715 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, DefinesCmdLineArgument(), and m_comm.
Referenced by SessionReader().
|
private |
Reads the FILTERS section of the XML document.
Definition at line 2474 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, GetXMLElementTimeLevel(), m_filters, and m_timeLevel.
Referenced by ParseDocument().
|
private |
Reads the FUNCTIONS section of the XML document.
Definition at line 2245 of file BasicUtils/SessionReader.cpp.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::ErrorUtil::efatal, Nektar::LibUtilities::eFunctionTypeExpression, Nektar::LibUtilities::eFunctionTypeFile, Nektar::LibUtilities::eFunctionTypeTransientFile, Nektar::ParseUtils::GenerateSeqVector(), Nektar::ParseUtils::GenerateVector(), GetXMLElementTimeLevel(), m_comm, Nektar::LibUtilities::FunctionVariableDefinition::m_expression, Nektar::LibUtilities::FunctionVariableDefinition::m_filename, Nektar::LibUtilities::FunctionVariableDefinition::m_fileVariable, m_functions, m_interpreter, m_timeLevel, Nektar::LibUtilities::FunctionVariableDefinition::m_type, and NEKERROR.
Referenced by ParseDocument().
|
private |
Reads the GLOBALSYSSOLNINFO section of the XML document.
Definition at line 1931 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, Nektar::ParseUtils::GenerateVector(), GetGloSysSolnList(), GetXMLElementTimeLevel(), m_comm, m_timeLevel, and m_verbose.
Referenced by ParseDocument().
|
private |
Reads the PARAMETERS section of the XML document.
Definition at line 1772 of file BasicUtils/SessionReader.cpp.
References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Equation::Evaluate(), GetXMLElementTimeLevel(), m_interpreter, m_parameters, m_timeLevel, NEKERROR, and ParseEquals().
Referenced by ParseDocument().
|
private |
Reads the SOLVERINFO section of the XML document.
Definition at line 1857 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, GetSolverInfoDefaults(), GetXMLElementTimeLevel(), m_comm, m_solverInfo, and m_timeLevel.
Referenced by ParseDocument().
|
private |
Reads the TIMEINTEGRATIONSCHEME section of the XML document.
Read the time-integration scheme structure, if present.
Definition at line 2059 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, Nektar::ErrorUtil::efatal, Nektar::LibUtilities::TimeIntScheme::freeParams, GetXMLElementTimeLevel(), m_comm, m_timeIntScheme, m_timeLevel, m_verbose, Nektar::LibUtilities::TimeIntScheme::method, NEKERROR, Nektar::LibUtilities::TimeIntScheme::order, and Nektar::LibUtilities::TimeIntScheme::variant.
Referenced by ParseDocument().
|
private |
Reads the VARIABLES section of the XML document.
All elements are of the form: "<V ID="#"> name = value </V>", with ? being the element type.
Definition at line 2165 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, Nektar::StdRegions::find(), GetXMLElementTimeLevel(), m_timeLevel, and m_variables.
Referenced by ParseDocument().
|
inlinestatic |
Registers a command-line argument with the session reader.
Definition at line 628 of file SessionReader.h.
References ASSERTL0, Nektar::LibUtilities::CmdLineArg::description, GetCmdLineArgMap(), Nektar::LibUtilities::CmdLineArg::isFlag, and Nektar::LibUtilities::CmdLineArg::shortName.
|
inlinestatic |
Registers a command-line flag with the session reader.
Definition at line 644 of file SessionReader.h.
References ASSERTL0, Nektar::LibUtilities::CmdLineArg::description, GetCmdLineArgMap(), Nektar::LibUtilities::CmdLineArg::isFlag, and Nektar::LibUtilities::CmdLineArg::shortName.
|
inlinestatic |
Registers the default string value of a solver info property.
A default value for a given solver info property may be registered using this function. The property will take this value until it is overwritten by a value specified in the XML document, or specified as a command-line argument. Usage has the form:
pName | The name of the property. |
pValue | The default value of the property. |
Definition at line 617 of file SessionReader.h.
References GetSolverInfoDefaults().
|
inlinestatic |
Registers an enumeration value.
A set of valid values for a given solver info property may be registered using this function. It must be called statically during the initialisation of a static variable. For example:
pEnum | The name of the property. |
pString | A valid value for the property. |
pEnumValue | An enumeration value corresponding to this value. |
Definition at line 583 of file SessionReader.h.
References GetSolverInfoEnums().
void Nektar::LibUtilities::SessionReader::SetParameter | ( | const std::string & | name, |
int & | var | ||
) |
Set an integer parameter.
Definition at line 898 of file BasicUtils/SessionReader.cpp.
References m_parameters.
void Nektar::LibUtilities::SessionReader::SetParameter | ( | const std::string & | name, |
NekDouble & | var | ||
) |
Set a double precision parameter.
Definition at line 916 of file BasicUtils/SessionReader.cpp.
References m_parameters.
void Nektar::LibUtilities::SessionReader::SetParameter | ( | const std::string & | name, |
size_t & | var | ||
) |
Set an size_t parameter.
Definition at line 907 of file BasicUtils/SessionReader.cpp.
References m_parameters.
void Nektar::LibUtilities::SessionReader::SetSolverInfo | ( | const std::string & | pProperty, |
const std::string & | pValue | ||
) |
Sets the value of the specified solver info property.
Definition at line 950 of file BasicUtils/SessionReader.cpp.
References ASSERTL1, and m_solverInfo.
void Nektar::LibUtilities::SessionReader::SetTag | ( | const std::string & | pName, |
const std::string & | pValue | ||
) |
Sets a specified tag.
Definition at line 1463 of file BasicUtils/SessionReader.cpp.
References m_tags.
|
inline |
Set bool to update optimisation file.
Definition at line 392 of file SessionReader.h.
References m_updateOptFile.
void Nektar::LibUtilities::SessionReader::SetVariable | ( | const unsigned int & | idx, |
std::string | newname | ||
) |
Definition at line 1214 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, and m_variables.
|
private |
Definition at line 399 of file BasicUtils/SessionReader.cpp.
References ASSERTL1, m_comm, m_sharedFilesystem, m_verbose, and Nektar::LibUtilities::ReduceSum.
Referenced by SessionReader().
|
private |
Check values of solver info options are valid.
Definition at line 2607 of file BasicUtils/SessionReader.cpp.
References ASSERTL0, GetSolverInfoEnums(), and m_solverInfo.
Referenced by InitSession().
|
friend |
Support creation through MemoryManager.
Definition at line 107 of file SessionReader.h.
|
private |
Backups.
Definition at line 444 of file SessionReader.h.
Referenced by GetBackups(), InitSession(), and ParseCommandLineArguments().
|
private |
Definition at line 409 of file SessionReader.h.
Referenced by CmdLineOverride(), CreateComm(), DefinesCmdLineArgument(), GetCmdLineArgument(), InitSession(), and ParseCommandLineArguments().
|
private |
Communication object.
Definition at line 412 of file SessionReader.h.
Referenced by CreateComm(), Finalise(), GetComm(), GetSessionNameRank(), InitSession(), LoadDoc(), PartitionComm(), ReadFunctions(), ReadGlobalSysSolnInfo(), ReadSolverInfo(), ReadTimeIntScheme(), SessionReader(), and TestSharedFilesystem().
|
private |
Filenames.
Definition at line 414 of file SessionReader.h.
Referenced by GetFilenames(), InitSession(), and SessionReader().
|
private |
Filters map.
Definition at line 434 of file SessionReader.h.
Referenced by GetFilters(), and ReadFilters().
|
private |
Functions.
Definition at line 428 of file SessionReader.h.
Referenced by DefinesFunction(), GetFunction(), GetFunctionFilename(), GetFunctionFilenameVariable(), GetFunctionType(), and ReadFunctions().
|
private |
Geometric information properties.
Definition at line 424 of file SessionReader.h.
Referenced by DefinesGeometricInfo(), LoadGeometricInfo(), and MatchGeometricInfo().
|
private |
Interpreter instance.
Definition at line 426 of file SessionReader.h.
Referenced by GetInterpreter(), ReadFunctions(), ReadParameters(), and SessionReader().
|
private |
Parameters.
Definition at line 420 of file SessionReader.h.
Referenced by CmdLineOverride(), DefinesParameter(), GetParameter(), InitSession(), LoadParameter(), ReadParameters(), and SetParameter().
|
private |
Session name of the loaded XML document (filename minus ext).
Definition at line 416 of file SessionReader.h.
Referenced by GetSessionName(), GetSessionNameRank(), InitSession(), and SessionReader().
|
private |
Running on a shared filesystem.
Definition at line 442 of file SessionReader.h.
Referenced by GetSharedFilesystem(), and TestSharedFilesystem().
|
private |
Solver information properties.
Definition at line 422 of file SessionReader.h.
Referenced by CmdLineOverride(), DefinesSolverInfo(), GetSolverInfo(), InitSession(), LoadSolverInfo(), MatchSolverInfo(), ReadSolverInfo(), SetSolverInfo(), and VerifySolverInfo().
|
private |
Custom tags.
Definition at line 432 of file SessionReader.h.
Referenced by DefinesTag(), GetTag(), and SetTag().
|
private |
Time integration scheme information.
Definition at line 436 of file SessionReader.h.
Referenced by DefinesTimeIntScheme(), GetTimeIntScheme(), and ReadTimeIntScheme().
|
private |
Time level.
Definition at line 438 of file SessionReader.h.
Referenced by GetTimeLevel(), InitSession(), ReadFilters(), ReadFunctions(), ReadGlobalSysSolnInfo(), ReadParameters(), ReadSolverInfo(), ReadTimeIntScheme(), ReadVariables(), and SessionReader().
|
private |
Update optimisation file.
Definition at line 446 of file SessionReader.h.
Referenced by GetUpdateOptFile(), InitSession(), ParseCommandLineArguments(), and SetUpdateOptFile().
|
private |
Variables.
Definition at line 430 of file SessionReader.h.
Referenced by GetFunction(), GetFunctionFilename(), GetFunctionType(), GetVariable(), GetVariables(), ReadVariables(), and SetVariable().
|
private |
Be verbose.
Definition at line 440 of file SessionReader.h.
Referenced by InitSession(), ParseCommandLineArguments(), ReadGlobalSysSolnInfo(), ReadTimeIntScheme(), and TestSharedFilesystem().
|
private |
Pointer to the loaded XML document.
Definition at line 418 of file SessionReader.h.
Referenced by DefinesElement(), GetDocument(), GetElement(), GetGeometryType(), InitSession(), ParseDocument(), SessionReader(), and ~SessionReader().