Nektar++
Functions
Python/BasicUtils/SessionReader.cpp File Reference
#include "../NekPyConvertors.hpp"
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <LibUtilities/Python/NekPyConfig.hpp>

Go to the source code of this file.

Functions

SessionReaderSharedPtr SessionReader_CreateInstance (py::list &ns)
 
void SessionReader_SetParameterInt (SessionReaderSharedPtr session, std::string paramName, int paramValue)
 
void SessionReader_SetParameterDouble (SessionReaderSharedPtr session, std::string paramName, double paramValue)
 
EquationSharedPtr SessionReader_GetFunction1 (SessionReaderSharedPtr session, std::string func, int var)
 
EquationSharedPtr SessionReader_GetFunction2 (SessionReaderSharedPtr session, std::string func, std::string var)
 
py::dict SessionReader_GetParameters (SessionReaderSharedPtr s)
 Function to wrap SessionReader::GetParameters. More...
 
py::list SessionReader_GetVariables (SessionReaderSharedPtr s)
 Function to wrap SessionReader::GetVariables. More...
 
void export_SessionReader ()
 SessionReader exports. More...
 

Function Documentation

◆ export_SessionReader()

void export_SessionReader ( )

SessionReader exports.

Currently wrapped functions:

  • SessionReader::CreateInstance for creating objects
  • SessionReader::GetSessionName to return the session name
  • SessionReader::Finalise to deal with finalising things

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

147{
148 py::class_<SessionReader, std::shared_ptr<SessionReader>,
149 boost::noncopyable>("SessionReader", py::no_init)
150
151 .def("CreateInstance", SessionReader_CreateInstance)
152 .staticmethod("CreateInstance")
153
154 .def("GetSessionName", &SessionReader::GetSessionName,
155 py::return_value_policy<py::copy_const_reference>())
156
157 .def("Finalise", &SessionReader::Finalise)
158
159 .def("DefinesParameter", &SessionReader::DefinesParameter)
160 .def("GetParameter", &SessionReader::GetParameter,
161 py::return_value_policy<py::return_by_value>())
162 .def("GetParameters", &SessionReader_GetParameters)
163
164 .def("SetParameter", SessionReader_SetParameterInt)
165 .def("SetParameter", SessionReader_SetParameterDouble)
166
167 .def("DefinesSolverInfo", &SessionReader::DefinesSolverInfo)
168 .def("GetSolverInfo", &SessionReader::GetSolverInfo,
169 py::return_value_policy<py::copy_const_reference>())
170 .def("SetSolverInfo", &SessionReader::SetSolverInfo)
171
172 .def("GetVariable", &SessionReader::GetVariable,
173 py::return_value_policy<py::copy_const_reference>())
174 .def("GetVariables", SessionReader_GetVariables)
175
176 .def("GetFunction", SessionReader_GetFunction1)
177 .def("GetFunction", SessionReader_GetFunction2)
178
179 .def("GetComm", &SessionReader::GetComm)
180
181 .def("GetSharedFilesystem", &SessionReader::GetSharedFilesystem);
182}
EquationSharedPtr SessionReader_GetFunction2(SessionReaderSharedPtr session, std::string func, std::string var)
void SessionReader_SetParameterDouble(SessionReaderSharedPtr session, std::string paramName, double paramValue)
EquationSharedPtr SessionReader_GetFunction1(SessionReaderSharedPtr session, std::string func, int var)
py::dict SessionReader_GetParameters(SessionReaderSharedPtr s)
Function to wrap SessionReader::GetParameters.
py::list SessionReader_GetVariables(SessionReaderSharedPtr s)
Function to wrap SessionReader::GetVariables.
SessionReaderSharedPtr SessionReader_CreateInstance(py::list &ns)
void SessionReader_SetParameterInt(SessionReaderSharedPtr session, std::string paramName, int paramValue)
static void Finalise(gs_data *pGsh)
Deallocates the GSLib mapping data.
Definition: GsLib.hpp:248

References Gs::Finalise(), SessionReader_CreateInstance(), SessionReader_GetFunction1(), SessionReader_GetFunction2(), SessionReader_GetParameters(), SessionReader_GetVariables(), SessionReader_SetParameterDouble(), and SessionReader_SetParameterInt().

Referenced by BOOST_PYTHON_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.

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

Referenced by export_SessionReader().

◆ SessionReader_GetFunction1()

EquationSharedPtr SessionReader_GetFunction1 ( SessionReaderSharedPtr  session,
std::string  func,
int  var 
)

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

106{
107 return session->GetFunction(func, var);
108}

Referenced by export_SessionReader().

◆ SessionReader_GetFunction2()

EquationSharedPtr SessionReader_GetFunction2 ( SessionReaderSharedPtr  session,
std::string  func,
std::string  var 
)

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

112{
113 return session->GetFunction(func, var);
114}

Referenced by export_SessionReader().

◆ SessionReader_GetParameters()

py::dict SessionReader_GetParameters ( SessionReaderSharedPtr  s)

Function to wrap SessionReader::GetParameters.

Returns a Python dict containing (parameter name)-> (parameter value) entries.

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

123{
124 return MapToPyDict(s->GetParameters());
125}
py::dict MapToPyDict(const std::map< KeyT, ValT > &input)
Converts a std::map to a Python dict.

References MapToPyDict().

Referenced by export_SessionReader().

◆ SessionReader_GetVariables()

py::list SessionReader_GetVariables ( SessionReaderSharedPtr  s)

Function to wrap SessionReader::GetVariables.

Returns a Python list containing variable names.

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

133{
134 return VectorToPyList(s->GetVariables());
135}
py::list VectorToPyList(const std::vector< T > &input)
Converts a std::vector to a Python list.

References VectorToPyList().

Referenced by export_SessionReader().

◆ SessionReader_SetParameterDouble()

void SessionReader_SetParameterDouble ( SessionReaderSharedPtr  session,
std::string  paramName,
double  paramValue 
)

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

100{
101 session->SetParameter(paramName, paramValue);
102}

Referenced by export_SessionReader().

◆ SessionReader_SetParameterInt()

void SessionReader_SetParameterInt ( SessionReaderSharedPtr  session,
std::string  paramName,
int  paramValue 
)

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

94{
95 session->SetParameter(paramName, paramValue);
96}

Referenced by export_SessionReader().