From d3b946ff9de490353631b59690089897e6326263 Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.watanabe@ufz.de>
Date: Wed, 19 Mar 2014 19:13:39 +0100
Subject: [PATCH] add a linear function of space

---
 NumLib/Function/SpatialFunctionLinear.h   | 27 ++++++++++++
 NumLib/Function/TemplateSpatialFunction.h | 54 +++++++++++++++++++++++
 2 files changed, 81 insertions(+)
 create mode 100644 NumLib/Function/SpatialFunctionLinear.h
 create mode 100644 NumLib/Function/TemplateSpatialFunction.h

diff --git a/NumLib/Function/SpatialFunctionLinear.h b/NumLib/Function/SpatialFunctionLinear.h
new file mode 100644
index 00000000000..ec8411728cb
--- /dev/null
+++ b/NumLib/Function/SpatialFunctionLinear.h
@@ -0,0 +1,27 @@
+/**
+ * \author Norihiro Watanabe
+ * \date   2013-08-13
+ *
+ * \copyright
+ * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#ifndef SPATIALFUNCTIONLINEAR_H_
+#define SPATIALFUNCTIONLINEAR_H_
+
+#include "MathLib/LinearFunction.h"
+#include "TemplateSpatialFunction.h"
+
+namespace NumLib
+{
+
+/// Linear function of space
+typedef TemplateSpatialFunction<MathLib::LinearFunction<double, 3> > SpatialFunctionLinear;
+
+}
+
+#endif /* SPATIALFUNCTIONLINEAR_H_ */
diff --git a/NumLib/Function/TemplateSpatialFunction.h b/NumLib/Function/TemplateSpatialFunction.h
new file mode 100644
index 00000000000..dbfddcce23c
--- /dev/null
+++ b/NumLib/Function/TemplateSpatialFunction.h
@@ -0,0 +1,54 @@
+/**
+ * \author Norihiro Watanabe
+ * \date   2013-08-13
+ *
+ * \copyright
+ * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#ifndef TEMPLATESPATIALFUNCTION_H_
+#define TEMPLATESPATIALFUNCTION_H_
+
+#include "ISpatialFunction.h"
+
+namespace NumLib
+{
+
+/**
+ * Template class to relate pure mathematical functions with ISpatialFunction
+ *
+ * @tparam T_FUNCTION Function object which takes "double const* const" as an argument.
+ */
+template <class T_FUNCTION>
+class TemplateSpatialFunction : public ISpatialFunction
+{
+public:
+	/**
+	 * Constructor
+	 * @param f  a function object
+	 */
+	TemplateSpatialFunction(const T_FUNCTION &f)
+	: _f(f) {}
+
+	/**
+	 * evaluate a function
+	 * @param pnt  a point object
+	 * @return evaluated value
+	 */
+	virtual double operator()(const GeoLib::Point& pnt) const
+	{
+		return _f(pnt.getCoords());
+	}
+
+private:
+	/// a function object
+	const T_FUNCTION _f;
+};
+
+}
+
+#endif /* TEMPLATESPATIALFUNCTION_H_ */
-- 
GitLab