diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 947a3eaa141035961bada73d95c649f803fb2a8a..93398f45340adfd1e2977d46f8b52c834ddd8621 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -28,6 +28,8 @@ #include "FileIO/XmlIO/Boost/BoostXmlGmlInterface.h" #include "FileIO/readMeshFromFile.h" +#include "BaseLib/ConfigTreeNew.h" + namespace detail { static @@ -61,7 +63,9 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, _mesh_vec.push_back(mesh); // process variables - parseProcessVariables(project_config.get_child("process_variables")); + + BaseLib::ConfigTreeNew var_conf(project_config.get_child("process_variables")); + parseProcessVariables(var_conf); // parameters parseParameters(project_config.get_child("parameters")); @@ -174,7 +178,7 @@ bool ProjectData::isMeshNameUniqueAndProvideUniqueName(std::string &name) const } void ProjectData::parseProcessVariables( - BaseLib::ConfigTree const& process_variables_config) + BaseLib::ConfigTreeNew& process_variables_config) { DBUG("Parse process variables:") if (_geoObjects == nullptr) { @@ -191,12 +195,12 @@ void ProjectData::parseProcessVariables( return; } - _process_variables.reserve(process_variables_config.size()); + // _process_variables.reserve(process_variables_config.size()); - for (auto it : process_variables_config) { - BaseLib::ConfigTree const& var_config = it.second; + for (auto var_config + : process_variables_config.getConfSubtreeList("process_variable")) { // TODO Extend to referenced meshes. - _process_variables.emplace_back(var_config,*_mesh_vec[0],*_geoObjects); + _process_variables.emplace_back(var_config, *_mesh_vec[0], *_geoObjects); } } diff --git a/Applications/ApplicationsLib/ProjectData.h b/Applications/ApplicationsLib/ProjectData.h index d5fa7f0f8604874c80e1d1c1c609237665443b69..a537af688a88bc615a1e58a25abcdedce75bd3d9 100644 --- a/Applications/ApplicationsLib/ProjectData.h +++ b/Applications/ApplicationsLib/ProjectData.h @@ -167,7 +167,7 @@ private: /// Parses the process variables configuration and creates new variables for /// each variable entry passing the corresponding subtree to the process /// variable constructor. - void parseProcessVariables(BaseLib::ConfigTree const& process_variables_config); + void parseProcessVariables(BaseLib::ConfigTreeNew& process_variables_config); /// Parses the parameters configuration and saves them in a list. /// Checks if a parameter has name tag. diff --git a/ProcessLib/InitialCondition.cpp b/ProcessLib/InitialCondition.cpp index bad0bb68a43aae732c757e30104f5fe32a9d8401..ff0789664f198d420a759bc8897da15235e9c60e 100644 --- a/ProcessLib/InitialCondition.cpp +++ b/ProcessLib/InitialCondition.cpp @@ -16,46 +16,40 @@ #include "MeshLib/Elements/Element.h" #include "MeshLib/Mesh.h" +#include "BaseLib/ConfigTreeNew.h" + namespace ProcessLib { std::unique_ptr<InitialCondition> createUniformInitialCondition( - BaseLib::ConfigTree const& config) + BaseLib::ConfigTreeNew& config) { - auto value = config.get_optional<double>("value"); - if (!value) - { - ERR("Could not find required parameter value."); - std::abort(); - } - DBUG("Using value %g", *value); + config.checkConfParam("type", "Uniform"); + + auto value = config.getConfParam<double>("value"); + DBUG("Using value %g", value); return std::unique_ptr<InitialCondition>( - new UniformInitialCondition(*value)); + new UniformInitialCondition(value)); } std::unique_ptr<InitialCondition> createMeshPropertyInitialCondition( - BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh) + BaseLib::ConfigTreeNew& config, MeshLib::Mesh const& mesh) { - auto field_name = config.get_optional<std::string>("field_name"); - if (!field_name) - { - ERR("Could not find required parameter field_name."); - std::abort(); - } - DBUG("Using field_name %s", field_name->c_str()); + auto field_name = config.getConfParam<std::string>("field_name"); + DBUG("Using field_name %s", field_name.c_str()); - if (!mesh.getProperties().hasPropertyVector(*field_name)) + if (!mesh.getProperties().hasPropertyVector(field_name)) { ERR("The required property %s does not exists in the mesh.", - field_name->c_str()); + field_name.c_str()); std::abort(); } auto const& property = - mesh.getProperties().template getPropertyVector<double>(*field_name); + mesh.getProperties().template getPropertyVector<double>(field_name); if (!property) { ERR("The required property %s is not of the requested type.", - field_name->c_str()); + field_name.c_str()); std::abort(); } diff --git a/ProcessLib/InitialCondition.h b/ProcessLib/InitialCondition.h index b3093bc39308d8524d004b38cfa215e56e2d8ae7..b8a6831cdf80f6ff40ae5fdf01cf58300ad4348e 100644 --- a/ProcessLib/InitialCondition.h +++ b/ProcessLib/InitialCondition.h @@ -15,6 +15,11 @@ #include "MeshLib/Node.h" #include "MeshLib/PropertyVector.h" +namespace BaseLib +{ +class ConfigTreeNew; +} + namespace MeshLib { template <typename> @@ -52,7 +57,7 @@ private: /// Construct a UniformInitialCondition from configuration. std::unique_ptr<InitialCondition> createUniformInitialCondition( - BaseLib::ConfigTree const& config); + BaseLib::ConfigTreeNew& config); /// Distribution of values given by a mesh property defined on nodes. class MeshPropertyInitialCondition : public InitialCondition @@ -76,7 +81,7 @@ private: /// Construct a MeshPropertyInitialCondition from configuration. std::unique_ptr<InitialCondition> createMeshPropertyInitialCondition( - BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh); + BaseLib::ConfigTreeNew& config, MeshLib::Mesh const& mesh); } // namespace ProcessLib diff --git a/ProcessLib/NeumannBcConfig.h b/ProcessLib/NeumannBcConfig.h index 5cccdadb7ff782735bd562bf93a81ea1d7ce0300..e65d2d972258aa1d3fc310ac5f2cec3209750fe8 100644 --- a/ProcessLib/NeumannBcConfig.h +++ b/ProcessLib/NeumannBcConfig.h @@ -12,7 +12,7 @@ #include "logog/include/logog.hpp" -#include "BaseLib/ConfigTree.h" +#include "BaseLib/ConfigTreeNew.h" #include "MathLib/ConstantFunction.h" #include "MeshGeoToolsLib/BoundaryElementsSearcher.h" #include "MeshLib/Elements/Element.h" @@ -44,12 +44,13 @@ class NeumannBcConfig : public BoundaryConditionConfig { public: NeumannBcConfig(GeoLib::GeoObject const* const geometry, - BaseLib::ConfigTree const& config) + BaseLib::ConfigTreeNew& config) : BoundaryConditionConfig(geometry) { DBUG("Constructing NeumannBcConfig from config."); + config.checkConfParam("type", "UniformNeumann"); - double const value = config.get<double>("value", 0); + double const value = config.getConfParam<double>("value"); DBUG("Using value %g", value); _function = new MathLib::ConstantFunction<double>(value); diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index 8ccf66315e9928ff02aacd47d88e577d85db6daa..58b3a083f5e27f72b22c46cbafca69a74c81ffff 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -14,54 +14,52 @@ #include "GeoLib/GEOObjects.h" #include "MeshLib/Mesh.h" +#include "BaseLib/ConfigTreeNew.h" + namespace ProcessLib { -ProcessVariable::ProcessVariable(BaseLib::ConfigTree const& config, +ProcessVariable::ProcessVariable(BaseLib::ConfigTreeNew& config, MeshLib::Mesh const& mesh, GeoLib::GEOObjects const& geometries) - : _name(config.get<std::string>("name")), _mesh(mesh) + : _name(config.getConfParam<std::string>("name")) + , _mesh(mesh) { DBUG("Constructing process variable %s", this->_name.c_str()); // Initial condition + if (auto ic_config = config.getConfSubtreeOptional("initial_condition")) { - auto const& ic_config = config.find("initial_condition"); - if (ic_config == config.not_found()) - INFO("No initial condition found."); - - std::string const type = - config.get<std::string>("initial_condition.type"); + auto const type = ic_config->peekConfParam<std::string>("type"); if (type == "Uniform") { _initial_condition = - createUniformInitialCondition(ic_config->second); + createUniformInitialCondition(*ic_config); } else if (type == "MeshProperty") { _initial_condition = - createMeshPropertyInitialCondition(ic_config->second, _mesh); + createMeshPropertyInitialCondition(*ic_config, _mesh); } else { ERR("Unknown type of the initial condition."); } } + else + { + INFO("No initial condition found."); + } // Boundary conditions + if (auto bcs_config = config.getConfSubtreeOptional("boundary_conditions")) { - auto const& bcs_config = config.find("boundary_conditions"); - if (bcs_config == config.not_found()) - INFO("No boundary conditions found."); - - for (auto const& bc_iterator : bcs_config->second) + for (auto bc_config + : bcs_config->getConfSubtreeList("boundary_condition")) { - BaseLib::ConfigTree const& bc_config = bc_iterator.second; - - // Find corresponding GeoObject - std::string const geometrical_set_name = - bc_config.get<std::string>("geometrical_set"); - std::string const geometry_name = - bc_config.get<std::string>("geometry"); + auto const geometrical_set_name = + bc_config.getConfParam<std::string>("geometrical_set"); + auto const geometry_name = + bc_config.getConfParam<std::string>("geometry"); GeoLib::GeoObject const* const geometry = geometries.getGeoObject(geometrical_set_name, geometry_name); @@ -70,7 +68,7 @@ ProcessVariable::ProcessVariable(BaseLib::ConfigTree const& config, GeoLib::convertGeoTypeToString(geometry->getGeoType()).c_str()); // Construct type dependent boundary condition - std::string const type = bc_config.get<std::string>("type"); + auto const type = bc_config.peekConfParam<std::string>("type"); if (type == "UniformDirichlet") { @@ -88,7 +86,12 @@ ProcessVariable::ProcessVariable(BaseLib::ConfigTree const& config, type.c_str()); } } + } else { + INFO("No boundary conditions found."); } + + // Source Terms + config.ignoreConfParam("source_terms"); } ProcessVariable::ProcessVariable(ProcessVariable&& other) diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h index f83b61e760166b91181508fa4b193697aca26c3b..957cdc45f6d771aef0fe41da70145bd8677affba 100644 --- a/ProcessLib/ProcessVariable.h +++ b/ProcessLib/ProcessVariable.h @@ -46,7 +46,7 @@ namespace ProcessLib class ProcessVariable { public: - ProcessVariable(BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh, + ProcessVariable(BaseLib::ConfigTreeNew& config, MeshLib::Mesh const& mesh, GeoLib::GEOObjects const& geometries); ProcessVariable(ProcessVariable&&); diff --git a/ProcessLib/UniformDirichletBoundaryCondition.h b/ProcessLib/UniformDirichletBoundaryCondition.h index 5eed826238821c2572b273205357b8e969600005..2275e49d4f97162f54546bb6aa50cd6e578031de 100644 --- a/ProcessLib/UniformDirichletBoundaryCondition.h +++ b/ProcessLib/UniformDirichletBoundaryCondition.h @@ -17,7 +17,7 @@ #include "NumericsConfig.h" // for GlobalIndexType -#include "BaseLib/ConfigTree.h" +#include "BaseLib/ConfigTreeNew.h" #include "AssemblerLib/LocalToGlobalIndexMap.h" #include "MeshGeoToolsLib/MeshNodeSearcher.h" @@ -37,12 +37,13 @@ class UniformDirichletBoundaryCondition { public: UniformDirichletBoundaryCondition(GeoLib::GeoObject const* const geometry, - BaseLib::ConfigTree const& config) + BaseLib::ConfigTreeNew& config) : _geometry(geometry) { DBUG("Constructing UniformDirichletBoundaryCondition from config."); + config.checkConfParam("type", "UniformDirichlet"); - _value = config.get<double>("value", 0); + _value = config.getConfParam<double>("value"); DBUG("Using value %g", _value); }