From 0017c43ab7d177cd5325df619f594b022449a8b6 Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Wed, 18 Oct 2017 14:53:12 +0200
Subject: [PATCH] [HT] Set thermal dispersivity as an optional input

---
 .../i_thermal_dispersivity.md                 |   1 +
 .../t_longitudinal.md}                        |   0
 .../t_transversal.md}                         |   0
 ProcessLib/HT/CreateHTProcess.cpp             | 105 +++++++++---------
 .../HT/ConstViscosity/square_5500x5500.prj    |   7 +-
 5 files changed, 58 insertions(+), 55 deletions(-)
 create mode 100644 Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/i_thermal_dispersivity.md
 rename Documentation/ProjectFile/prj/processes/process/HT/{t_thermal_dispersivity_longitudinal.md => thermal_dispersivity/t_longitudinal.md} (100%)
 rename Documentation/ProjectFile/prj/processes/process/HT/{t_thermal_dispersivity_transversal.md => thermal_dispersivity/t_transversal.md} (100%)

diff --git a/Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/i_thermal_dispersivity.md b/Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/i_thermal_dispersivity.md
new file mode 100644
index 00000000000..570535f773e
--- /dev/null
+++ b/Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/i_thermal_dispersivity.md
@@ -0,0 +1 @@
+Optional input for thermal dispersion properties.
diff --git a/Documentation/ProjectFile/prj/processes/process/HT/t_thermal_dispersivity_longitudinal.md b/Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/t_longitudinal.md
similarity index 100%
rename from Documentation/ProjectFile/prj/processes/process/HT/t_thermal_dispersivity_longitudinal.md
rename to Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/t_longitudinal.md
diff --git a/Documentation/ProjectFile/prj/processes/process/HT/t_thermal_dispersivity_transversal.md b/Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/t_transversal.md
similarity index 100%
rename from Documentation/ProjectFile/prj/processes/process/HT/t_thermal_dispersivity_transversal.md
rename to Documentation/ProjectFile/prj/processes/process/HT/thermal_dispersivity/t_transversal.md
diff --git a/ProcessLib/HT/CreateHTProcess.cpp b/ProcessLib/HT/CreateHTProcess.cpp
index e6e12aeccec..0b244892a9a 100644
--- a/ProcessLib/HT/CreateHTProcess.cpp
+++ b/ProcessLib/HT/CreateHTProcess.cpp
@@ -83,21 +83,38 @@ std::unique_ptr<Process> createHTProcess(
 
     // Parameter for the thermal conductivity of the solid (only one scalar per
     // element, i.e., the isotropic case is handled at the moment)
-    auto& thermal_dispersivity_longitudinal = findParameter<double>(
-        config,
-        //! \ogs_file_param_special{prj__processes__process__HT__thermal_dispersivity_longitudinal}
-        "thermal_dispersivity_longitudinal", parameters, 1);
-    DBUG("Use \'%s\' as thermal_dispersivity_longitudinal parameter.",
-         thermal_dispersivity_longitudinal.name.c_str());
 
-    // Parameter for the thermal conductivity of the solid (only one scalar per
-    // element, i.e., the isotropic case is handled at the moment)
-    auto& thermal_dispersivity_transversal = findParameter<double>(
-        config,
-        //! \ogs_file_param_special{prj__processes__process__HT__thermal_dispersivity_transversal}
-        "thermal_dispersivity_transversal", parameters, 1);
-    DBUG("Use \'%s\' as thermal_dispersivity_transversal parameter.",
-         thermal_dispersivity_transversal.name.c_str());
+    ConstantParameter<double> default_thermal_dispersivity_longitudinal(
+        "default thermal dispersivity longitudinal", 0.);
+    ConstantParameter<double> default_thermal_dispersivity_transversal(
+        "default thermal dispersivity transversal", 0.);
+
+    Parameter<double>* thermal_dispersivity_longitudinal =
+        &default_thermal_dispersivity_longitudinal;
+    Parameter<double>* thermal_dispersivity_transversal =
+        &default_thermal_dispersivity_transversal;
+    auto const dispersion_config =
+        //! \ogs_file_param{prj__processes__process__HT__thermal_dispersivity}
+        config.getConfigSubtreeOptional("thermal_dispersivity");
+    if (dispersion_config)
+    {
+        thermal_dispersivity_longitudinal = &findParameter<double>(
+            *dispersion_config,
+            //! \ogs_file_param_special{prj__processes__process__HT__thermal_dispersivity__longitudinal}
+            "longitudinal", parameters, 1);
+        DBUG("Use \'%s\' as thermal_dispersivity_longitudinal parameter.",
+             thermal_dispersivity_longitudinal->name.c_str());
+
+        // Parameter for the thermal conductivity of the solid (only one scalar
+        // per
+        // element, i.e., the isotropic case is handled at the moment)
+        thermal_dispersivity_transversal = &findParameter<double>(
+            *dispersion_config,
+            //! \ogs_file_param_special{prj__processes__process__HT__thermal_dispersivity__transversal}
+            "transversal", parameters, 1);
+        DBUG("Use \'%s\' as thermal_dispersivity_transversal parameter.",
+             thermal_dispersivity_transversal->name.c_str());
+    }
 
     // Parameter for the thermal conductivity of the solid (only one scalar per
     // element, i.e., the isotropic case is handled at the moment)
@@ -134,62 +151,38 @@ std::unique_ptr<Process> createHTProcess(
         std::copy_n(b.data(), b.size(), specific_body_force.data());
     }
 
-    SecondaryVariableCollection secondary_variables;
-
-    NumLib::NamedFunctionCaller named_function_caller(
-        {"HT_temperature_pressure"});
-
-    ProcessLib::parseSecondaryVariables(config, secondary_variables,
-                                        named_function_caller);
+    ConstantParameter<double> default_solid_thermal_expansion(
+        "default solid thermal expansion", 0.);
+    ConstantParameter<double> default_biot_constant("default_biot constant",
+                                                    0.);
+    Parameter<double>* solid_thermal_expansion =
+        &default_solid_thermal_expansion;
+    Parameter<double>* biot_constant = &default_biot_constant;
 
-    //! \ogs_file_param{prj__processes__process__HT__solid_thermal_expansion}
     auto const solid_config =
+        //! \ogs_file_param{prj__processes__process__HT__solid_thermal_expansion}
         config.getConfigSubtreeOptional("solid_thermal_expansion");
     if (solid_config)
     {
-        auto& solid_thermal_expansion = findParameter<double>(
+        solid_thermal_expansion = &findParameter<double>(
             //! \ogs_file_param_special{prj__processes__process__HT__solid_thermal_expansion__thermal_expansion}
             *solid_config, "thermal_expansion", parameters, 1);
         DBUG("Use \'%s\' as solid thermal expansion.",
-             solid_thermal_expansion.name.c_str());
-        auto& biot_constant = findParameter<double>(
+             solid_thermal_expansion->name.c_str());
+        biot_constant = &findParameter<double>(
             //! \ogs_file_param_special{prj__processes__process__HT__solid_thermal_expansion__biot_constant}
             *solid_config, "biot_constant", parameters, 1);
-
-        std::unique_ptr<HTMaterialProperties> material_properties =
-            std::make_unique<HTMaterialProperties>(
-                std::move(porous_media_properties),
-                density_solid,
-                fluid_reference_density,
-                std::move(fluid_properties),
-                thermal_dispersivity_longitudinal,
-                thermal_dispersivity_transversal,
-                specific_heat_capacity_solid,
-                thermal_conductivity_solid,
-                thermal_conductivity_fluid,
-                solid_thermal_expansion,
-                biot_constant,
-                specific_body_force,
-                has_gravity);
-
-        return std::make_unique<HTProcess>(
-            mesh, std::move(jacobian_assembler), parameters, integration_order,
-            std::move(process_variables), std::move(material_properties),
-            std::move(secondary_variables), std::move(named_function_caller));
+        DBUG("Use \'%s\' as Biot's constant.", biot_constant->name.c_str());
     }
 
-    ConstantParameter<double> default_solid_thermal_expansion(
-        "default solid thermal expansion", 0.);
-    ConstantParameter<double> default_biot_constant("default_biot constant",
-                                                    0.);
     std::unique_ptr<HTMaterialProperties> material_properties =
         std::make_unique<HTMaterialProperties>(
             std::move(porous_media_properties),
             density_solid,
             fluid_reference_density,
             std::move(fluid_properties),
-            thermal_dispersivity_longitudinal,
-            thermal_dispersivity_transversal,
+            *thermal_dispersivity_longitudinal,
+            *thermal_dispersivity_transversal,
             specific_heat_capacity_solid,
             thermal_conductivity_solid,
             thermal_conductivity_fluid,
@@ -198,6 +191,14 @@ std::unique_ptr<Process> createHTProcess(
             specific_body_force,
             has_gravity);
 
+    SecondaryVariableCollection secondary_variables;
+
+    NumLib::NamedFunctionCaller named_function_caller(
+        {"HT_temperature_pressure"});
+
+    ProcessLib::parseSecondaryVariables(config, secondary_variables,
+                                        named_function_caller);
+
     return std::make_unique<HTProcess>(
         mesh, std::move(jacobian_assembler), parameters, integration_order,
         std::move(process_variables), std::move(material_properties),
diff --git a/Tests/lfs-data/Parabolic/HT/ConstViscosity/square_5500x5500.prj b/Tests/lfs-data/Parabolic/HT/ConstViscosity/square_5500x5500.prj
index 81faa39a19b..03740f603c4 100644
--- a/Tests/lfs-data/Parabolic/HT/ConstViscosity/square_5500x5500.prj
+++ b/Tests/lfs-data/Parabolic/HT/ConstViscosity/square_5500x5500.prj
@@ -44,12 +44,13 @@
                 </porous_medium>
             </porous_medium>
             <density_solid>rho_solid</density_solid>
-            <fluid_reference_density>rho_fluid</fluid_reference_density>
             <specific_heat_capacity_solid>c_solid</specific_heat_capacity_solid>
             <thermal_conductivity_solid>lambda_solid</thermal_conductivity_solid>
             <thermal_conductivity_fluid>lambda_fluid</thermal_conductivity_fluid>
-            <thermal_dispersivity_longitudinal>alpha_l</thermal_dispersivity_longitudinal>
-            <thermal_dispersivity_transversal>alpha_t</thermal_dispersivity_transversal>
+            <thermal_dispersivity>
+                <longitudinal>alpha_l</longitudinal>
+                <transversal>alpha_t</transversal>
+            </thermal_dispersivity>
             <specific_body_force>0 -9.81</specific_body_force>
             <secondary_variables>
                 <secondary_variable type="static" internal_name="darcy_velocity" output_name="darcy_velocity"/>
-- 
GitLab