diff --git a/Solver/function.cpp b/Solver/function.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..02803ae152a1e8672000c42de0f6b41e556a262f
--- /dev/null
+++ b/Solver/function.cpp
@@ -0,0 +1,39 @@
+#include "function.h"
+
+class functionXYZ : public function{
+ private:
+  class data : public dataCacheDouble{
+   private:
+    dataCacheElement &_element;
+    dataCacheDouble &_uvw;
+   public:
+    data(dataCacheMap *m) 
+      : dataCache(m), _element(m->getElement(this)), _uvw(m->get("UVW", this))
+    {
+      _value.resize(_uvw.size1(), 3);
+    }
+    void eval()
+    {
+      MElement *ele = _element();
+      for(int i = 0; i < _uvw.size1(); i++){
+        SPoint3 p;
+        ele->pnt(_uvw(i, 0), _uvw(i, 1), _uvw(i, 2), p);
+        _value(i, 0) = p.x();
+        _value(i, 1) = p.y();
+        _value(i, 2) = p.z();
+      }
+    }
+  };
+ public:
+  dataCache &getDataCache(dataCacheMap *m)
+  {
+    return new data(m);
+  }
+};
+
+
+void registerFunctions()
+{
+  function::add("XYZ", new functionXYZ);
+
+}
diff --git a/Solver/function.h b/Solver/function.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab7b6ab56fabdd7113e2252230429fb8cb328820
--- /dev/null
+++ b/Solver/function.h
@@ -0,0 +1,66 @@
+#ifndef _FUNCTION_H_
+#define _FUNCTION_H_
+
+#include <map>
+#include <string>
+
+// An abstract interface to functions
+class function{
+ private:
+  static std::map<std::string, function*> _allFunctions;
+  std::string _name;
+ public:
+  virtual dataCache &getDataCache(dataCacheMap *m) = 0;
+  static bool add(std::string functionName, function *f);
+};
+
+// A class to store function data and cache it intelligently (by
+// computing dependencies)
+class dataCache{
+ protected:
+  bool _valid;
+  std::set<dataCache*> _iDependOnThem, _theyDependOnMe;
+  // validates all the dependencies
+  void _validate();
+  void _invalidateDependencies();
+};
+
+// A node in the dependency tree for which all the leafs depend on the
+// given double value
+class dataCacheDouble : public dataCache {
+ private:
+  fullMatrix<double> _value;
+ public:
+  void set(const fullMatrix<double> &mat);
+  void set(int i, int j, double val);
+  inline const fullMatrix<double> &operator () ()
+  {
+    if(!_valid) _validate();
+    return _value;
+  }
+  virtual void eval() = 0;
+};
+
+// A special node in the dependency tree for which all the leafs
+// depend on the given element
+class dataCacheElement : public dataCache {
+ private:
+  MElement *_element;
+ public:
+  void set(const MElement *ele);
+  inline const MElement *operator () () { return _element; }
+};
+
+class dataCacheMap{
+ private:
+  // keep track of the current element and all the dataCaches that
+  // depend on it
+  dataCacheElement *_dependOnElement;
+ public:
+  dataCacheDouble &get(const std::string &functionName,
+                       dataCache *caller=0);
+  dataCacheElement &getElement(dataCache *caller=0);
+
+};
+
+#endif