Commits

Anonymous committed 3daa5f2

Added a new cylindrical geometry selection. Allows for cylinder to be oriented in any axis direction.

Comments (0)

Files changed (2)

src/enzo/InitializationKernel.C

     else return FALSE;
 }
 
+Enzo::Geometry::CylindricalRegion::CylindricalRegion(
+    FLOAT radius, FLOAT length, FLOAT *center, int axis)
+{
+    this->radius = radius;
+    this->radius2 = radius * radius;
+    this->length = length;
+    this->halflength = length / 2.0
+    this->center[0] = center[0];
+    this->center[1] = center[1];
+    this->center[2] = center[2];
+    this->axis = axis
+}
+
+int Enzo::Geometry::CylindericalRegion::PointContained(
+    FLOAT x, FLOAT y, FLOAT z, FLOAT dx, FLOAT dy, FLOAT dz)
+{
+    /* If the cell center is within the radial or lengthwise extent,
+    we return TRUE */
+    FLOAT temp[3], r2 = 0, l=0;
+    int i;
+    
+    temp[0] = (x - this->center[0]);
+    temp[1] = (y - this->center[1]);
+    temp[2] = (z - this->center[2]);
+
+    l = abs(temp[this->axis])
+
+    if (axis == 0)
+        r2 = (temp[1] * temp[1]) + (temp[2] * temp[2]);
+
+    if (axis == 1)
+        r2 = (temp[0] * temp[0]) + (temp[2] * temp[2]);
+
+    if (axis == 2)
+        r2 = (temp[0] * temp[0]) + (temp[1] * temp[1]);
+
+    if ( (r2 < this->radius2) && (l < this-halflength) ) return TRUE;
+    else return FALSE;
+}
+
 #endif

src/enzo/InitializationKernel.h

         FLOAT radius2;
         FLOAT center[3];
     };
+
+    class CylindricalRegion : public GeometricRegion
+    {
+      public:
+        CylindricalRegion(FLOAT radius, FLOAT length, FLOAT *center, int axis);
+        int PointContained(
+                   FLOAT x, FLOAT y, FLOAT z,
+                   FLOAT dx, FLOAT dy, FLOAT dz) = 0;
+      private:
+        FLOAT radius;
+        FLOAT radius2;
+        FLOAT length;
+        FLOAT halflength;
+        FLOAT center[3];
+        int axis;
+    };
+
   }
 }