From 504ffa95cb11dcd78ce67942a45ce4cecf36e033 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Wed, 20 Jan 2021 07:02:20 +0100
Subject: [PATCH] [PL/T2PF] Substitute permeability by MPL::permeablitity.

---
 ...CreateThermalTwoPhaseFlowWithPPProcess.cpp |  3 ++-
 ...malTwoPhaseFlowWithPPLocalAssembler-impl.h | 20 ++++++-------------
 .../Twophase_HeatPipe_quad_curve_small.prj    |  5 +++++
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp
index 8c02fb29556..a3da28785f7 100644
--- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp
+++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp
@@ -31,7 +31,8 @@ void checkMPLProperties(
     MaterialPropertyLib::MaterialSpatialDistributionMap const& media_map)
 {
     std::array const required_property_medium = {
-        MaterialPropertyLib::PropertyType::porosity};
+        MaterialPropertyLib::PropertyType::porosity,
+        MaterialPropertyLib::PropertyType::permeability};
 
     std::array const required_property_solid_phase = {
         MaterialPropertyLib::PropertyType::density};
diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h
index a63aee04bc4..59fbac6529a 100644
--- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h
+++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h
@@ -45,6 +45,7 @@
 
 #include "MaterialLib/MPL/Medium.h"
 #include "MaterialLib/MPL/Property.h"
+#include "MaterialLib/MPL/Utils/FormEigenTensor.h"
 #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
 #include "NumLib/Function/Interpolation.h"
 #include "ThermalTwoPhaseFlowWithPPLocalAssembler.h"
@@ -150,20 +151,6 @@ void ThermalTwoPhaseFlowWithPPLocalAssembler<
     auto const pc_nodal_values =
         Eigen::Map<const NodalVectorType>(&local_x[num_nodes], num_nodes);
 
-    const Eigen::MatrixXd& perm = two_phase_material_model.getPermeability(
-        material_id, t, pos, _element.getDimension());
-    assert(perm.rows() == _element.getDimension() || perm.rows() == 1);
-    GlobalDimMatrixType permeability = GlobalDimMatrixType::Zero(
-        _element.getDimension(), _element.getDimension());
-    if (perm.rows() == _element.getDimension())
-    {
-        permeability = perm;
-    }
-    else if (perm.rows() == 1)
-    {
-        permeability.diagonal().setConstant(perm(0, 0));
-    }
-
     MaterialPropertyLib::VariableArray vars;
     for (unsigned ip = 0; ip < n_integration_points; ip++)
     {
@@ -358,6 +345,11 @@ void ThermalTwoPhaseFlowWithPPLocalAssembler<
             two_phase_material_model.getLiquidViscosity(pg_int_pt, T_int_pt);
         double const lambda_wet = k_rel_wet / mu_wet;
 
+        auto const permeability =
+            MaterialPropertyLib::formEigenTensor<GlobalDim>(
+                medium.property(MaterialPropertyLib::PropertyType::permeability)
+                    .value(vars, pos, t, dt));
+
         GlobalDimVectorType const velocity_nonwet =
             -lambda_nonwet * permeability *
             (_ip_data[ip].dNdx * pg_nodal_values);
diff --git a/Tests/Data/Parabolic/ThermalTwoPhaseFlowPP/HeatPipe/Twophase_HeatPipe_quad_curve_small.prj b/Tests/Data/Parabolic/ThermalTwoPhaseFlowPP/HeatPipe/Twophase_HeatPipe_quad_curve_small.prj
index 926c894ead3..c0d221c0df0 100644
--- a/Tests/Data/Parabolic/ThermalTwoPhaseFlowPP/HeatPipe/Twophase_HeatPipe_quad_curve_small.prj
+++ b/Tests/Data/Parabolic/ThermalTwoPhaseFlowPP/HeatPipe/Twophase_HeatPipe_quad_curve_small.prj
@@ -143,6 +143,11 @@
                     <type>Constant</type>
                     <value>0.4</value>
                 </property>
+                <property>
+                    <name>permeability</name>
+                    <type>Constant</type>
+                    <value>1e-12</value>
+                </property>
             </properties>
         </medium>
     </media>
-- 
GitLab