[cig-commits] r9290 - cs/benchmark/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Feb 13 01:51:09 PST 2008


Author: luis
Date: 2008-02-13 01:51:09 -0800 (Wed, 13 Feb 2008)
New Revision: 9290

Added:
   cs/benchmark/cigma/trunk/src/PointField.cpp
   cs/benchmark/cigma/trunk/src/PointField.h
Modified:
   cs/benchmark/cigma/trunk/src/Makefile.am
Log:
Added PointField class

Modified: cs/benchmark/cigma/trunk/src/Makefile.am
===================================================================
--- cs/benchmark/cigma/trunk/src/Makefile.am	2008-02-13 09:51:08 UTC (rev 9289)
+++ cs/benchmark/cigma/trunk/src/Makefile.am	2008-02-13 09:51:09 UTC (rev 9290)
@@ -107,6 +107,8 @@
 	Numeric.h \
 	Points.cpp \
 	Points.h \
+	PointField.cpp \
+	PointField.h \
 	Quad.cpp \
 	Quad.h \
 	Quadrature.cpp \

Added: cs/benchmark/cigma/trunk/src/PointField.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/PointField.cpp	                        (rev 0)
+++ cs/benchmark/cigma/trunk/src/PointField.cpp	2008-02-13 09:51:09 UTC (rev 9290)
@@ -0,0 +1,59 @@
+#include <cassert>
+#include "PointField.h"
+
+// ---------------------------------------------------------------------------
+
+cigma::PointField::PointField()
+{
+    points = new Points();
+    values = new Points();
+}
+
+cigma::PointField::~PointField()
+{
+    delete points;
+    delete values;
+}
+
+// ---------------------------------------------------------------------------
+
+void cigma::PointField::
+set_points(double *pts, int npts, int nsd)
+{
+    points->set_data(pts, npts, nsd);
+}
+
+void cigma::PointField::
+set_values(double *vals, int nvals, int rank)
+{
+    values->set_data(vals, nvals, rank);
+}
+
+// ---------------------------------------------------------------------------
+
+void cigma::PointField::
+eval(double *point, double *value)
+{
+    //* XXX: quick sanity check
+    static int checked = 0;
+    if (!checked)
+    {
+        assert(points->n_points() != 0);
+        assert(values->n_points() != 0);
+        assert(points->n_points() == values->n_points());
+        assert(points->n_dim() == values->n_dim());
+        checked = 1;
+    } // */
+
+
+    // Find index of closest point
+    int n;
+    points->find_ann_index(point, &n);
+    assert(0 <= n);
+    assert(n < points->n_points());
+
+    // Retrieve corresponding value
+    value = (*values)[n];
+}
+
+// ---------------------------------------------------------------------------

Added: cs/benchmark/cigma/trunk/src/PointField.h
===================================================================
--- cs/benchmark/cigma/trunk/src/PointField.h	                        (rev 0)
+++ cs/benchmark/cigma/trunk/src/PointField.h	2008-02-13 09:51:09 UTC (rev 9290)
@@ -0,0 +1,40 @@
+#ifndef __POINT_FIELD_H__
+#define __POINT_FIELD_H__
+
+#include "Field.h"
+#include "Points.h"
+
+namespace cigma
+{
+    class PointField;
+}
+
+/**
+ * @brief Point field object
+ *
+ */
+
+class cigma::PointField : public Field
+{
+public:
+    PointField();
+    ~PointField();
+
+public:
+    void set_points(double *pts, int npts, int nsd);
+    void set_values(double *vals, int nvals, int rank);
+    void set_locator(Locator *locator);
+
+public:
+    void eval(double *point, double *value);
+
+public:
+    Points *points;
+    Points *values;
+
+public:
+    Locator *locator;
+};
+
+
+#endif



More information about the cig-commits mailing list