From 014df9ae849e80fbb5b1e15c8110616b9a263454 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Tue, 12 Jan 2016 19:05:51 +0100
Subject: [PATCH] [PL] Move up setInitialConditions.

---
 ProcessLib/GroundwaterFlowProcess.h | 20 +-------------------
 ProcessLib/Process.h                | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/ProcessLib/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlowProcess.h
index 2ab57aadc4e..5eae3155390 100644
--- a/ProcessLib/GroundwaterFlowProcess.h
+++ b/ProcessLib/GroundwaterFlowProcess.h
@@ -37,7 +37,6 @@
 #include "NeumannBc.h"
 #include "Parameter.h"
 #include "Process.h"
-#include "ProcessVariable.h"
 
 namespace MeshLib
 {
@@ -219,7 +218,7 @@ public:
     {
         DBUG("Initialize GroundwaterFlowProcess.");
 
-        setInitialConditions(*_hydraulic_head, 0);
+        Process<GlobalSetup>::setInitialConditions(*_hydraulic_head, 0);
 
         if (this->_mesh.getDimension()==1)
             createLocalAssemblers<1>();
@@ -231,23 +230,6 @@ public:
             assert(false);
     }
 
-    void setInitialConditions(ProcessVariable const& variable,
-                              int const component_id)
-    {
-        std::size_t const n = this->_mesh.getNNodes();
-        for (std::size_t i = 0; i < n; ++i)
-        {
-            MeshLib::Location const l(this->_mesh.getID(),
-                                      MeshLib::MeshItemType::Node, i);
-            auto const global_index =  // 0 is the component id.
-                std::abs(this->_local_to_global_index_map->getGlobalIndex(
-                    l, component_id));
-            this->_x->set(
-                global_index,
-                variable.getInitialConditionValue(*this->_mesh.getNode(i)));
-        }
-    }
-
     bool assemble(const double /*delta_t*/) override
     {
         DBUG("Assemble GroundwaterFlowProcess.");
diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h
index 5731d212505..afb68da27a8 100644
--- a/ProcessLib/Process.h
+++ b/ProcessLib/Process.h
@@ -23,6 +23,8 @@
 #include "MathLib/LinAlg/PETSc/PETScMatrixOption.h"
 #endif
 
+#include "ProcessVariable.h"
+
 namespace MeshLib
 {
 class Mesh;
@@ -128,6 +130,24 @@ protected:
 		    *_local_to_global_index_map, _mesh));
 	}
 
+
+	/// Sets the initial condition values in the solution vector x for a given
+	/// process variable and component.
+	void setInitialConditions(ProcessVariable const& variable,
+	                          int const component_id)
+	{
+		std::size_t const n = _mesh.getNNodes();
+		for (std::size_t i = 0; i < n; ++i)
+		{
+			MeshLib::Location const l(_mesh.getID(),
+			                          MeshLib::MeshItemType::Node, i);
+			auto const global_index = std::abs(
+			    _local_to_global_index_map->getGlobalIndex(l, component_id));
+			_x->set(global_index,
+			        variable.getInitialConditionValue(*_mesh.getNode(i)));
+		}
+	}
+
 protected:
 	MeshLib::Mesh& _mesh;
 	std::vector<MeshLib::MeshSubsets*> _all_mesh_subsets;
-- 
GitLab