Simplify the running of Nektar solvers from external code by allowing programmatic set up of session and mesh objects, bypassing the usual XML file(s).
Extract the XML-parsing functionality in SessionReader to a separate subclass, then add constructors and functions to populate session and mesh objects programmatically.
The main changes are:
SessionReaderclass renamed to
SessionReadermember functions split up/rejigged in order to separate out XML-parsing from population of member variables.
- Xml-parsing functionality from
SessionReadermoved to the
SessionXmlReaderclass, which inherits from
Sessionconstructors chained to reduce duplicate code.
Sessionconstructor added that performs initialisation based on various STL container arguments. e.g. a
std::map<std::string,std::string>for solver settings.
MeshGraphProgrammaticclass added. This is a subclass of
MeshGraphXml, rather than
MeshGraphin order to allow hybrid set ups, wherein parameters describing the expansion(s) are set programmatically, but the mesh itself is still read from XML.
- Constructors of
EquationSystemand its subclasses modified to allow pre-existing boundary conditions to be passed in, meaning they can be set up externally.
See library/Demos/LibUtilities/SessionWithoutXMLDemo.cpp for demos/tests of 1D and 2D problem set up.
N.B. The above implementation incorporates the approach described in the first bullet of !1375 (comment 20057). A description of the original implementation is retained below:
- New SessionConfigurable class (subclass of SessionReader)
- Several SessionReader member functions split up/rejigged in order to separate XML-parsing from population of member variables
- SessionReader constructors chained to reduce duplicate code
- New MeshGraphProgrammatic class (subclass of MeshGraph)
- Constructors of EquationSystem and its subclasses modified to allow pre-existing boundary conditions to be passed in, meaning they can be set up externally.
This approach seemed like the least disruptive way to change things for now; one downside is that SessionConfigurable inherits the XML doc and associated member functions. To mitigate that, I've overridden most (all?) of those functions to throw exceptions.
The intent is for external code to call SessionConfigurable::CreateInstance([variable_names, parameters, solver_info etc. in the form of STL containers]) . At least one part of the session is populated later (using SessionConfigurable::AddFunction), but that could be moved into the constructor too.
- (Demos/LibUtilities/Tests/)SessionWithoutXMLDemo_Helmholtz1D - mimics the Helmholtz1D_8nodes test, buts sets up the session and mesh programmatically.
- (Demos/LibUtilities/Tests/)SessionWithoutXMLDemo_Helmholtz2D_modal_DG - mimics the Helmholtz2D_modal_DG test, buts sets up the session programmatically (the mesh is still read from xml).
- clang-format changes handled in accordance with #295.
Functions and classes, or changes to them, are documented.
User guide/documentation is updated.
Changelog is updated.
Suitable tests added for new functionality.
Contributed code is correctly formatted. (See the contributing guidelines).
License added to any new files.
No extraneous files have been added (e.g. compiler output or test data files).