From 6e8ac6c1e2f06ac86543dc15db2dc390f77cdac5 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Thu, 31 May 2018 23:11:01 +0200
Subject: [PATCH] [PL] Using updated DOF tables and replace MSS.

MSS being the mesh subsets.
---
 .../CalculateSurfaceFlux.cpp                  | 11 ++-
 ProcessLib/HT/HTProcess.cpp                   |  5 +-
 .../HydroMechanics/HydroMechanicsProcess.cpp  | 32 +++-----
 .../GenericNaturalBoundaryCondition-impl.h    | 12 +--
 .../HydroMechanics/HydroMechanicsProcess.cpp  | 39 ++++-----
 .../LocalAssembler/LocalDataInitializer.h     |  5 +-
 .../LocalAssembler/LocalDataInitializer.h     |  5 +-
 .../SmallDeformationProcess.cpp               | 15 ++--
 ProcessLib/Output/ProcessOutput.cpp           | 32 ++++----
 ProcessLib/PhaseField/PhaseFieldProcess.cpp   | 17 ++--
 ProcessLib/Process.cpp                        | 80 ++++++++-----------
 .../SmallDeformationProcess.cpp               |  5 +-
 .../ThermoMechanicalPhaseFieldProcess-impl.h  | 18 ++---
 .../ThermoMechanicsProcess.cpp                |  5 +-
 14 files changed, 117 insertions(+), 164 deletions(-)

diff --git a/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp b/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp
index 8d06ccea54f..6df76d75d7a 100644
--- a/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp
+++ b/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp
@@ -25,15 +25,14 @@ CalculateSurfaceFlux::CalculateSurfaceFlux(
     _local_assemblers.resize(boundary_mesh.getElements().size());
 
     // needed to create dof table
-    auto mesh_subset_all_nodes = std::make_unique<MeshLib::MeshSubset const>(
+    auto mesh_subset_all_nodes = std::make_unique<MeshLib::MeshSubset>(
         boundary_mesh, &boundary_mesh.getNodes());
 
     // Collect the mesh subsets in a vector.
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
-    std::generate_n(
-        std::back_inserter(all_mesh_subsets),
-        bulk_property_number_of_components,
-        [&]() { return MeshLib::MeshSubsets{mesh_subset_all_nodes.get()}; });
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets;
+    std::generate_n(std::back_inserter(all_mesh_subsets),
+                    bulk_property_number_of_components,
+                    [&]() { return *mesh_subset_all_nodes; });
 
     // needed for creation of local assemblers
     auto dof_table = std::make_unique<NumLib::LocalToGlobalIndexMap const>(
diff --git a/ProcessLib/HT/HTProcess.cpp b/ProcessLib/HT/HTProcess.cpp
index 97787d9410d..b35de56df01 100644
--- a/ProcessLib/HT/HTProcess.cpp
+++ b/ProcessLib/HT/HTProcess.cpp
@@ -206,9 +206,8 @@ HTProcess::getDOFTableForExtrapolatorData() const
     }
 
     // Otherwise construct a new DOF table.
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
+        *_mesh_subset_all_nodes};
 
     const bool manage_storage = true;
     return std::make_tuple(new NumLib::LocalToGlobalIndexMap(
diff --git a/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
index 956a77a28d8..2516041361f 100644
--- a/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
+++ b/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
@@ -87,9 +87,8 @@ void HydroMechanicsProcess<DisplacementDim>::constructDofTable()
 
     // TODO move the two data members somewhere else.
     // for extrapolation of secondary variables of stress or strain
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
+        *_mesh_subset_all_nodes};
     _local_to_global_index_map_single_component =
         std::make_unique<NumLib::LocalToGlobalIndexMap>(
             std::move(all_mesh_subsets_single_component),
@@ -99,19 +98,16 @@ void HydroMechanicsProcess<DisplacementDim>::constructDofTable()
     if (_use_monolithic_scheme)
     {
         // For pressure, which is the first
-        std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
-        all_mesh_subsets.emplace_back(_mesh_subset_base_nodes.get());
+        std::vector<MeshLib::MeshSubset> all_mesh_subsets{
+            *_mesh_subset_base_nodes};
 
         // For displacement.
         const int monolithic_process_id = 0;
-        std::generate_n(
-            std::back_inserter(all_mesh_subsets),
-            getProcessVariables(monolithic_process_id)[1]
-                .get()
-                .getNumberOfComponents(),
-            [&]() {
-                return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()};
-            });
+        std::generate_n(std::back_inserter(all_mesh_subsets),
+                        getProcessVariables(monolithic_process_id)[1]
+                            .get()
+                            .getNumberOfComponents(),
+                        [&]() { return *_mesh_subset_all_nodes; });
 
         std::vector<int> const vec_n_components{1, DisplacementDim};
         _local_to_global_index_map =
@@ -124,13 +120,11 @@ void HydroMechanicsProcess<DisplacementDim>::constructDofTable()
     {
         // For displacement equation.
         const int process_id = 1;
-        std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
+        std::vector<MeshLib::MeshSubset> all_mesh_subsets;
         std::generate_n(
             std::back_inserter(all_mesh_subsets),
             getProcessVariables(process_id)[0].get().getNumberOfComponents(),
-            [&]() {
-                return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()};
-            });
+            [&]() { return *_mesh_subset_all_nodes; });
 
         std::vector<int> const vec_n_components{DisplacementDim};
         _local_to_global_index_map =
@@ -140,8 +134,8 @@ void HydroMechanicsProcess<DisplacementDim>::constructDofTable()
 
         // For pressure equation.
         // Collect the mesh subsets with base nodes in a vector.
-        std::vector<MeshLib::MeshSubsets> all_mesh_subsets_base_nodes;
-        all_mesh_subsets_base_nodes.emplace_back(_mesh_subset_base_nodes.get());
+        std::vector<MeshLib::MeshSubset> all_mesh_subsets_base_nodes{
+            *_mesh_subset_base_nodes};
         _local_to_global_index_map_with_base_nodes =
             std::make_unique<NumLib::LocalToGlobalIndexMap>(
                 std::move(all_mesh_subsets_base_nodes),
diff --git a/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h b/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h
index bf3ca757a07..6a6ea4959e2 100644
--- a/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h
+++ b/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h
@@ -44,19 +44,13 @@ GenericNaturalBoundaryCondition<BoundaryConditionData,
     DBUG("Found %d nodes for Natural BCs for the variable %d and component %d",
          nodes.size(), variable_id, component_id);
 
-    auto const& mesh_subsets =
-        dof_table_bulk.getMeshSubsets(variable_id, component_id);
-
-    // TODO extend the node intersection to all parts of mesh_subsets, i.e.
-    // to each of the MeshSubset in the mesh_subsets.
-    _mesh_subset_all_nodes.reset(
-        mesh_subsets.getMeshSubset(0).getIntersectionByNodes(nodes));
-    MeshLib::MeshSubsets all_mesh_subsets{_mesh_subset_all_nodes.get()};
+    MeshLib::MeshSubset mesh_subset =
+        dof_table_bulk.getMeshSubset(variable_id, component_id);
 
     // Create local DOF table from intersected mesh subsets for the given
     // variable and component ids.
     _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap(
-        variable_id, {component_id}, std::move(all_mesh_subsets), _elements));
+        variable_id, {component_id}, std::move(mesh_subset), _elements));
 
     createLocalAssemblers<LocalAssemblerImplementation>(
         global_dim, _elements, *_dof_table_boundary, shapefunction_order,
diff --git a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp
index 56969acb05a..06a915b843d 100644
--- a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp
+++ b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp
@@ -146,12 +146,12 @@ void HydroMechanicsProcess<GlobalDim>::constructDofTable()
     }
 
     // Collect the mesh subsets in a vector.
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets;
     std::vector<int> vec_n_components;
     std::vector<std::vector<MeshLib::Element*> const*> vec_var_elements;
     // pressure
     vec_n_components.push_back(1);
-    all_mesh_subsets.emplace_back(_mesh_subset_nodes_p.get());
+    all_mesh_subsets.emplace_back(*_mesh_subset_nodes_p);
     if (!_process_data.deactivate_matrix_in_flow)
     {
         vec_var_elements.push_back(&_mesh.getElements());
@@ -164,17 +164,15 @@ void HydroMechanicsProcess<GlobalDim>::constructDofTable()
     }
     // regular displacement
     vec_n_components.push_back(GlobalDim);
-    std::generate_n(std::back_inserter(all_mesh_subsets), GlobalDim, [&]() {
-        return MeshLib::MeshSubsets{_mesh_subset_matrix_nodes.get()};
-    });
+    std::generate_n(std::back_inserter(all_mesh_subsets), GlobalDim,
+                    [&]() { return *_mesh_subset_matrix_nodes; });
     vec_var_elements.push_back(&_vec_matrix_elements);
     if (!_vec_fracture_nodes.empty())
     {
         // displacement jump
         vec_n_components.push_back(GlobalDim);
-        std::generate_n(std::back_inserter(all_mesh_subsets), GlobalDim, [&]() {
-            return MeshLib::MeshSubsets{_mesh_subset_fracture_nodes.get()};
-        });
+        std::generate_n(std::back_inserter(all_mesh_subsets), GlobalDim,
+                        [&]() { return *_mesh_subset_fracture_nodes; });
         vec_var_elements.push_back(&_vec_fracture_matrix_elements);
     }
 
@@ -469,22 +467,19 @@ void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
     auto const num_comp = pv_g.getNumberOfComponents();
     for (int component_id = 0; component_id < num_comp; ++component_id)
     {
-        auto const& mesh_subsets = _local_to_global_index_map->getMeshSubsets(
+        auto const& mesh_subset = _local_to_global_index_map->getMeshSubset(
             g_variable_id, component_id);
-        for (auto const& mesh_subset : mesh_subsets)
+        auto const mesh_id = mesh_subset.getMeshID();
+        for (auto const* node : mesh_subset.getNodes())
         {
-            auto const mesh_id = mesh_subset->getMeshID();
-            for (auto const* node : mesh_subset->getNodes())
-            {
-                MeshLib::Location const l(mesh_id, MeshLib::MeshItemType::Node,
-                                          node->getID());
-
-                auto const global_index =
-                    _local_to_global_index_map->getGlobalIndex(l, g_variable_id,
-                                                               component_id);
-                mesh_prop_g[node->getID() * num_comp + component_id] =
-                    x[global_index];
-            }
+            MeshLib::Location const l(mesh_id, MeshLib::MeshItemType::Node,
+                                      node->getID());
+
+            auto const global_index =
+                _local_to_global_index_map->getGlobalIndex(l, g_variable_id,
+                                                           component_id);
+            mesh_prop_g[node->getID() * num_comp + component_id] =
+                x[global_index];
         }
     }
 
diff --git a/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h b/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h
index dbc43b629de..d6f9b2e4e68 100644
--- a/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h
+++ b/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h
@@ -232,9 +232,8 @@ public:
             auto const n_var_element_nodes = vec_n_element_nodes[i];
             for (int var_comp_id = 0; var_comp_id < n_var_comp; var_comp_id++)
             {
-                auto& mss = _dof_table.getMeshSubsets(var_id, var_comp_id);
-                assert(mss.size() == 1);
-                auto mesh_id = mss.getMeshSubset(0).getMeshID();
+                auto const& ms = _dof_table.getMeshSubset(var_id, var_comp_id);
+                auto const mesh_id = ms.getMeshID();
                 for (unsigned k = 0; k < n_var_element_nodes; k++)
                 {
                     MeshLib::Location l(mesh_id,
diff --git a/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h b/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h
index 02cb8948a2f..dbde6f63505 100644
--- a/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h
+++ b/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h
@@ -270,9 +270,8 @@ public:
                 for (int j = 0; j < _dof_table.getNumberOfVariableComponents(i);
                      j++)
                 {
-                    auto& mss = _dof_table.getMeshSubsets(i, j);
-                    assert(mss.size() == 1);
-                    auto mesh_id = mss.getMeshSubset(0).getMeshID();
+                    auto const& ms = _dof_table.getMeshSubset(i, j);
+                    auto const mesh_id = ms.getMeshID();
                     for (unsigned k = 0; k < mesh_item.getNumberOfNodes(); k++)
                     {
                         MeshLib::Location l(mesh_id,
diff --git a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp
index 5dfd2841b2a..f5a778c712d 100644
--- a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp
+++ b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp
@@ -138,16 +138,14 @@ void SmallDeformationProcess<DisplacementDim>::constructDofTable()
     }
 
     // Collect the mesh subsets in a vector.
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
-    std::generate_n(
-        std::back_inserter(all_mesh_subsets), DisplacementDim, [&]() {
-            return MeshLib::MeshSubsets{_mesh_subset_matrix_nodes.get()};
-        });
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets;
+    std::generate_n(std::back_inserter(all_mesh_subsets), DisplacementDim,
+                    [&]() { return *_mesh_subset_matrix_nodes; });
     for (auto& ms : _mesh_subset_fracture_nodes)
     {
         std::generate_n(std::back_inserter(all_mesh_subsets),
                         DisplacementDim,
-                        [&]() { return MeshLib::MeshSubsets{ms.get()}; });
+                        [&]() { return *ms; });
     }
 
     std::vector<int> const vec_n_components(1 + _vec_fracture_mat_IDs.size(),
@@ -183,9 +181,8 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
 
     // TODO move the two data members somewhere else.
     // for extrapolation of secondary variables
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
+        *_mesh_subset_all_nodes};
     _local_to_global_index_map_single_component =
         std::make_unique<NumLib::LocalToGlobalIndexMap>(
             std::move(all_mesh_subsets_single_component),
diff --git a/ProcessLib/Output/ProcessOutput.cpp b/ProcessLib/Output/ProcessOutput.cpp
index 2e91b04b03d..95267db18e4 100644
--- a/ProcessLib/Output/ProcessOutput.cpp
+++ b/ProcessLib/Output/ProcessOutput.cpp
@@ -191,25 +191,21 @@ void processOutputData(
 
         for (int component_id = 0; component_id < num_comp; ++component_id)
         {
-            auto const& mesh_subsets =
-                dof_table.getMeshSubsets(sub_meshset_id, component_id);
-            for (auto const& mesh_subset : mesh_subsets)
+            auto const& mesh_subset =
+                dof_table.getMeshSubset(sub_meshset_id, component_id);
+            auto const mesh_id = mesh_subset.getMeshID();
+            for (auto const* node : mesh_subset.getNodes())
             {
-                auto const mesh_id = mesh_subset->getMeshID();
-                for (auto const* node : mesh_subset->getNodes())
-                {
-                    MeshLib::Location const l(
-                        mesh_id, MeshLib::MeshItemType::Node, node->getID());
-
-                    auto const global_component_id =
-                        global_component_offset + component_id;
-                    auto const index = dof_table.getLocalIndex(
-                        l, global_component_id, x.getRangeBegin(),
-                        x.getRangeEnd());
-
-                    output_data[node->getID() * n_components + component_id] =
-                        x_copy[index];
-                }
+                MeshLib::Location const l(mesh_id, MeshLib::MeshItemType::Node,
+                                          node->getID());
+
+                auto const global_component_id =
+                    global_component_offset + component_id;
+                auto const index = dof_table.getLocalIndex(
+                    l, global_component_id, x.getRangeBegin(), x.getRangeEnd());
+
+                output_data[node->getID() * n_components + component_id] =
+                    x_copy[index];
             }
         }
     }
diff --git a/ProcessLib/PhaseField/PhaseFieldProcess.cpp b/ProcessLib/PhaseField/PhaseFieldProcess.cpp
index 08a955f90d2..3ca66b403e6 100644
--- a/ProcessLib/PhaseField/PhaseFieldProcess.cpp
+++ b/ProcessLib/PhaseField/PhaseFieldProcess.cpp
@@ -100,9 +100,8 @@ void PhaseFieldProcess<DisplacementDim>::constructDofTable()
 
     // TODO move the two data members somewhere else.
     // for extrapolation of secondary variables of stress or strain
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
+        *_mesh_subset_all_nodes};
     _local_to_global_index_map_single_component =
         std::make_unique<NumLib::LocalToGlobalIndexMap>(
             std::move(all_mesh_subsets_single_component),
@@ -114,14 +113,12 @@ void PhaseFieldProcess<DisplacementDim>::constructDofTable()
     if (_use_monolithic_scheme)
     {
         const int process_id = 0;  // Only one process in the monolithic scheme.
-        std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
+        std::vector<MeshLib::MeshSubset> all_mesh_subsets;
         std::generate_n(
             std::back_inserter(all_mesh_subsets),
             getProcessVariables(process_id)[1].get().getNumberOfComponents() +
                 1,
-            [&]() {
-                return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()};
-            });
+            [&]() { return *_mesh_subset_all_nodes; });
 
         std::vector<int> const vec_n_components{1, DisplacementDim};
         _local_to_global_index_map =
@@ -134,13 +131,11 @@ void PhaseFieldProcess<DisplacementDim>::constructDofTable()
     {
         // For displacement equation.
         const int process_id = 0;
-        std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
+        std::vector<MeshLib::MeshSubset> all_mesh_subsets;
         std::generate_n(
             std::back_inserter(all_mesh_subsets),
             getProcessVariables(process_id)[0].get().getNumberOfComponents(),
-            [&]() {
-                return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()};
-            });
+            [&]() { return *_mesh_subset_all_nodes; });
 
         std::vector<int> const vec_n_components{DisplacementDim};
         _local_to_global_index_map =
diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp
index 6296bc41724..f95c095e12d 100644
--- a/ProcessLib/Process.cpp
+++ b/ProcessLib/Process.cpp
@@ -133,36 +133,33 @@ void Process::setInitialConditions(const int process_id, double const t,
 
         for (int component_id = 0; component_id < num_comp; ++component_id)
         {
-            auto const& mesh_subsets =
-                dof_table_of_process.getMeshSubsets(variable_id, component_id);
-            for (auto const& mesh_subset : mesh_subsets)
+            auto const& mesh_subset =
+                dof_table_of_process.getMeshSubset(variable_id, component_id);
+            auto const mesh_id = mesh_subset.getMeshID();
+            for (auto const* node : mesh_subset.getNodes())
             {
-                auto const mesh_id = mesh_subset->getMeshID();
-                for (auto const* node : mesh_subset->getNodes())
-                {
-                    MeshLib::Location const l(
-                        mesh_id, MeshLib::MeshItemType::Node, node->getID());
-
-                    pos.setNodeID(node->getID());
-                    auto const& ic_value = ic(t, pos);
-
-                    auto global_index =
-                        std::abs(dof_table_of_process.getGlobalIndex(
-                            l, variable_id, component_id));
+                MeshLib::Location const l(mesh_id, MeshLib::MeshItemType::Node,
+                                          node->getID());
+
+                pos.setNodeID(node->getID());
+                auto const& ic_value = ic(t, pos);
+
+                auto global_index =
+                    std::abs(dof_table_of_process.getGlobalIndex(l, variable_id,
+                                                                 component_id));
 #ifdef USE_PETSC
-                    // The global indices of the ghost entries of the global
-                    // matrix or the global vectors need to be set as negative
-                    // values for equation assembly, however the global indices
-                    // start from zero. Therefore, any ghost entry with zero
-                    // index is assigned an negative value of the vector size
-                    // or the matrix dimension. To assign the initial value for
-                    // the ghost entries, the negative indices of the ghost
-                    // entries are restored to zero.
-                    if (global_index == x.size())
-                        global_index = 0;
+                // The global indices of the ghost entries of the global
+                // matrix or the global vectors need to be set as negative
+                // values for equation assembly, however the global indices
+                // start from zero. Therefore, any ghost entry with zero
+                // index is assigned an negative value of the vector size
+                // or the matrix dimension. To assign the initial value for
+                // the ghost entries, the negative indices of the ghost
+                // entries are restored to zero.
+                if (global_index == x.size())
+                    global_index = 0;
 #endif
-                    x.set(global_index, ic_value[component_id]);
-                }
+                x.set(global_index, ic_value[component_id]);
             }
         }
     }
@@ -220,21 +217,18 @@ void Process::constructDofTable()
         std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh.getNodes());
 
     // Vector of mesh subsets.
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets;
 
     // Vector of the number of variable components
     std::vector<int> vec_var_n_components;
     if (_use_monolithic_scheme)
     {
-        // Collect the mesh subsets in a vector.
+        // Collect the mesh subsets in a vector for each variables' components.
         for (ProcessVariable const& pv : _process_variables[0])
         {
-            std::generate_n(
-                std::back_inserter(all_mesh_subsets),
-                pv.getNumberOfComponents(),
-                [&]() {
-                    return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()};
-                });
+            std::generate_n(std::back_inserter(all_mesh_subsets),
+                            pv.getNumberOfComponents(),
+                            [&]() { return *_mesh_subset_all_nodes; });
         }
 
         // Create a vector of the number of variable components
@@ -249,13 +243,10 @@ void Process::constructDofTable()
         // element order. Other cases can be considered by overloading this
         // member function in the derived class.
 
-        // Collect the mesh subsets in a vector.
-        std::generate_n(
-            std::back_inserter(all_mesh_subsets),
-            _process_variables[0][0].get().getNumberOfComponents(),
-            [&]() {
-                return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()};
-            });
+        // Collect the mesh subsets in a vector for each variables' components.
+        std::generate_n(std::back_inserter(all_mesh_subsets),
+                        _process_variables[0][0].get().getNumberOfComponents(),
+                        [&]() { return *_mesh_subset_all_nodes; });
 
         // Create a vector of the number of variable components.
         vec_var_n_components.push_back(
@@ -280,9 +271,8 @@ Process::getDOFTableForExtrapolatorData() const
     }
 
     // Otherwise construct a new DOF table.
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component;
+    all_mesh_subsets_single_component.emplace_back(*_mesh_subset_all_nodes);
 
     const bool manage_storage = true;
 
diff --git a/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp
index 33295c9a1be..9b4e112c4de 100644
--- a/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp
+++ b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp
@@ -85,9 +85,8 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
 
     // TODO move the two data members somewhere else.
     // for extrapolation of secondary variables
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
+        *_mesh_subset_all_nodes};
     _local_to_global_index_map_single_component =
         std::make_unique<NumLib::LocalToGlobalIndexMap>(
             std::move(all_mesh_subsets_single_component),
diff --git a/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess-impl.h b/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess-impl.h
index 47c37461d48..0818ae7f362 100644
--- a/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess-impl.h
+++ b/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess-impl.h
@@ -111,9 +111,8 @@ void ThermoMechanicalPhaseFieldProcess<DisplacementDim>::constructDofTable()
 
     // TODO move the two data members somewhere else.
     // for extrapolation of secondary variables of stress or strain
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
+        *_mesh_subset_all_nodes};
     _local_to_global_index_map_single_component =
         std::make_unique<NumLib::LocalToGlobalIndexMap>(
             std::move(all_mesh_subsets_single_component),
@@ -123,13 +122,12 @@ void ThermoMechanicalPhaseFieldProcess<DisplacementDim>::constructDofTable()
     assert(_local_to_global_index_map_single_component);
 
     // For displacement equation.
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets;
-    std::generate_n(
-        std::back_inserter(all_mesh_subsets),
-        getProcessVariables(_mechanics_related_process_id)[0]
-            .get()
-            .getNumberOfComponents(),
-        [&]() { return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()}; });
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets;
+    std::generate_n(std::back_inserter(all_mesh_subsets),
+                    getProcessVariables(_mechanics_related_process_id)[0]
+                        .get()
+                        .getNumberOfComponents(),
+                    [&]() { return *_mesh_subset_all_nodes; });
 
     std::vector<int> const vec_n_components{DisplacementDim};
     _local_to_global_index_map =
diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp
index 517056af0b4..d0fa7d22265 100644
--- a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp
+++ b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp
@@ -59,9 +59,8 @@ void ThermoMechanicsProcess<DisplacementDim>::initializeConcreteProcess(
 
     // TODO move the two data members somewhere else.
     // for extrapolation of secondary variables
-    std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
-    all_mesh_subsets_single_component.emplace_back(
-        _mesh_subset_all_nodes.get());
+    std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
+        *_mesh_subset_all_nodes};
     _local_to_global_index_map_single_component.reset(
         new NumLib::LocalToGlobalIndexMap(
             std::move(all_mesh_subsets_single_component),
-- 
GitLab