From b75c12216fb3dd630e953e4118a6b27218e79425 Mon Sep 17 00:00:00 2001 From: Florian Zill <florian.zill@ufz.de> Date: Fri, 24 Jan 2020 11:27:25 +0100 Subject: [PATCH] [HM] add check for required MPL properties --- MaterialLib/MPL/Phase.cpp | 1 + MaterialLib/MPL/Phase.h | 14 ++++++++++++++ .../HydroMechanics/CreateHydroMechanicsProcess.cpp | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/MaterialLib/MPL/Phase.cpp b/MaterialLib/MPL/Phase.cpp index 382ab438aa3..94a09592611 100644 --- a/MaterialLib/MPL/Phase.cpp +++ b/MaterialLib/MPL/Phase.cpp @@ -65,4 +65,5 @@ std::string Phase::name() const { return std::get<std::string>(_properties[PropertyType::name]->value()); } + } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Phase.h b/MaterialLib/MPL/Phase.h index 6fc1c300247..b7e6778ca47 100644 --- a/MaterialLib/MPL/Phase.h +++ b/MaterialLib/MPL/Phase.h @@ -52,6 +52,20 @@ public: std::string name() const; + template <size_t N> + void checkRequiredProperties( + std::array<PropertyType, N> const& required_properties) const + { + for (auto const& p : required_properties) + { + if (!hasProperty(p)) + { + OGS_FATAL("The property '%s' is missing in the %s phase.", + property_enum_to_string[p].c_str(), name().c_str()); + } + } + } + private: std::vector<std::unique_ptr<Component>> const _components; diff --git a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp index ea1b29bd97d..26ad711fb42 100644 --- a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp +++ b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp @@ -14,6 +14,7 @@ #include "MaterialLib/MPL/CreateMaterialSpatialDistributionMap.h" #include "MaterialLib/MPL/MaterialSpatialDistributionMap.h" +#include "MaterialLib/MPL/Medium.h" #include "MaterialLib/SolidModels/CreateConstitutiveRelation.h" #include "MaterialLib/SolidModels/MechanicsBase.h" @@ -164,6 +165,15 @@ std::unique_ptr<Process> createHydroMechanicsProcess( auto media_map = MaterialPropertyLib::createMaterialSpatialDistributionMap(media, mesh); + std::array const requiredGasProperties = {MaterialPropertyLib::viscosity}; + std::array const requiredSolidProperties = {MaterialPropertyLib::porosity}; + for (auto const& m : media) + { + m.second->phase("Gas").checkRequiredProperties(requiredGasProperties); + m.second->phase("Solid").checkRequiredProperties( + requiredSolidProperties); + } + // Initial stress conditions auto const initial_stress = ParameterLib::findOptionalTagParameter<double>( //! \ogs_file_param_special{prj__processes__process__HYDRO_MECHANICS__initial_stress} -- GitLab