From 23de5761a89484b1360866d53bf4be390fc1c50b Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Tue, 12 Jul 2016 09:47:47 +0200
Subject: [PATCH] matrix specs created in extrapolator ctor

---
 .../LocalLinearLeastSquaresExtrapolator.cpp   | 26 +++++++++++++++
 .../LocalLinearLeastSquaresExtrapolator.h     | 33 +++----------------
 ProcessLib/Process.cpp                        |  8 +----
 Tests/NumLib/TestExtrapolation.cpp            |  7 +---
 4 files changed, 32 insertions(+), 42 deletions(-)

diff --git a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp
index 9437b1fad39..f863f6f5a83 100644
--- a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp
+++ b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp
@@ -22,6 +22,32 @@
 
 namespace NumLib
 {
+LocalLinearLeastSquaresExtrapolator::LocalLinearLeastSquaresExtrapolator(
+    NumLib::LocalToGlobalIndexMap const& dof_table)
+    : _nodal_values(NumLib::GlobalVectorProvider::provider.getVector(
+          MathLib::MatrixSpecifications(dof_table.dofSizeWithoutGhosts(),
+                                        dof_table.dofSizeWithoutGhosts(),
+                                        &dof_table.getGhostIndices(),
+                                        nullptr)))
+#ifndef USE_PETSC
+    , _residuals(dof_table.size())
+#else
+    , _residuals(dof_table.size(), false)
+#endif
+    , _local_to_global(dof_table)
+{
+    /* Note in case the following assertion fails:
+     * If you copied the extrapolation code, for your processes from
+     * somewhere, note that the code from the groundwater flow process might
+     * not suit your needs: It is a special case and is therefore most
+     * likely too simplistic. You better adapt the extrapolation code from
+     * some more advanced process, like the TES process.
+     */
+    assert(dof_table.getNumberOfComponents() == 1 &&
+           "The d.o.f. table passed must be for one variable that has "
+           "only one component!");
+}
+
 void LocalLinearLeastSquaresExtrapolator::extrapolate(
     ExtrapolatableElementCollection const& extrapolatables)
 {
diff --git a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h
index db1154f717c..5ec53ac395b 100644
--- a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h
+++ b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h
@@ -38,39 +38,14 @@ namespace NumLib
 class LocalLinearLeastSquaresExtrapolator : public Extrapolator
 {
 public:
-    /*! Constructs a new instance
+    /*! Constructs a new instance.
      *
      * \note
-     * The \c dof_table of \c matrix_specs must be set, and it must point to a
-     * dof_table for one single component variable.
+     * The \c dof_table must point to a d.o.f. table for one single-component
+     * variable.
      */
     explicit LocalLinearLeastSquaresExtrapolator(
-        MathLib::MatrixSpecifications const& matrix_specs,
-        NumLib::LocalToGlobalIndexMap const& dof_table)
-        : _nodal_values(
-              NumLib::GlobalVectorProvider::provider.getVector(
-                  matrix_specs))
-#ifndef USE_PETSC
-          ,
-          _residuals(dof_table.size())
-#else
-          ,
-          _residuals(dof_table.size(), false)
-#endif
-          ,
-          _local_to_global(dof_table)
-    {
-        /* Note in case the following assertion fails.
-         * If you copied the extrapolation code, for your processes from
-         * somewhere, note that the code from the groundwater flow process might
-         * not suit your needs: It is a special case and is therefore most
-         * likely too simplistic. You better adapt the extrapolation code from
-         * some more advanced process, like the TES process.
-         */
-        assert(dof_table.getNumberOfComponents() == 1 &&
-               "The d.o.f. table passed must be for one variable that has "
-               "only one component!");
-    }
+        NumLib::LocalToGlobalIndexMap const& dof_table);
 
     void extrapolate(
             ExtrapolatableElementCollection const& extrapolatables) override;
diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp
index b414b30e5b7..ca4f47bb42b 100644
--- a/ProcessLib/Process.cpp
+++ b/ProcessLib/Process.cpp
@@ -199,15 +199,9 @@ void Process::initializeExtrapolator()
         manage_storage = true;
     }
 
-    MathLib::MatrixSpecifications mat_specs(
-        dof_table_single_component->dofSizeWithoutGhosts(),
-        dof_table_single_component->dofSizeWithoutGhosts(),
-        &dof_table_single_component->getGhostIndices(),
-        nullptr);
-
     std::unique_ptr<NumLib::Extrapolator> extrapolator(
         new NumLib::LocalLinearLeastSquaresExtrapolator(
-            mat_specs, *dof_table_single_component));
+            *dof_table_single_component));
 
     // TODO Later on the DOF table can change during the simulation!
     _extrapolator_data = ExtrapolatorData(
diff --git a/Tests/NumLib/TestExtrapolation.cpp b/Tests/NumLib/TestExtrapolation.cpp
index 2cb6b549e3f..c33916bfc9c 100644
--- a/Tests/NumLib/TestExtrapolation.cpp
+++ b/Tests/NumLib/TestExtrapolation.cpp
@@ -156,12 +156,7 @@ public:
 
         // Passing _dof_table works, because this process has only one variable
         // and the variable has exactly one component.
-        _extrapolator.reset(new ExtrapolatorImplementation(
-            MathLib::MatrixSpecifications{_dof_table->dofSizeWithoutGhosts(),
-                                          _dof_table->dofSizeWithoutGhosts(),
-                                          &_dof_table->getGhostIndices(),
-                                          nullptr},
-            *_dof_table));
+        _extrapolator.reset(new ExtrapolatorImplementation(*_dof_table));
 
         createAssemblers(mesh);
     }
-- 
GitLab