diff --git a/MaterialLib/MPL/MaterialSpatialDistributionMap.h b/MaterialLib/MPL/MaterialSpatialDistributionMap.h index 60b6568747b4cadcf992d031269fb65f2aa551ec..0116e89e553f7584a0c0df1adea8d5aec77b03c3 100644 --- a/MaterialLib/MPL/MaterialSpatialDistributionMap.h +++ b/MaterialLib/MPL/MaterialSpatialDistributionMap.h @@ -13,6 +13,7 @@ #include <map> #include <memory> +#include <range/v3/view.hpp> #include <vector> namespace MeshLib @@ -35,6 +36,8 @@ public: { } + auto media() const { return media_ | ranges::views::values; } + Medium* getMedium(std::size_t element_id); Medium const* getMedium(std::size_t element_id) const; void checkElementHasMedium(std::size_t const element_id) const; diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp index 9ee99a2e7559418ac12e5c199406fd702794cac6..cca70eec3a129a98bdabc563d6c8c8d15c6d2979 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp @@ -45,10 +45,9 @@ void checkMPLProperties( // Collect phases of all elements... auto all_phases = - mesh.getElements() | MeshLib::views::ids | - ranges::views::transform( - [&](auto const& element_id) - { return &fluidPhase(*media_map.getMedium(element_id)); }) | + media_map.media() | + ranges::views::transform([&](auto const& medium) + { return &fluidPhase(*medium); }) | ranges::to_vector; assert(!all_phases.empty()); @@ -76,28 +75,27 @@ void checkMPLProperties( // Check Constant-type density. if (is_equation_type_volume) { - for (auto const& element_id : mesh.getElements() | MeshLib::views::ids) + for (auto const& medium : media_map.media()) { - auto const& medium = *media_map.getMedium(element_id); + // auto const& medium = *media_map.getMedium(element_id); auto const& fluid_phase_density = - fluidPhase(medium)[MaterialPropertyLib::PropertyType::density]; + fluidPhase(*medium)[MaterialPropertyLib::PropertyType::density]; if (typeid(fluid_phase_density) != typeid(MaterialPropertyLib::Constant)) { OGS_FATAL( "Since `equation_balance_type` is set to `volume`,the " "phase density type must be `Constant`. Note: by " - "default, " - "`equation_balance_type` is set to `volume`."); + "default, `equation_balance_type` is set to `volume`."); } } } - for (auto const& element_id : mesh.getElements() | MeshLib::views::ids) + for (auto const& medium : media_map.media()) { - auto const& medium = *media_map.getMedium(element_id); - checkRequiredProperties(medium, required_medium_properties); - checkRequiredProperties(fluidPhase(medium), required_liquid_properties); + checkRequiredProperties(*medium, required_medium_properties); + checkRequiredProperties(fluidPhase(*medium), + required_liquid_properties); } DBUG("Media properties verified."); }