[cig-commits] r13584 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Tue Dec 9 18:15:08 PST 2008


Author: luis
Date: 2008-12-09 18:15:08 -0800 (Tue, 09 Dec 2008)
New Revision: 13584

Modified:
   cs/cigma/trunk/src/Field.h
   cs/cigma/trunk/src/Function.h
   cs/cigma/trunk/src/fn_one.h
   cs/cigma/trunk/src/fn_test.h
   cs/cigma/trunk/src/fn_zero.h
Log:
Added Function::type enum in order to simplify function dispatch

Modified: cs/cigma/trunk/src/Field.h
===================================================================
--- cs/cigma/trunk/src/Field.h	2008-12-10 02:15:06 UTC (rev 13583)
+++ cs/cigma/trunk/src/Field.h	2008-12-10 02:15:08 UTC (rev 13584)
@@ -25,6 +25,10 @@
     int n_dim() const;
     int n_rank() const;
     bool eval(double *point, double *value);
+
+    inline Function::type getType() const { return FIELD_FN; }
+
+    // XXX: move this method to DofHandler class
     void getCellDofs(int cellIndex, double *cellDofs); // XXX: move method to DofHandler
 
     /* direct setters */

Modified: cs/cigma/trunk/src/Function.h
===================================================================
--- cs/cigma/trunk/src/Function.h	2008-12-10 02:15:06 UTC (rev 13583)
+++ cs/cigma/trunk/src/Function.h	2008-12-10 02:15:08 UTC (rev 13584)
@@ -15,10 +15,20 @@
     Function();
     virtual ~Function();
 
+    /* call interface (raw) */
     virtual int n_dim() const = 0;
     virtual int n_rank() const = 0;
     virtual bool eval(double *point, double *value) = 0;
 
+    /* Function type for dispatch */
+    typedef enum
+    {
+        GENERAL_FN = 0,
+        FIELD_FN = 1,
+        POINTWISE_FN = 2
+    } type;
+    virtual type getType() const = 0;
+
     /* static factory methods */
     static boost::shared_ptr<Function> New(std::string fn_name);
     static boost::shared_ptr<Function> NewFunction(const FunctionInfo& fn_info);

Modified: cs/cigma/trunk/src/fn_one.h
===================================================================
--- cs/cigma/trunk/src/fn_one.h	2008-12-10 02:15:06 UTC (rev 13583)
+++ cs/cigma/trunk/src/fn_one.h	2008-12-10 02:15:08 UTC (rev 13584)
@@ -15,13 +15,15 @@
     UnitScalarFn();
     ~UnitScalarFn();
 
-    void setDim(int dim);
-
     int n_dim() const;
     int n_rank() const;
 
     bool eval(double *point, double *value);
 
+    inline Function::type getType() const { return GENERAL_FN; }
+
+    void setDim(int dim);
+
 public:
     int dim;
 };

Modified: cs/cigma/trunk/src/fn_test.h
===================================================================
--- cs/cigma/trunk/src/fn_test.h	2008-12-10 02:15:06 UTC (rev 13583)
+++ cs/cigma/trunk/src/fn_test.h	2008-12-10 02:15:08 UTC (rev 13584)
@@ -19,6 +19,7 @@
 
     inline int n_dim() const { return 3; }
     inline int n_rank() const { return 1; }
+    inline type getType() const { return GENERAL_FN; }
 
     bool eval(double *point, double *value);
 
@@ -34,6 +35,7 @@
 
     inline int n_dim() const { return 2; }
     inline int n_rank() const { return 1; }
+    inline type getType() const { return GENERAL_FN; }
 
     bool eval(double *point, double *value);
 

Modified: cs/cigma/trunk/src/fn_zero.h
===================================================================
--- cs/cigma/trunk/src/fn_zero.h	2008-12-10 02:15:06 UTC (rev 13583)
+++ cs/cigma/trunk/src/fn_zero.h	2008-12-10 02:15:08 UTC (rev 13584)
@@ -14,13 +14,15 @@
     ZeroFn();
     ~ZeroFn();
 
-    void setShape(int dim, int rank);
-
     int n_dim() const;
     int n_rank() const;
 
     bool eval(double *point, double *value);
 
+    inline Function::type getType() const { return GENERAL_FN; }
+
+    void setShape(int dim, int rank);
+
 public:
     int dim;
     int rank;



More information about the CIG-COMMITS mailing list