PLaSK library
|
Geometry manager features: More...
#include <plask/manager.hpp>
Classes | |
struct | ExternalSourcesFromFile |
Allow to support reading some sections from other files. More... | |
struct | Map |
class | SetAxisNames |
Set axis name from current reader tag, set it in manager as current, and restore old axisNames value when out of the scope. More... | |
Public Member Functions | |
void | pushError (const std::string &mesg, int line=-1) |
Save non-critical error. | |
void | pushError (const std::runtime_error &error, int line=-1) |
Save non-critical error. | |
void | pushError (const XMLException &error, int line=-1) |
Save non-critical error. | |
template<typename ErrorType > | |
void | throwErrorIfNotDraft (ErrorType error, int line=-1) |
Throw error if not in draft mode. | |
std::string | getAxisName (std::size_t axis_index) |
Get current axis name. | |
std::string | getAxisLongName () |
Get current lon direction axis name. | |
std::string | getAxisTranName () |
Get current tran direction axis name. | |
std::string | getAxisVertName () |
Get current up direction axis name. | |
Manager (bool draft=false) | |
virtual | ~Manager () |
PathHints * | getPathHints (const std::string &path_hints_name) |
Get path hints with given name. | |
const PathHints * | getPathHints (const std::string &path_hints_name) const |
Get path hints with given name. | |
PathHints & | requirePathHints (const std::string &path_hints_name) |
Get path hints with given name, throw exception if there is no path hints with name path_hints_name . | |
const PathHints & | requirePathHints (const std::string &path_hints_name) const |
Get path hints with given name, throw exception if there is no path hints with name path_hints_name . | |
shared_ptr< GeometryObject > | getGeometryObject (const std::string &name) const |
Get object with given name . | |
template<typename RequiredObjectType > | |
shared_ptr< RequiredObjectType > | getGeometryObject (const std::string &name) const |
Call getObject(name) and try dynamic cast it to RequiredObjectType. | |
shared_ptr< GeometryObject > | requireGeometryObject (const std::string &name) |
Get object with given name or throw exception if object with given name does not exist. | |
template<typename RequiredObjectType > | |
shared_ptr< RequiredObjectType > | requireGeometryObject (const std::string &name) |
Call requireElement(name) and try dynamic cast it to RequiredObjectType. | |
shared_ptr< Geometry > | getGeometry (const std::string &name) const |
Get geometry trunk with given name . | |
shared_ptr< MeshBase > | getMesh (const std::string &name) const |
Get mesh with given name . | |
template<typename RequiredCalcSpaceType > | |
shared_ptr< RequiredCalcSpaceType > | getGeometry (const std::string &name) const |
Get geometry trunk with given name and try dynamic cast it to RequiredCalcSpaceType. | |
template<typename RequiredCalcSpaceType > | |
shared_ptr< RequiredCalcSpaceType > | requireGeometry (const std::string &name) const |
Get geometry trunk with given name and try dynamic cast it to RequiredCalcSpaceType. | |
virtual void | loadDefines (XMLReader &reader) |
Load constants definitions from the reader . | |
virtual void | loadGeometry (GeometryReader &reader) |
Load geometry using geometry reader . | |
virtual void | loadMaterials (XMLReader &reader) |
Load materials using reader to default database. | |
virtual void | loadGrids (XMLReader &reader) |
Load meshes and mesh generators using reader. | |
virtual void | loadSolvers (XMLReader &reader) |
Load solvers using reader. | |
virtual void | loadConnects (XMLReader &reader) |
Load solvers intrconnects from the reader . | |
virtual void | loadScript (XMLReader &reader) |
Load script from the reader . | |
void | loadFromReader (XMLReader &XMLreader, const LoadFunCallbackT &load_from_cb=&disallowExternalSources) |
Load geometry using XML reader. | |
void | loadFromStream (std::unique_ptr< std::istream > &&input, const LoadFunCallbackT &load_from_cb=&disallowExternalSources) |
Load geometry from (XML) stream. | |
void | loadFromXMLString (const std::string &input_XML_str, const LoadFunCallbackT &load_from_cb=&disallowExternalSources) |
Load geometry from string which consist of XML. | |
void | loadFromFile (const std::string &fileName) |
Load geometry from XML file. | |
void | loadFromFILE (FILE *file, const LoadFunCallbackT &load_from_cb=&disallowExternalSources) |
Load geometry from C file object. | |
template<typename Boundary > | |
Boundary | readBoundary (XMLReader &reader) |
Read boundary (place) from current tag and move parser to end of the current tag. | |
template<typename Boundary , typename ConditionT > | |
void | readBoundaryConditions (XMLReader &reader, BoundaryConditions< Boundary, ConditionT > &dest) |
Read boundary conditions from current tag and move parser to end of current tag. | |
void | load (XMLReader &XMLreader, const LoadFunCallbackT &load_from_cb=&disallowExternalSources, const std::function< bool(const std::string §ion_name)> §ion_filter=&acceptAllSections) |
Load XML content. | |
void | loadSection (XMLReader &XMLreader, const std::string §ion_to_load, const LoadFunCallbackT &load_from_cb=&disallowExternalSources) |
Load one section from XML content. | |
void | validatePositions (const std::function< void(const Geometry *, const Geometry *, std::vector< const GeometryObject * > &&, const std::map< const GeometryObject *, const char * > &)> &callback) const |
Try to find mistake in position of objects. | |
void | validatePositions () const |
Try to find mistake in position of objects. | |
std::size_t | getRootIndex (const Geometry *geom) const |
Get index of geometry in root. | |
template<> | |
shared_ptr< GeometryObject > | getGeometryObject (const std::string &name) const |
template<> | |
shared_ptr< GeometryObject > | requireGeometryObject (const std::string &name) |
template<> | |
shared_ptr< Geometry > | getGeometry (const std::string &name) const |
Static Public Member Functions | |
static void | disallowExternalSources (Manager &PLASK_UNUSED(manager), const std::string &url, const std::string §ion) |
Throw exception with information that loading from external sources is not supported or disallowed. | |
Public Attributes | |
Map< PathHints > | pathHints |
Allow to access path hints by name. | |
std::vector< shared_ptr< Geometry > > | roots |
Roots objects, geometries. | |
Map< shared_ptr< GeometryObject > > | geometrics |
Geometries and geometry objects by name. | |
Map< shared_ptr< MeshBase > > | meshes |
Meshes by name. | |
Map< shared_ptr< Solver > > | solvers |
Solvers by name. | |
Map< boost::any > | boundaries |
Boundaries places by name. | |
std::string | script |
Script read from file. | |
unsigned | scriptline |
Line in which script begins. | |
const AxisNames * | axisNames |
Current or default names of axis. | |
bool | draft |
Flag indicating if unknown materials are allowed. | |
std::deque< std::pair< int, std::string > > | errors |
Errors which occurred during loading (only in draft mode) | |
Static Public Attributes | |
static constexpr const char * | TAG_NAME_ROOT = "plask" |
name of root XML tag | |
static constexpr const char * | TAG_NAME_DEFINES = "defines" |
name of XML tag of section with const definitions | |
static constexpr const char * | TAG_NAME_MATERIALS = "materials" |
name of XML tag of section with materials | |
static constexpr const char * | TAG_NAME_GEOMETRY = "geometry" |
name of XML tag of section with geometry | |
static constexpr const char * | TAG_NAME_GRIDS = "grids" |
name of XML tag of section with grids (meshes and generators) | |
static constexpr const char * | TAG_NAME_SOLVERS = "solvers" |
name of XML tag of section with solvers | |
static constexpr const char * | TAG_NAME_CONNECTS = "connects" |
name of XML tag of section with provides-receiver connections | |
static constexpr const char * | TAG_NAME_SCRIPT = "script" |
name of XML tag of section with (python) script | |
static constexpr const char * | XML_AXES_ATTR = "axes" |
name of axes attribute in XML | |
Protected Member Functions | |
virtual shared_ptr< Solver > | loadSolver (const std::string &category, const std::string &lib, const std::string &solver_name, const std::string &name) |
Load solver from file. | |
void | loadMaterialLib (XMLReader &reader) |
Load binary material library to default database. | |
virtual void | loadMaterial (XMLReader &reader) |
Load one material using reader to default database. | |
Geometry manager features:
Definition at line 51 of file manager.hpp.
Definition at line 307 of file manager.hpp.
|
inlinevirtual |
Definition at line 309 of file manager.hpp.
|
inlinestatic |
Throw exception with information that loading from external sources is not supported or disallowed.
Definition at line 69 of file manager.hpp.
|
inline |
Get current lon direction axis name.
Definition at line 257 of file manager.hpp.
|
inline |
Get current axis name.
axis_index | axis index |
axis_index
Definition at line 251 of file manager.hpp.
|
inline |
Get current tran direction axis name.
Definition at line 263 of file manager.hpp.
|
inline |
Get current up direction axis name.
Definition at line 269 of file manager.hpp.
Get geometry trunk with given name
.
name | name of calculation space to get |
name
or shared_ptr<Geometry>() if there is geometry with given name
Definition at line 110 of file manager.cpp.
|
inline |
Get geometry trunk with given name
and try dynamic cast it to RequiredCalcSpaceType.
name | name of calculation space to get |
name
or can't be casted to RequiredCalcSpaceType Definition at line 642 of file manager.hpp.
|
inline |
Definition at line 642 of file manager.hpp.
shared_ptr< GeometryObject > plask::Manager::getGeometryObject | ( | const std::string & | name | ) | const |
Get object with given name
.
name | name of object |
name
or nullptr
if there is no object with given name Definition at line 93 of file manager.cpp.
shared_ptr< RequiredObjectType > plask::Manager::getGeometryObject | ( | const std::string & | name | ) | const |
Call getObject(name) and try dynamic cast it to RequiredObjectType.
name | name of object |
name
or nullptr
if there is no object with given name or object with given name is not of type RequiredObjectType @tparm RequiredObjectType required type of object Definition at line 616 of file manager.hpp.
|
inline |
Definition at line 616 of file manager.hpp.
Get mesh with given name
.
name | name of calculation space to get |
name
or shared_ptr<Mesh>() if there is no mesh with given name
Definition at line 115 of file manager.cpp.
Get path hints with given name.
path_hints_name | name of path hints to get |
nullptr
if there is no path hints with name path_hints_name
Definition at line 69 of file manager.cpp.
Get path hints with given name.
path_hints_name | name of path hints to get |
nullptr
if there is no path hints with name path_hints_name
Definition at line 75 of file manager.cpp.
Get index of geometry in root.
geom | geometry to get index |
geom
in root vector, equal to size() if not found Definition at line 601 of file manager.cpp.
void plask::Manager::load | ( | XMLReader & | XMLreader, |
const LoadFunCallbackT & | load_from_cb = &disallowExternalSources , |
||
const std::function< bool(const std::string §ion_name)> & | section_filter = &acceptAllSections |
||
) |
Load XML content.
XMLreader | XML data source, to load |
load_from_cb | callback called to open external location, allow loading some section from another sources, this callback should read section from external XML source pointed by url (typically name of file) or throw exception |
section_filter | predicate which returns true only if given section should be read, by default it always return true |
Definition at line 311 of file manager.cpp.
Load solvers intrconnects from the reader
.
reader | XMLreader to load from |
Definition at line 285 of file manager.cpp.
Load constants definitions from the reader
.
reader | XMLreader to load from, should point to <defines> tag, after read it will be point to </defines> tag |
Definition at line 120 of file manager.cpp.
Load geometry from XML file.
fileName | name of XML file |
Definition at line 138 of file manager.cpp.
void plask::Manager::loadFromFILE | ( | FILE * | file, |
const LoadFunCallbackT & | load_from_cb = &disallowExternalSources |
||
) |
Load geometry from C file object.
file | open file object |
load_from_cb | callback called to open external location, allow loading some section from another sources, this callback should read section from external XML source pointed by url (typically name of file) or throw exception |
Definition at line 143 of file manager.cpp.
void plask::Manager::loadFromReader | ( | XMLReader & | XMLreader, |
const LoadFunCallbackT & | load_from_cb = &disallowExternalSources |
||
) |
Load geometry using XML reader.
XMLreader | reader to read from, should point to <geometry> tag, after read it will be point to </geometry> tag |
load_from_cb | callback called to open external location, allow loading some section from another sources, this callback should read section from external XML source pointed by url (typically name of file) or throw exception |
Definition at line 125 of file manager.cpp.
void plask::Manager::loadFromStream | ( | std::unique_ptr< std::istream > && | input, |
const LoadFunCallbackT & | load_from_cb = &disallowExternalSources |
||
) |
Load geometry from (XML) stream.
input | stream to read from, with XML content, will be closed and deleted after read |
load_from_cb | callback called to open external location, allow loading some section from another sources, this callback should read section from external XML source pointed by url (typically name of file) or throw exception |
Definition at line 129 of file manager.cpp.
void plask::Manager::loadFromXMLString | ( | const std::string & | input_XML_str, |
const LoadFunCallbackT & | load_from_cb = &disallowExternalSources |
||
) |
Load geometry from string which consist of XML.
input_XML_str | string with XML content |
load_from_cb | callback called to open external location, allow loading some section from another sources, this callback should read section from external XML source pointed by url (typically name of file) or throw exception |
Definition at line 134 of file manager.cpp.
|
virtual |
Load geometry using geometry reader
.
reader | reader to read from, should point to <geometry> tag, after read it will be point to </geometry> tag |
Definition at line 149 of file manager.cpp.
Load meshes and mesh generators using reader.
reader | reader to read from, should point to <solver> tag, after read it will be point to </solver> tag |
Definition at line 187 of file manager.cpp.
Load one material using reader
to default database.
reader | reader to read from |
Definition at line 169 of file manager.cpp.
Load binary material library to default database.
reader | reader to read from |
Definition at line 158 of file manager.cpp.
Load materials using reader
to default database.
reader | reader to read from, should point to <materials> tag, after read it will be point to </materials> tag |
Definition at line 175 of file manager.cpp.
Load script from the reader
.
Do not execute it.
reader | XMLreader to load from |
Definition at line 291 of file manager.cpp.
|
inline |
Load one section from XML content.
XMLreader | XML data source, to load |
section_to_load | name of section to load |
load_from_cb | callback called to open external location, allow loading some section from another sources, this callback should read section from external XML source pointed by url (typically name of file) or throw exception |
Definition at line 582 of file manager.hpp.
|
protectedvirtual |
Load solver from file.
category,lib,solver_name | solver parameters |
name | solver name |
Definition at line 221 of file manager.cpp.
Load solvers using reader.
reader | reader to read from, should point to <solver> tag, after read it will be point to </solver> tag |
Definition at line 229 of file manager.cpp.
Save non-critical error.
error | error |
line | line in XML file where error occurred |
Definition at line 221 of file manager.hpp.
Save non-critical error.
mesg | error message |
line | line in XML file where error occurred |
Definition at line 212 of file manager.hpp.
|
inline |
Save non-critical error.
error | error |
line | line in XML file where error occurred |
Definition at line 230 of file manager.hpp.
Read boundary (place) from current tag and move parser to end of the current tag.
Definition at line 667 of file manager.hpp.
|
inline |
Read boundary conditions from current tag and move parser to end of current tag.
Use MeshT static methods to read boundaries, and parseBoundaryValue
to parse values of conditions:
(by default it just read value from "value" attribute)
Require format (one or more tag as below):
With restrictions:
reader | source of XML data |
dest | place to append read conditions |
Definition at line 705 of file manager.hpp.
|
inline |
Get geometry trunk with given name
and try dynamic cast it to RequiredCalcSpaceType.
name | name of calculation space to get |
name
or can't be casted to RequiredCalcSpaceType Definition at line 404 of file manager.hpp.
shared_ptr< GeometryObject > plask::Manager::requireGeometryObject | ( | const std::string & | name | ) |
Get object with given name or throw exception if object with given name does not exist.
name | name of object |
NoSuchGeometryObject | if there is no object with given name |
Definition at line 104 of file manager.cpp.
|
inline |
Call requireElement(name) and try dynamic cast it to RequiredObjectType.
name | name of object |
name
RequiredObjectType | required type of object |
UnexpectedGeometryObjectTypeException | if requested object is not of type RequiredObjectType |
NoSuchGeometryObject | if there is no object with given name |
Definition at line 628 of file manager.hpp.
|
inline |
Definition at line 628 of file manager.hpp.
Get path hints with given name, throw exception if there is no path hints with name path_hints_name
.
path_hints_name | name of path hints to get |
plask::Exception | if there is no path hints with name path_hints_name |
Definition at line 81 of file manager.cpp.
Get path hints with given name, throw exception if there is no path hints with name path_hints_name
.
path_hints_name | name of path hints to get |
plask::Exception | if there is no path hints with name path_hints_name |
Definition at line 87 of file manager.cpp.
Throw error if not in draft mode.
error | error to throw |
line | line in XML file where error occurred |
Definition at line 241 of file manager.hpp.
void plask::Manager::validatePositions | ( | ) | const |
Try to find mistake in position of objects.
Reports in returned string when some object has, probably by mistake, different position in two geometries.
Definition at line 587 of file manager.cpp.
void plask::Manager::validatePositions | ( | const std::function< void(const Geometry *, const Geometry *, std::vector< const GeometryObject * > &&, const std::map< const GeometryObject *, const char * > &)> & | callback | ) | const |
Try to find mistake in position of objects.
Reports (by calling callback
) when some object has, probably by mistake, different position in two geometries.
callback | call for each pair of geometries in which objects with different (by mistake) positions have been found. Details are passed in parameters:
|
Definition at line 543 of file manager.cpp.
Current or default names of axis.
Definition at line 199 of file manager.hpp.
Map<boost::any> plask::Manager::boundaries |
Boundaries places by name.
Definition at line 190 of file manager.hpp.
bool plask::Manager::draft |
Flag indicating if unknown materials are allowed.
Definition at line 202 of file manager.hpp.
std::deque<std::pair<int,std::string> > plask::Manager::errors |
Errors which occurred during loading (only in draft mode)
Definition at line 205 of file manager.hpp.
Map<shared_ptr<GeometryObject> > plask::Manager::geometrics |
Geometries and geometry objects by name.
Definition at line 180 of file manager.hpp.
Meshes by name.
Definition at line 183 of file manager.hpp.
Allow to access path hints by name.
Definition at line 174 of file manager.hpp.
std::vector<shared_ptr<Geometry> > plask::Manager::roots |
Roots objects, geometries.
Definition at line 177 of file manager.hpp.
std::string plask::Manager::script |
Script read from file.
Definition at line 193 of file manager.hpp.
unsigned plask::Manager::scriptline |
Line in which script begins.
Definition at line 196 of file manager.hpp.
Solvers by name.
Definition at line 186 of file manager.hpp.
name of XML tag of section with provides-receiver connections
Definition at line 168 of file manager.hpp.
name of XML tag of section with const definitions
Definition at line 163 of file manager.hpp.
name of XML tag of section with geometry
Definition at line 165 of file manager.hpp.
name of XML tag of section with grids (meshes and generators)
Definition at line 166 of file manager.hpp.
name of XML tag of section with materials
Definition at line 164 of file manager.hpp.
name of root XML tag
Definition at line 162 of file manager.hpp.
name of XML tag of section with (python) script
Definition at line 169 of file manager.hpp.
name of XML tag of section with solvers
Definition at line 167 of file manager.hpp.
name of axes attribute in XML
Definition at line 171 of file manager.hpp.