Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
Nektar::LibUtilities::SessionReader Class Reference

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.
 
void InitSession (const std::vector< std::string > &filenames=std::vector< std::string >())
 
TiXmlDocument & GetDocument ()
 Provides direct access to the TiXmlDocument object.
 
TiXmlElement * GetElement (const std::string &pPath)
 Provides direct access to the TiXmlElement specified.
 
bool DefinesElement (const std::string &pPath) const
 Tests if a specified element is defined in the XML document.
 
const std::vector< std::string > & GetFilenames () const
 Returns the filename of the loaded XML document.
 
const std::string & GetSessionName () const
 Returns the session name of the loaded XML document.
 
CommSharedPtr GetComm ()
 Returns the communication object.
 
bool GetSharedFilesystem ()
 Returns if file system shared.
 
void Finalise ()
 Finalises the session.
 
bool DefinesParameter (const std::string &name) const
 Checks if a parameter is specified in the XML document.
 
const NekDoubleGetParameter (const std::string &pName) const
 Returns the value of the specified parameter.
 
const ParameterMapGetParameters ()
 
void LoadParameter (const std::string &name, int &var) const
 Load an integer parameter.
 
void LoadParameter (const std::string &name, unsigned int &var) const
 Load an unsigned integer parameter.
 
void LoadParameter (const std::string &name, size_t &var) const
 Load an size_t parameter.
 
void LoadParameter (const std::string &name, int &var, const int &def) const
 Check for and load an integer parameter.
 
void LoadParameter (const std::string &name, unsigned int &var, const unsigned int &def) const
 Check for and load an unsigned integer parameter.
 
void LoadParameter (const std::string &name, size_t &var, const size_t &def) const
 Check for and load an size_t parameter.
 
void LoadParameter (const std::string &name, NekDouble &var) const
 Load a double precision parameter.
 
void LoadParameter (const std::string &name, NekDouble &var, const NekDouble &def) const
 Check for and load a double-precision parameter.
 
void SetParameter (const std::string &name, int &var)
 Set an integer parameter.
 
void SetParameter (const std::string &name, unsigned int &var)
 Set an unsigned integer parameter.
 
void SetParameter (const std::string &name, size_t &var)
 Set an size_t parameter.
 
void SetParameter (const std::string &name, NekDouble &var)
 Set a double precision parameter.
 
bool DefinesSolverInfo (const std::string &name) const
 Checks if a solver info property is specified.
 
const std::string & GetSolverInfo (const std::string &pProperty) const
 Returns the value of the specified solver info property.
 
void SetSolverInfo (const std::string &pProperty, const std::string &pValue)
 Sets the value of the specified solver info property.
 
template<typename T >
const T GetSolverInfoAsEnum (const std::string &pName) const
 Returns the value of the specified solver info property as enum.
 
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.
 
void LoadSolverInfo (const std::string &name, std::string &var, const std::string &def="") const
 Check for and load a solver info property.
 
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.
 
bool MatchSolverInfo (const std::string &name, const std::string &trueval) const
 Check if the value of a solver info property matches.
 
template<typename T >
bool MatchSolverInfoAsEnum (const std::string &name, const T &trueval) const
 Check if the value of a solver info property matches.
 
bool GetBackups () const
 Returns the backups.
 
bool DefinesGlobalSysSolnInfo (const std::string &variable, const std::string &property) const
 
const std::string & GetGlobalSysSolnInfo (const std::string &variable, const std::string &property) const
 
void SetGlobalSysSolnInfo (const std::string &variable, const std::string &property, const std::string &value)
 
bool DefinesTimeIntScheme () const
 Returns true if the TIMEINTEGRATIONSCHEME section is defined in the session file.
 
const TimeIntSchemeGetTimeIntScheme () const
 Returns the time integration scheme structure m_timeIntScheme from the session file.
 
std::string GetGeometryType () const
 
const std::string & GetVariable (const unsigned int &idx) const
 Returns the name of the variable specified by the given index.
 
void SetVariable (const unsigned int &idx, std::string newname)
 
std::vector< std::string > GetVariables () const
 Returns the names of all variables.
 
bool DefinesFunction (const std::string &name) const
 Checks if a specified function is defined in the XML document.
 
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.
 
EquationSharedPtr GetFunction (const std::string &name, const std::string &variable, const int pDomain=0) const
 Returns an EquationSharedPtr to a given function variable.
 
EquationSharedPtr GetFunction (const std::string &name, const unsigned int &var, const int pDomain=0) const
 Returns an EquationSharedPtr to a given function variable index.
 
enum FunctionType GetFunctionType (const std::string &name, const std::string &variable, const int pDomain=0) const
 Returns the type of a given function variable.
 
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.
 
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.
 
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.
 
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.
 
InterpreterSharedPtr GetInterpreter ()
 Returns the instance of the Interpreter specific to this session.
 
bool DefinesTag (const std::string &pName) const
 Checks if a specified tag is defined.
 
void SetTag (const std::string &pName, const std::string &pValue)
 Sets a specified tag.
 
const std::string & GetTag (const std::string &pName) const
 Returns the value of a specified tag.
 
const FilterMapGetFilters () const
 
bool DefinesCmdLineArgument (const std::string &pName) const
 Checks if a specified cmdline argument has been given.
 
template<typename T >
GetCmdLineArgument (const std::string &pName) const
 Retrieves a command-line argument value.
 
bool GetUpdateOptFile () const
 Get bool to update optimisation file.
 
void SetUpdateOptFile (bool flag)
 Set bool to update optimisation file.
 
size_t GetTimeLevel (void) const
 Get time level (Parallel-in-Time)
 

Static Public Member Functions

static SessionReaderSharedPtr CreateInstance (int argc, char *argv[])
 Creates an instance of the SessionReader class.
 
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.
 
static std::string RegisterEnumValue (std::string pEnum, std::string pString, int pEnumValue)
 Registers an enumeration value.
 
static std::string RegisterDefaultSolverInfo (const std::string &pName, const std::string &pValue)
 Registers the default string value of a solver info property.
 
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.
 
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.
 
static void GetXMLElementTimeLevel (TiXmlElement *&element, const size_t timeLevel, const bool enableCheck=true)
 Get XML elment time level (Parallel-in-Time)
 

Private Member Functions

 SessionReader (int argc, char *argv[])
 Main constructor.
 
void TestSharedFilesystem ()
 
std::vector< std::string > ParseCommandLineArguments (int argc, char *argv[])
 Parse the program arguments and fill m_cmdLineOptions.
 
std::string ParseSessionName (std::vector< std::string > &filenames)
 Parse the session name.
 
void LoadDoc (const std::string &pFilename, TiXmlDocument *pDoc) const
 Loads an xml file into a tinyxml doc and decompresses if needed.
 
TiXmlDocument * MergeDoc (const std::vector< std::string > &pFilenames) const
 Creates an XML document from a list of input files.
 
void ParseDocument ()
 Loads and parses the specified file.
 
void CreateComm (int &argc, char *argv[])
 Loads the given XML document and instantiates an appropriate communication object.
 
void PartitionComm ()
 Partitions the comm object based on session parameters.
 
void ReadParameters (TiXmlElement *conditions)
 Reads the PARAMETERS section of the XML document.
 
void ReadSolverInfo (TiXmlElement *conditions)
 Reads the SOLVERINFO section of the XML document.
 
void ReadGlobalSysSolnInfo (TiXmlElement *conditions)
 Reads the GLOBALSYSSOLNINFO section of the XML document.
 
void ReadTimeIntScheme (TiXmlElement *conditions)
 Reads the TIMEINTEGRATIONSCHEME section of the XML document.
 
void ReadVariables (TiXmlElement *conditions)
 Reads the VARIABLES section of the XML document.
 
void ReadFunctions (TiXmlElement *conditions)
 Reads the FUNCTIONS section of the XML document.
 
void ReadFilters (TiXmlElement *filters)
 Reads the FILTERS section of the XML document.
 
void CmdLineOverride ()
 Enforce parameters from command line arguments.
 
void VerifySolverInfo ()
 Check values of solver info options are valid.
 
void ParseEquals (const std::string &line, std::string &lhs, std::string &rhs)
 Parse a string in the form lhs = rhs.
 

Static Private Member Functions

static EnumMapListGetSolverInfoEnums ()
 String to enumeration map for Solver Info parameters.
 
static SolverInfoMapGetSolverInfoDefaults ()
 Default solver info options.
 
static GloSysSolnInfoListGetGloSysSolnList ()
 GlobalSysSoln Info map.
 
static CmdLineArgMapGetCmdLineArgMap ()
 CmdLine argument map.
 

Private Attributes

boost::program_options::variables_map m_cmdLineOptions
 
CommSharedPtr m_comm
 Communication object.
 
std::vector< std::string > m_filenames
 Filenames.
 
std::string m_sessionName
 Session name of the loaded XML document (filename minus ext).
 
TiXmlDocument * m_xmlDoc
 Pointer to the loaded XML document.
 
ParameterMap m_parameters
 Parameters.
 
SolverInfoMap m_solverInfo
 Solver information properties.
 
GeometricInfoMap m_geometricInfo
 Geometric information properties.
 
InterpreterSharedPtr m_interpreter
 Interpreter instance.
 
FunctionMap m_functions
 Functions.
 
VariableList m_variables
 Variables.
 
TagMap m_tags
 Custom tags.
 
FilterMap m_filters
 Filters map.
 
TimeIntScheme m_timeIntScheme
 Time integration scheme information.
 
size_t m_timeLevel = 0
 Time level.
 
bool m_verbose
 Be verbose.
 
bool m_sharedFilesystem
 Running on a shared filesystem.
 
bool m_backups = true
 Backups.
 
bool m_updateOptFile
 Update optimisation file.
 

Friends

class MemoryManager< SessionReader >
 Support creation through MemoryManager.
 

Detailed Description

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:

static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
std::shared_ptr< SessionReader > SessionReaderSharedPtr

The instance vSession can now be passed to other key Nektar++ components during their construction.

Note
At the end of the user application, it is important to call the Finalise routine in order to finalise any MPI communication and correctly free resources.

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 122 of file SessionReader.h.

Constructor & Destructor Documentation

◆ SessionReader() [1/2]

Nektar::LibUtilities::SessionReader::SessionReader ( int  argc,
char *  argv[],
const std::vector< std::string > &  pFilenames,
const CommSharedPtr pComm,
const int &  timelevel 
)

Definition at line 215 of file BasicUtils/SessionReader.cpp.

218{
219 ASSERTL0(pFilenames.size() > 0, "No filenames specified.");
220
221 ParseCommandLineArguments(argc, argv);
222 m_xmlDoc = nullptr;
223 m_filenames = pFilenames;
224
226
227 // Create communicator
228 if (!pComm.get())
229 {
230 CreateComm(argc, argv);
231 }
232 else
233 {
234 m_comm = pComm;
235 }
236
238
239 // Split up the communicator
241
242 // If running in parallel change the default global sys solution
243 // type.
244 if (m_comm->GetSpaceComm()->GetSize() > 1)
245 {
246 GetSolverInfoDefaults()["GLOBALSYSSOLN"] = "IterativeStaticCond";
247 }
248
250 m_interpreter->SetRandomSeed((m_comm->GetSpaceComm()->GetRank() + 1) *
251 (unsigned int)time(nullptr));
252
253 // Set time level (Parallel-in-Time)
254 m_timeLevel = timelevel;
255}
#define ASSERTL0(condition, msg)
std::vector< std::string > ParseCommandLineArguments(int argc, char *argv[])
Parse the program arguments and fill m_cmdLineOptions.
static SolverInfoMap & GetSolverInfoDefaults()
Default solver info options.
std::string ParseSessionName(std::vector< std::string > &filenames)
Parse the session name.
InterpreterSharedPtr m_interpreter
Interpreter instance.
std::vector< std::string > m_filenames
Filenames.
std::string m_sessionName
Session name of the loaded XML document (filename minus ext).
CommSharedPtr m_comm
Communication object.
void CreateComm(int &argc, char *argv[])
Loads the given XML document and instantiates an appropriate communication object.
void PartitionComm()
Partitions the comm object based on session parameters.
TiXmlDocument * m_xmlDoc
Pointer to the loaded XML document.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

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().

◆ ~SessionReader()

Nektar::LibUtilities::SessionReader::~SessionReader ( )

Destructor.

Definition at line 260 of file BasicUtils/SessionReader.cpp.

261{
262 if (m_xmlDoc)
263 {
264 delete m_xmlDoc;
265 }
266}

References m_xmlDoc.

◆ SessionReader() [2/2]

Nektar::LibUtilities::SessionReader::SessionReader ( int  argc,
char *  argv[] 
)
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.

Parameters
argcNumber of command-line arguments
argvArray of command-line arguments

Definition at line 183 of file BasicUtils/SessionReader.cpp.

184{
185 m_xmlDoc = nullptr;
187
188 ASSERTL0(m_filenames.size() > 0, "No session file(s) given.");
189
191
192 // Create communicator
193 CreateComm(argc, argv);
194
196
197 // Split up the communicator
199
200 // If running in parallel change the default global sys solution
201 // type.
202 if (m_comm->GetSpaceComm()->GetSize() > 1)
203 {
204 GetSolverInfoDefaults()["GLOBALSYSSOLN"] = "IterativeStaticCond";
205 }
206
208 m_interpreter->SetRandomSeed((m_comm->GetSpaceComm()->GetRank() + 1) *
209 (unsigned int)time(nullptr));
210}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, CreateComm(), GetSolverInfoDefaults(), m_comm, m_filenames, m_interpreter, m_sessionName, m_xmlDoc, ParseCommandLineArguments(), ParseSessionName(), PartitionComm(), and TestSharedFilesystem().

Member Function Documentation

◆ CmdLineOverride()

void Nektar::LibUtilities::SessionReader::CmdLineOverride ( )
private

Enforce parameters from command line arguments.

Definition at line 2568 of file BasicUtils/SessionReader.cpp.

2569{
2570 // Parse solver info overrides
2571 if (m_cmdLineOptions.count("solverinfo"))
2572 {
2573 std::vector<std::string> solverInfoList =
2574 m_cmdLineOptions["solverinfo"].as<std::vector<std::string>>();
2575
2576 for (size_t i = 0; i < solverInfoList.size(); ++i)
2577 {
2578 std::string lhs, rhs;
2579
2580 try
2581 {
2582 ParseEquals(solverInfoList[i], lhs, rhs);
2583 }
2584 catch (...)
2585 {
2586 NEKERROR(ErrorUtil::efatal, "Parse error with command line "
2587 "option: " +
2588 solverInfoList[i]);
2589 }
2590
2591 std::string lhsUpper = boost::to_upper_copy(lhs);
2592 m_solverInfo[lhsUpper] = rhs;
2593 }
2594 }
2595
2596 if (m_cmdLineOptions.count("parameter"))
2597 {
2598 std::vector<std::string> parametersList =
2599 m_cmdLineOptions["parameter"].as<std::vector<std::string>>();
2600
2601 for (size_t i = 0; i < parametersList.size(); ++i)
2602 {
2603 std::string lhs, rhs;
2604
2605 try
2606 {
2607 ParseEquals(parametersList[i], lhs, rhs);
2608 }
2609 catch (...)
2610 {
2611 NEKERROR(ErrorUtil::efatal, "Parse error with command line "
2612 "option: " +
2613 parametersList[i]);
2614 }
2615
2616 std::string lhsUpper = boost::to_upper_copy(lhs);
2617
2618 try
2619 {
2620 m_interpreter->SetParameter(lhs, std::stod(rhs));
2621 m_parameters[lhsUpper] = std::stod(rhs);
2622 }
2623 catch (...)
2624 {
2625 NEKERROR(ErrorUtil::efatal, "Unable to convert string: " + rhs +
2626 "to double value.");
2627 }
2628 }
2629 }
2630}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
SolverInfoMap m_solverInfo
Solver information properties.
ParameterMap m_parameters
Parameters.
boost::program_options::variables_map m_cmdLineOptions
void ParseEquals(const std::string &line, std::string &lhs, std::string &rhs)
Parse a string in the form lhs = rhs.

References Nektar::ErrorUtil::efatal, m_cmdLineOptions, m_interpreter, m_parameters, m_solverInfo, NEKERROR, and ParseEquals().

Referenced by InitSession().

◆ CreateComm()

void Nektar::LibUtilities::SessionReader::CreateComm ( int &  argc,
char *  argv[] 
)
private

Loads the given XML document and instantiates an appropriate communication object.

Definition at line 1686 of file BasicUtils/SessionReader.cpp.

1687{
1688 if (argc == 0)
1689 {
1690 m_comm = GetCommFactory().CreateInstance("Serial", 0, 0);
1691 }
1692 else
1693 {
1694 string vCommModule("Serial");
1695 if (GetCommFactory().ModuleExists("ParallelMPI"))
1696 {
1697 vCommModule = "ParallelMPI";
1698 }
1699 if (m_cmdLineOptions.count("cwipi") &&
1700 GetCommFactory().ModuleExists("CWIPI"))
1701 {
1702 vCommModule = "CWIPI";
1703 }
1704
1705 m_comm = GetCommFactory().CreateInstance(vCommModule, argc, argv);
1706 }
1707}
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
CommFactory & GetCommFactory()

References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::GetCommFactory(), m_cmdLineOptions, and m_comm.

Referenced by SessionReader(), and SessionReader().

◆ CreateInstance() [1/2]

static SessionReaderSharedPtr Nektar::LibUtilities::SessionReader::CreateInstance ( int  argc,
char *  argv[] 
)
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 138 of file SessionReader.h.

140 {
143 argv);
144 return p;
145 }
std::vector< double > p(NPUPPER)

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

Referenced by Nektar::MovementTests::CreateSession(), Diffusion::Diffusion(), main(), SessionReader_CreateInstance(), 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().

◆ CreateInstance() [2/2]

static SessionReaderSharedPtr Nektar::LibUtilities::SessionReader::CreateInstance ( int  argc,
char *  argv[],
std::vector< std::string > &  pFilenames,
const CommSharedPtr pComm = CommSharedPtr(),
const int &  timelevel = 0 
)
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 157 of file SessionReader.h.

160 {
163 argc, argv, pFilenames, pComm, timelevel);
164 return p;
165 }

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

◆ DefinesCmdLineArgument()

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.

1492{
1493 return (m_cmdLineOptions.find(pName) != m_cmdLineOptions.end());
1494}

References m_cmdLineOptions.

Referenced by InitSession(), and PartitionComm().

◆ DefinesElement()

bool Nektar::LibUtilities::SessionReader::DefinesElement ( const std::string &  pPath) const

Tests if a specified element is defined in the XML document.

Definition at line 722 of file BasicUtils/SessionReader.cpp.

723{
724 std::string vPath = boost::to_upper_copy(pPath);
725 std::vector<std::string> st;
726 boost::split(st, vPath, boost::is_any_of("\\/ "));
727 ASSERTL0(st.size() > 0, "No path given in XML element request.");
728
729 TiXmlElement *vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
730 ASSERTL0(vReturn,
731 std::string("Cannot find element '") + st[0] + std::string("'."));
732 for (int i = 1; i < st.size(); ++i)
733 {
734 vReturn = vReturn->FirstChildElement(st[i].c_str());
735 if (!vReturn)
736 {
737 return false;
738 }
739 }
740 return true;
741}

References ASSERTL0, and m_xmlDoc.

◆ DefinesFunction() [1/2]

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.

1240{
1241 std::string vName = boost::to_upper_copy(pName);
1242 return m_functions.find(vName) != m_functions.end();
1243}

References m_functions.

◆ DefinesFunction() [2/2]

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.

1251{
1252 std::string vName = boost::to_upper_copy(pName);
1253
1254 // Check function exists
1255 auto it1 = m_functions.find(vName);
1256 if (it1 != m_functions.end())
1257 {
1258 pair<std::string, int> key(pVariable, pDomain);
1259 pair<std::string, int> defkey("*", pDomain);
1260 bool varExists = it1->second.find(key) != it1->second.end() ||
1261 it1->second.find(defkey) != it1->second.end();
1262 return varExists;
1263 }
1264 return false;
1265}

References m_functions.

◆ DefinesGlobalSysSolnInfo()

bool Nektar::LibUtilities::SessionReader::DefinesGlobalSysSolnInfo ( const std::string &  variable,
const std::string &  property 
) const

Definition at line 1086 of file BasicUtils/SessionReader.cpp.

1088{
1089 auto iter = GetGloSysSolnList().find(pVariable);
1090 if (iter == GetGloSysSolnList().end())
1091 {
1092 return false;
1093 }
1094
1095 std::string vProperty = boost::to_upper_copy(pProperty);
1096
1097 auto iter1 = iter->second.find(vProperty);
1098 if (iter1 == iter->second.end())
1099 {
1100 return false;
1101 }
1102
1103 return true;
1104}
static GloSysSolnInfoList & GetGloSysSolnList()
GlobalSysSoln Info map.

References GetGloSysSolnList().

◆ DefinesParameter()

bool Nektar::LibUtilities::SessionReader::DefinesParameter ( const std::string &  name) const

Checks if a parameter is specified in the XML document.

Definition at line 786 of file BasicUtils/SessionReader.cpp.

787{
788 std::string vName = boost::to_upper_copy(pName);
789 return m_parameters.find(vName) != m_parameters.end();
790}

References m_parameters.

Referenced by export_SessionReader().

◆ DefinesSolverInfo()

bool Nektar::LibUtilities::SessionReader::DefinesSolverInfo ( const std::string &  name) const

Checks if a solver info property is specified.

Definition at line 991 of file BasicUtils/SessionReader.cpp.

992{
993 std::string vName = boost::to_upper_copy(pName);
994 auto infoIter = m_solverInfo.find(vName);
995 return (infoIter != m_solverInfo.end());
996}

References m_solverInfo.

Referenced by export_SessionReader(), GetSolverInfoAsEnum(), and MatchSolverInfo().

◆ DefinesTag()

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.

1455{
1456 std::string vName = boost::to_upper_copy(pName);
1457 return m_tags.find(vName) != m_tags.end();
1458}

References m_tags.

◆ DefinesTimeIntScheme()

bool Nektar::LibUtilities::SessionReader::DefinesTimeIntScheme ( ) const

Returns true if the TIMEINTEGRATIONSCHEME section is defined in the session file.

Definition at line 1151 of file BasicUtils/SessionReader.cpp.

1152{
1153 return m_timeIntScheme.method != "";
1154}
TimeIntScheme m_timeIntScheme
Time integration scheme information.

References m_timeIntScheme, and Nektar::LibUtilities::TimeIntScheme::method.

◆ Finalise()

void Nektar::LibUtilities::SessionReader::Finalise ( )

Finalises the session.

This routine finalises any parallel communication.

Note
This routine should be called at the very end of a users application.

Definition at line 778 of file BasicUtils/SessionReader.cpp.

779{
780 m_comm->Finalise();
781}

References m_comm.

Referenced by export_SessionReader().

◆ GetBackups()

bool Nektar::LibUtilities::SessionReader::GetBackups ( ) const

Returns the backups.

Definition at line 1231 of file BasicUtils/SessionReader.cpp.

1232{
1233 return m_backups;
1234}

References m_backups.

◆ GetCmdLineArgMap()

CmdLineArgMap & Nektar::LibUtilities::SessionReader::GetCmdLineArgMap ( )
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 169 of file BasicUtils/SessionReader.cpp.

170{
171 static CmdLineArgMap cmdLineArguments;
172 return cmdLineArguments;
173}
std::map< std::string, CmdLineArg > CmdLineArgMap

Referenced by ParseCommandLineArguments(), RegisterCmdLineArgument(), and RegisterCmdLineFlag().

◆ GetCmdLineArgument()

template<typename T >
T Nektar::LibUtilities::SessionReader::GetCmdLineArgument ( const std::string &  pName) const
inline

Retrieves a command-line argument value.

Definition at line 368 of file SessionReader.h.

369 {
370 return m_cmdLineOptions.find(pName)->second.as<T>();
371 }

References m_cmdLineOptions.

◆ GetComm()

CommSharedPtr Nektar::LibUtilities::SessionReader::GetComm ( )

Returns the communication object.

Definition at line 762 of file BasicUtils/SessionReader.cpp.

763{
764 return m_comm;
765}

References m_comm.

Referenced by export_SessionReader().

◆ GetDocument()

TiXmlDocument & Nektar::LibUtilities::SessionReader::GetDocument ( )

Provides direct access to the TiXmlDocument object.

Definition at line 672 of file BasicUtils/SessionReader.cpp.

673{
674 ASSERTL1(m_xmlDoc, "XML Document not defined.");
675 return *m_xmlDoc;
676}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....

References ASSERTL1, and m_xmlDoc.

◆ GetElement()

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:

<NEKTAR>
<CONDITIONS>
<PARAMETERS>
...
</PARAMETERS>
</CONDITIONS>
</NEKTAR>

the PARAMETERS element would be retrieved by requesting the path:

Nektar/Conditions/Parameters
Note
Paths are case-insensitive.
Parameters
pPathPath to requested element.
Returns
Direct pointer to requested XML Element.

Definition at line 700 of file BasicUtils/SessionReader.cpp.

701{
702 std::string vPath = boost::to_upper_copy(pPath);
703 std::vector<std::string> st;
704 boost::split(st, vPath, boost::is_any_of("\\/ "));
705 ASSERTL0(st.size() > 0, "No path given in XML element request.");
706
707 TiXmlElement *vReturn = m_xmlDoc->FirstChildElement(st[0].c_str());
708 ASSERTL0(vReturn,
709 std::string("Cannot find element '") + st[0] + std::string("'."));
710 for (int i = 1; i < st.size(); ++i)
711 {
712 vReturn = vReturn->FirstChildElement(st[i].c_str());
713 ASSERTL0(vReturn, std::string("Cannot find element '") + st[i] +
714 std::string("'."));
715 }
716 return vReturn;
717}

References ASSERTL0, and m_xmlDoc.

◆ GetFilenames()

const std::vector< std::string > & Nektar::LibUtilities::SessionReader::GetFilenames ( ) const

Returns the filename of the loaded XML document.

Definition at line 746 of file BasicUtils/SessionReader.cpp.

747{
748 return m_filenames;
749}

References m_filenames.

◆ GetFilters()

const FilterMap & Nektar::LibUtilities::SessionReader::GetFilters ( ) const

Definition at line 1483 of file BasicUtils/SessionReader.cpp.

1484{
1485 return m_filters;
1486}

References m_filters.

◆ GetFunction() [1/2]

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.

1273{
1274 std::string vName = boost::to_upper_copy(pName);
1275 auto it1 = m_functions.find(vName);
1276
1277 ASSERTL0(it1 != m_functions.end(),
1278 std::string("No such function '") + pName +
1279 std::string("' has been defined in the session file."));
1280
1281 // Check for specific and wildcard definitions
1282 pair<std::string, int> key(pVariable, pDomain);
1283 pair<std::string, int> defkey("*", pDomain);
1284
1285 auto it2 = it1->second.find(key);
1286 auto it3 = it1->second.find(defkey);
1287 bool specific = it2 != it1->second.end();
1288 bool wildcard = it3 != it1->second.end();
1289
1290 // Check function is defined somewhere
1291 ASSERTL0(specific || wildcard, "No such variable " + pVariable +
1292 " in domain " + std::to_string(pDomain) +
1293 " defined for function " + pName +
1294 " in session file.");
1295
1296 // If not specific, must be wildcard
1297 if (!specific)
1298 {
1299 it2 = it3;
1300 }
1301
1302 ASSERTL0((it2->second.m_type == eFunctionTypeExpression),
1303 std::string("Function is defined by a file."));
1304 return it2->second.m_expression;
1305}

References ASSERTL0, Nektar::LibUtilities::eFunctionTypeExpression, and m_functions.

Referenced by export_SessionReader(), and GetFunction().

◆ GetFunction() [2/2]

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.

1313{
1314 ASSERTL0(pVar < m_variables.size(), "Variable index out of range.");
1315 return GetFunction(pName, m_variables[pVar], pDomain);
1316}
VariableList m_variables
Variables.
EquationSharedPtr GetFunction(const std::string &name, const std::string &variable, const int pDomain=0) const
Returns an EquationSharedPtr to a given function variable.

References ASSERTL0, GetFunction(), and m_variables.

◆ GetFunctionFilename() [1/2]

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.

1372{
1373 std::string vName = boost::to_upper_copy(pName);
1374 auto it1 = m_functions.find(vName);
1375
1376 ASSERTL0(it1 != m_functions.end(),
1377 std::string("Function '") + pName + std::string("' not found."));
1378
1379 // Check for specific and wildcard definitions
1380 pair<std::string, int> key(pVariable, pDomain);
1381 pair<std::string, int> defkey("*", pDomain);
1382
1383 auto it2 = it1->second.find(key);
1384 auto it3 = it1->second.find(defkey);
1385 bool specific = it2 != it1->second.end();
1386 bool wildcard = it3 != it1->second.end();
1387
1388 // Check function is defined somewhere
1389 ASSERTL0(specific || wildcard, "No such variable " + pVariable +
1390 " in domain " + std::to_string(pDomain) +
1391 " defined for function " + pName +
1392 " in session file.");
1393
1394 // If not specific, must be wildcard
1395 if (!specific)
1396 {
1397 it2 = it3;
1398 }
1399
1400 return it2->second.m_filename;
1401}

References ASSERTL0, and m_functions.

Referenced by GetFunctionFilename().

◆ GetFunctionFilename() [2/2]

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.

1409{
1410 ASSERTL0(pVar < m_variables.size(), "Variable index out of range.");
1411 return GetFunctionFilename(pName, m_variables[pVar], pDomain);
1412}
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.

References ASSERTL0, GetFunctionFilename(), and m_variables.

◆ GetFunctionFilenameVariable()

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.

1420{
1421 std::string vName = boost::to_upper_copy(pName);
1422 auto it1 = m_functions.find(vName);
1423
1424 ASSERTL0(it1 != m_functions.end(),
1425 std::string("Function '") + pName + std::string("' not found."));
1426
1427 // Check for specific and wildcard definitions
1428 pair<std::string, int> key(pVariable, pDomain);
1429 pair<std::string, int> defkey("*", pDomain);
1430
1431 auto it2 = it1->second.find(key);
1432 auto it3 = it1->second.find(defkey);
1433 bool specific = it2 != it1->second.end();
1434 bool wildcard = it3 != it1->second.end();
1435
1436 // Check function is defined somewhere
1437 ASSERTL0(specific || wildcard, "No such variable " + pVariable +
1438 " in domain " + std::to_string(pDomain) +
1439 " defined for function " + pName +
1440 " in session file.");
1441
1442 // If not specific, must be wildcard
1443 if (!specific)
1444 {
1445 it2 = it3;
1446 }
1447
1448 return it2->second.m_fileVariable;
1449}

References ASSERTL0, and m_functions.

◆ GetFunctionType() [1/2]

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.

1324{
1325 std::string vName = boost::to_upper_copy(pName);
1326 auto it1 = m_functions.find(vName);
1327
1328 ASSERTL0(it1 != m_functions.end(),
1329 std::string("Function '") + pName + std::string("' not found."));
1330
1331 // Check for specific and wildcard definitions
1332 pair<std::string, int> key(pVariable, pDomain);
1333 pair<std::string, int> defkey("*", pDomain);
1334
1335 auto it2 = it1->second.find(key);
1336 auto it3 = it1->second.find(defkey);
1337 bool specific = it2 != it1->second.end();
1338 bool wildcard = it3 != it1->second.end();
1339
1340 // Check function is defined somewhere
1341 ASSERTL0(specific || wildcard, "No such variable " + pVariable +
1342 " in domain " + std::to_string(pDomain) +
1343 " defined for function " + pName +
1344 " in session file.");
1345
1346 // If not specific, must be wildcard
1347 if (!specific)
1348 {
1349 it2 = it3;
1350 }
1351
1352 return it2->second.m_type;
1353}

References ASSERTL0, and m_functions.

Referenced by GetFunctionType().

◆ GetFunctionType() [2/2]

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.

1361{
1362 ASSERTL0(pVar < m_variables.size(), "Variable index out of range.");
1363 return GetFunctionType(pName, m_variables[pVar], pDomain);
1364}
enum FunctionType GetFunctionType(const std::string &name, const std::string &variable, const int pDomain=0) const
Returns the type of a given function variable.

References ASSERTL0, GetFunctionType(), and m_variables.

◆ GetGeometryType()

std::string Nektar::LibUtilities::SessionReader::GetGeometryType ( ) const

Definition at line 1168 of file BasicUtils/SessionReader.cpp.

1169{
1170 TiXmlElement *xmlGeom =
1171 m_xmlDoc->FirstChildElement("NEKTAR")->FirstChildElement("GEOMETRY");
1172 ASSERTL1(xmlGeom, "Failed to find a GEOMETRY section in m_xmlDoc");
1173
1174 TiXmlAttribute *attr = xmlGeom->FirstAttribute();
1175 while (attr)
1176 {
1177 std::string attrName(attr->Name());
1178 if (attrName == "HDF5FILE")
1179 {
1180 // there is a file pointer, therefore is HDF5
1181 return "HDF5";
1182 }
1183 // Get the next attribute.
1184 attr = attr->Next();
1185 }
1186
1187 // Check the VERTEX block. If this is compressed, assume the file is
1188 // compressed, otherwise assume uncompressed.
1189 TiXmlElement *element = xmlGeom->FirstChildElement("VERTEX");
1190 string IsCompressed;
1191 element->QueryStringAttribute("COMPRESSED", &IsCompressed);
1192
1193 if (IsCompressed.size() > 0)
1194 {
1195 return "XmlCompressed";
1196 }
1197
1198 // no file pointer or compressed, just standard xml
1199 return "Xml";
1200}

References ASSERTL1, and m_xmlDoc.

◆ GetGlobalSysSolnInfo()

const std::string & Nektar::LibUtilities::SessionReader::GetGlobalSysSolnInfo ( const std::string &  variable,
const std::string &  property 
) const

Definition at line 1109 of file BasicUtils/SessionReader.cpp.

1111{
1112 auto iter = GetGloSysSolnList().find(pVariable);
1113 ASSERTL0(iter != GetGloSysSolnList().end(),
1114 "Failed to find variable in GlobalSysSolnInfoList");
1115
1116 std::string vProperty = boost::to_upper_copy(pProperty);
1117 auto iter1 = iter->second.find(vProperty);
1118
1119 ASSERTL0(iter1 != iter->second.end(),
1120 "Failed to find property: " + vProperty +
1121 " in GlobalSysSolnInfoList");
1122
1123 return iter1->second;
1124}

References ASSERTL0, and GetGloSysSolnList().

◆ GetGloSysSolnList()

GloSysSolnInfoList & Nektar::LibUtilities::SessionReader::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 ReadGlobalSysSolnInfo 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 155 of file BasicUtils/SessionReader.cpp.

156{
157 static GloSysSolnInfoList gloSysSolnInfoList;
158 return gloSysSolnInfoList;
159}
std::map< std::string, GloSysInfoMap > GloSysSolnInfoList

Referenced by DefinesGlobalSysSolnInfo(), GetGlobalSysSolnInfo(), ReadGlobalSysSolnInfo(), and SetGlobalSysSolnInfo().

◆ GetInterpreter()

InterpreterSharedPtr Nektar::LibUtilities::SessionReader::GetInterpreter ( )

Returns the instance of the Interpreter specific to this session.

Definition at line 2657 of file BasicUtils/SessionReader.cpp.

2658{
2659 return m_interpreter;
2660}

References m_interpreter.

◆ GetParameter()

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.

Parameters
pNameThe name of a floating-point parameter.
Returns
The value of the floating-point parameter.

Definition at line 800 of file BasicUtils/SessionReader.cpp.

801{
802 std::string vName = boost::to_upper_copy(pName);
803 auto paramIter = m_parameters.find(vName);
804
805 ASSERTL0(paramIter != m_parameters.end(),
806 "Unable to find requested parameter: " + pName);
807
808 return paramIter->second;
809}

References ASSERTL0, and m_parameters.

Referenced by export_SessionReader().

◆ GetParameters()

const ParameterMap & Nektar::LibUtilities::SessionReader::GetParameters ( )

Getter for the session's parameters

Returns
A reference to the parameter map

Definition at line 815 of file BasicUtils/SessionReader.cpp.

816{
817 return m_parameters;
818}

References m_parameters.

Referenced by export_SessionReader().

◆ GetSessionName()

const std::string & Nektar::LibUtilities::SessionReader::GetSessionName ( ) const

Returns the session name of the loaded XML document.

Definition at line 754 of file BasicUtils/SessionReader.cpp.

755{
756 return m_sessionName;
757}

References m_sessionName.

Referenced by export_SessionReader().

◆ GetSharedFilesystem()

bool Nektar::LibUtilities::SessionReader::GetSharedFilesystem ( )

Returns if file system shared.

Definition at line 767 of file BasicUtils/SessionReader.cpp.

768{
769 return m_sharedFilesystem;
770}
bool m_sharedFilesystem
Running on a shared filesystem.

References m_sharedFilesystem.

Referenced by export_SessionReader().

◆ GetSolverInfo()

const std::string & Nektar::LibUtilities::SessionReader::GetSolverInfo ( const std::string &  pProperty) const

Returns the value of the specified solver info property.

Definition at line 1001 of file BasicUtils/SessionReader.cpp.

1003{
1004 std::string vProperty = boost::to_upper_copy(pProperty);
1005 auto iter = m_solverInfo.find(vProperty);
1006
1007 ASSERTL1(iter != m_solverInfo.end(),
1008 "Unable to find requested property: " + pProperty);
1009
1010 return iter->second;
1011}

References ASSERTL1, and m_solverInfo.

Referenced by export_SessionReader(), and GetSolverInfoAsEnum().

◆ GetSolverInfoAsEnum()

template<typename T >
const T Nektar::LibUtilities::SessionReader::GetSolverInfoAsEnum ( const std::string &  pName) const
inline

Returns the value of the specified solver info property as enum.

Definition at line 517 of file SessionReader.h.

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}
bool DefinesSolverInfo(const std::string &name) const
Checks if a solver info property is specified.
static EnumMapList & GetSolverInfoEnums()
String to enumeration map for Solver Info parameters.
const std::string & GetSolverInfo(const std::string &pProperty) const
Returns the value of the specified solver info property.

References ASSERTL0, DefinesSolverInfo(), GetSolverInfo(), and GetSolverInfoEnums().

◆ GetSolverInfoDefaults()

SolverInfoMap & Nektar::LibUtilities::SessionReader::GetSolverInfoDefaults ( )
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 140 of file BasicUtils/SessionReader.cpp.

141{
142 static SolverInfoMap solverInfoMap;
143 return solverInfoMap;
144}
std::map< std::string, std::string > SolverInfoMap

Referenced by ReadSolverInfo(), RegisterDefaultSolverInfo(), SessionReader(), and SessionReader().

◆ GetSolverInfoEnums()

EnumMapList & Nektar::LibUtilities::SessionReader::GetSolverInfoEnums ( )
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 126 of file BasicUtils/SessionReader.cpp.

127{
128 static EnumMapList solverInfoEnums;
129 return solverInfoEnums;
130}
std::map< std::string, EnumMap > EnumMapList

Referenced by GetSolverInfoAsEnum(), GetValueAsEnum(), RegisterEnumValue(), and VerifySolverInfo().

◆ GetTag()

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.

1473{
1474 std::string vName = boost::to_upper_copy(pName);
1475 auto vTagIterator = m_tags.find(vName);
1476 ASSERTL0(vTagIterator != m_tags.end(), "Requested tag does not exist.");
1477 return vTagIterator->second;
1478}

References ASSERTL0, and m_tags.

◆ GetTimeIntScheme()

const TimeIntScheme & Nektar::LibUtilities::SessionReader::GetTimeIntScheme ( ) const

Returns the time integration scheme structure m_timeIntScheme from the session file.

Definition at line 1160 of file BasicUtils/SessionReader.cpp.

1161{
1162 return m_timeIntScheme;
1163}

References m_timeIntScheme.

◆ GetTimeLevel()

size_t Nektar::LibUtilities::SessionReader::GetTimeLevel ( void  ) const
inline

Get time level (Parallel-in-Time)

Definition at line 394 of file SessionReader.h.

395 {
396 return m_timeLevel;
397 }

References m_timeLevel.

◆ GetUpdateOptFile()

bool Nektar::LibUtilities::SessionReader::GetUpdateOptFile ( ) const
inline

Get bool to update optimisation file.

Definition at line 382 of file SessionReader.h.

383 {
384 return m_updateOptFile;
385 }
bool m_updateOptFile
Update optimisation file.

References m_updateOptFile.

◆ GetValueAsEnum()

template<typename T >
const T Nektar::LibUtilities::SessionReader::GetValueAsEnum ( const std::string &  pName,
const std::string &  vValue 
) const
inline

Returns the value of the specified property and value as enum.

Definition at line 540 of file SessionReader.h.

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}

References ASSERTL0, and GetSolverInfoEnums().

◆ GetVariable()

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.

1206{
1207 ASSERTL0(idx < m_variables.size(), "Variable index out of range.");
1208 return m_variables[idx];
1209}

References ASSERTL0, and m_variables.

Referenced by export_SessionReader().

◆ GetVariables()

std::vector< std::string > Nektar::LibUtilities::SessionReader::GetVariables ( ) const

Returns the names of all variables.

Definition at line 1223 of file BasicUtils/SessionReader.cpp.

1224{
1225 return m_variables;
1226}

References m_variables.

Referenced by export_SessionReader().

◆ GetXMLElementTimeLevel()

void Nektar::LibUtilities::SessionReader::GetXMLElementTimeLevel ( TiXmlElement *&  element,
const size_t  timeLevel,
const bool  enableCheck = true 
)
static

Get XML elment time level (Parallel-in-Time)

Definition at line 1499 of file BasicUtils/SessionReader.cpp.

1502{
1503 if (Element && Element->FirstChildElement("TIMELEVEL"))
1504 {
1505 Element = Element->FirstChildElement("TIMELEVEL");
1506 std::string timeLevelStr;
1507 while (Element)
1508 {
1509 std::stringstream tagcontent;
1510 tagcontent << *Element;
1511 ASSERTL0(Element->Attribute("VALUE"),
1512 "Missing LEVEL attribute in solver info "
1513 "XML element: \n\t'" +
1514 tagcontent.str() + "'");
1515 timeLevelStr = Element->Attribute("VALUE");
1516 ASSERTL0(!timeLevelStr.empty(),
1517 "LEVEL attribute must be non-empty in XML "
1518 "element: \n\t'" +
1519 tagcontent.str() + "'");
1520 if (stoi(timeLevelStr) == timeLevel)
1521 {
1522 break;
1523 }
1524 Element = Element->NextSiblingElement("TIMELEVEL");
1525 }
1526 if (enableCheck)
1527 {
1528 ASSERTL0(stoi(timeLevelStr) == timeLevel,
1529 "TIMELEVEL value " + std::to_string(timeLevel) +
1530 " not found in solver info "
1531 "XML element: \n\t'");
1532 }
1533 }
1534}

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::MeshGraphIOHDF5::v_PartitionMesh(), and Nektar::SpatialDomains::MeshGraphIOXml::WriteXMLGeometry().

◆ InitSession()

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 274 of file BasicUtils/SessionReader.cpp.

275{
276 // Re-load filenames for session if required.
277 if (filenames.size() > 0)
278 {
279 m_filenames = filenames;
280 }
281
282 // check specified opt file
283 std::string optfile;
284 int exists;
285
286 if (DefinesCmdLineArgument("use-opt-file"))
287 {
288 optfile =
289 m_cmdLineOptions.find("use-opt-file")->second.as<std::string>();
290 exists = fs::exists(optfile.c_str());
291 ASSERTL0(exists, "A valid .opt file was not specified "
292 "with the --use-opt-file command line option");
293
294 m_filenames.push_back(optfile);
295
296 // put opt file at beginning
297 std::rotate(m_filenames.rbegin(), m_filenames.rbegin() + 1,
298 m_filenames.rend());
299 }
300 else // check for write-opt-file
301 {
302 // check for opt file
303 optfile = m_sessionName.substr(0, m_sessionName.find("_xml/")) + ".opt";
304 exists = fs::exists(optfile.c_str());
305
306 // For Paralell-in-Time
307 if (exists && m_comm->IsParallelInTime())
308 {
309 TiXmlDocument doc;
310 doc.LoadFile(optfile);
311 TiXmlElement *xmlTag = doc.FirstChildElement("NEKTAR")
312 ->FirstChildElement("COLLECTIONS")
313 ->FirstChildElement("TIMELEVEL");
314 if (xmlTag)
315 {
316 // if there is a TIMELEVEL tag, then turn existing flag to false
317 // and check if the required time level is specified in the
318 // optfile.
319 exists = false;
320 while (xmlTag)
321 {
322 if (m_timeLevel == stoi(xmlTag->Attribute("VALUE")))
323 {
324 exists = true;
325 break;
326 }
327 xmlTag = xmlTag->NextSiblingElement();
328 }
329 }
330 }
331
332 if (exists)
333 {
334 m_filenames.push_back(optfile);
335 // rotate order so opt file can be overwritten by
336 // direct choice in xml file
337 std::rotate(m_filenames.rbegin(), m_filenames.rbegin() + 1,
338 m_filenames.rend());
339 }
340 else
341 {
342 m_updateOptFile = true;
343 }
344 }
345
346 // Merge document if required.
347 if (m_xmlDoc)
348 {
349 delete m_xmlDoc;
350 }
351
353
354 // Parse the XML data in #m_xmlDoc
356
357 // Override SOLVERINFO and parameters with any specified on the
358 // command line.
360
361 // Verify SOLVERINFO values
363
364 // Disable backups if NEKTAR_DISABLE_BACKUPS is set.
365 if (std::getenv("NEKTAR_DISABLE_BACKUPS") != nullptr)
366 {
367 m_backups = false;
368 }
369
370 // In verbose mode, print out parameters and solver info sections
371 if (m_verbose && m_comm)
372 {
373 if (m_comm->TreatAsRankZero() && m_parameters.size() > 0)
374 {
375 cout << "Parameters:" << endl;
376 for (auto &x : m_parameters)
377 {
378 cout << "\t" << x.first << " = " << x.second << endl;
379 }
380 cout << endl;
381 }
382
383 if (m_comm->TreatAsRankZero() && m_solverInfo.size() > 0)
384 {
385 cout << "Solver Info:" << endl;
386 for (auto &x : m_solverInfo)
387 {
388 cout << "\t" << x.first << " = " << x.second << endl;
389 }
390 cout << endl;
391 }
392 }
393}
TiXmlDocument * MergeDoc(const std::vector< std::string > &pFilenames) const
Creates an XML document from a list of input files.
void CmdLineOverride()
Enforce parameters from command line arguments.
void ParseDocument()
Loads and parses the specified file.
void VerifySolverInfo()
Check values of solver info options are valid.
bool DefinesCmdLineArgument(const std::string &pName) const
Checks if a specified cmdline argument has been given.

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().

Referenced by export_SessionReader().

◆ LoadDoc()

void Nektar::LibUtilities::SessionReader::LoadDoc ( const std::string &  pFilename,
TiXmlDocument *  pDoc 
) const
private

Loads an xml file into a tinyxml doc and decompresses if needed.

Definition at line 1539 of file BasicUtils/SessionReader.cpp.

1541{
1542 if (pFilename.size() > 3 &&
1543 pFilename.substr(pFilename.size() - 3, 3) == ".gz")
1544 {
1545 ifstream file(pFilename.c_str(), ios_base::in | ios_base::binary);
1546 ASSERTL0(file.good(), "Unable to open file: " + pFilename);
1547 stringstream ss;
1548 io::filtering_streambuf<io::input> in;
1549 in.push(io::gzip_decompressor());
1550 in.push(file);
1551 try
1552 {
1553 io::copy(in, ss);
1554 ss >> (*pDoc);
1555 }
1556 catch (io::gzip_error &)
1557 {
1559 "Error: File '" + pFilename + "' is corrupt.");
1560 }
1561 }
1562 else if (pFilename.size() > 4 &&
1563 pFilename.substr(pFilename.size() - 4, 4) == "_xml")
1564 {
1565 fs::path pdirname(pFilename);
1566 boost::format pad("P%1$07d.xml");
1567 pad % m_comm->GetSpaceComm()->GetRank();
1568 fs::path pRankFilename(pad.str());
1569 fs::path fullpath = pdirname / pRankFilename;
1570
1571 ifstream file(PortablePath(fullpath).c_str());
1572 ASSERTL0(file.good(), "Unable to open file: " + fullpath.string());
1573 file >> (*pDoc);
1574 }
1575 else
1576 {
1577 ifstream file(pFilename.c_str());
1578 ASSERTL0(file.good(), "Unable to open file: " + pFilename);
1579 file >> (*pDoc);
1580 }
1581}
static std::string PortablePath(const fs::path &path)
create portable path on different platforms for std::filesystem path.

References ASSERTL0, Nektar::ErrorUtil::efatal, m_comm, NEKERROR, and Nektar::LibUtilities::PortablePath().

Referenced by MergeDoc().

◆ LoadParameter() [1/8]

void Nektar::LibUtilities::SessionReader::LoadParameter ( const std::string &  name,
int &  var 
) const

Load an integer parameter.

Definition at line 823 of file BasicUtils/SessionReader.cpp.

824{
825 std::string vName = boost::to_upper_copy(pName);
826 auto paramIter = m_parameters.find(vName);
827 ASSERTL0(paramIter != m_parameters.end(),
828 "Required parameter '" + pName + "' not specified in session.");
829 NekDouble param = round(paramIter->second);
830 pVar = checked_cast<int>(param);
831}

References ASSERTL0, and m_parameters.

◆ LoadParameter() [2/8]

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 836 of file BasicUtils/SessionReader.cpp.

838{
839 std::string vName = boost::to_upper_copy(pName);
840 auto paramIter = m_parameters.find(vName);
841 if (paramIter != m_parameters.end())
842 {
843 NekDouble param = round(paramIter->second);
844 pVar = checked_cast<int>(param);
845 }
846 else
847 {
848 pVar = pDefault;
849 }
850}

References m_parameters.

◆ LoadParameter() [3/8]

void Nektar::LibUtilities::SessionReader::LoadParameter ( const std::string &  name,
NekDouble var 
) const

Load a double precision parameter.

Definition at line 920 of file BasicUtils/SessionReader.cpp.

922{
923 std::string vName = boost::to_upper_copy(pName);
924 auto paramIter = m_parameters.find(vName);
925 ASSERTL0(paramIter != m_parameters.end(),
926 "Required parameter '" + pName + "' not specified in session.");
927 pVar = paramIter->second;
928}

References ASSERTL0, and m_parameters.

◆ LoadParameter() [4/8]

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 933 of file BasicUtils/SessionReader.cpp.

935{
936 std::string vName = boost::to_upper_copy(pName);
937 auto paramIter = m_parameters.find(vName);
938 if (paramIter != m_parameters.end())
939 {
940 pVar = paramIter->second;
941 }
942 else
943 {
944 pVar = pDefault;
945 }
946}

References m_parameters.

◆ LoadParameter() [5/8]

void Nektar::LibUtilities::SessionReader::LoadParameter ( const std::string &  name,
size_t &  var 
) const

Load an size_t parameter.

Definition at line 888 of file BasicUtils/SessionReader.cpp.

889{
890 std::string vName = boost::to_upper_copy(pName);
891 auto paramIter = m_parameters.find(vName);
892 ASSERTL0(paramIter != m_parameters.end(),
893 "Required parameter '" + pName + "' not specified in session.");
894 NekDouble param = round(paramIter->second);
895 pVar = checked_cast<int>(param);
896}

References ASSERTL0, and m_parameters.

◆ LoadParameter() [6/8]

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 901 of file BasicUtils/SessionReader.cpp.

903{
904 std::string vName = boost::to_upper_copy(pName);
905 auto paramIter = m_parameters.find(vName);
906 if (paramIter != m_parameters.end())
907 {
908 NekDouble param = round(paramIter->second);
909 pVar = checked_cast<int>(param);
910 }
911 else
912 {
913 pVar = pDefault;
914 }
915}

References m_parameters.

◆ LoadParameter() [7/8]

void Nektar::LibUtilities::SessionReader::LoadParameter ( const std::string &  name,
unsigned int &  var 
) const

Load an unsigned integer parameter.

Definition at line 855 of file BasicUtils/SessionReader.cpp.

857{
858 std::string vName = boost::to_upper_copy(pName);
859 auto paramIter = m_parameters.find(vName);
860 ASSERTL0(paramIter != m_parameters.end(),
861 "Required parameter '" + pName + "' not specified in session.");
862 NekDouble param = round(paramIter->second);
863 pVar = checked_cast<unsigned int>(param);
864}

References ASSERTL0, and m_parameters.

◆ LoadParameter() [8/8]

void Nektar::LibUtilities::SessionReader::LoadParameter ( const std::string &  name,
unsigned int &  var,
const unsigned int &  def 
) const

Check for and load an unsigned integer parameter.

Definition at line 869 of file BasicUtils/SessionReader.cpp.

871{
872 std::string vName = boost::to_upper_copy(pName);
873 auto paramIter = m_parameters.find(vName);
874 if (paramIter != m_parameters.end())
875 {
876 NekDouble param = round(paramIter->second);
877 pVar = checked_cast<unsigned int>(param);
878 }
879 else
880 {
881 pVar = pDefault;
882 }
883}

References m_parameters.

◆ LoadSolverInfo()

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 1031 of file BasicUtils/SessionReader.cpp.

1033{
1034 std::string vName = boost::to_upper_copy(pName);
1035 auto infoIter = m_solverInfo.find(vName);
1036 if (infoIter != m_solverInfo.end())
1037 {
1038 pVar = infoIter->second;
1039 }
1040 else
1041 {
1042 pVar = pDefault;
1043 }
1044}

References m_solverInfo.

◆ MatchSolverInfo() [1/2]

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 1068 of file BasicUtils/SessionReader.cpp.

1070{
1071 if (DefinesSolverInfo(pName))
1072 {
1073 std::string vName = boost::to_upper_copy(pName);
1074 auto iter = m_solverInfo.find(vName);
1075 if (iter != m_solverInfo.end())
1076 {
1077 return boost::iequals(iter->second, pTrueVal);
1078 }
1079 }
1080 return false;
1081}

References DefinesSolverInfo(), and m_solverInfo.

◆ MatchSolverInfo() [2/2]

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 1049 of file BasicUtils/SessionReader.cpp.

1052{
1053 std::string vName = boost::to_upper_copy(pName);
1054 auto infoIter = m_solverInfo.find(vName);
1055 if (infoIter != m_solverInfo.end())
1056 {
1057 pVar = boost::iequals(infoIter->second, pTrueVal);
1058 }
1059 else
1060 {
1061 pVar = pDefault;
1062 }
1063}

References m_solverInfo.

◆ MatchSolverInfoAsEnum()

template<typename T >
bool Nektar::LibUtilities::SessionReader::MatchSolverInfoAsEnum ( const std::string &  name,
const T &  trueval 
) const
inline

Check if the value of a solver info property matches.

Definition at line 507 of file SessionReader.h.

509{
510 return (GetSolverInfoAsEnum<T>(name) == trueval);
511}

◆ MergeDoc()

TiXmlDocument * Nektar::LibUtilities::SessionReader::MergeDoc ( const std::vector< std::string > &  pFilenames) const
private

Creates an XML document from a list of input files.

Definition at line 1586 of file BasicUtils/SessionReader.cpp.

1588{
1589 ASSERTL0(pFilenames.size() > 0, "No filenames for merging.");
1590
1591 // Read the first document
1592 TiXmlDocument *vMainDoc = new TiXmlDocument;
1593 LoadDoc(pFilenames[0], vMainDoc);
1594
1595 TiXmlHandle vMainHandle(vMainDoc);
1596 TiXmlElement *vMainNektar =
1597 GetChildElementOrThrow(pFilenames[0], "NEKTAR", vMainHandle);
1598
1599 // Read all subsequent XML documents.
1600 // For each element within the NEKTAR tag, use it to replace the
1601 // version already present in the loaded XML data.
1602 for (int i = 1; i < pFilenames.size(); ++i)
1603 {
1604 if ((pFilenames[i].compare(pFilenames[i].size() - 3, 3, "xml") == 0) ||
1605 (pFilenames[i].compare(pFilenames[i].size() - 6, 6, "xml.gz") ==
1606 0) ||
1607 (pFilenames[i].compare(pFilenames[i].size() - 3, 3, "opt") == 0))
1608 {
1609 TiXmlDocument *vTempDoc = new TiXmlDocument;
1610 LoadDoc(pFilenames[i], vTempDoc);
1611
1612 TiXmlHandle docHandle(vTempDoc);
1613 TiXmlElement *vTempNektar =
1614 GetChildElementOrThrow(pFilenames[i], "NEKTAR", docHandle);
1615 TiXmlElement *p = vTempNektar->FirstChildElement();
1616
1617 while (p)
1618 {
1619 TiXmlElement *vMainEntry =
1620 vMainNektar->FirstChildElement(p->Value());
1621
1622 // First check if the new item is in fact blank
1623 // replace if it is a COLLECTIONS section however.
1624 if (!p->FirstChild() && vMainEntry &&
1625 !boost::iequals(p->Value(), "COLLECTIONS"))
1626 {
1627 std::string warningmsg =
1628 "File " + pFilenames[i] + " contains " +
1629 "an empty XML element " + std::string(p->Value()) +
1630 " which will be ignored.";
1631 NEKERROR(ErrorUtil::ewarning, warningmsg.c_str());
1632 }
1633 else
1634 {
1635 if (vMainEntry)
1636 {
1637 vMainNektar->RemoveChild(vMainEntry);
1638 }
1639 TiXmlElement *q = new TiXmlElement(*p);
1640 vMainNektar->LinkEndChild(q);
1641 }
1642 p = p->NextSiblingElement();
1643 }
1644 delete vTempDoc;
1645 }
1646 }
1647 return vMainDoc;
1648}
void LoadDoc(const std::string &pFilename, TiXmlDocument *pDoc) const
Loads an xml file into a tinyxml doc and decompresses if needed.
TiXmlElement * GetChildElementOrThrow(const std::string &filename, std::string elementName, const TiXmlHandle &docHandle)
std::vector< double > q(NPUPPER *NPUPPER)

References ASSERTL0, Nektar::ErrorUtil::ewarning, Nektar::LibUtilities::GetChildElementOrThrow(), LoadDoc(), and NEKERROR.

Referenced by InitSession().

◆ ParseCommandLineArguments()

std::vector< std::string > Nektar::LibUtilities::SessionReader::ParseCommandLineArguments ( int  argc,
char *  argv[] 
)
private

Parse the program arguments and fill m_cmdLineOptions.

Parses the command-line arguments for known options and filenames.

Definition at line 439 of file BasicUtils/SessionReader.cpp.

441{
442 // List the publically visible options (listed using --help).
443 po::options_description desc("Allowed options");
444 po::options_description dep("Deprecated options");
445
446 // clang-format off
447 desc.add_options()
448 ("force-output,f","disables backups files and forces output to be "
449 "written without any checks")
450 ("help,h", "print this help message")
451 ("solverinfo,I", po::value<vector<std::string>>(),
452 "override a SOLVERINFO property")
453 ("parameter,P", po::value<vector<std::string>>(),
454 "override a parameter")
455 ("verbose,v", "be verbose")
456 ("version,V", "print version information")
457 ("no-exp-opt", "Do not use expansion optimisation for collections")
458 ("npx", po::value<int>(),
459 "number of procs in X-dir")
460 ("npy", po::value<int>(),
461 "number of procs in Y-dir")
462 ("npz", po::value<int>(),
463 "number of procs in Z-dir")
464 ("nsz", po::value<int>(),
465 "number of slices in Z-dir")
466 ("npt", po::value<int>(),
467 "number of procs in T-dir (parareal)")
468 ("part-only", po::value<int>(),
469 "only partition mesh into N partitions.")
470 ("part-only-overlapping", po::value<int>(),
471 "only partition mesh into N overlapping partitions.")
472 ("part-info", "output partition information")
473 ("write-opt-file","write an optimisation file")
474 ("use-opt-file", po::value<std::string>(),
475 "use an optimisation file");
476 // clang-format on
477
478#ifdef NEKTAR_USE_CWIPI
479 desc.add_options()("cwipi", po::value<std::string>(), "set CWIPI name");
480#endif
481
482 for (auto &cmdIt : GetCmdLineArgMap())
483 {
484 std::string names = cmdIt.first;
485 if (cmdIt.second.shortName != "")
486 {
487 names += "," + cmdIt.second.shortName;
488 }
489 if (cmdIt.second.isFlag)
490 {
491 desc.add_options()(names.c_str(), cmdIt.second.description.c_str());
492 }
493 else
494 {
495 desc.add_options()(names.c_str(), po::value<std::string>(),
496 cmdIt.second.description.c_str());
497 }
498 }
499
500 // Deprecated options: introduced in 5.4.0 to homogenise command-line
501 // options to use '-' instead of camelCase or no spaces.
502 std::map<std::string, std::string> deprecated = {
503 {"forceoutput", "force-output"},
504 {"writeoptfile", "write-opt-file"},
505 {"useoptfile", "use-opt-file"}};
506
507 for (auto &d : deprecated)
508 {
509 std::string description = "Deprecated: use --" + d.second;
510 dep.add_options()(d.first.c_str(), description.c_str());
511 }
512
513 // List hidden options (e.g. session file arguments are not actually
514 // specified using the input-file option by the user).
515 po::options_description hidden("Hidden options");
516
517 hidden.add_options()("input-file", po::value<vector<string>>(),
518 "input filename");
519
520 // Combine all options for the parser
521 po::options_description all("All options");
522 all.add(desc).add(dep).add(hidden);
523
524 // Session file is a positional option
525 po::positional_options_description p;
526 p.add("input-file", -1);
527
528 // Parse the command-line options
529 po::parsed_options parsed = po::command_line_parser(argc, argv)
530 .options(all)
531 .positional(p)
532 .allow_unregistered()
533 .run();
534
535 // Extract known options to map and update
536 po::store(parsed, m_cmdLineOptions);
537 po::notify(m_cmdLineOptions);
538
539 // Help message
540 if (m_cmdLineOptions.count("help"))
541 {
542 cout << desc;
543 exit(0);
544 }
545
546 // Version information
547 if (m_cmdLineOptions.count("version"))
548 {
549 cout << "Nektar++ version " << NEKTAR_VERSION;
550
551 if (NekConstants::kGitSha1 != "GITDIR-NOTFOUND")
552 {
554 string branch(NekConstants::kGitBranch);
555 boost::replace_all(branch, "refs/heads/", "");
556
557 cout << " (git changeset " << sha1.substr(0, 8) << ", ";
558
559 if (branch == "")
560 {
561 cout << "detached head";
562 }
563 else
564 {
565 cout << "head " << branch;
566 }
567
568 cout << ")";
569 }
570
571 cout << endl;
572 exit(0);
573 }
574
575 // Deal with deprecated options.
576 for (auto &d : deprecated)
577 {
578 if (m_cmdLineOptions.count(d.first))
579 {
580 std::cerr << "Warning: --" << d.first << " deprecated: use --"
581 << d.second << std::endl;
582 m_cmdLineOptions.emplace(
583 d.second, po::variable_value(m_cmdLineOptions[d.first]));
584 }
585 }
586
587 // Enable verbose mode
588 if (m_cmdLineOptions.count("verbose"))
589 {
590 m_verbose = true;
591 }
592 else
593 {
594 m_verbose = false;
595 }
596
597 // Disable backups
598 if (m_cmdLineOptions.count("force-output"))
599 {
600 m_backups = false;
601 }
602 else
603 {
604 m_backups = true;
605 }
606
607 // Enable update optimisation file
608 if (m_cmdLineOptions.count("write-opt-file"))
609 {
610 m_updateOptFile = true;
611 }
612 else
613 {
614 m_updateOptFile = false;
615 }
616
617 // Print a warning for unknown options
618 for (auto &x : parsed.options)
619 {
620 if (x.unregistered)
621 {
622 cout << "Warning: Unknown option: " << x.string_key << endl;
623 }
624 }
625
626 // Return the vector of filename(s) given as positional options
627 if (m_cmdLineOptions.count("input-file"))
628 {
629 return m_cmdLineOptions["input-file"].as<std::vector<std::string>>();
630 }
631 else
632 {
633 return std::vector<std::string>();
634 }
635}
#define NEKTAR_VERSION
static CmdLineArgMap & GetCmdLineArgMap()
CmdLine argument map.
const std::string kGitBranch
Definition GitRevision.h:46
const std::string kGitSha1
Definition GitRevision.h:45
std::vector< double > d(NPUPPER *NPUPPER)
Definition sha1.cpp:72

References GetCmdLineArgMap(), Nektar::NekConstants::kGitBranch, Nektar::NekConstants::kGitSha1, m_backups, m_cmdLineOptions, m_updateOptFile, m_verbose, and NEKTAR_VERSION.

Referenced by SessionReader(), and SessionReader().

◆ ParseDocument()

void Nektar::LibUtilities::SessionReader::ParseDocument ( )
private

Loads and parses the specified file.

Definition at line 1653 of file BasicUtils/SessionReader.cpp.

1654{
1655 // Check we actually have a document loaded.
1656 ASSERTL0(m_xmlDoc, "No XML document loaded.");
1657
1658 TiXmlHandle docHandle(m_xmlDoc);
1659 TiXmlElement *e;
1660
1661 // Look for all data in CONDITIONS block.
1662 e = docHandle.FirstChildElement("NEKTAR")
1663 .FirstChildElement("CONDITIONS")
1664 .Element();
1665
1666 // Read the various sections of the CONDITIONS block
1667 ReadParameters(e);
1668 ReadSolverInfo(e);
1671 ReadVariables(e);
1672 ReadFunctions(e);
1673
1674 // Look for all data in FILTERS block.
1675 e = docHandle.FirstChildElement("NEKTAR")
1676 .FirstChildElement("FILTERS")
1677 .Element();
1678
1679 // Read the various sections of the FILTERS block
1680 ReadFilters(e);
1681}
void ReadSolverInfo(TiXmlElement *conditions)
Reads the SOLVERINFO section of the XML document.
void ReadVariables(TiXmlElement *conditions)
Reads the VARIABLES section of the 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.
void ReadFunctions(TiXmlElement *conditions)
Reads the FUNCTIONS section of the XML document.
void ReadParameters(TiXmlElement *conditions)
Reads the PARAMETERS section of the XML document.

References ASSERTL0, m_xmlDoc, ReadFilters(), ReadFunctions(), ReadGlobalSysSolnInfo(), ReadParameters(), ReadSolverInfo(), ReadTimeIntScheme(), and ReadVariables().

Referenced by InitSession().

◆ ParseEquals()

void Nektar::LibUtilities::SessionReader::ParseEquals ( const std::string &  line,
std::string &  lhs,
std::string &  rhs 
)
private

Parse a string in the form lhs = rhs.

Pull out lhs and rhs and eliminate any spaces.

Definition at line 2536 of file BasicUtils/SessionReader.cpp.

2538{
2539 /// Pull out lhs and rhs and eliminate any spaces.
2540 size_t beg = line.find_first_not_of(" ");
2541 size_t end = line.find_first_of("=");
2542 // Check for no parameter name
2543 if (beg == end)
2544 {
2545 throw 1;
2546 }
2547 // Check for no parameter value
2548 if (end != line.find_last_of("="))
2549 {
2550 throw 1;
2551 }
2552 // Check for no equals sign
2553 if (end == std::string::npos)
2554 {
2555 throw 1;
2556 }
2557
2558 lhs = line.substr(line.find_first_not_of(" "), end - beg);
2559 lhs = lhs.substr(0, lhs.find_last_not_of(" ") + 1);
2560 rhs = line.substr(line.find_last_of("=") + 1);
2561 rhs = rhs.substr(rhs.find_first_not_of(" "));
2562 rhs = rhs.substr(0, rhs.find_last_not_of(" ") + 1);
2563}

Referenced by CmdLineOverride(), and ReadParameters().

◆ ParseSessionName()

std::string Nektar::LibUtilities::SessionReader::ParseSessionName ( std::vector< std::string > &  filenames)
private

Parse the session name.

Definition at line 640 of file BasicUtils/SessionReader.cpp.

641{
642 ASSERTL0(!filenames.empty(), "At least one filename expected.");
643
644 std::string retval = "";
645
646 // First input file defines the session name
647 std::string fname = filenames[0];
648
649 // If loading a pre-partitioned mesh, remove _xml extension
650 if (fname.size() > 4 && fname.substr(fname.size() - 4, 4) == "_xml")
651 {
652 retval = fname.substr(0, fname.find_last_of("_"));
653 }
654 // otherwise remove the .xml extension
655 else if (fname.size() > 4 && fname.substr(fname.size() - 4, 4) == ".xml")
656 {
657 retval = fname.substr(0, fname.find_last_of("."));
658 }
659 // If compressed .xml.gz, remove both extensions
660 else if (fname.size() > 7 && fname.substr(fname.size() - 7, 7) == ".xml.gz")
661 {
662 retval = fname.substr(0, fname.find_last_of("."));
663 retval = retval.substr(0, retval.find_last_of("."));
664 }
665
666 return retval;
667}

References ASSERTL0.

Referenced by SessionReader(), and SessionReader().

◆ PartitionComm()

void Nektar::LibUtilities::SessionReader::PartitionComm ( )
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.

Definition at line 1713 of file BasicUtils/SessionReader.cpp.

1714{
1715 if (m_comm->GetSize() > 1)
1716 {
1717 int nProcZ = 1;
1718 int nProcY = 1;
1719 int nProcX = 1;
1720 int nStripZ = 1;
1721 int nTime = 0;
1722 if (DefinesCmdLineArgument("npx"))
1723 {
1724 nProcX = GetCmdLineArgument<int>("npx");
1725 }
1726 if (DefinesCmdLineArgument("npy"))
1727 {
1728 nProcY = GetCmdLineArgument<int>("npy");
1729 }
1730 if (DefinesCmdLineArgument("npz"))
1731 {
1732 nProcZ = GetCmdLineArgument<int>("npz");
1733 }
1734 if (DefinesCmdLineArgument("nsz"))
1735 {
1736 nStripZ = GetCmdLineArgument<int>("nsz");
1737 }
1738 if (DefinesCmdLineArgument("npt"))
1739 {
1740 nTime = GetCmdLineArgument<int>("npt");
1741 }
1742
1743 if (nTime)
1744 {
1745 ASSERTL0(m_comm->GetSize() % nTime == 0,
1746 "Cannot exactly partition time using npt value.");
1747 ASSERTL0((m_comm->GetSize() / nTime) % (nProcZ * nProcY * nProcX) ==
1748 0,
1749 "Cannot exactly partition using PROC_Z value.");
1750 ASSERTL0(nProcZ % nProcY == 0,
1751 "Cannot exactly partition using PROC_Y value.");
1752 ASSERTL0(nProcY % nProcX == 0,
1753 "Cannot exactly partition using PROC_X value.");
1754 }
1755 else
1756 {
1757 ASSERTL0(m_comm->GetSize() % (nProcZ * nProcY * nProcX) == 0,
1758 "Cannot exactly partition using PROC_Z value.");
1759 ASSERTL0(nProcZ % nProcY == 0,
1760 "Cannot exactly partition using PROC_Y value.");
1761 ASSERTL0(nProcY % nProcX == 0,
1762 "Cannot exactly partition using PROC_X value.");
1763 }
1764
1765 // Number of processes associated with the spectral method
1766 int nProcSm = nProcZ * nProcY * nProcX;
1767
1768 // Number of processes associated with the spectral element
1769 // method.
1770 int nProcSem = nTime ? m_comm->GetSize() / nTime / nProcSm
1771 : m_comm->GetSize() / nProcSm;
1772
1773 m_comm->SplitComm(nProcSm, nProcSem, nTime);
1774 m_comm->GetColumnComm()->SplitComm(nProcZ / nStripZ, nStripZ);
1775 m_comm->GetColumnComm()->GetColumnComm()->SplitComm((nProcY * nProcX),
1776 nProcZ / nStripZ);
1777 m_comm->GetColumnComm()->GetColumnComm()->GetColumnComm()->SplitComm(
1778 nProcX, nProcY);
1779 }
1780}

References ASSERTL0, DefinesCmdLineArgument(), and m_comm.

Referenced by SessionReader(), and SessionReader().

◆ ReadFilters()

void Nektar::LibUtilities::SessionReader::ReadFilters ( TiXmlElement *  filters)
private

Reads the FILTERS section of the XML document.

Definition at line 2477 of file BasicUtils/SessionReader.cpp.

2478{
2479 if (!filters)
2480 {
2481 return;
2482 }
2483
2484 m_filters.clear();
2485
2486 TiXmlElement *filter = filters->FirstChildElement("FILTER");
2487
2488 while (filter)
2489 {
2490 ASSERTL0(filter->Attribute("TYPE"),
2491 "Missing attribute 'TYPE' for filter.");
2492 std::string typeStr = filter->Attribute("TYPE");
2493
2494 int domainID = -1;
2495 if (filter->Attribute("DOMAIN"))
2496 {
2497 // domainID = int(filter->Attribute("DOMAIN"));
2498 int err = filter->QueryIntAttribute("DOMAIN", &domainID);
2499 ASSERTL0(err == TIXML_SUCCESS,
2500 "Unable to read attribute DOMAIN in filter.");
2501 }
2502
2503 std::map<std::string, std::string> vParams;
2504
2505 TiXmlElement *element = filter;
2506 GetXMLElementTimeLevel(element, m_timeLevel, false);
2507 TiXmlElement *param = element->FirstChildElement("PARAM");
2508 while (param)
2509 {
2510 ASSERTL0(param->Attribute("NAME"),
2511 "Missing attribute 'NAME' for parameter in filter " +
2512 typeStr + "'.");
2513 std::string nameStr = param->Attribute("NAME");
2514
2515 ASSERTL0(param->GetText(), "Empty value string for param.");
2516 std::string valueStr = param->GetText();
2517
2518 vParams[nameStr] = valueStr;
2519
2520 param = param->NextSiblingElement("PARAM");
2521 }
2522
2523 FilterDefinition filterDef;
2524 filterDef.domain = domainID;
2525 filterDef.name = typeStr;
2526 filterDef.params = vParams;
2527 m_filters.push_back(filterDef);
2528
2529 filter = filter->NextSiblingElement("FILTER");
2530 }
2531}
static void GetXMLElementTimeLevel(TiXmlElement *&element, const size_t timeLevel, const bool enableCheck=true)
Get XML elment time level (Parallel-in-Time)

References ASSERTL0, Nektar::LibUtilities::FilterDefinition::domain, GetXMLElementTimeLevel(), m_filters, m_timeLevel, Nektar::LibUtilities::FilterDefinition::name, and Nektar::LibUtilities::FilterDefinition::params.

Referenced by ParseDocument().

◆ ReadFunctions()

void Nektar::LibUtilities::SessionReader::ReadFunctions ( TiXmlElement *  conditions)
private

Reads the FUNCTIONS section of the XML document.

Definition at line 2252 of file BasicUtils/SessionReader.cpp.

2253{
2254 m_functions.clear();
2255
2256 if (!conditions)
2257 {
2258 return;
2259 }
2260
2261 // Scan through conditions section looking for functions.
2262 TiXmlElement *function = conditions->FirstChildElement("FUNCTION");
2263
2264 while (function)
2265 {
2266 stringstream tagcontent;
2267 tagcontent << *function;
2268
2269 // Every function must have a NAME attribute
2270 ASSERTL0(function->Attribute("NAME"),
2271 "Functions must have a NAME attribute defined in XML "
2272 "element: \n\t'" +
2273 tagcontent.str() + "'");
2274 std::string functionStr = function->Attribute("NAME");
2275 ASSERTL0(!functionStr.empty(),
2276 "Functions must have a non-empty name in XML "
2277 "element: \n\t'" +
2278 tagcontent.str() + "'");
2279
2280 // Store function names in uppercase to remain case-insensitive.
2281 boost::to_upper(functionStr);
2282
2283 // Retrieve first entry (variable, or file)
2284 TiXmlElement *element = function;
2285 GetXMLElementTimeLevel(element, m_timeLevel, false);
2286 TiXmlElement *variable = element->FirstChildElement();
2287
2288 // Create new function structure with default type of none.
2289 FunctionVariableMap functionVarMap;
2290
2291 // Process all entries in the function block
2292 while (variable)
2293 {
2294 FunctionVariableDefinition funcDef;
2295 std::string conditionType = variable->Value();
2296
2297 // If no var is specified, assume wildcard
2298 std::string variableStr;
2299 if (!variable->Attribute("VAR"))
2300 {
2301 variableStr = "*";
2302 }
2303 else
2304 {
2305 variableStr = variable->Attribute("VAR");
2306 }
2307
2308 // Parse list of variables
2309 std::vector<std::string> variableList;
2310 ParseUtils::GenerateVector(variableStr, variableList);
2311
2312 // If no domain is specified, put to 0
2313 std::string domainStr;
2314 if (!variable->Attribute("DOMAIN"))
2315 {
2316 domainStr = "0";
2317 }
2318 else
2319 {
2320 domainStr = variable->Attribute("DOMAIN");
2321 }
2322
2323 // Parse list of domains
2324 std::vector<std::string> varSplit;
2325 std::vector<unsigned int> domainList;
2326 ParseUtils::GenerateSeqVector(domainStr, domainList);
2327
2328 // if no evars is specified, put "x y z t"
2329 std::string evarsStr = "x y z t";
2330 if (variable->Attribute("EVARS"))
2331 {
2332 evarsStr =
2333 evarsStr + std::string(" ") + variable->Attribute("EVARS");
2334 }
2335
2336 // Expressions are denoted by E
2337 if (conditionType == "E")
2338 {
2339 funcDef.m_type = eFunctionTypeExpression;
2340
2341 // Expression must have a VALUE.
2342 ASSERTL0(variable->Attribute("VALUE"),
2343 "Attribute VALUE expected for function '" +
2344 functionStr + "'.");
2345 std::string fcnStr = variable->Attribute("VALUE");
2346 ASSERTL0(!fcnStr.empty(),
2347 (std::string("Expression for var: ") + variableStr +
2348 std::string(" must be specified."))
2349 .c_str());
2350
2351 // set expression
2352 funcDef.m_expression =
2354 m_interpreter, fcnStr, evarsStr);
2355 }
2356
2357 // Files are denoted by F
2358 else if (conditionType == "F")
2359 {
2360 // Check if transient or not
2361 if (variable->Attribute("TIMEDEPENDENT") &&
2362 boost::lexical_cast<bool>(
2363 variable->Attribute("TIMEDEPENDENT")))
2364 {
2365 funcDef.m_type = eFunctionTypeTransientFile;
2366 }
2367 else
2368 {
2369 funcDef.m_type = eFunctionTypeFile;
2370 }
2371
2372 // File must have a FILE.
2373 ASSERTL0(variable->Attribute("FILE"),
2374 "Attribute FILE expected for function '" +
2375 functionStr + "'.");
2376 std::string filenameStr = variable->Attribute("FILE");
2377 ASSERTL0(!filenameStr.empty(),
2378 "A filename must be specified for the FILE "
2379 "attribute of function '" +
2380 functionStr + "'.");
2381
2382 std::vector<std::string> fSplit;
2383 boost::split(fSplit, filenameStr, boost::is_any_of(":"));
2384 ASSERTL0(fSplit.size() == 1 || fSplit.size() == 2,
2385 "Incorrect filename specification in function " +
2386 functionStr +
2387 "'. "
2388 "Specify variables inside file as: "
2389 "filename:var1,var2");
2390
2391 // set the filename
2392 fs::path fullpath = fSplit[0];
2393 fs::path ftype = fullpath.extension();
2394 if (fullpath.parent_path().extension() == ".pit")
2395 {
2396 string filename = fullpath.stem().string();
2397 fullpath = fullpath.parent_path();
2398 size_t start = filename.find_last_of("_") + 1;
2399 int index =
2400 atoi(filename.substr(start, filename.size()).c_str());
2401 fullpath /= filename.substr(0, start) +
2402 std::to_string(
2403 index + m_comm->GetTimeComm()->GetRank()) +
2404 ftype.string();
2405 }
2406 funcDef.m_filename = fullpath.string();
2407
2408 if (fSplit.size() == 2)
2409 {
2410 ASSERTL0(variableList[0] != "*",
2411 "Filename variable mapping not valid "
2412 "when using * as a variable inside "
2413 "function '" +
2414 functionStr + "'.");
2415
2416 boost::split(varSplit, fSplit[1], boost::is_any_of(","));
2417 ASSERTL0(varSplit.size() == variableList.size(),
2418 "Filename variables should contain the "
2419 "same number of variables defined in "
2420 "VAR in function " +
2421 functionStr + "'.");
2422 }
2423 }
2424
2425 // Nothing else supported so throw an error
2426 else
2427 {
2428 stringstream tagcontent;
2429 tagcontent << *variable;
2430
2432 "Identifier " + conditionType + " in function " +
2433 std::string(function->Attribute("NAME")) +
2434 " is not recognised in XML element: \n\t'" +
2435 tagcontent.str() + "'");
2436 }
2437
2438 // Add variables to function
2439 for (unsigned int i = 0; i < variableList.size(); ++i)
2440 {
2441 for (unsigned int j = 0; j < domainList.size(); ++j)
2442 {
2443 // Check it has not already been defined
2444 pair<std::string, int> key(variableList[i], domainList[j]);
2445 auto fcnsIter = functionVarMap.find(key);
2446 ASSERTL0(fcnsIter == functionVarMap.end(),
2447 "Error setting expression '" + variableList[i] +
2448 " in domain " + std::to_string(domainList[j]) +
2449 "' in function '" + functionStr +
2450 "'. "
2451 "Expression has already been defined.");
2452
2453 if (varSplit.size() > 0)
2454 {
2455 FunctionVariableDefinition funcDef2 = funcDef;
2456 funcDef2.m_fileVariable = varSplit[i];
2457 functionVarMap[key] = funcDef2;
2458 }
2459 else
2460 {
2461 functionVarMap[key] = funcDef;
2462 }
2463 }
2464 }
2465 variable = variable->NextSiblingElement();
2466 }
2467
2468 // Add function definition to map
2469 m_functions[functionStr] = functionVarMap;
2470 function = function->NextSiblingElement("FUNCTION");
2471 }
2472}
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
static bool GenerateSeqVector(const std::string &str, std::vector< unsigned int > &out)
Takes a comma-separated compressed string and converts it to entries in a vector.
std::map< std::pair< std::string, int >, FunctionVariableDefinition > FunctionVariableMap

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().

◆ ReadGlobalSysSolnInfo()

void Nektar::LibUtilities::SessionReader::ReadGlobalSysSolnInfo ( TiXmlElement *  conditions)
private

Reads the GLOBALSYSSOLNINFO section of the XML document.

Definition at line 1943 of file BasicUtils/SessionReader.cpp.

1944{
1945 GetGloSysSolnList().clear();
1946
1947 if (!conditions)
1948 {
1949 return;
1950 }
1951
1952 TiXmlElement *GlobalSys =
1953 conditions->FirstChildElement("GLOBALSYSSOLNINFO");
1955
1956 if (!GlobalSys)
1957 {
1958 return;
1959 }
1960
1961 TiXmlElement *VarInfo = GlobalSys->FirstChildElement("V");
1962
1963 while (VarInfo)
1964 {
1965 std::stringstream tagcontent;
1966 tagcontent << *VarInfo;
1967
1968 ASSERTL0(VarInfo->Attribute("VAR"),
1969 "Missing VAR attribute in GobalSysSolnInfo XML "
1970 "element: \n\t'" +
1971 tagcontent.str() + "'");
1972 std::string VarList = VarInfo->Attribute("VAR");
1973 ASSERTL0(!VarList.empty(),
1974 "VAR attribute must be non-empty in XML element:\n\t'" +
1975 tagcontent.str() + "'");
1976
1977 // generate a list of variables.
1978 std::vector<std::string> varStrings;
1979 bool valid = ParseUtils::GenerateVector(VarList, varStrings);
1980
1981 ASSERTL0(valid, "Unable to process list of variable in XML "
1982 "element \n\t'" +
1983 tagcontent.str() + "'");
1984
1985 if (varStrings.size())
1986 {
1987 TiXmlElement *SysSolnInfo = VarInfo->FirstChildElement("I");
1988
1989 while (SysSolnInfo)
1990 {
1991 tagcontent.clear();
1992 tagcontent << *SysSolnInfo;
1993 // read the property name
1994 ASSERTL0(SysSolnInfo->Attribute("PROPERTY"),
1995 "Missing PROPERTY attribute in "
1996 "GlobalSysSolnInfo for variable(s) '" +
1997 VarList + "' in XML element: \n\t'" +
1998 tagcontent.str() + "'");
1999 std::string SysSolnProperty =
2000 SysSolnInfo->Attribute("PROPERTY");
2001 ASSERTL0(!SysSolnProperty.empty(),
2002 "GlobalSysSolnIno properties must have a "
2003 "non-empty name for variable(s) : '" +
2004 VarList + "' in XML element: \n\t'" +
2005 tagcontent.str() + "'");
2006
2007 // make sure that solver property is capitalised
2008 std::string SysSolnPropertyUpper =
2009 boost::to_upper_copy(SysSolnProperty);
2010
2011 // read the value
2012 ASSERTL0(SysSolnInfo->Attribute("VALUE"),
2013 "Missing VALUE attribute in GlobalSysSolnInfo "
2014 "for variable(s) '" +
2015 VarList + "' in XML element: \n\t" +
2016 tagcontent.str() + "'");
2017 std::string SysSolnValue = SysSolnInfo->Attribute("VALUE");
2018 ASSERTL0(!SysSolnValue.empty(),
2019 "GlobalSysSolnInfo properties must have a "
2020 "non-empty value for variable(s) '" +
2021 VarList + "' in XML element: \n\t'" +
2022 tagcontent.str() + "'");
2023
2024 // Store values under variable map.
2025 for (int i = 0; i < varStrings.size(); ++i)
2026 {
2027 auto x = GetGloSysSolnList().find(varStrings[i]);
2028 if (x == GetGloSysSolnList().end())
2029 {
2030 (GetGloSysSolnList()[varStrings[i]])
2031 [SysSolnPropertyUpper] = SysSolnValue;
2032 }
2033 else
2034 {
2035 x->second[SysSolnPropertyUpper] = SysSolnValue;
2036 }
2037 }
2038 SysSolnInfo = SysSolnInfo->NextSiblingElement("I");
2039 }
2040 VarInfo = VarInfo->NextSiblingElement("V");
2041 }
2042 }
2043
2044 if (m_verbose && GetGloSysSolnList().size() > 0 && m_comm)
2045 {
2046 if (m_comm->GetRank() == 0)
2047 {
2048 cout << "GlobalSysSoln Info:" << endl;
2049
2050 for (auto &x : GetGloSysSolnList())
2051 {
2052 cout << "\t Variable: " << x.first << endl;
2053
2054 for (auto &y : x.second)
2055 {
2056 cout << "\t\t " << y.first << " = " << y.second << endl;
2057 }
2058 }
2059 cout << endl;
2060 }
2061 }
2062}

References ASSERTL0, Nektar::ParseUtils::GenerateVector(), GetGloSysSolnList(), GetXMLElementTimeLevel(), m_comm, m_timeLevel, and m_verbose.

Referenced by ParseDocument().

◆ ReadParameters()

void Nektar::LibUtilities::SessionReader::ReadParameters ( TiXmlElement *  conditions)
private

Reads the PARAMETERS section of the XML document.

Definition at line 1785 of file BasicUtils/SessionReader.cpp.

1786{
1787 m_parameters.clear();
1788
1789 if (!conditions)
1790 {
1791 return;
1792 }
1793
1794 TiXmlElement *parametersElement =
1795 conditions->FirstChildElement("PARAMETERS");
1796 GetXMLElementTimeLevel(parametersElement, m_timeLevel);
1797
1798 // See if we have parameters defined. They are optional so we go on
1799 // if not.
1800 if (parametersElement)
1801 {
1802 TiXmlElement *parameter = parametersElement->FirstChildElement("P");
1803
1804 ParameterMap caseSensitiveParameters;
1805
1806 // Multiple nodes will only occur if there is a comment in
1807 // between definitions.
1808 while (parameter)
1809 {
1810 stringstream tagcontent;
1811 tagcontent << *parameter;
1812 TiXmlNode *node = parameter->FirstChild();
1813
1814 while (node && node->Type() != TiXmlNode::TINYXML_TEXT)
1815 {
1816 node = node->NextSibling();
1817 }
1818
1819 if (node)
1820 {
1821 // Format is "paramName = value"
1822 std::string line = node->ToText()->Value(), lhs, rhs;
1823
1824 try
1825 {
1826 ParseEquals(line, lhs, rhs);
1827 }
1828 catch (...)
1829 {
1831 "Syntax error in parameter expression '" + line +
1832 "' in XML element: \n\t'" + tagcontent.str() +
1833 "'");
1834 }
1835
1836 // We want the list of parameters to have their RHS
1837 // evaluated, so we use the expression evaluator to do
1838 // the dirty work.
1839 if (!lhs.empty() && !rhs.empty())
1840 {
1841 NekDouble value = 0.0;
1842 try
1843 {
1844 LibUtilities::Equation expession(m_interpreter, rhs);
1845 value = expession.Evaluate();
1846 }
1847 catch (const std::runtime_error &)
1848 {
1850 "Error evaluating parameter expression"
1851 " '" +
1852 rhs + "' in XML element: \n\t'" +
1853 tagcontent.str() + "'");
1854 }
1855 m_interpreter->SetParameter(lhs, value);
1856 caseSensitiveParameters[lhs] = value;
1857 boost::to_upper(lhs);
1858 m_parameters[lhs] = value;
1859 }
1860 }
1861 parameter = parameter->NextSiblingElement();
1862 }
1863 }
1864}
std::map< std::string, NekDouble > ParameterMap

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Equation::Evaluate(), GetXMLElementTimeLevel(), m_interpreter, m_parameters, m_timeLevel, NEKERROR, and ParseEquals().

Referenced by ParseDocument().

◆ ReadSolverInfo()

void Nektar::LibUtilities::SessionReader::ReadSolverInfo ( TiXmlElement *  conditions)
private

Reads the SOLVERINFO section of the XML document.

Definition at line 1869 of file BasicUtils/SessionReader.cpp.

1870{
1871 m_solverInfo.clear();
1873
1874 if (!conditions)
1875 {
1876 return;
1877 }
1878
1879 TiXmlElement *solverInfoElement =
1880 conditions->FirstChildElement("SOLVERINFO");
1881 GetXMLElementTimeLevel(solverInfoElement, m_timeLevel);
1882
1883 if (solverInfoElement)
1884 {
1885 TiXmlElement *solverInfo = solverInfoElement->FirstChildElement("I");
1886
1887 while (solverInfo)
1888 {
1889 std::stringstream tagcontent;
1890 tagcontent << *solverInfo;
1891 // read the property name
1892 ASSERTL0(solverInfo->Attribute("PROPERTY"),
1893 "Missing PROPERTY attribute in solver info "
1894 "XML element: \n\t'" +
1895 tagcontent.str() + "'");
1896 std::string solverProperty = solverInfo->Attribute("PROPERTY");
1897 ASSERTL0(!solverProperty.empty(),
1898 "PROPERTY attribute must be non-empty in XML "
1899 "element: \n\t'" +
1900 tagcontent.str() + "'");
1901
1902 // make sure that solver property is capitalised
1903 std::string solverPropertyUpper =
1904 boost::to_upper_copy(solverProperty);
1905
1906 // read the value
1907 ASSERTL0(solverInfo->Attribute("VALUE"),
1908 "Missing VALUE attribute in solver info "
1909 "XML element: \n\t'" +
1910 tagcontent.str() + "'");
1911 std::string solverValue = solverInfo->Attribute("VALUE");
1912 ASSERTL0(!solverValue.empty(),
1913 "VALUE attribute must be non-empty in XML "
1914 "element: \n\t'" +
1915 tagcontent.str() + "'");
1916
1917 // Set Variable
1918 m_solverInfo[solverPropertyUpper] = solverValue;
1919 solverInfo = solverInfo->NextSiblingElement("I");
1920 }
1921 }
1922
1923 if (m_comm && m_comm->GetRowComm()->GetSize() > 1)
1924 {
1925 ASSERTL0(
1926 m_solverInfo["GLOBALSYSSOLN"] == "IterativeFull" ||
1927 m_solverInfo["GLOBALSYSSOLN"] == "IterativeStaticCond" ||
1928 m_solverInfo["GLOBALSYSSOLN"] ==
1929 "IterativeMultiLevelStaticCond" ||
1930 m_solverInfo["GLOBALSYSSOLN"] == "XxtFull" ||
1931 m_solverInfo["GLOBALSYSSOLN"] == "XxtStaticCond" ||
1932 m_solverInfo["GLOBALSYSSOLN"] == "XxtMultiLevelStaticCond" ||
1933 m_solverInfo["GLOBALSYSSOLN"] == "PETScFull" ||
1934 m_solverInfo["GLOBALSYSSOLN"] == "PETScStaticCond" ||
1935 m_solverInfo["GLOBALSYSSOLN"] == "PETScMultiLevelStaticCond",
1936 "A parallel solver must be used when run in parallel.");
1937 }
1938}

References ASSERTL0, GetSolverInfoDefaults(), GetXMLElementTimeLevel(), m_comm, m_solverInfo, and m_timeLevel.

Referenced by ParseDocument().

◆ ReadTimeIntScheme()

void Nektar::LibUtilities::SessionReader::ReadTimeIntScheme ( TiXmlElement *  conditions)
private

Reads the TIMEINTEGRATIONSCHEME section of the XML document.

Read the time-integration scheme structure, if present.

Definition at line 2067 of file BasicUtils/SessionReader.cpp.

2068{
2069 if (!conditions)
2070 {
2071 return;
2072 }
2073
2074 TiXmlElement *timeInt =
2075 conditions->FirstChildElement("TIMEINTEGRATIONSCHEME");
2077
2078 if (!timeInt)
2079 {
2080 return;
2081 }
2082
2083 TiXmlElement *method = timeInt->FirstChildElement("METHOD");
2084 TiXmlElement *variant = timeInt->FirstChildElement("VARIANT");
2085 TiXmlElement *order = timeInt->FirstChildElement("ORDER");
2086 TiXmlElement *params = timeInt->FirstChildElement("FREEPARAMETERS");
2087
2088 // Only the method and order are required.
2089 ASSERTL0(method, "Missing METHOD tag inside "
2090 "TIMEINTEGRATIONSCHEME.");
2091 ASSERTL0(order, "Missing ORDER tag inside "
2092 "TIMEINTEGRATIONSCHEME.");
2093
2094 m_timeIntScheme.method = method->GetText();
2095
2096 std::string orderStr = order->GetText();
2097
2098 // Only the method and order are required.
2099 ASSERTL0(m_timeIntScheme.method.size() > 0,
2100 "Empty text inside METHOD tag in TIMEINTEGRATIONSCHEME.");
2101 ASSERTL0(orderStr.size() > 0,
2102 "Empty text inside ORDER tag in TIMEINTEGRATIONSCHEME.");
2103 try
2104 {
2105 m_timeIntScheme.order = std::stol(orderStr);
2106 }
2107 catch (...)
2108 {
2109 NEKERROR(ErrorUtil::efatal, "In ORDER tag, unable to convert "
2110 "string '" +
2111 orderStr + "' to an unsigned integer.");
2112 }
2113
2114 if (variant)
2115 {
2116 m_timeIntScheme.variant = variant->GetText();
2117 }
2118
2119 if (params)
2120 {
2121 std::string paramsStr = params->GetText();
2122 ASSERTL0(paramsStr.size() > 0,
2123 "Empty text inside FREEPARAMETERS tag in "
2124 "TIMEINTEGRATIONSCHEME.");
2125
2126 std::vector<std::string> pSplit;
2127 boost::split(pSplit, paramsStr, boost::is_any_of(" "));
2128
2129 m_timeIntScheme.freeParams.resize(pSplit.size());
2130 for (size_t i = 0; i < pSplit.size(); ++i)
2131 {
2132 try
2133 {
2134 m_timeIntScheme.freeParams[i] = std::stod(pSplit[i]);
2135 }
2136 catch (...)
2137 {
2138 NEKERROR(ErrorUtil::efatal, "In FREEPARAMETERS tag, "
2139 "unable to convert string '" +
2140 pSplit[i] +
2141 "' "
2142 "to a floating-point value.");
2143 }
2144 }
2145 }
2146
2147 if (m_verbose && m_comm)
2148 {
2149 if (m_comm->GetRank() == 0)
2150 {
2151 cout << "Trying to use time integration scheme:" << endl;
2152 cout << "\t Method : " << m_timeIntScheme.method << endl;
2153 cout << "\t Variant: " << m_timeIntScheme.variant << endl;
2154 cout << "\t Order : " << m_timeIntScheme.order << endl;
2155
2156 if (m_timeIntScheme.freeParams.size() > 0)
2157 {
2158 cout << "\t Params :";
2159 for (auto &x : m_timeIntScheme.freeParams)
2160 {
2161 cout << " " << x;
2162 }
2163 cout << endl;
2164 }
2165 }
2166 }
2167}
std::vector< NekDouble > freeParams

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().

◆ ReadVariables()

void Nektar::LibUtilities::SessionReader::ReadVariables ( TiXmlElement *  conditions)
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 2172 of file BasicUtils/SessionReader.cpp.

2173{
2174 m_variables.clear();
2175
2176 if (!conditions)
2177 {
2178 return;
2179 }
2180
2181 TiXmlElement *variablesElement = conditions->FirstChildElement("VARIABLES");
2182 GetXMLElementTimeLevel(variablesElement, m_timeLevel);
2183
2184 // See if we have parameters defined. They are optional so we go on
2185 // if not.
2186 if (variablesElement)
2187 {
2188 TiXmlElement *varElement = variablesElement->FirstChildElement("V");
2189
2190 // Sequential counter for the composite numbers.
2191 int nextVariableNumber = -1;
2192
2193 while (varElement)
2194 {
2195 stringstream tagcontent;
2196 tagcontent << *varElement;
2197
2198 /// All elements are of the form: "<V ID="#"> name = value
2199 /// </V>", with ? being the element type.
2200 nextVariableNumber++;
2201
2202 int i;
2203 int err = varElement->QueryIntAttribute("ID", &i);
2204 ASSERTL0(err == TIXML_SUCCESS,
2205 "Variables must have a unique ID number attribute "
2206 "in XML element: \n\t'" +
2207 tagcontent.str() + "'");
2208 ASSERTL0(i == nextVariableNumber,
2209 "ID numbers for variables must begin with zero and"
2210 " be sequential in XML element: \n\t'" +
2211 tagcontent.str() + "'");
2212
2213 TiXmlNode *varChild = varElement->FirstChild();
2214 // This is primarily to skip comments that may be present.
2215 // Comments appear as nodes just like elements. We are
2216 // specifically looking for text in the body of the
2217 // definition.
2218 while (varChild && varChild->Type() != TiXmlNode::TINYXML_TEXT)
2219 {
2220 varChild = varChild->NextSibling();
2221 }
2222
2223 ASSERTL0(varChild, "Unable to read variable definition body for "
2224 "variable with ID " +
2225 std::to_string(i) +
2226 " in XML element: \n\t'" + tagcontent.str() +
2227 "'");
2228 std::string variableName = varChild->ToText()->ValueStr();
2229
2230 std::istringstream variableStrm(variableName);
2231 variableStrm >> variableName;
2232
2233 ASSERTL0(std::find(m_variables.begin(), m_variables.end(),
2234 variableName) == m_variables.end(),
2235 "Variable with ID " + std::to_string(i) +
2236 " in XML element \n\t'" + tagcontent.str() +
2237 "'\nhas already been defined.");
2238
2239 m_variables.push_back(variableName);
2240
2241 varElement = varElement->NextSiblingElement("V");
2242 }
2243
2244 ASSERTL0(nextVariableNumber > -1,
2245 "Number of variables must be greater than zero.");
2246 }
2247}

References ASSERTL0, GetXMLElementTimeLevel(), m_timeLevel, and m_variables.

Referenced by ParseDocument().

◆ RegisterCmdLineArgument()

std::string Nektar::LibUtilities::SessionReader::RegisterCmdLineArgument ( const std::string &  pName,
const std::string &  pShortName,
const std::string &  pDescription 
)
inlinestatic

Registers a command-line argument with the session reader.

Definition at line 625 of file SessionReader.h.

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}

References ASSERTL0, Nektar::LibUtilities::CmdLineArg::description, GetCmdLineArgMap(), Nektar::LibUtilities::CmdLineArg::isFlag, and Nektar::LibUtilities::CmdLineArg::shortName.

◆ RegisterCmdLineFlag()

std::string Nektar::LibUtilities::SessionReader::RegisterCmdLineFlag ( const std::string &  pName,
const std::string &  pShortName,
const std::string &  pDescription 
)
inlinestatic

Registers a command-line flag with the session reader.

Definition at line 641 of file SessionReader.h.

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}

References ASSERTL0, Nektar::LibUtilities::CmdLineArg::description, GetCmdLineArgMap(), Nektar::LibUtilities::CmdLineArg::isFlag, and Nektar::LibUtilities::CmdLineArg::shortName.

◆ RegisterDefaultSolverInfo()

std::string Nektar::LibUtilities::SessionReader::RegisterDefaultSolverInfo ( const std::string &  pName,
const std::string &  pValue 
)
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:

std::string GlobalLinSys::def
"GlobalSysSoln","DirectMultiLevelStaticCond");
static std::string RegisterDefaultSolverInfo(const std::string &pName, const std::string &pValue)
Registers the default string value of a solver info property.
Parameters
pNameThe name of the property.
pValueThe default value of the property.
Returns
The default value of the property provided by #pValue.

Definition at line 614 of file SessionReader.h.

616{
617 std::string vName = boost::to_upper_copy(pName);
618 GetSolverInfoDefaults()[vName] = pValue;
619 return pValue;
620}

References GetSolverInfoDefaults().

◆ RegisterEnumValue()

std::string Nektar::LibUtilities::SessionReader::RegisterEnumValue ( std::string  pEnum,
std::string  pString,
int  pEnumValue 
)
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:

std::string GlobalLinSys::lookupIds[2] = {
"GlobalSysSoln",
"DirectFull",
"GlobalSysSoln",
"DirectStaticCond",
}
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
Parameters
pEnumThe name of the property.
pStringA valid value for the property.
pEnumValueAn enumeration value corresponding to this value.
Returns
The value for the property provided by #pString.

Definition at line 580 of file SessionReader.h.

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}
std::map< std::string, int > EnumMap

References GetSolverInfoEnums().

◆ SetGlobalSysSolnInfo()

void Nektar::LibUtilities::SessionReader::SetGlobalSysSolnInfo ( const std::string &  variable,
const std::string &  property,
const std::string &  value 
)

Definition at line 1129 of file BasicUtils/SessionReader.cpp.

1132{
1133
1134 std::string vProperty = boost::to_upper_copy(pProperty);
1135
1136 auto iter = GetGloSysSolnList().find(pVariable);
1137 if (iter == GetGloSysSolnList().end())
1138 {
1139 (GetGloSysSolnList()[pVariable])[vProperty] = pValue;
1140 }
1141 else
1142 {
1143 iter->second[vProperty] = pValue;
1144 }
1145}

References GetGloSysSolnList().

◆ SetParameter() [1/4]

void Nektar::LibUtilities::SessionReader::SetParameter ( const std::string &  name,
int &  var 
)

Set an integer parameter.

Definition at line 951 of file BasicUtils/SessionReader.cpp.

952{
953 std::string vName = boost::to_upper_copy(pName);
954 m_parameters[vName] = pVar;
955 m_interpreter->SetParameter(pName, pVar);
956}

References m_interpreter, and m_parameters.

Referenced by export_SessionReader().

◆ SetParameter() [2/4]

void Nektar::LibUtilities::SessionReader::SetParameter ( const std::string &  name,
NekDouble var 
)

Set a double precision parameter.

Definition at line 981 of file BasicUtils/SessionReader.cpp.

982{
983 std::string vName = boost::to_upper_copy(pName);
984 m_parameters[vName] = pVar;
985 m_interpreter->SetParameter(pName, pVar);
986}

References m_interpreter, and m_parameters.

◆ SetParameter() [3/4]

void Nektar::LibUtilities::SessionReader::SetParameter ( const std::string &  name,
size_t &  var 
)

Set an size_t parameter.

Definition at line 971 of file BasicUtils/SessionReader.cpp.

972{
973 std::string vName = boost::to_upper_copy(pName);
974 m_parameters[vName] = pVar;
975 m_interpreter->SetParameter(pName, pVar);
976}

References m_interpreter, and m_parameters.

◆ SetParameter() [4/4]

void Nektar::LibUtilities::SessionReader::SetParameter ( const std::string &  name,
unsigned int &  var 
)

Set an unsigned integer parameter.

Definition at line 961 of file BasicUtils/SessionReader.cpp.

962{
963 std::string vName = boost::to_upper_copy(pName);
964 m_parameters[vName] = pVar;
965 m_interpreter->SetParameter(pName, pVar);
966}

References m_interpreter, and m_parameters.

◆ SetSolverInfo()

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 1016 of file BasicUtils/SessionReader.cpp.

1018{
1019 std::string vProperty = boost::to_upper_copy(pProperty);
1020 auto iter = m_solverInfo.find(vProperty);
1021
1022 ASSERTL1(iter != m_solverInfo.end(),
1023 "Unable to find requested property: " + pProperty);
1024
1025 iter->second = pValue;
1026}

References ASSERTL1, and m_solverInfo.

Referenced by export_SessionReader().

◆ SetTag()

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.

1464{
1465 std::string vName = boost::to_upper_copy(pName);
1466 m_tags[vName] = pValue;
1467}

References m_tags.

◆ SetUpdateOptFile()

void Nektar::LibUtilities::SessionReader::SetUpdateOptFile ( bool  flag)
inline

Set bool to update optimisation file.

Definition at line 388 of file SessionReader.h.

389 {
390 m_updateOptFile = flag;
391 }

References m_updateOptFile.

◆ SetVariable()

void Nektar::LibUtilities::SessionReader::SetVariable ( const unsigned int &  idx,
std::string  newname 
)

Definition at line 1214 of file BasicUtils/SessionReader.cpp.

1215{
1216 ASSERTL0(idx < m_variables.size(), "Variable index out of range.");
1217 m_variables[idx] = newname;
1218}

References ASSERTL0, and m_variables.

◆ TestSharedFilesystem()

void Nektar::LibUtilities::SessionReader::TestSharedFilesystem ( )
private

Definition at line 398 of file BasicUtils/SessionReader.cpp.

399{
400 m_sharedFilesystem = false;
401
402 if (m_comm->GetSize() > 1)
403 {
404 if (m_comm->GetRank() == 0)
405 {
406 std::ofstream testfile("shared-fs-testfile");
407 testfile << "" << std::endl;
408 ASSERTL1(!testfile.fail(), "Test file creation failed");
409 testfile.close();
410 }
411 m_comm->Block();
412
413 int exists = fs::exists("shared-fs-testfile");
414 m_comm->AllReduce(exists, LibUtilities::ReduceSum);
415
416 m_sharedFilesystem = (exists == m_comm->GetSize());
417
418 if ((m_sharedFilesystem && m_comm->GetRank() == 0) ||
420 {
421 std::remove("shared-fs-testfile");
422 }
423 }
424 else
425 {
426 m_sharedFilesystem = false;
427 }
428
429 if (m_verbose && m_comm->GetRank() == 0 && m_sharedFilesystem)
430 {
431 cout << "Shared filesystem detected" << endl;
432 }
433}

References ASSERTL1, m_comm, m_sharedFilesystem, m_verbose, and Nektar::LibUtilities::ReduceSum.

Referenced by SessionReader(), and SessionReader().

◆ VerifySolverInfo()

void Nektar::LibUtilities::SessionReader::VerifySolverInfo ( )
private

Check values of solver info options are valid.

Definition at line 2635 of file BasicUtils/SessionReader.cpp.

2636{
2637 for (auto &x : m_solverInfo)
2638 {
2639 std::string solverProperty = x.first;
2640 std::string solverValue = x.second;
2641
2642 auto propIt = GetSolverInfoEnums().find(solverProperty);
2643 if (propIt != GetSolverInfoEnums().end())
2644 {
2645 auto valIt = propIt->second.find(solverValue);
2646 ASSERTL0(valIt != propIt->second.end(), "Value '" + solverValue +
2647 "' is not valid for "
2648 "property '" +
2649 solverProperty + "'");
2650 }
2651 }
2652}

References ASSERTL0, GetSolverInfoEnums(), and m_solverInfo.

Referenced by InitSession().

Friends And Related Symbol Documentation

◆ MemoryManager< SessionReader >

friend class MemoryManager< SessionReader >
friend

Support creation through MemoryManager.

Definition at line 111 of file SessionReader.h.

Member Data Documentation

◆ m_backups

bool Nektar::LibUtilities::SessionReader::m_backups = true
private

Backups.

Definition at line 440 of file SessionReader.h.

Referenced by GetBackups(), InitSession(), and ParseCommandLineArguments().

◆ m_cmdLineOptions

boost::program_options::variables_map Nektar::LibUtilities::SessionReader::m_cmdLineOptions
private

◆ m_comm

CommSharedPtr Nektar::LibUtilities::SessionReader::m_comm
private

◆ m_filenames

std::vector<std::string> Nektar::LibUtilities::SessionReader::m_filenames
private

Filenames.

Definition at line 410 of file SessionReader.h.

Referenced by GetFilenames(), InitSession(), SessionReader(), and SessionReader().

◆ m_filters

FilterMap Nektar::LibUtilities::SessionReader::m_filters
private

Filters map.

Definition at line 430 of file SessionReader.h.

Referenced by GetFilters(), and ReadFilters().

◆ m_functions

FunctionMap Nektar::LibUtilities::SessionReader::m_functions
private

◆ m_geometricInfo

GeometricInfoMap Nektar::LibUtilities::SessionReader::m_geometricInfo
private

Geometric information properties.

Definition at line 420 of file SessionReader.h.

◆ m_interpreter

InterpreterSharedPtr Nektar::LibUtilities::SessionReader::m_interpreter
private

◆ m_parameters

ParameterMap Nektar::LibUtilities::SessionReader::m_parameters
private

◆ m_sessionName

std::string Nektar::LibUtilities::SessionReader::m_sessionName
private

Session name of the loaded XML document (filename minus ext).

Definition at line 412 of file SessionReader.h.

Referenced by GetSessionName(), InitSession(), SessionReader(), and SessionReader().

◆ m_sharedFilesystem

bool Nektar::LibUtilities::SessionReader::m_sharedFilesystem
private

Running on a shared filesystem.

Definition at line 438 of file SessionReader.h.

Referenced by GetSharedFilesystem(), and TestSharedFilesystem().

◆ m_solverInfo

SolverInfoMap Nektar::LibUtilities::SessionReader::m_solverInfo
private

◆ m_tags

TagMap Nektar::LibUtilities::SessionReader::m_tags
private

Custom tags.

Definition at line 428 of file SessionReader.h.

Referenced by DefinesTag(), GetTag(), and SetTag().

◆ m_timeIntScheme

TimeIntScheme Nektar::LibUtilities::SessionReader::m_timeIntScheme
private

Time integration scheme information.

Definition at line 432 of file SessionReader.h.

Referenced by DefinesTimeIntScheme(), GetTimeIntScheme(), and ReadTimeIntScheme().

◆ m_timeLevel

size_t Nektar::LibUtilities::SessionReader::m_timeLevel = 0
private

◆ m_updateOptFile

bool Nektar::LibUtilities::SessionReader::m_updateOptFile
private

Update optimisation file.

Definition at line 442 of file SessionReader.h.

Referenced by GetUpdateOptFile(), InitSession(), ParseCommandLineArguments(), and SetUpdateOptFile().

◆ m_variables

VariableList Nektar::LibUtilities::SessionReader::m_variables
private

◆ m_verbose

bool Nektar::LibUtilities::SessionReader::m_verbose
private

◆ m_xmlDoc

TiXmlDocument* Nektar::LibUtilities::SessionReader::m_xmlDoc
private

Pointer to the loaded XML document.

Definition at line 414 of file SessionReader.h.

Referenced by DefinesElement(), GetDocument(), GetElement(), GetGeometryType(), InitSession(), ParseDocument(), SessionReader(), SessionReader(), and ~SessionReader().