diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 1d0c60c2240f128adfb04336b761b51025381670..434869390cd58ea0b3e5eeb8c6a3785baa553427 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -488,7 +488,8 @@ void ProjectData::parseMedia( if (id == material_ids_of_this_medium[0]) { _media[id] = MaterialPropertyLib::createMedium( - _mesh_vec[0]->getDimension(), medium_config, _parameters, + id, _mesh_vec[0]->getDimension(), medium_config, + _parameters, _local_coordinate_system ? &*_local_coordinate_system : nullptr, _curves); diff --git a/MaterialLib/MPL/CreateMedium.cpp b/MaterialLib/MPL/CreateMedium.cpp index 388b910a249d5f34adac94595983cd8ad75e3597..b563262dce3db3f55fc1ff21a0c6b2752d780bbb 100644 --- a/MaterialLib/MPL/CreateMedium.cpp +++ b/MaterialLib/MPL/CreateMedium.cpp @@ -22,6 +22,7 @@ namespace MaterialPropertyLib { std::unique_ptr<Medium> createMedium( + int const material_id, int const geometry_dimension, BaseLib::ConfigTree const& config, std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters, @@ -49,7 +50,8 @@ std::unique_ptr<Medium> createMedium( OGS_FATAL("Neither tag <phases> nor tag <properties> has been found."); } - return std::make_unique<Medium>(std::move(phases), std::move(properties)); + return std::make_unique<Medium>(material_id, std::move(phases), + std::move(properties)); } } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/CreateMedium.h b/MaterialLib/MPL/CreateMedium.h index 8e8587e02c4f242f21159cb42576790e7079de74..bf84ddbb10de67c7242d4c17f7785a90d52f3c57 100644 --- a/MaterialLib/MPL/CreateMedium.h +++ b/MaterialLib/MPL/CreateMedium.h @@ -42,6 +42,7 @@ namespace MaterialPropertyLib /// Medium properties are optional. If not defined, default properties are /// assigned. std::unique_ptr<Medium> createMedium( + int const material_id, int const geometry_dimension, BaseLib::ConfigTree const& config, std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters, diff --git a/MaterialLib/MPL/Medium.cpp b/MaterialLib/MPL/Medium.cpp index f995c260241369030deea0e241178ce673979b3c..aeb3f0c402ddb8e04898d7fdf40146fbff5a7a73 100644 --- a/MaterialLib/MPL/Medium.cpp +++ b/MaterialLib/MPL/Medium.cpp @@ -17,9 +17,10 @@ namespace MaterialPropertyLib { -Medium::Medium(std::vector<std::unique_ptr<Phase>>&& phases, +Medium::Medium(int const material_id, + std::vector<std::unique_ptr<Phase>>&& phases, std::unique_ptr<PropertyArray>&& properties) - : phases_(std::move(phases)) + : phases_(std::move(phases)), material_id_(material_id) { if (properties) { @@ -74,9 +75,9 @@ std::size_t Medium::numberOfPhases() const return phases_.size(); } -std::string Medium::description() +std::string Medium::description() const { - return "medium"; + return "medium " + std::to_string(material_id_); } Phase const& fluidPhase(Medium const& medium) diff --git a/MaterialLib/MPL/Medium.h b/MaterialLib/MPL/Medium.h index 44636acd0484037b61c16d966a7399b23c389074..5c58be939bd353180f7c25900135519de17d5de5 100644 --- a/MaterialLib/MPL/Medium.h +++ b/MaterialLib/MPL/Medium.h @@ -31,7 +31,8 @@ namespace MaterialPropertyLib class Medium final { public: - Medium(std::vector<std::unique_ptr<Phase>>&& phases, + Medium(int const material_id, + std::vector<std::unique_ptr<Phase>>&& phases, std::unique_ptr<PropertyArray>&& properties); /// A get-function for a particular phase. The ul argument specifies the @@ -56,7 +57,7 @@ public: std::size_t numberOfPhases() const; /// Short description of the medium. - static std::string description(); + std::string description() const; template <typename T> T value(PropertyType const p) const @@ -98,6 +99,10 @@ private: /// Most properties are fine with the volume fraction average, but /// special-defaults are allowed as well... PropertyArray properties_; + + /// The first material id for which the medium was created. Used in the + /// description. + int const material_id_; }; template <typename Container> diff --git a/Tests/MaterialLib/TestMPL.cpp b/Tests/MaterialLib/TestMPL.cpp index 8539ae9b4480dd316db0c0b9ba1a4605984c212a..688ec60e15a31a179c77f0c57efdad988fad02e9 100644 --- a/Tests/MaterialLib/TestMPL.cpp +++ b/Tests/MaterialLib/TestMPL.cpp @@ -38,8 +38,8 @@ std::unique_ptr<MPL::Medium> createTestMaterial( std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> curves; - return MPL::createMedium(geometry_dimension, config, parameters, - local_coordinate_system, curves); + return MPL::createMedium(0 /*material id*/, geometry_dimension, config, + parameters, local_coordinate_system, curves); } std::unique_ptr<MaterialPropertyLib::Property> createTestProperty(