From 19f2656740373459f9eef9b5300f73ff630c5816 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Fri, 26 Sep 2014 12:34:15 +0200
Subject: [PATCH] [T] Replace LocalDataInitializer with function.

A static function in the SteadyDiffusion2DExample1 class.
---
 .../AssemblerLib/SteadyDiffusion2DExample1.h  | 23 ++++++++-----------
 Tests/AssemblerLib/TestSerialLinearSolver.cpp | 16 ++++++-------
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/Tests/AssemblerLib/SteadyDiffusion2DExample1.h b/Tests/AssemblerLib/SteadyDiffusion2DExample1.h
index 358d0bcd745..cc15de15887 100644
--- a/Tests/AssemblerLib/SteadyDiffusion2DExample1.h
+++ b/Tests/AssemblerLib/SteadyDiffusion2DExample1.h
@@ -64,25 +64,20 @@ private:
 	LocalVectorType const* _localRhs = nullptr;
 };
 
-template <typename LocalMatrixType_, typename LocalVectorType_>
-struct LocalDataInitializer
-{
-	template <typename ...Args_>
-	void operator()(const MeshLib::Element& e,
-		LocalAssemblerData<LocalMatrixType_, LocalVectorType_>*& data_ptr,
-		Args_&&... args)
-	{
-		data_ptr = new LocalAssemblerData<LocalMatrixType_, LocalVectorType_>;
-		data_ptr->init(e, std::forward<Args_>(args)...);
-	}
-};
-
-
 struct SteadyDiffusion2DExample1
 {
 	using LocalMatrixType = MathLib::DenseMatrix<double>;
 	using LocalVectorType = MathLib::DenseVector<double>;
 
+	static
+	void initializeLocalData(const MeshLib::Element& e,
+			LocalAssemblerData<LocalMatrixType, LocalVectorType>*& data_ptr,
+			SteadyDiffusion2DExample1 const& example)
+	{
+		data_ptr = new LocalAssemblerData<LocalMatrixType, LocalVectorType>;
+		data_ptr->init(e, example._localA, example._localRhs);
+	}
+
 	SteadyDiffusion2DExample1()
 		: _localA(4, 4), _localRhs(4)
 	{
diff --git a/Tests/AssemblerLib/TestSerialLinearSolver.cpp b/Tests/AssemblerLib/TestSerialLinearSolver.cpp
index 5893dbbc413..790abc6fb57 100644
--- a/Tests/AssemblerLib/TestSerialLinearSolver.cpp
+++ b/Tests/AssemblerLib/TestSerialLinearSolver.cpp
@@ -104,22 +104,22 @@ TEST(AssemblerLibSerialLinearSolver, Steady2DdiffusionQuadElem)
         local_assembler_data;
     local_assembler_data.resize(ex1.msh->getNElements());
 
-    LocalDataInitializer<LocalMatrixType, LocalVectorType> initializer;
-
     typedef AssemblerLib::LocalAssemblerBuilder<
             MeshLib::Element,
-            LocalDataInitializer<LocalMatrixType, LocalVectorType>
-                > GlobalInitializer;
+            void (const MeshLib::Element &,
+                    LocalAssemblerData<LocalMatrixType, LocalVectorType> *&,
+                    SteadyDiffusion2DExample1 const&)
+                > LocalAssemblerBuilder;
 
-    GlobalInitializer global_initializer(initializer);
+    LocalAssemblerBuilder local_asm_builder(
+        SteadyDiffusion2DExample1::initializeLocalData);
 
     // Call global initializer for each mesh element.
     globalSetup.execute(
-            global_initializer,
+            local_asm_builder,
             ex1.msh->getElements(),
             local_assembler_data,
-            ex1._localA,
-            ex1._localRhs);
+            ex1);
 
     // Local and global assemblers.
     typedef AssemblerLib::VectorMatrixAssembler<
-- 
GitLab