diff --git a/MaterialLib/MPL/Medium.h b/MaterialLib/MPL/Medium.h index 02ca470aee7f1253ca25f40dba99f158e41e661a..f3defca3d60a1098ac4f41445d47637fd14c6681 100644 --- a/MaterialLib/MPL/Medium.h +++ b/MaterialLib/MPL/Medium.h @@ -88,4 +88,19 @@ private: /// special-defaults are allowed as well... PropertyArray _properties; }; + +template <typename Container> +void checkRequiredProperties(Medium const& medium, + Container const& required_properties) +{ + for (auto const& p : required_properties) + { + if (!medium.hasProperty(p)) + { + OGS_FATAL("The property '%s' is missing in the medium definition.", + property_enum_to_string[p].c_str()); + } + } +} + } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Phase.h b/MaterialLib/MPL/Phase.h index b7e6778ca47327bf51596682f4bc66f50e73790a..951e764099e7cb63af3a819ba6b76d219814c9d8 100644 --- a/MaterialLib/MPL/Phase.h +++ b/MaterialLib/MPL/Phase.h @@ -52,20 +52,6 @@ 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; @@ -77,4 +63,17 @@ private: PropertyArray _properties; }; +template <typename Container> +void checkRequiredProperties(Phase const& phase, Container const& required_properties) +{ + for (auto const& p : required_properties) + { + if (!phase.hasProperty(p)) + { + OGS_FATAL("The property '%s' is missing in the %s phase.", + property_enum_to_string[p].c_str(), phase.name().c_str()); + } + } +} + } // namespace MaterialPropertyLib diff --git a/ProcessLib/HT/HTProcess.cpp b/ProcessLib/HT/HTProcess.cpp index 9eb373accd42e5007193f28ba99527796ca0d39e..b9097fc45ac1b7c6e84075d43b42dbe4208324ce 100644 --- a/ProcessLib/HT/HTProcess.cpp +++ b/ProcessLib/HT/HTProcess.cpp @@ -24,6 +24,42 @@ namespace ProcessLib { namespace HT { +void checkMPLProperties(MeshLib::Mesh const& mesh, + HTProcessData const& process_data) +{ + DBUG("Check the media properties of HT process ..."); + + std::array const requiredPropertyMedium = { + MaterialPropertyLib::PropertyType::porosity, + MaterialPropertyLib::PropertyType::permeability}; + + std::array const requiredPropertyLiquidPhase = { + MaterialPropertyLib::PropertyType::viscosity, + MaterialPropertyLib::PropertyType::density, + MaterialPropertyLib::PropertyType::specific_heat_capacity}; + + std::array const requiredPropertySolidPhase = { + MaterialPropertyLib::PropertyType::specific_heat_capacity, + MaterialPropertyLib::PropertyType::density, + MaterialPropertyLib::PropertyType::storage}; + + for (auto const& element : mesh.getElements()) + { + auto const element_id = element->getID(); + + auto const& medium = *process_data.media_map->getMedium(element_id); + MaterialPropertyLib::checkRequiredProperties( + medium, requiredPropertyMedium); + + MaterialPropertyLib::checkRequiredProperties( + medium.phase("AqueousLiquid"), requiredPropertyLiquidPhase); + + MaterialPropertyLib::checkRequiredProperties( + medium.phase("Solid"), requiredPropertySolidPhase); + } + DBUG("Media properties verified."); +} + HTProcess::HTProcess( std::string name, MeshLib::Mesh& mesh, @@ -285,72 +321,5 @@ void HTProcess::postTimestepConcreteProcess(std::vector<GlobalVector*> const& x, pv.getActiveElementIDs()); _surfaceflux->save(t); } - -void checkMPLProperties(MeshLib::Mesh const& mesh, - HTProcessData const& process_data) -{ - DBUG("Check the media properties of HT process ..."); - - std::array const requiredPropertyMedium = { - MaterialPropertyLib::PropertyType::porosity, - MaterialPropertyLib::PropertyType::permeability}; - - std::array const requiredPropertyLiquidPhase = { - MaterialPropertyLib::PropertyType::viscosity, - MaterialPropertyLib::PropertyType::density, - MaterialPropertyLib::PropertyType::specific_heat_capacity}; - - std::array const requiredPropertySolidPhase = { - MaterialPropertyLib::PropertyType::specific_heat_capacity, - MaterialPropertyLib::PropertyType::density, - MaterialPropertyLib::PropertyType::storage}; - - for (auto const& element : mesh.getElements()) - { - auto const element_id = element->getID(); - - // check if a definition of the porous media exists - auto const& medium = *process_data.media_map->getMedium(element_id); - - for (auto const property : requiredPropertyMedium) - { - if (!medium.hasProperty(property)) - { - OGS_FATAL("The property '%s' is not specified for the medium.", - MaterialPropertyLib::property_enum_to_string[property] - .c_str()); - } - } - - // check if liquid phase definition and the corresponding properties - // exists - auto const& liquid_phase = medium.phase("AqueousLiquid"); - for (auto const property : requiredPropertyLiquidPhase) - { - if (!liquid_phase.hasProperty(property)) - { - OGS_FATAL( - "The property '%s' is not specified for the liquid phase.", - MaterialPropertyLib::property_enum_to_string[property] - .c_str()); - } - } - - // check if solid phase definition and the corresponding properties - // exists - auto const& solid_phase = medium.phase("Solid"); - for (auto const property : requiredPropertySolidPhase) - { - if (!solid_phase.hasProperty(property)) - { - OGS_FATAL( - "The property '%s' is not specified for the solid phase.", - MaterialPropertyLib::property_enum_to_string[property] - .c_str()); - } - } - } - DBUG("Media properties verified."); -} } // namespace HT } // namespace ProcessLib diff --git a/ProcessLib/HT/HTProcess.h b/ProcessLib/HT/HTProcess.h index e39b241ae47406f282ffd37bdd8f3391b4674f1d..a65bea11323cf4c6ffd2f98f20ac37605ec6893d 100644 --- a/ProcessLib/HT/HTProcess.h +++ b/ProcessLib/HT/HTProcess.h @@ -135,8 +135,5 @@ private: const int _hydraulic_process_id; }; -void checkMPLProperties(MeshLib::Mesh const& mesh, - HTProcessData const& process_data); - } // namespace HT } // namespace ProcessLib diff --git a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp index 06496c002e235701c0cd3ba0e3cf4714e7175756..410299d5da0769e3e259e220c1e7df5f3ac79a4c 100644 --- a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp +++ b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp @@ -156,9 +156,9 @@ std::unique_ptr<Process> createHydroMechanicsProcess( MaterialPropertyLib::density}; for (auto const& m : media) { - m.second->phase("Gas").checkRequiredProperties(requiredGasProperties); - m.second->phase("Solid").checkRequiredProperties( - requiredSolidProperties); + checkRequiredProperties(m.second->phase("Gas"), requiredGasProperties); + checkRequiredProperties(m.second->phase("Solid"), + requiredSolidProperties); } // Initial stress conditions