From ae31d7fd047bade45395750059a18eecef8528d7 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Mon, 28 Aug 2023 22:30:33 +0200 Subject: [PATCH] Use MeshLib::views::ids in for-loops The first transformation can be directly applied in the for-range-loop. --- .../MPL/CheckMaterialSpatialDistributionMap.h | 4 +--- .../ConstraintDirichletBoundaryCondition.cpp | 14 ++++++-------- .../CreateComponentTransportProcess.cpp | 4 +--- .../HydroMechanics/CreateHydroMechanicsProcess.cpp | 3 +-- .../SmallDeformation/SmallDeformationProcess.cpp | 6 +++--- .../CreateRichardsComponentTransportProcess.cpp | 4 +--- ProcessLib/StokesFlow/CreateStokesFlowProcess.cpp | 3 +-- 7 files changed, 14 insertions(+), 24 deletions(-) diff --git a/MaterialLib/MPL/CheckMaterialSpatialDistributionMap.h b/MaterialLib/MPL/CheckMaterialSpatialDistributionMap.h index f3d78a977fc..7d4ec3b2a94 100644 --- a/MaterialLib/MPL/CheckMaterialSpatialDistributionMap.h +++ b/MaterialLib/MPL/CheckMaterialSpatialDistributionMap.h @@ -28,10 +28,8 @@ void checkMaterialSpatialDistributionMap( ContainerLiquid const& required_properties_liquid_phase, ContainerGas const& required_properties_gas_phase) { - for (auto const& element : mesh.getElements()) + for (auto const element_id : mesh.getElements() | MeshLib::views::ids) { - auto const element_id = element->getID(); - auto const& medium = *media_map.getMedium(element_id); if (!required_properties_medium.empty()) { diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp index b9593bd78b8..acf8af3f23b 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp @@ -114,15 +114,13 @@ void ConstraintDirichletBoundaryCondition::preTimestep( DBUG( "ConstraintDirichletBoundaryCondition::preTimestep: computing flux " "constraints"); - for (auto const* boundary_element : _bc_mesh.getElements()) + for (auto const id : _bc_mesh.getElements() | MeshLib::views::ids) { - _flux_values[boundary_element->getID()] = - _local_assemblers[boundary_element->getID()]->integrate( - x, t, - [this](std::size_t const element_id, - MathLib::Point3d const& pnt, double const t, - std::vector<GlobalVector*> const& x) - { return _getFlux(element_id, pnt, t, x); }); + _flux_values[id] = _local_assemblers[id]->integrate( + x, t, + [this](std::size_t const element_id, MathLib::Point3d const& pnt, + double const t, std::vector<GlobalVector*> const& x) + { return _getFlux(element_id, pnt, t, x); }); } } diff --git a/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp b/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp index 5446d3f9112..022adcac2c3 100644 --- a/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp +++ b/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp @@ -47,10 +47,8 @@ void checkMPLProperties( MaterialPropertyLib::PropertyType::decay_rate, MaterialPropertyLib::PropertyType::pore_diffusion}; - for (auto const& element : mesh.getElements()) + for (auto const& element_id : mesh.getElements() | MeshLib::views::ids) { - auto const element_id = element->getID(); - auto const& medium = *media_map.getMedium(element_id); checkRequiredProperties(medium, required_properties_medium); diff --git a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp index d69ac4a5f40..a40c37308ae 100644 --- a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp +++ b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp @@ -214,9 +214,8 @@ std::unique_ptr<Process> createHydroMechanicsProcess( MaterialPropertyLib::density}; std::array const requiredSolidProperties = {MaterialPropertyLib::density}; - for (auto const& element : mesh.getElements()) + for (auto const& element_id : mesh.getElements() | MeshLib::views::ids) { - auto const element_id = element->getID(); media_map->checkElementHasMedium(element_id); auto const& medium = *media_map->getMedium(element_id); checkRequiredProperties(medium, requiredMediumProperties); diff --git a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp index e605bd92790..b2f079c5fbe 100644 --- a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp +++ b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp @@ -144,10 +144,10 @@ SmallDeformationProcess<DisplacementDim>::SmallDeformationProcess( for (unsigned i = 0; i < vec_junction_nodeID_matIDs.size(); i++) { auto node = mesh.getNode(vec_junction_nodeID_matIDs[i].first); - for (auto e : mesh.getElementsConnectedToNode(*node)) + for (auto id : + mesh.getElementsConnectedToNode(*node) | MeshLib::views::ids) { - _process_data._vec_ele_connected_junctionIDs[e->getID()].push_back( - i); + _process_data._vec_ele_connected_junctionIDs[id].push_back(i); } } diff --git a/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp b/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp index 71ab59ce439..a94e9842b0c 100644 --- a/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp +++ b/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp @@ -46,10 +46,8 @@ void checkMPLProperties( MaterialPropertyLib::PropertyType::decay_rate, MaterialPropertyLib::PropertyType::pore_diffusion}; - for (auto const& element : mesh.getElements()) + for (auto const element_id : mesh.getElements() | MeshLib::views::ids) { - auto const element_id = element->getID(); - auto const& medium = *media_map.getMedium(element_id); checkRequiredProperties(medium, required_properties_medium); diff --git a/ProcessLib/StokesFlow/CreateStokesFlowProcess.cpp b/ProcessLib/StokesFlow/CreateStokesFlowProcess.cpp index 91cea3678a8..955011e536e 100644 --- a/ProcessLib/StokesFlow/CreateStokesFlowProcess.cpp +++ b/ProcessLib/StokesFlow/CreateStokesFlowProcess.cpp @@ -33,9 +33,8 @@ void checkMPLProperties( std::array const required_properties_medium = { MaterialPropertyLib::PropertyType::permeability}; - for (auto const& element : mesh.getElements()) + for (auto const element_id : mesh.getElements() | MeshLib::views::ids) { - auto const element_id = element->getID(); auto const& medium = *media_map.getMedium(element_id); if (use_stokes_brinkman_form) -- GitLab