Nektar++
Functions
Python/BasicUtils/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. More...
 

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,
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,
114 .def("GetParameters", &SessionReader::GetParameters)
115
116 .def("SetParameter", py::overload_cast<const std::string &, int &>(
117 &SessionReader::SetParameter))
118 .def("SetParameter", py::overload_cast<const std::string &, double &>(
119 &SessionReader::SetParameter))
120 .def("SetParameter", py::overload_cast<const std::string &, size_t &>(
121 &SessionReader::SetParameter))
122
123 .def("DefinesSolverInfo", &SessionReader::DefinesSolverInfo)
124 .def("GetSolverInfo", &SessionReader::GetSolverInfo,
126 .def("SetSolverInfo", &SessionReader::SetSolverInfo)
127
128 .def("GetVariable", &SessionReader::GetVariable,
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)
def copy(self)
Definition: pycml.py:2663
static void Finalise(gs_data *pGsh)
Deallocates the GSLib mapping data.
Definition: GsLib.hpp:248

References CellMLToNektar.pycml::copy(), Gs::Finalise(), and SessionReader_CreateInstance().

Referenced by PYBIND11_MODULE().

◆ SessionReader_CreateInstance()

SessionReaderSharedPtr SessionReader_CreateInstance ( py::list &  ns)

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

58{
59 CppCommandLine 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.
86 SessionReaderSharedPtr sr = SessionReader::CreateInstance(argc, argv);
87#endif
88
89 return sr;
90}
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
CommFactory & GetCommFactory()
Helper structure to construct C++ command line argc and argv variables from a Python list.
Definition: NekPyConfig.hpp:89

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

Referenced by export_SessionReader().