Nektar++
Loading...
Searching...
No Matches
Functions
SessionReader.cpp File Reference
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <LibUtilities/Python/NekPyConfig.hpp>
#include <pybind11/stl.h>

Go to the source code of this file.

Functions

SessionReaderSharedPtr SessionReader_CreateInstance (py::list &ns)
 
void export_SessionReader (py::module &m)
 SessionReader exports.
 

Function Documentation

◆ export_SessionReader()

void export_SessionReader ( py::module &  m)

SessionReader exports.

Definition at line 96 of file Python/BasicUtils/SessionReader.cpp.

97{
98 py::class_<SessionReader, std::shared_ptr<SessionReader>>(m,
99 "SessionReader")
100
101 .def_static("CreateInstance", SessionReader_CreateInstance)
102
103 .def("GetSessionName", &SessionReader::GetSessionName,
104 py::return_value_policy::copy)
105
106 .def("InitSession", &SessionReader::InitSession,
107 py::arg("filenames") = py::list())
108
109 .def("Finalise", &SessionReader::Finalise)
110
111 .def("DefinesParameter", &SessionReader::DefinesParameter)
112 .def("GetParameter", &SessionReader::GetParameter,
113 py::return_value_policy::copy)
114 .def("GetParameters", &SessionReader::GetParameters)
115
116 .def("SetParameter", py::overload_cast<const std::string &, int &>(
118 .def("SetParameter", py::overload_cast<const std::string &, double &>(
120 .def("SetParameter", py::overload_cast<const std::string &, size_t &>(
122
123 .def("DefinesSolverInfo", &SessionReader::DefinesSolverInfo)
124 .def("GetSolverInfo", &SessionReader::GetSolverInfo,
125 py::return_value_policy::copy)
126 .def("SetSolverInfo", &SessionReader::SetSolverInfo)
127
128 .def("GetVariable", &SessionReader::GetVariable,
129 py::return_value_policy::copy)
130 .def("GetVariables", &SessionReader::GetVariables)
131
132 .def("GetFunction",
133 py::overload_cast<const std::string &, const std::string &,
134 const int>(&SessionReader::GetFunction,
135 py::const_),
136 py::arg("name"), py::arg("var"), py::arg("domain") = 0)
137 .def("GetFunction",
138 py::overload_cast<const std::string &, const unsigned int &,
139 const int>(&SessionReader::GetFunction,
140 py::const_),
141 py::arg("name"), py::arg("var"), py::arg("domain") = 0)
142
143 .def("GetComm", &SessionReader::GetComm)
144
145 .def("GetSharedFilesystem", &SessionReader::GetSharedFilesystem);
146}
SessionReaderSharedPtr SessionReader_CreateInstance(py::list &ns)
bool DefinesSolverInfo(const std::string &name) const
Checks if a solver info property is specified.
const std::string & GetSessionName() const
Returns the session name of the loaded XML document.
void InitSession(const std::vector< std::string > &filenames=std::vector< std::string >())
std::vector< std::string > GetVariables() const
Returns the names of all variables.
CommSharedPtr GetComm()
Returns the communication object.
const NekDouble & GetParameter(const std::string &pName) const
Returns the value of the specified parameter.
void SetParameter(const std::string &name, int &var)
Set an integer parameter.
void SetSolverInfo(const std::string &pProperty, const std::string &pValue)
Sets the value of the specified solver info property.
const std::string & GetVariable(const unsigned int &idx) const
Returns the name of the variable specified by the given index.
EquationSharedPtr GetFunction(const std::string &name, const std::string &variable, const int pDomain=0) const
Returns an EquationSharedPtr to a given function variable.
bool DefinesParameter(const std::string &name) const
Checks if a parameter is specified in the XML document.
const std::string & GetSolverInfo(const std::string &pProperty) const
Returns the value of the specified solver info property.
bool GetSharedFilesystem()
Returns if file system shared.

References Nektar::LibUtilities::SessionReader::DefinesParameter(), Nektar::LibUtilities::SessionReader::DefinesSolverInfo(), Nektar::LibUtilities::SessionReader::Finalise(), Nektar::LibUtilities::SessionReader::GetComm(), Nektar::LibUtilities::SessionReader::GetFunction(), Nektar::LibUtilities::SessionReader::GetParameter(), Nektar::LibUtilities::SessionReader::GetParameters(), Nektar::LibUtilities::SessionReader::GetSessionName(), Nektar::LibUtilities::SessionReader::GetSharedFilesystem(), Nektar::LibUtilities::SessionReader::GetSolverInfo(), Nektar::LibUtilities::SessionReader::GetVariable(), Nektar::LibUtilities::SessionReader::GetVariables(), Nektar::LibUtilities::SessionReader::InitSession(), SessionReader_CreateInstance(), Nektar::LibUtilities::SessionReader::SetParameter(), and Nektar::LibUtilities::SessionReader::SetSolverInfo().

Referenced by PYBIND11_MODULE().

◆ SessionReader_CreateInstance()

SessionReaderSharedPtr SessionReader_CreateInstance ( py::list &  ns)

Definition at line 57 of file Python/BasicUtils/SessionReader.cpp.

58{
59 PyCppCommandLine cpp(ns);
60
61 int argc = cpp.GetArgc();
62 char **argv = cpp.GetArgv();
63
64#ifdef NEKTAR_USE_MPI
65 // In the case we're using MPI, it may already have been initialised. So to
66 // handle this, we'll construct our own CommMpi object and pass through to
67 // the SessionReader. This will persist indefinitely, or at least until the
68 // library is unloaded by Python.
69
70 if (!MPICOMM)
71 {
72 MPICOMM = GetCommFactory().CreateInstance("ParallelMPI", argc, argv);
73 }
74
75 std::vector<std::string> filenames(argc - 1);
76 for (int i = 1; i < argc; ++i)
77 {
78 filenames[i - 1] = std::string(argv[i]);
79 }
80
81 // Create session reader.
83 SessionReader::CreateInstance(argc, argv, filenames, MPICOMM);
84#else
85 // Create session reader.
87#endif
88
89 return sr;
90}
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
CommFactory & GetCommFactory()
Helper structure to construct C++ command line argc and argv variables from a Python list.

References Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::CppCommandLine::GetArgc(), Nektar::LibUtilities::CppCommandLine::GetArgv(), and Nektar::LibUtilities::GetCommFactory().

Referenced by export_SessionReader().