v0.16.0
Loading...
Searching...
No Matches
JsonConfigManager.hpp
Go to the documentation of this file.
1/** \file JsonConfigManager.hpp
2 * \brief JSON configuration loader for PETSc options and meshsets
3 */
4
5#ifndef __JSONCONFIGMANAGER_HPP__
6#define __JSONCONFIGMANAGER_HPP__
7
9
10namespace MoFEM {
11
13
14 inline static std::vector<std::string> canonical_attributes_ordering =
16
17 static const std::string &supportedVersion();
18 /**
19 * Register additional numeric JSON attribute names.
20 */
21 static MoFEMErrorCode
22 addCanonicalAttributeNames(const std::vector<std::string> &names);
23
24 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
25 UnknownInterface **iface) const;
26
27 JsonConfigManager(const MoFEM::Core &core);
28 virtual ~JsonConfigManager() = default;
29
30 /**
31 * @brief Set -file_name from JSON before Core is available.
32 *
33 * Use only in programs that must read the mesh before MoFEM::Core and the
34 * JsonConfigManager interface are initialised.
35 */
37
39
40 MoFEMErrorCode loadFromFile(const std::string &file_name);
42 std::string getPythonScriptByKey(const std::string &key) const;
43 std::string getMoabMeshByKey(const std::string &key) const;
44 std::map<std::string, double>
45 getParamsFromBlockset(const std::string &type_name, int meshset_id) const;
46 std::map<std::string, std::string>
47 getStringParamsFromBlockset(const std::string &type_name,
48 int meshset_id) const;
49
50 inline bool hasMeshsetsSection() const { return hasMeshsets; }
51
52private:
53 using MeshsetKey = std::pair<std::string, int>;
54 using MeshsetParams = std::map<std::string, double>;
55 using MeshsetStringParams = std::map<std::string, std::string>;
56
58 boost::json::value configRoot;
59 std::string configFileName;
60 bool configLoaded = false;
61 bool hasMeshsets = false;
62 bool meshsetsApplied = false;
63 std::map<std::string, std::string> moabMeshesByKey;
64 std::map<std::string, std::string> pythonScriptsByKey;
65 std::map<MeshsetKey, MeshsetParams> primaryMeshsetParamsByKey;
66 std::map<MeshsetKey, MeshsetStringParams> primaryMeshsetStringParamsByKey;
67
70};
71
72} // namespace MoFEM
73
74#endif // __JSONCONFIGMANAGER_HPP__
Default canonical JSON block attribute names.
std::string key
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
std::vector< std::string > getDefaultJsonCanonicalAttributeNames()
Core (interface) class.
Definition Core.hpp:83
static const std::string & supportedVersion()
static MoFEMErrorCode setMeshFileFromJson()
Set -file_name from JSON before Core is available.
std::string getPythonScriptByKey(const std::string &key) const
std::map< std::string, std::string > moabMeshesByKey
std::map< std::string, double > MeshsetParams
virtual ~JsonConfigManager()=default
std::string getMoabMeshByKey(const std::string &key) const
std::map< std::string, double > getParamsFromBlockset(const std::string &type_name, int meshset_id) const
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
static MoFEMErrorCode addCanonicalAttributeNames(const std::vector< std::string > &names)
static std::vector< std::string > canonical_attributes_ordering
std::map< std::string, std::string > pythonScriptsByKey
MoFEMErrorCode loadFromFile(const std::string &file_name)
MoFEMErrorCode getSubInterfaceOptions()
std::map< MeshsetKey, MeshsetParams > primaryMeshsetParamsByKey
std::map< std::string, std::string > MeshsetStringParams
std::map< MeshsetKey, MeshsetStringParams > primaryMeshsetStringParamsByKey
boost::json::value configRoot
std::pair< std::string, int > MeshsetKey
MoFEMErrorCode loadFromCommandLine()
std::map< std::string, std::string > getStringParamsFromBlockset(const std::string &type_name, int meshset_id) const
base class for all interface classes