Commits

Matthew Turk committed 543df60

First pass at geometric selections. Anticipating potentially many of these,
they have been namespaced. One can access them with something like
Enzo::Geometry::SphericalRegion, for instance.

Comments (0)

Files changed (3)

src/enzo/InitializationKernel.C

     return;
 }
 
+Enzo::Geometry::SphericalRegion::SphericalRegion(
+    FLOAT radius, FLOAT *center)
+{
+    this->radius = radius;
+    this->radius2 = radius * radius;
+    this->center[0] = center[0];
+    this->center[1] = center[1];
+    this->center[2] = center[2];
+}
+
+int Enzo::Geometry::SphericalRegion::PointContained(
+    FLOAT x, FLOAT y, FLOAT z, FLOAT dx, FLOAT dy, FLOAT dz)
+{
+    /* If the cell center is within the radius, we return TRUE */
+    FLOAT temp[3], r2 = 0;
+    int i;
+    temp[0] = (x - this->center[0]);
+    temp[1] = (y - this->center[1]);
+    temp[2] = (z - this->center[2]);
+    for (i = 0; i < 3; i++)
+        r2 += temp[i] * temp[i];
+    if (r2 < this->radius2) return TRUE;
+    else return FALSE;
+}
+
 #endif

src/enzo/InitializationKernel.h

         int additive;
 };
 
+namespace Enzo {
+  namespace Geometry {
+    class GeometricRegion : public InitializationKernel
+    {
+      public:
+        int AddKernel(InitializationKernel *kernel)
+        {
+            this->kernels[this->NumberOfKernels++] = kernel;
+            return this->NumberOfKernels;
+        }
+        void Apply(FieldContainer *fields,
+                   FLOAT x, FLOAT y, FLOAT z,
+                   FLOAT dx, FLOAT dy, FLOAT dz)
+        {
+            int i;
+            if (this->PointContained(x,y,z, dx, dy, dz) == TRUE)
+            {
+                for(i = 0; i < this->NumberOfKernels; i++)
+                {
+                    this->kernels[i]->Apply(fields,
+                        x, y, z, dx, dy, dz);
+                }
+            }
+        }
+        virtual int PointContained(
+                   FLOAT x, FLOAT y, FLOAT z,
+                   FLOAT dx, FLOAT dy, FLOAT dz) = 0;
+      private:
+        InitializationKernel *kernels[100];
+        int NumberOfKernels;
+    };
+
+    class SphericalRegion : public GeometricRegion
+    {
+      public:
+        SphericalRegion(FLOAT radius, FLOAT *center);
+        int PointContained(
+                   FLOAT x, FLOAT y, FLOAT z,
+                   FLOAT dx, FLOAT dy, FLOAT dz) = 0;
+      private:
+        FLOAT radius;
+        FLOAT radius2;
+        FLOAT center[3];
+    };
+  }
+}
+
 #endif

src/enzo/ProblemType_RotatingCylinder.C

         fprintf(Outfptr, "RotatingCylinderCenterPosition = %"PSYM" %"PSYM" %"PSYM"\n",
                 this->RotatingCylinderCenterPosition, (this->RotatingCylinderCenterPosition)+1,
                 (this->RotatingCylinderCenterPosition)+2);
-        fprintf(Outfptr, "TestProblemUseMetallicityField  = %"ISYM"\n", this->TestProblemData.UseMetallicityField);
-        fprintf(Outfptr, "TestProblemInitialMetallicityFraction  = %"FSYM"\n", this->TestProblemData.MetallicityField_Fraction);
+        fprintf(Outfptr, "TestProblemUseMetallicityField  = %"ISYM"\n", TestProblemData.UseMetallicityField);
+        fprintf(Outfptr, "TestProblemInitialMetallicityFraction  = %"FSYM"\n", TestProblemData.MetallicityField_Fraction);
     }
 
 };