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

luis at geodynamics.org luis at geodynamics.org
Tue Apr 8 17:35:21 PDT 2008


Author: luis
Date: 2008-04-08 17:35:21 -0700 (Tue, 08 Apr 2008)
New Revision: 11772

Added:
   cs/benchmark/cigma/trunk/src/TestBenchmarkFields.cpp
   cs/benchmark/cigma/trunk/src/TestBenchmarkFields.h
Log:
Testing random functions of various ranks and dimensions.


Added: cs/benchmark/cigma/trunk/src/TestBenchmarkFields.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/TestBenchmarkFields.cpp	                        (rev 0)
+++ cs/benchmark/cigma/trunk/src/TestBenchmarkFields.cpp	2008-04-09 00:35:21 UTC (rev 11772)
@@ -0,0 +1,72 @@
+#include "TestBenchmarkFields.h"
+#include <cmath>
+
+using namespace cigma::test_benchmarks;
+
+
+// ---------------------------------------------------------------------------
+
+Cube::Cube() {}
+Cube::~Cube() {}
+
+bool Cube::eval(double *x, double *value)
+{
+    value[0] = 3 * sin(M_PI * x[0]) * sin(M_PI * x[1]) * sin(M_PI * x[2]);
+    return true;
+}
+
+Sphere::Sphere() {}
+Sphere::~Sphere() {}
+
+bool Sphere::eval(double *x, double *value)
+{
+    const double xc = 0.0;
+    const double yc = 0.0;
+    const double zc = 0.0;
+    double dx = x[0] - xc;
+    double dy = x[1] - yc;
+    double dz = x[2] - zc;
+    double r2 = dx*dx + dy*dy + dz*dz;
+    value[0] = dx;
+    value[1] = dy;
+    value[2] = dz;
+    return true;
+}
+
+
+
+// ---------------------------------------------------------------------------
+
+Square::Square() {}
+Square::~Square() {}
+
+bool Square::eval(double *x, double *value)
+{
+    value[0] = 2 * sin(M_PI * x[0]) * sin(M_PI * x[1]);
+    return true;
+}
+
+
+Circle::Circle() {}
+Circle::~Circle() {}
+
+bool Circle::eval(double *x, double *value)
+{
+    const double R2 = 0.1;
+    const double xc = 0.5;
+    const double yc = 0.5;
+    double dx = x[0] - xc;
+    double dy = x[1] - yc;
+    double r2 = dx*dx + dy*dy;
+
+    if (r2 <= R2)
+    {
+        value[0] = dx/R2;
+        value[1] = dy/R2;
+    }
+    value[0] = dx/r2;
+    value[1] = dy/r2;
+    return true;
+}
+
+// ---------------------------------------------------------------------------

Added: cs/benchmark/cigma/trunk/src/TestBenchmarkFields.h
===================================================================
--- cs/benchmark/cigma/trunk/src/TestBenchmarkFields.h	                        (rev 0)
+++ cs/benchmark/cigma/trunk/src/TestBenchmarkFields.h	2008-04-09 00:35:21 UTC (rev 11772)
@@ -0,0 +1,81 @@
+#ifndef __TestBenchmarkFields_h__
+#define __TestBenchmarkFields_h__
+
+#include "UserField.h"
+
+namespace cigma
+{
+    namespace test_benchmarks
+    {
+        class Cube;
+        class Sphere;
+        class Square;
+        class Circle;
+    }
+}
+
+class cigma::test_benchmarks::Cube : public cigma::UserField
+{
+public:
+    Cube();
+    ~Cube();
+
+public:
+    int n_dim() { return 3; }
+    int n_rank() { return 1; }
+
+public:
+    bool eval(double *x, double *value);
+
+};
+
+
+class cigma::test_benchmarks::Sphere : public cigma::UserField
+{
+public:
+    Sphere();
+    ~Sphere();
+
+public:
+    int n_dim() { return 3; }
+    int n_rank() { return 3; }
+
+public:
+    bool eval(double *x, double *value);
+
+};
+
+
+class cigma::test_benchmarks::Square : public cigma::UserField
+{
+public:
+    Square();
+    ~Square();
+
+public:
+    int n_dim() { return 2; }
+    int n_rank() { return 1; }
+
+public:
+    bool eval(double *x, double *value);
+
+};
+
+
+class cigma::test_benchmarks::Circle : public cigma::UserField
+{
+public:
+    Circle();
+    ~Circle();
+
+public:
+    int n_dim() { return 2; }
+    int n_rank() { return 2; }
+
+public:
+    bool eval(double *x, double *value);
+
+};
+
+
+#endif



More information about the cig-commits mailing list