From 2f68e689d3eaad7d2c36aebd19665f2b08990655 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Tue, 2 Apr 2024 21:36:50 +0200
Subject: [PATCH] [PL/HT] Use shape matrix cache in HT assembler

---
 ProcessLib/HT/HTFEM.h               |  9 +++++++--
 ProcessLib/HT/MonolithicHTFEM.h     |  6 +++++-
 ProcessLib/HT/StaggeredHTFEM-impl.h | 12 ++++++++++--
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/ProcessLib/HT/HTFEM.h b/ProcessLib/HT/HTFEM.h
index 3ed82f8411b..9e2804d3868 100644
--- a/ProcessLib/HT/HTFEM.h
+++ b/ProcessLib/HT/HTFEM.h
@@ -91,7 +91,8 @@ public:
     Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
         const unsigned integration_point) const override
     {
-        auto const& N = _ip_data[integration_point].N;
+        auto const& N = _shape_matrix_cache.NsHigherOrder<
+            typename ShapeFunction::MeshElement>()[integration_point];
 
         // assumes N is stored contiguously in memory
         return Eigen::Map<const Eigen::RowVectorXd>(N.data(), N.size());
@@ -273,11 +274,15 @@ protected:
             *_process_data.media_map.getMedium(_element.getID());
         auto const& liquid_phase = medium.phase("AqueousLiquid");
 
+        auto const& Ns =
+            _shape_matrix_cache
+                .NsHigherOrder<typename ShapeFunction::MeshElement>();
+
         for (unsigned ip = 0; ip < n_integration_points; ++ip)
         {
             auto const& ip_data = _ip_data[ip];
-            auto const& N = ip_data.N;
             auto const& dNdx = ip_data.dNdx;
+            auto const& N = Ns[ip];
 
             pos.setIntegrationPoint(ip);
 
diff --git a/ProcessLib/HT/MonolithicHTFEM.h b/ProcessLib/HT/MonolithicHTFEM.h
index 73474c5908e..ff7381ad074 100644
--- a/ProcessLib/HT/MonolithicHTFEM.h
+++ b/ProcessLib/HT/MonolithicHTFEM.h
@@ -123,13 +123,17 @@ public:
         double average_velocity_norm = 0.0;
         ip_flux_vector.reserve(n_integration_points);
 
+        auto const& Ns =
+            this->_shape_matrix_cache
+                .template NsHigherOrder<typename ShapeFunction::MeshElement>();
+
         for (unsigned ip(0); ip < n_integration_points; ip++)
         {
             pos.setIntegrationPoint(ip);
 
             auto const& ip_data = this->_ip_data[ip];
-            auto const& N = ip_data.N;
             auto const& dNdx = ip_data.dNdx;
+            auto const& N = Ns[ip];
             auto const& w = ip_data.integration_weight;
 
             double T_int_pt = 0.0;
diff --git a/ProcessLib/HT/StaggeredHTFEM-impl.h b/ProcessLib/HT/StaggeredHTFEM-impl.h
index 65c67a68b1e..7a828cdddac 100644
--- a/ProcessLib/HT/StaggeredHTFEM-impl.h
+++ b/ProcessLib/HT/StaggeredHTFEM-impl.h
@@ -79,13 +79,17 @@ void StaggeredHTFEM<ShapeFunction, GlobalDim>::assembleHydraulicEquation(
     unsigned const n_integration_points =
         this->_integration_method.getNumberOfPoints();
 
+    auto const& Ns =
+        this->_shape_matrix_cache
+            .template NsHigherOrder<typename ShapeFunction::MeshElement>();
+
     for (unsigned ip(0); ip < n_integration_points; ip++)
     {
         pos.setIntegrationPoint(ip);
 
         auto const& ip_data = this->_ip_data[ip];
-        auto const& N = ip_data.N;
         auto const& dNdx = ip_data.dNdx;
+        auto const& N = Ns[ip];
         auto const& w = ip_data.integration_weight;
 
         double p_int_pt = 0.0;
@@ -208,13 +212,17 @@ void StaggeredHTFEM<ShapeFunction, GlobalDim>::assembleHeatTransportEquation(
     double average_velocity_norm = 0.0;
     ip_flux_vector.reserve(n_integration_points);
 
+    auto const& Ns =
+        this->_shape_matrix_cache
+            .template NsHigherOrder<typename ShapeFunction::MeshElement>();
+
     for (unsigned ip(0); ip < n_integration_points; ip++)
     {
         pos.setIntegrationPoint(ip);
 
         auto const& ip_data = this->_ip_data[ip];
-        auto const& N = ip_data.N;
         auto const& dNdx = ip_data.dNdx;
+        auto const& N = Ns[ip];
         auto const& w = ip_data.integration_weight;
 
         double p_at_xi = 0.;
-- 
GitLab