From 06e32320a5e789fd9f190e73ceb01664bd0e82dc Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Fri, 18 Nov 2016 10:49:20 +0100
Subject: [PATCH] [PL] set current solution, time, dof_table in Cached2ndVar

---
 ProcessLib/CachedSecondaryVariable.cpp |  8 +++-----
 ProcessLib/CachedSecondaryVariable.h   | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/ProcessLib/CachedSecondaryVariable.cpp b/ProcessLib/CachedSecondaryVariable.cpp
index 127fe51a605..a5d442ca411 100644
--- a/ProcessLib/CachedSecondaryVariable.cpp
+++ b/ProcessLib/CachedSecondaryVariable.cpp
@@ -51,8 +51,8 @@ GlobalVector const& CachedSecondaryVariable::evalField(
     std::unique_ptr<GlobalVector>& /*result_cache*/
     ) const
 {
-    // _current_solution = &x;
-    // _dof_table = &dof_table;
+    (void)t, (void)x, (void)dof_table;
+    assert(t == _t && &x == _current_solution && &dof_table == _dof_table);
     return evalFieldNoArgs();
 }
 
@@ -64,10 +64,8 @@ GlobalVector const& CachedSecondaryVariable::evalFieldNoArgs() const
         return _cached_nodal_values;
     }
     DBUG("Recomputing %s.", _internal_variable_name.c_str());
-    // TODO fix
-    const double t = 0.0;
     _extrapolator.extrapolate(
-        1, *_extrapolatables, t, *_current_solution, *_dof_table);
+        1, *_extrapolatables, _t, *_current_solution, *_dof_table);
     auto const& nodal_values = _extrapolator.getNodalValues();
     MathLib::LinAlg::copy(nodal_values, _cached_nodal_values);
     _needs_recomputation = false;
diff --git a/ProcessLib/CachedSecondaryVariable.h b/ProcessLib/CachedSecondaryVariable.h
index dcc659f1a68..28fe3a6e09b 100644
--- a/ProcessLib/CachedSecondaryVariable.h
+++ b/ProcessLib/CachedSecondaryVariable.h
@@ -60,8 +60,19 @@ public:
     //! Returns extrapolation functions that compute the secondary variable.
     SecondaryVariableFunctions getExtrapolator();
 
-    //! Set that recomputation is necessary.
-    void expire() { _needs_recomputation = true; }
+    void setTime(const double t)
+    {
+        _t = t;
+        _needs_recomputation = true;
+    }
+
+    void updateCurrentSolution(GlobalVector const& x,
+                               NumLib::LocalToGlobalIndexMap const& dof_table)
+    {
+        _current_solution = &x;
+        _dof_table = &dof_table;
+        _needs_recomputation = true;
+    }
 
 private:
     //! Provides the value at the current index of the _context.
@@ -87,6 +98,7 @@ private:
     SecondaryVariableContext const& _context;
     std::string const _internal_variable_name;
 
+    double _t = 0.0;
     GlobalVector const* _current_solution = nullptr;
     NumLib::LocalToGlobalIndexMap const* _dof_table = nullptr;
 };
-- 
GitLab