Commits

Michael Kuhlen  committed 63ae40d

Converted collapse test to newconfig, and added run/Hydro/Hydro-3D/CollapseTestTwoSphere.

  • Participants
  • Parent commits bfb5e31

Comments (0)

Files changed (5)

File run/Hydro/Hydro-3D/CollapseTestTwoSphere/CollapseTestTwoSphere.cfg

+#  AMR PROBLEM DEFINITION FILE: Non-cosmological Collapse test
+#  Description: a sphere collapses until becoming pressure supported.
+
+SimulationControl:
+{
+	StopTime            = 1.0;
+#	StopFirstTimeAtLevel    = 10;
+
+	Units:
+	{
+		Density = 3.82e-20;  # 10^4 cm^-3
+		Length = 5.0e17;     # 1 pc in cm
+		Time = 1.0e12;       # 10^4 yrs
+	};
+
+	Domain:
+	{
+		TopGridRank         = 3;
+		TopGridDimensions   = [64, 64, 64];
+		LeftFaceBoundaryCondition  = [3, 3, 3];
+		RightFaceBoundaryCondition = [3, 3, 3];
+	};
+	
+	AMR:
+	{
+		RefineBy                       = 2;
+		MaximumRefinementLevel         = 1;
+		StaticHierarchy                = False;
+		CellFlaggingMethod             = [6];
+		RefineByJeansLengthSafetyFactor  = 8.0;
+	};
+
+	Optimization:
+	{
+		MinimumEfficiency              = 0.3;
+	};
+
+}; # end SimulationControl
+
+
+OutputControl:
+{
+	DataDump:
+	{
+		Name = "DD";
+		Dir  = "DD";
+		dt   = 0.01;
+	};
+
+	OutputTriggers:
+        {
+#                OutputFirstTimeAtLevel = 4;
+        };
+
+	SupplementalFields:
+	{
+		OutputTemperature              = True;
+	};
+
+}; # end OutputControlParameters
+
+
+Physics:
+{
+
+	TopGridGravityBoundary     = 0;
+	SmallRho                   = 1.0e-8;
+	SmallEint                  = 1.0e-8;
+	
+	Hydro:
+	{
+		CourantSafetyNumber    = 0.3;
+		HydroMethod            = 0;   # PPM Direct Euler
+		Gamma                  = 1.0000001;
+
+		PPMDiffusionParameter  = False;
+
+		Mu                         = 3.0;
+
+		FluxCorrection                 = True;
+		InterpolationMethod            = 1;  # SecondOrderA
+		ConservativeInterpolation      = True;
+
+		DualEnergyFormalism         = True;
+
+		RiemannSolver              = 4;
+	};
+
+	ActiveParticles:
+	{
+		ActiveParticlesEnabled        = ["AccretingParticle"];
+	};
+
+	Gravity:
+	{
+		SelfGravity                  = True;
+
+		GravitationalConstant        = 0.0320327594; # 4*pi*G_{cgs}*DensityUnits*TimeUnits^2
+
+		PotentialIterations          = 100;
+		GreensFunctionMaxNumber      = 10;
+	};
+
+
+	AtomicPhysics:
+	{	
+		RadiativeCooling               = False;
+		MultiSpecies                   = 0;
+	};
+
+	Cosmology:
+	{
+		ComovingCoordinates = False;
+	};
+
+}; # end PhysicsParameters
+
+
+Initialization:
+{
+	ProblemType                    = 27;
+}; # end Initialization
+
+
+Problem: {
+	 CollapseTest:
+	 {
+		RefineAtStart   = True;
+		NumberOfSpheres = 2;
+		UseParticles    = 0;
+		InitialTemperature = 500.0; # temperature of the background gas
+		UniformVelocity = [0.0, 0.1, 0.0];
+
+		Spheres = ["Sphere1", "Sphere2"];
+
+		Sphere1: {
+			 Position       = [0.7, 0.2, 0.5];
+			 Velocity       = [0.0, 0.0, 0.0];
+			 Radius         = 0.1;
+			 CoreRadius     = 0.05;  # only used with sphere type 5
+			 Density        = 50.0;  # sphere density, the background density is 1
+			 Temperature    = 10.0;  # put sphere in pressure equilibrium (rho * T is constant)
+			 RotationPeriod = 0.0;
+			 Type           = 5;     # 1: uniform
+				 	         # 2: r^-2 power-law
+					         # 3: NFW
+					         # 4: Gaussian
+					         # 5: r^-2 power-law with a core
+					         # 11: Burkert & Bodenheimer setup
+		};
+
+		Sphere2: {
+			 Position   = [0.3, 0.2, 0.5];
+			 Velocity   = [0.0, 0.0, 0.0];
+			 Radius     = 0.1;
+			 CoreRadius = 0.05;
+			 Density    = 50.0;
+			 Temperature = 10.0;
+			 RotationPeriod = 0.0;
+			 Type       = 5;
+		};
+
+	 };
+}; # end Problem

File run/Hydro/Hydro-3D/CollapseTestTwoSphere/CollapseTestTwoSphere.enzo

+#
+#  AMR PROBLEM DEFINITION FILE: Non-cosmological Collapse test
+#  Description: a sphere collapses until becoming pressure supported.
+#
+#  define problem
+#
+ProblemType                = 27         // Collapse test
+TopGridRank                = 3
+TopGridDimensions          = 64 64 64
+SelfGravity                = 1          // gravity on
+TopGridGravityBoundary     = 0          // periodic
+LeftFaceBoundaryCondition  = 3 3 3      // periodic
+RightFaceBoundaryCondition = 3 3 3
+#ExtraOutputs               = 1 2 3 4 5 6 7 8 9
+#
+# problem parameters
+#
+
+CollapseTestRefineAtStart   = 1         // check refinement before running
+CollapseTestNumberOfSpheres = 2
+CollapseTestUseParticles    = 0
+CollapseTestInitialTemperature = 500    // temperature of the background gas
+CollapseTestUniformVelocity = 0.0 0.1 0.0
+CollapseTestSpherePosition[0]   = 0.7 0.2 0.5
+CollapseTestSphereVelocity[0]   = 0.0 0.0 0.0
+CollapseTestSphereRadius[0]     = 0.1
+CollapseTestSphereCoreRadius[0] = 0.05  // only used with sphere type 5
+CollapseTestSphereDensity[0]    = 50   // sphere density, the background density is 1
+CollapseTestSphereTemperature[0] = 10    // put sphere in pressure equilibrium (rho * T is constant)
+CollapseTestSphereRotationPeriod[0] = 0
+CollapseTestSphereType[0]       = 5     // constant density
+                                        // 1: uniform
+					// 2: r^-2 power-law
+					// 3: NFW
+					// 4: Gaussian
+					// 5: r^-2 power-law with a core
+					// 11: Burkert & Bodenheimer setup
+CollapseTestSpherePosition[1]   = 0.3 0.2 0.5
+CollapseTestSphereVelocity[1]   = 0.0 0.0 0.0
+CollapseTestSphereRadius[1]     = 0.1
+CollapseTestSphereCoreRadius[1] = 0.05  // only used with sphere type 5
+CollapseTestSphereDensity[1]    = 50   // sphere density, the background density is 1
+CollapseTestSphereTemperature[1] = 10    // put sphere in pressure equilibrium (rho * T is constant)
+CollapseTestSphereRotationPeriod[1] = 0
+CollapseTestSphereType[1]       = 5     // constant density
+                                        // 1: uniform
+					// 2: r^-2 power-law
+					// 3: NFW
+					// 4: Gaussian
+					// 5: r^-2 power-law with a core
+					// 11: Burkert & Bodenheimer setup
+
+
+
+#  no cosmology for this run
+#
+ComovingCoordinates   = 0              // Expansion OFF
+#
+#  units
+#
+DensityUnits          = 3.82e-20      // 10^4 cm^-3
+LengthUnits           = 5e17          // 1 pc in cm
+TimeUnits             = 1.0e12        // 10^4 yrs
+GravitationalConstant = 0.0320327594   // 4*pi*G_{cgs}*DensityUnits*TimeUnits^2
+#
+#  set I/O and stop/start parameters
+#
+StopTime          = 1.0
+dtDataDump        = 0.01
+#CycleSkipDataDump = 1
+DataDumpDir       = DD
+DataDumpName      = DD
+OutputTemperature = 1                  // Output temperature field.
+#
+#  set hydro parameters
+#
+Gamma                       = 1.0000001
+PPMDiffusionParameter       = 0        // diffusion off
+DualEnergyFormalism         = 1        // use total & internal energy
+InterpolationMethod         = 1        // SecondOrderA
+CourantSafetyNumber         = 0.3
+FluxCorrection              = 1
+ConservativeInterpolation   = 1
+RiemannSolver = 4
+HydroMethod                 = 0        // PPM
+SmallRho                    = 1e-8
+SmallE			    = 1e-8
+#
+#  chemistry/cooling
+#
+MultiSpecies                = 0        // chemistry off
+RadiativeCooling            = 0        // cooling off
+Mu  			    = 3.0
+#
+#  set grid refinement parameters
+#
+StaticHierarchy           = 0          // dynamic hierarchy
+MaximumRefinementLevel    = 1         // use up to 10 levels
+RefineBy                  = 2          // refinement factor
+CellFlaggingMethod        = 6         // use Truelove criterion for refinement 
+MinimumEfficiency         = 0.3
+#OutputFirstTimeAtLevel    = 4         // output when level 4, 5, 6, etc reached (commented out for now)
+#StopFirstTimeAtLevel      = 10         // stop if/when level 10 reached
+RefineByJeansLengthSafetyFactor = 8    // resolve Jeans length by 4 cells (used with CellFlaggingMethod 6)
+
+
+#
+#  set some global parameters
+#
+GreensFunctionMaxNumber   = 10         // # of greens function at any one time
+PotentialIterations	  = 100
+#
+#  active particle parameters
+#
+AppendActiveParticleType = AccretingParticle

File src/enzo/problem_types/CollapseTestInitialize.C

+/***********************************************************************
+/
+/  INITIALIZE A COLLAPSE TEST
+/
+/  written by: Greg Bryan
+/  date:       May, 1998
+/  modified1:
+/
+/  PURPOSE:
+/    Set up a number of spherical objects
+/
+/  RETURNS: SUCCESS or FAIL
+/
+************************************************************************/
+
+// This routine intializes a new simulation based on the parameter file.
+//
+  
+#include "ParameterControl.h"
+extern Configuration Param;
+
+#include "preincludes.h"
+#include "ErrorExceptions.h"
+#include "macros_and_parameters.h"
+#include "typedefs.h"
+#include "global_data.h"
+#include "Fluxes.h"
+#include "GridList.h"
+#include "ExternalBoundary.h"
+#include "Grid.h"
+#include "Hierarchy.h"
+#include "LevelHierarchy.h"
+#include "TopGridData.h"
+ 
+/* Set default parameter values. */
+
+const char config_collapse_test_defaults[] = 
+"### COLLAPSE TEST INITIALIZATION DEFAULTS ###\n"
+"\n"
+"Problem: {\n"
+"    CollapseTest: {\n"
+"        RefineAtStart = True;\n"
+"        UseParticles  = False;\n"
+"        ParticleMeanDensity = 0.0;\n"
+"        UseColour = False;\n"
+"        UseMetals = False;\n"
+"        InitialTemperature = 1000;\n"
+"        InitialDensity     = 1.0;\n"
+"        UniformVelocity = [0.0, 0.0, 0.0];\n"
+"\n"
+"        Spheres = [\"DefaultSphere\"];\n"
+"    };\n"
+"};\n";
+
+const char config_collapse_test_sphere_defaults[] =
+"            Density = 1.0;\n"
+"            Temperature = 1.0;\n"
+"            Velocity = [0.0, 0.0, 0.0];\n"
+"            FracKeplerianRot = 0.0;\n"
+"            Turbulence = 0.0;\n"
+"            Dispersion = 0.0;\n"
+"            CutOff = 6.5;\n"
+"            Ang1 = 0.0;\n"
+"            Ang2 = 0.0;\n"
+"            RotationPeriod = 0.0;\n"
+"            Metallicity = 0.0;\n"
+"            NumShells = 1;\n"
+"            InitialLevel = 0;\n"
+"            Type = 0;\n"
+"            Radius = 1.0;\n"
+"            CoreRadius = 0.1;\n"
+"            Position = [0.5, 0.5, 0.5];\n";
+
+void WriteListOfFloats(FILE *fptr, int N, float floats[]);
+void WriteListOfFloats(FILE *fptr, int N, FLOAT floats[]);
+void AddLevel(LevelHierarchyEntry *Array[], HierarchyEntry *Grid, int level);
+int RebuildHierarchy(TopGridData *MetaData,
+		     LevelHierarchyEntry *LevelArray[], int level);
+
+int CollapseTestInitialize(FILE *Outfptr, HierarchyEntry &TopGrid, TopGridData &MetaData)
+{
+  const char *DensName = "Density";
+  const char *TEName   = "TotalEnergy";
+  const char *GEName   = "GasEnergy";
+  const char *Vel1Name = "x-velocity";
+  const char *Vel2Name = "y-velocity";
+  const char *Vel3Name = "z-velocity";
+  const char *ColourName = "colour";
+  const char *ElectronName = "Electron_Density";
+  const char *HIName    = "HI_Density";
+  const char *HIIName   = "HII_Density";
+  const char *HeIName   = "HeI_Density";
+  const char *HeIIName  = "HeII_Density";
+  const char *HeIIIName = "HeIII_Density";
+  const char *HMName    = "HM_Density";
+  const char *H2IName   = "H2I_Density";
+
+  const char *H2IIName  = "H2II_Density";
+  const char *DIName    = "DI_Density";
+  const char *DIIName   = "DII_Density";
+  const char *HDIName   = "HDI_Density";
+  const char *MetalName = "Metal_Density";
+
+  /* declarations */
+
+  int   dim, level, sphere, i;
+
+  /* set default parameters */
+
+  int CollapseTestNumberOfSpheres;
+  int CollapseTestRefineAtStart;
+  int CollapseTestUseParticles;
+  float CollapseTestParticleMeanDensity;
+  int CollapseTestUseColour;
+  int CollapseTestUseMetals;
+  float CollapseTestInitialTemperature;
+  float CollapseTestInitialDensity;
+  float CollapseTestSphereDensity[MAX_SPHERES],
+    CollapseTestSphereTemperature[MAX_SPHERES],
+    CollapseTestSphereVelocity[MAX_SPHERES][MAX_DIMENSION],
+    CollapseTestUniformVelocity[MAX_DIMENSION],
+    CollapseTestFracKeplerianRot[MAX_SPHERES],
+    CollapseTestSphereTurbulence[MAX_SPHERES],
+    CollapseTestSphereDispersion[MAX_SPHERES],
+    CollapseTestSphereCutOff[MAX_SPHERES],
+    CollapseTestSphereAng1[MAX_SPHERES],
+    CollapseTestSphereAng2[MAX_SPHERES],
+    CollapseTestSphereRotationPeriod[MAX_SPHERES],
+    CollapseTestSphereMetallicity[MAX_SPHERES];
+  int CollapseTestSphereNumShells[MAX_SPHERES],
+    CollapseTestSphereInitialLevel[MAX_SPHERES],
+    CollapseTestSphereType[MAX_SPHERES];
+  FLOAT CollapseTestSphereRadius[MAX_SPHERES],
+    CollapseTestSphereCoreRadius[MAX_SPHERES],
+    CollapseTestSpherePosition[MAX_SPHERES][MAX_DIMENSION];
+
+  // Update the parameter config to include the local defaults. Note
+  // that this does not overwrite values previously specified.
+  Param.Update(config_collapse_test_defaults);
+
+
+  /* read input from file */
+
+  Param.GetScalar(CollapseTestRefineAtStart, "Problem.CollapseTest.RefineAtStart");
+  Param.GetScalar(CollapseTestUseParticles, "Problem.CollapseTest.UseParticles");
+  Param.GetScalar(CollapseTestParticleMeanDensity, "Problem.CollapseTest.ParticleMeanDensity");
+  Param.GetScalar(CollapseTestUseColour, "Problem.CollapseTest.UseColour");
+  Param.GetScalar(CollapseTestUseMetals, "Problem.CollapseTest.UseMetals");
+  Param.GetScalar(CollapseTestInitialTemperature, "Problem.CollapseTest.InitialTemperature");
+  Param.GetScalar(CollapseTestInitialDensity, "Problem.CollapseTest.InitialDensity");
+  Param.GetArray(CollapseTestUniformVelocity, "Problem.CollapseTest.UniformVelocity");
+  
+  int NumberOfSpheres = Param.Size("Problem.CollapseTest.Spheres");
+  if (NumberOfSpheres > MAX_SPHERES-1) {
+    ENZO_VFAIL("You've exceeded the maximum number of CollapseTest spheres (%d)!\n",MAX_SPHERES)
+      }
+  CollapseTestNumberOfSpheres = NumberOfSpheres;
+  
+  char SphereNames[MAX_LINE_LENGTH][MAX_SPHERES];
+  Param.GetArray(SphereNames,"Problem.CollapseTest.Spheres");
+  
+  char config_sphere_defaults[1024];
+  for (i = 0; i < NumberOfSpheres; i++) {
+
+    // Update the parameter config to include the sphere
+    // defaults. Note that this does not overwrite the values
+    // specified by the user (and read in below).
+    config_sphere_defaults[0] = 0;
+    sprintf(config_sphere_defaults, "%s"
+	    "Problem: {\n"
+	    "    CollapseTest: {\n"
+	    "        %s: {\n%s"
+	    "        };\n"
+	    "    };\n"
+	    "};\n", config_sphere_defaults,
+	    SphereNames[i], config_collapse_test_sphere_defaults);
+    Param.Update(config_sphere_defaults);
+
+
+    Param.GetScalar(CollapseTestSphereType[i], "Problem.CollapseTest.%s.Type",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereRadius[i], "Problem.CollapseTest.%s.Radius",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereCoreRadius[i], "Problem.CollapseTest.%s.CoreRadius",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereDensity[i], "Problem.CollapseTest.%s.Density",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereTemperature[i], "Problem.CollapseTest.%s.Temperature",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereMetallicity[i], "Problem.CollapseTest.%s.Metallicity",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereRotationPeriod[i], "Problem.CollapseTest.%s.RotationPeriod",SphereNames[i]);
+    Param.GetArray(CollapseTestSpherePosition[i], "Problem.CollapseTest.%s.Position",SphereNames[i]);
+    Param.GetArray(CollapseTestSphereVelocity[i], "Problem.CollapseTest.%s.Velocity",SphereNames[i]);
+    Param.GetScalar(CollapseTestFracKeplerianRot[i], "Problem.CollapseTest.%s.FracKeplerianRot",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereTurbulence[i], "Problem.CollapseTest.%s.Turbulence",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereDispersion[i], "Problem.CollapseTest.%s.Dispersion",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereCutOff[i], "Problem.CollapseTest.%s.CutOff",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereAng1[i], "Problem.CollapseTest.%s.Ang1",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereAng2[i], "Problem.CollapseTest.%s.Ang2",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereNumShells[i], "Problem.CollapseTest.%s.NumShells",SphereNames[i]);
+    Param.GetScalar(CollapseTestSphereInitialLevel[i], "Problem.CollapseTest.%s.InitialLevel",SphereNames[i]);
+  } 
+
+
+  /* set up grid */
+
+  if (TopGrid.GridData->CollapseTestInitializeGrid(
+	     CollapseTestNumberOfSpheres, CollapseTestSphereRadius,
+	     CollapseTestSphereCoreRadius, CollapseTestSphereDensity,
+	     CollapseTestSphereTemperature, CollapseTestSphereMetallicity,
+	     CollapseTestSpherePosition, CollapseTestSphereVelocity,
+             CollapseTestFracKeplerianRot, CollapseTestSphereTurbulence,
+	     CollapseTestSphereDispersion,
+             CollapseTestSphereCutOff, CollapseTestSphereAng1,
+             CollapseTestSphereAng2, CollapseTestSphereRotationPeriod,
+	     CollapseTestSphereNumShells,
+	     CollapseTestSphereType, CollapseTestUseParticles,
+	     CollapseTestParticleMeanDensity,
+             CollapseTestUniformVelocity, CollapseTestUseColour,
+	     CollapseTestUseMetals,
+             CollapseTestInitialTemperature, CollapseTestInitialDensity,
+	     0) == FAIL) {
+    ENZO_FAIL("Error in CollapseTestInitializeGrid.");
+  }
+
+  /* Convert minimum initial overdensity for refinement to mass
+     (unless MinimumMass itself was actually set). */
+
+  for (i = 0; i < MAX_FLAGGING_METHODS; i++)
+    if (MinimumMassForRefinement[i] == FLOAT_UNDEFINED) {
+      MinimumMassForRefinement[i] = MinimumOverDensityForRefinement[i];
+      for (dim = 0; dim < MetaData.TopGridRank; dim++)
+	MinimumMassForRefinement[i] *=
+	  (DomainRightEdge[dim]-DomainLeftEdge[dim])/
+	  float(MetaData.TopGridDims[dim]);
+    }
+
+  /* If requested and there are no manual settings of the refinement
+     of spheres, refine the grid to the desired level. */
+
+  int MaxInitialLevel = 0;
+  for (sphere = 0; sphere < CollapseTestNumberOfSpheres; sphere++)
+    MaxInitialLevel = max(MaxInitialLevel, CollapseTestSphereInitialLevel[sphere]);
+
+  if (CollapseTestRefineAtStart) {
+
+    /* If the user specified an initial refinement level for a sphere,
+       then manually create the hierarchy first. */
+
+    if (MaxInitialLevel > 0) {
+
+      int lev, max_level;
+      float dx;
+      HierarchyEntry **Subgrid;
+      int NumberOfSubgridDims[MAX_DIMENSION];
+      FLOAT ThisLeftEdge[MAX_DIMENSION], ThisRightEdge[MAX_DIMENSION];
+
+      for (sphere = 0; sphere < CollapseTestNumberOfSpheres; sphere++) {
+	
+	max_level = CollapseTestSphereInitialLevel[sphere];
+	if (max_level > 0) {
+
+	  Subgrid = new HierarchyEntry*[max_level];
+	  for (lev = 0; lev < max_level; lev++)
+	    Subgrid[lev] = new HierarchyEntry;
+
+	  for (lev = 0; lev < max_level; lev++) {
+	    
+	    for (dim = 0; dim < MetaData.TopGridRank; dim++) {
+	      dx = 1.0 / float(MetaData.TopGridDims[dim]) / POW(RefineBy, lev);
+	      ThisLeftEdge[dim] = CollapseTestSpherePosition[sphere][dim] -
+		0.5 * CollapseTestSphereRadius[sphere] - 2*dx;  // plus some buffer
+	      ThisLeftEdge[dim] = nint(ThisLeftEdge[dim] / dx) * dx;
+	      ThisRightEdge[dim] = CollapseTestSpherePosition[sphere][dim] +
+		0.5 * CollapseTestSphereRadius[sphere] + 2*dx;
+	      ThisRightEdge[dim] = nint(ThisRightEdge[dim] / dx) * dx;
+	      NumberOfSubgridDims[dim] = 
+		nint((ThisRightEdge[dim] - ThisLeftEdge[dim]) / 
+		     (DomainRightEdge[dim] - DomainLeftEdge[dim]) / dx);		
+	    } // ENDFOR dims
+
+	    if (debug)
+	      printf("CollapseTest:: Level[%"ISYM"]: NumberOfSubgridZones[0] = %"ISYM"\n",
+		     lev+1, NumberOfSubgridDims[0]);
+	    
+	    if (NumberOfSubgridDims[0] > 0) {
+
+	      // Insert into AMR hierarchy
+	      if (lev == 0) {
+		Subgrid[lev]->NextGridThisLevel = TopGrid.NextGridNextLevel;
+		TopGrid.NextGridNextLevel = Subgrid[lev];
+		Subgrid[lev]->ParentGrid = &TopGrid;
+	      } else {
+		Subgrid[lev]->NextGridThisLevel = NULL;
+		Subgrid[lev]->ParentGrid = Subgrid[lev-1];
+	      }
+	      if (lev == max_level-1)
+		Subgrid[lev]->NextGridNextLevel = NULL;
+	      else
+		Subgrid[lev]->NextGridNextLevel = Subgrid[lev+1];
+
+	      // Create grid
+	      for (dim = 0; dim < MetaData.TopGridRank; dim++)
+		NumberOfSubgridDims[dim] += 2*DEFAULT_GHOST_ZONES;
+	      Subgrid[lev]->GridData = new grid;
+	      Subgrid[lev]->GridData->InheritProperties(TopGrid.GridData);
+	      Subgrid[lev]->GridData->PrepareGrid(MetaData.TopGridRank, 
+						  NumberOfSubgridDims,
+						  ThisLeftEdge,
+						  ThisRightEdge, 0);
+
+
+	      if (Subgrid[lev]->GridData->CollapseTestInitializeGrid(
+	          CollapseTestNumberOfSpheres, CollapseTestSphereRadius,
+		  CollapseTestSphereCoreRadius, CollapseTestSphereDensity,
+		  CollapseTestSphereTemperature, CollapseTestSphereMetallicity,
+		  CollapseTestSpherePosition, CollapseTestSphereVelocity,
+		  CollapseTestFracKeplerianRot, CollapseTestSphereTurbulence,
+		  CollapseTestSphereDispersion,
+		  CollapseTestSphereCutOff, CollapseTestSphereAng1,
+		  CollapseTestSphereAng2, CollapseTestSphereRotationPeriod,
+		  CollapseTestSphereNumShells,
+		  CollapseTestSphereType, CollapseTestUseParticles,
+		  CollapseTestParticleMeanDensity,
+		  CollapseTestUniformVelocity, CollapseTestUseColour,
+		  CollapseTestUseMetals,
+		  CollapseTestInitialTemperature, CollapseTestInitialDensity,
+		  lev-1) == FAIL) {
+		ENZO_FAIL("Error in CollapseTestInitializeGrid.");
+	      }
+	      
+	    } // ENDIF zones exist
+	  } // ENDFOR levels
+	} // ENDIF max_level > 0
+      } // ENDFOR spheres
+    } // ENDIF MaxInitialLevel > 0
+
+    /* Declare, initialize and fill out the LevelArray. */
+
+    LevelHierarchyEntry *LevelArray[MAX_DEPTH_OF_HIERARCHY];
+    for (level = 0; level < MAX_DEPTH_OF_HIERARCHY; level++)
+      LevelArray[level] = NULL;
+    AddLevel(LevelArray, &TopGrid, 0);
+
+    /* Add levels to the maximum depth or until no new levels are created,
+       and re-initialize the level after it is created. */
+
+    if (MaxInitialLevel == 0) {
+      for (level = 0; level < MaximumRefinementLevel; level++) {
+	if (RebuildHierarchy(&MetaData, LevelArray, level) == FAIL) {
+	  ENZO_FAIL("Error in RebuildHierarchy.");
+	}
+	if (LevelArray[level+1] == NULL)
+	  break;
+	LevelHierarchyEntry *Temp = LevelArray[level+1];
+	while (Temp != NULL) {
+	  if (Temp->GridData->CollapseTestInitializeGrid(
+		 CollapseTestNumberOfSpheres, CollapseTestSphereRadius,
+		 CollapseTestSphereCoreRadius, CollapseTestSphereDensity,
+		 CollapseTestSphereTemperature, CollapseTestSphereMetallicity,
+		 CollapseTestSpherePosition, CollapseTestSphereVelocity,
+		 CollapseTestFracKeplerianRot, CollapseTestSphereTurbulence,
+		 CollapseTestSphereDispersion,
+		 CollapseTestSphereCutOff, CollapseTestSphereAng1,
+		 CollapseTestSphereAng2, CollapseTestSphereRotationPeriod,
+		 CollapseTestSphereNumShells,
+		 CollapseTestSphereType, CollapseTestUseParticles,
+		 CollapseTestParticleMeanDensity,
+		 CollapseTestUniformVelocity, CollapseTestUseColour,
+		 CollapseTestUseMetals,
+		 CollapseTestInitialTemperature, CollapseTestInitialDensity,
+		 level+1) == FAIL) {
+	    ENZO_FAIL("Error in CollapseTestInitializeGrid.");
+	  }
+	  Temp = Temp->NextGridThisLevel;
+	}
+      } // end: loop over levels
+    } // ENDELSE manually set refinement levels
+
+      /* Loop back from the bottom, restoring the consistency among levels. */
+
+    for (level = MaximumRefinementLevel; level > 0; level--) {
+      LevelHierarchyEntry *Temp = LevelArray[level];
+      while (Temp != NULL) {
+	if (Temp->GridData->ProjectSolutionToParentGrid(
+			      *LevelArray[level-1]->GridData) == FAIL) {
+	  ENZO_FAIL("Error in grid->ProjectSolutionToParentGrid.");
+	}
+	Temp = Temp->NextGridThisLevel;
+      }
+    }
+
+  } // end: if (CollapseTestRefineAtStart)
+
+  /* set up field names and units */
+
+  int count = 0;
+  DataLabel[count++] = (char*) DensName;
+  DataLabel[count++] = (char*) TEName;
+  if (DualEnergyFormalism)
+    DataLabel[count++] = (char*) GEName;
+  DataLabel[count++] = (char*) Vel1Name;
+  DataLabel[count++] = (char*) Vel2Name;
+  DataLabel[count++] = (char*) Vel3Name;
+  if (MultiSpecies) {
+    DataLabel[count++] = (char*) ElectronName;
+    DataLabel[count++] = (char*) HIName;
+    DataLabel[count++] = (char*) HIIName;
+    DataLabel[count++] = (char*) HeIName;
+    DataLabel[count++] = (char*) HeIIName;
+    DataLabel[count++] = (char*) HeIIIName;
+    if (MultiSpecies > 1) {
+      DataLabel[count++] = (char*) HMName;
+      DataLabel[count++] = (char*) H2IName;
+      DataLabel[count++] = (char*) H2IIName;
+    }
+    if (MultiSpecies > 2) {
+      DataLabel[count++] = (char*) DIName;
+      DataLabel[count++] = (char*) DIIName;
+      DataLabel[count++] = (char*) HDIName;
+    }
+  }  // if Multispecies
+  if (CollapseTestUseColour)
+    DataLabel[count++] = (char*) ColourName;
+  if (CollapseTestUseMetals)
+    DataLabel[count++] = (char*) MetalName;
+
+  for (i = 0; i < count; i++)
+    DataUnits[i] = NULL;
+
+  /* Write parameters to parameter output file */
+
+  if (MyProcessorNumber == ROOT_PROCESSOR) {
+    fprintf(Outfptr, "CollapseTestNumberOfSpheres    = %"ISYM"\n",
+	    CollapseTestNumberOfSpheres);
+    fprintf(Outfptr, "CollapseTestRefineAtStart      = %"ISYM"\n",
+	    CollapseTestRefineAtStart);
+    fprintf(Outfptr, "CollapseTestUseParticles       = %"ISYM"\n",
+	    CollapseTestUseParticles);
+    fprintf(Outfptr, "CollapseTestUseColour          = %"ISYM"\n",
+	    CollapseTestUseColour);
+    fprintf(Outfptr, "CollapseTestUseMetals          = %"ISYM"\n",
+	    CollapseTestUseMetals);
+    fprintf(Outfptr, "CollapseTestInitialTemperature = %"FSYM"\n",
+	    CollapseTestInitialTemperature);
+    fprintf(Outfptr, "CollapseTestInitialDensity     = %"FSYM"\n",
+	    CollapseTestInitialDensity);
+    fprintf(Outfptr, "CollapseTestUniformVelocity    = %"FSYM" %"FSYM" %"FSYM"\n",
+	    CollapseTestUniformVelocity[0], CollapseTestUniformVelocity[1],
+	    CollapseTestUniformVelocity[2]);
+    for (sphere = 0; sphere < CollapseTestNumberOfSpheres; sphere++) {
+      fprintf(Outfptr, "CollapseTestSphereType[%"ISYM"] = %"ISYM"\n", sphere,
+	      CollapseTestSphereType[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereRadius[%"ISYM"] = %"GOUTSYM"\n", sphere,
+	      CollapseTestSphereRadius[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereCoreRadius[%"ISYM"] = %"GOUTSYM"\n", sphere,
+	      CollapseTestSphereCoreRadius[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereDensity[%"ISYM"] = %"FSYM"\n", sphere,
+	      CollapseTestSphereDensity[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereTemperature[%"ISYM"] = %"FSYM"\n", sphere,
+	      CollapseTestSphereTemperature[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereMetallicity[%"ISYM"] = %"FSYM"\n", sphere,
+	      CollapseTestSphereMetallicity[sphere]);
+      fprintf(Outfptr, "CollapseTestSpherePosition[%"ISYM"] = ", sphere);
+      WriteListOfFloats(Outfptr, MetaData.TopGridRank,
+			CollapseTestSpherePosition[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereVelocity[%"ISYM"] = ", sphere);
+      WriteListOfFloats(Outfptr, MetaData.TopGridRank,
+			CollapseTestSphereVelocity[sphere]);
+      fprintf(Outfptr, "CollapseTestFracKeplerianRot[%"ISYM"] = %"GOUTSYM"\n", sphere,
+              CollapseTestFracKeplerianRot[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereTurbulence[%"ISYM"] = %"GOUTSYM"\n", sphere,
+              CollapseTestSphereTurbulence[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereCutOff[%"ISYM"] = %"GOUTSYM"\n", sphere,
+              CollapseTestSphereCutOff[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereAng1[%"ISYM"] = %"GOUTSYM"\n", sphere,
+              CollapseTestSphereAng1[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereAng2[%"ISYM"] = %"GOUTSYM"\n", sphere,
+              CollapseTestSphereAng2[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereRotationPeriod[%"ISYM"] = %"GOUTSYM"\n", sphere,
+	      CollapseTestSphereRotationPeriod[sphere]);
+      fprintf(Outfptr, "CollapseTestSphereNumShells[%"ISYM"] = %"ISYM"\n", sphere,
+              CollapseTestSphereNumShells[sphere]);
+    }
+  }
+
+  return SUCCESS;
+
+}

File src/enzo/problem_types/InitializeNew.C

 			     TopGridData &MetaData);
 int ZeldovichPancakeInitialize(FILE *fptr, FILE *Outfptr,
 			       HierarchyEntry &TopGrid, TopGridData &MetaData);
-int PressurelessCollapseInitialize(FILE *fptr, FILE *Outfptr,
-			       HierarchyEntry &TopGrid, TopGridData &MetaData);
+int PressurelessCollapseInitialize(FILE *fptr, FILE *Outfptr, HierarchyEntry &TopGrid, TopGridData &MetaData);
 int AdiabaticExpansionInitialize(FILE *fptr, FILE *Outfptr,
 				 HierarchyEntry &TopGrid);
 int TestGravityInitialize(FILE *fptr, FILE *Outfptr, HierarchyEntry &TopGrid,
 			      HierarchyEntry &TopGrid, TopGridData &MetaData);
 int GravityEquilibriumTestInitialize(FILE *fptr, FILE *Outfptr,
 			      HierarchyEntry &TopGrid, TopGridData &MetaData);
-int CollapseTestInitialize(FILE *fptr, FILE *Outfptr,
-			  HierarchyEntry &TopGrid, TopGridData &MetaData);
+int CollapseTestInitialize(FILE *Outfptr, HierarchyEntry &TopGrid, TopGridData &MetaData);
 int ClusterInitialize(FILE *fptr, FILE *Outfptr,
                           HierarchyEntry &TopGrid, TopGridData &MetaData, ExternalBoundary &Exterior);
 int TestGravityMotion(FILE *fptr, FILE *Outfptr, HierarchyEntry &TopGrid,
   // 27) CollapseTest
  
   if (ProblemType == 27)
-    ret = CollapseTestInitialize(fptr, Outfptr, TopGrid, MetaData);
+    ret = CollapseTestInitialize(Outfptr, TopGrid, MetaData);
  
   // 28) TestGravityMotion
  

File src/enzo/problem_types/not_yet_converted/CollapseTestInitialize.C

-/***********************************************************************
-/
-/  INITIALIZE A COLLAPSE TEST
-/
-/  written by: Greg Bryan
-/  date:       May, 1998
-/  modified1:
-/
-/  PURPOSE:
-/    Set up a number of spherical objects
-/
-/  RETURNS: SUCCESS or FAIL
-/
-************************************************************************/
-
-// This routine intializes a new simulation based on the parameter file.
-//
-
-#include "preincludes.h"
-#include "ErrorExceptions.h"
-#include "macros_and_parameters.h"
-#include "typedefs.h"
-#include "global_data.h"
-#include "Fluxes.h"
-#include "GridList.h"
-#include "ExternalBoundary.h"
-#include "Grid.h"
-#include "Hierarchy.h"
-#include "LevelHierarchy.h"
-#include "TopGridData.h"
-
-void WriteListOfFloats(FILE *fptr, int N, float floats[]);
-void WriteListOfFloats(FILE *fptr, int N, FLOAT floats[]);
-void AddLevel(LevelHierarchyEntry *Array[], HierarchyEntry *Grid, int level);
-int RebuildHierarchy(TopGridData *MetaData,
-		     LevelHierarchyEntry *LevelArray[], int level);
-
-int CollapseTestInitialize(FILE *fptr, FILE *Outfptr, 
-			  HierarchyEntry &TopGrid, TopGridData &MetaData)
-{
-  const char *DensName = "Density";
-  const char *TEName   = "TotalEnergy";
-  const char *GEName   = "GasEnergy";
-  const char *Vel1Name = "x-velocity";
-  const char *Vel2Name = "y-velocity";
-  const char *Vel3Name = "z-velocity";
-  const char *ColourName = "colour";
-  const char *ElectronName = "Electron_Density";
-  const char *HIName    = "HI_Density";
-  const char *HIIName   = "HII_Density";
-  const char *HeIName   = "HeI_Density";
-  const char *HeIIName  = "HeII_Density";
-  const char *HeIIIName = "HeIII_Density";
-  const char *HMName    = "HM_Density";
-  const char *H2IName   = "H2I_Density";
-  const char *H2IIName  = "H2II_Density";
-  const char *DIName    = "DI_Density";
-  const char *DIIName   = "DII_Density";
-  const char *HDIName   = "HDI_Density";
-  const char *MetalName = "Metal_Density";
-
-  /* declarations */
-
-  char  line[MAX_LINE_LENGTH];
-  int   dim, ret, level, sphere, i;
-
-  /* set default parameters */
-
-  int CollapseTestNumberOfSpheres = 1;
-  int CollapseTestRefineAtStart   = TRUE;
-  int CollapseTestUseParticles    = FALSE;
-  float CollapseTestParticleMeanDensity = FLOAT_UNDEFINED;
-  int CollapseTestUseColour       = FALSE;
-  int CollapseTestUseMetals       = FALSE;
-  float CollapseTestInitialTemperature = 1000;
-  float CollapseTestInitialDensity     = 1.0;
-  float CollapseTestSphereDensity[MAX_SPHERES],
-    CollapseTestSphereTemperature[MAX_SPHERES],
-    CollapseTestSphereVelocity[MAX_SPHERES][MAX_DIMENSION],
-    CollapseTestUniformVelocity[MAX_DIMENSION],
-    CollapseTestFracKeplerianRot[MAX_SPHERES],
-    CollapseTestSphereTurbulence[MAX_SPHERES],
-    CollapseTestSphereDispersion[MAX_SPHERES],
-    CollapseTestSphereCutOff[MAX_SPHERES],
-    CollapseTestSphereAng1[MAX_SPHERES],
-    CollapseTestSphereAng2[MAX_SPHERES],
-    CollapseTestSphereRotationPeriod[MAX_SPHERES],
-    CollapseTestSphereMetallicity[MAX_SPHERES];
-  int CollapseTestSphereNumShells[MAX_SPHERES],
-    CollapseTestSphereInitialLevel[MAX_SPHERES],
-    CollapseTestSphereType[MAX_SPHERES];
-  FLOAT CollapseTestSphereRadius[MAX_SPHERES],
-    CollapseTestSphereCoreRadius[MAX_SPHERES],
-    CollapseTestSpherePosition[MAX_SPHERES][MAX_DIMENSION];
-
-  for (sphere = 0; sphere < MAX_SPHERES; sphere++) {
-    CollapseTestSphereRadius[sphere]     = 1.0;
-    CollapseTestSphereCoreRadius[sphere] = 0.1;
-    CollapseTestSphereDensity[sphere]    = 1.0;
-    CollapseTestSphereTemperature[sphere] = 1.0;
-    CollapseTestFracKeplerianRot[sphere] = 0.0;
-    CollapseTestSphereTurbulence[sphere] = 0.0;
-    CollapseTestSphereDispersion[sphere] = 0.0;
-    CollapseTestSphereCutOff[sphere] = 6.5;
-    CollapseTestSphereAng1[sphere] = 0;
-    CollapseTestSphereAng2[sphere] = 0;
-    CollapseTestSphereRotationPeriod[sphere] = 0;
-    CollapseTestSphereNumShells[sphere] = 1;
-    CollapseTestSphereMetallicity[sphere] = 0;
-    CollapseTestSphereInitialLevel[sphere] = 0;
-
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      CollapseTestSpherePosition[sphere][dim] = 0.5*(DomainLeftEdge[dim] +
-						     DomainRightEdge[dim]);
-      CollapseTestSphereVelocity[sphere][dim] = 0;
-    }
-    CollapseTestSphereType[sphere]       = 0;
-  }
-  for (dim = 0; dim < MAX_DIMENSION; dim++)
-    CollapseTestUniformVelocity[dim] = 0;
-
-  /* read input from file */
-
-  while (fgets(line, MAX_LINE_LENGTH, fptr) != NULL) {
-
-    ret = 0;
-
-    /* read parameters */
-
-    ret += sscanf(line, "CollapseTestNumberOfSpheres = %"ISYM,
-		  &CollapseTestNumberOfSpheres);
-    ret += sscanf(line, "CollapseTestRefineAtStart = %"ISYM, 
-		  &CollapseTestRefineAtStart);
-    ret += sscanf(line, "CollapseTestUseParticles = %"ISYM, 
-		  &CollapseTestUseParticles);
-    ret += sscanf(line, "CollapseTestParticleMeanDensity = %"FSYM,
-		  &CollapseTestParticleMeanDensity);
-    ret += sscanf(line, "CollapseTestUseColour = %"ISYM, 
-		  &CollapseTestUseColour);
-    ret += sscanf(line, "CollapseTestUseMetals = %"ISYM, 
-		  &CollapseTestUseMetals);
-    ret += sscanf(line, "CollapseTestInitialTemperature = %"FSYM, 
-		  &CollapseTestInitialTemperature);
-    ret += sscanf(line, "CollapseTestInitialDensity = %"FSYM,
-		  &CollapseTestInitialDensity);
-    ret += sscanf(line, "CollapseTestUniformVelocity = %"FSYM" %"FSYM" %"FSYM, 
-		  CollapseTestUniformVelocity, CollapseTestUniformVelocity+1,
-		  CollapseTestUniformVelocity+2);
-    if (sscanf(line, "CollapseTestSphereType[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereType[%"ISYM"] = %"ISYM, &sphere,
-		    &CollapseTestSphereType[sphere]);
-    if (sscanf(line, "CollapseTestSphereRadius[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereRadius[%"ISYM"] = %"PSYM, &sphere,
-		    &CollapseTestSphereRadius[sphere]);
-    if (sscanf(line, "CollapseTestSphereCoreRadius[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereCoreRadius[%"ISYM"] = %"PSYM, &sphere,
-		    &CollapseTestSphereCoreRadius[sphere]);
-    if (sscanf(line, "CollapseTestSphereDensity[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereDensity[%"ISYM"] = %"FSYM, &sphere,
-		    &CollapseTestSphereDensity[sphere]);
-    if (sscanf(line, "CollapseTestSphereTemperature[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereTemperature[%"ISYM"] = %"FSYM, &sphere,
-		    &CollapseTestSphereTemperature[sphere]);
-    if (sscanf(line, "CollapseTestSphereMetallicity[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereMetallicity[%"ISYM"] = %"FSYM, &sphere,
-		    &CollapseTestSphereMetallicity[sphere]);
-    if (sscanf(line, "CollapseTestSpherePosition[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSpherePosition[%"ISYM"] = %"PSYM" %"PSYM" %"PSYM, 
-		    &sphere, &CollapseTestSpherePosition[sphere][0],
-		    &CollapseTestSpherePosition[sphere][1],
-		    &CollapseTestSpherePosition[sphere][2]);
-    if (sscanf(line, "CollapseTestSphereVelocity[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereVelocity[%"ISYM"] = %"FSYM" %"FSYM" %"FSYM, 
-		    &sphere, &CollapseTestSphereVelocity[sphere][0],
-		    &CollapseTestSphereVelocity[sphere][1],
-		    &CollapseTestSphereVelocity[sphere][2]);
-    if (sscanf(line, "CollapseTestFracKeplerianRot[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestFracKeplerianRot[%"ISYM"] = %"FSYM, &sphere,
-                    &CollapseTestFracKeplerianRot[sphere]);
-    if (sscanf(line, "CollapseTestSphereTurbulence[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereTurbulence[%"ISYM"] = %"FSYM, &sphere,
-                    &CollapseTestSphereTurbulence[sphere]);
-    if (sscanf(line, "CollapseTestSphereDispersion[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereDispersion[%"ISYM"] = %"FSYM, &sphere,
-                    &CollapseTestSphereDispersion[sphere]);
-    if (sscanf(line, "CollapseTestSphereCutOff[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereCutOff[%"ISYM"] = %"FSYM, &sphere,
-                    &CollapseTestSphereCutOff[sphere]);
-    if (sscanf(line, "CollapseTestSphereAng1[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereAng1[%"ISYM"] = %"FSYM, &sphere,
-                    &CollapseTestSphereAng1[sphere]);
-    if (sscanf(line, "CollapseTestSphereAng2[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereAng2[%"ISYM"] = %"FSYM, &sphere,
-                    &CollapseTestSphereAng2[sphere]);
-    if (sscanf(line, "CollapseTestSphereRotationPeriod[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereRotationPeriod[%"ISYM"] = %"FSYM, &sphere,
-		    &CollapseTestSphereRotationPeriod[sphere]);
-    if (sscanf(line, "CollapseTestSphereNumShells[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereNumShells[%"ISYM"] = %"ISYM, &sphere,
-                    &CollapseTestSphereNumShells[sphere]);
-    if (sscanf(line, "CollapseTestSphereInitialLevel[%"ISYM"]", &sphere) > 0)
-      ret += sscanf(line, "CollapseTestSphereInitialLevel[%"ISYM"] = %"ISYM, &sphere,
-                    &CollapseTestSphereInitialLevel[sphere]);
-
-    /* if the line is suspicious, issue a warning */
-
-    if (ret == 0 && strstr(line, "=") && strstr(line, "CollapseTest") 
-	&& line[0] != '#')
-      fprintf(stderr, "warning: the following parameter line was not interpreted:\n%s\n", line);
-
-  } // end input from parameter file
-
-  /* set up grid */
-
-  if (TopGrid.GridData->CollapseTestInitializeGrid(
-	     CollapseTestNumberOfSpheres, CollapseTestSphereRadius,
-	     CollapseTestSphereCoreRadius, CollapseTestSphereDensity,
-	     CollapseTestSphereTemperature, CollapseTestSphereMetallicity,
-	     CollapseTestSpherePosition, CollapseTestSphereVelocity,
-             CollapseTestFracKeplerianRot, CollapseTestSphereTurbulence,
-	     CollapseTestSphereDispersion,
-             CollapseTestSphereCutOff, CollapseTestSphereAng1,
-             CollapseTestSphereAng2, CollapseTestSphereRotationPeriod,
-	     CollapseTestSphereNumShells,
-	     CollapseTestSphereType, CollapseTestUseParticles,
-	     CollapseTestParticleMeanDensity,
-             CollapseTestUniformVelocity, CollapseTestUseColour,
-	     CollapseTestUseMetals,
-             CollapseTestInitialTemperature, CollapseTestInitialDensity,
-	     0) == FAIL) {
-    ENZO_FAIL("Error in CollapseTestInitializeGrid.");
-  }
-
-  /* Convert minimum initial overdensity for refinement to mass
-     (unless MinimumMass itself was actually set). */
-
-  for (i = 0; i < MAX_FLAGGING_METHODS; i++)
-    if (MinimumMassForRefinement[i] == FLOAT_UNDEFINED) {
-      MinimumMassForRefinement[i] = MinimumOverDensityForRefinement[i];
-      for (dim = 0; dim < MetaData.TopGridRank; dim++)
-	MinimumMassForRefinement[i] *=
-	  (DomainRightEdge[dim]-DomainLeftEdge[dim])/
-	  float(MetaData.TopGridDims[dim]);
-    }
-
-  /* If requested and there are no manual settings of the refinement
-     of spheres, refine the grid to the desired level. */
-
-  int MaxInitialLevel = 0;
-  for (sphere = 0; sphere < CollapseTestNumberOfSpheres; sphere++)
-    MaxInitialLevel = max(MaxInitialLevel, CollapseTestSphereInitialLevel[sphere]);
-
-  if (CollapseTestRefineAtStart) {
-
-    /* If the user specified an initial refinement level for a sphere,
-       then manually create the hierarchy first. */
-
-    if (MaxInitialLevel > 0) {
-
-      int lev, max_level;
-      float dx;
-      HierarchyEntry **Subgrid;
-      int NumberOfSubgridDims[MAX_DIMENSION];
-      FLOAT ThisLeftEdge[MAX_DIMENSION], ThisRightEdge[MAX_DIMENSION];
-
-      for (sphere = 0; sphere < CollapseTestNumberOfSpheres; sphere++) {
-	
-	max_level = CollapseTestSphereInitialLevel[sphere];
-	if (max_level > 0) {
-
-	  Subgrid = new HierarchyEntry*[max_level];
-	  for (lev = 0; lev < max_level; lev++)
-	    Subgrid[lev] = new HierarchyEntry;
-
-	  for (lev = 0; lev < max_level; lev++) {
-	    
-	    for (dim = 0; dim < MetaData.TopGridRank; dim++) {
-	      dx = 1.0 / float(MetaData.TopGridDims[dim]) / POW(RefineBy, lev);
-	      ThisLeftEdge[dim] = CollapseTestSpherePosition[sphere][dim] -
-		0.5 * CollapseTestSphereRadius[sphere] - 2*dx;  // plus some buffer
-	      ThisLeftEdge[dim] = nint(ThisLeftEdge[dim] / dx) * dx;
-	      ThisRightEdge[dim] = CollapseTestSpherePosition[sphere][dim] +
-		0.5 * CollapseTestSphereRadius[sphere] + 2*dx;
-	      ThisRightEdge[dim] = nint(ThisRightEdge[dim] / dx) * dx;
-	      NumberOfSubgridDims[dim] = 
-		nint((ThisRightEdge[dim] - ThisLeftEdge[dim]) / 
-		     (DomainRightEdge[dim] - DomainLeftEdge[dim]) / dx);		
-	    } // ENDFOR dims
-
-	    if (debug)
-	      printf("CollapseTest:: Level[%"ISYM"]: NumberOfSubgridZones[0] = %"ISYM"\n",
-		     lev+1, NumberOfSubgridDims[0]);
-	    
-	    if (NumberOfSubgridDims[0] > 0) {
-
-	      // Insert into AMR hierarchy
-	      if (lev == 0) {
-		Subgrid[lev]->NextGridThisLevel = TopGrid.NextGridNextLevel;
-		TopGrid.NextGridNextLevel = Subgrid[lev];
-		Subgrid[lev]->ParentGrid = &TopGrid;
-	      } else {
-		Subgrid[lev]->NextGridThisLevel = NULL;
-		Subgrid[lev]->ParentGrid = Subgrid[lev-1];
-	      }
-	      if (lev == max_level-1)
-		Subgrid[lev]->NextGridNextLevel = NULL;
-	      else
-		Subgrid[lev]->NextGridNextLevel = Subgrid[lev+1];
-
-	      // Create grid
-	      for (dim = 0; dim < MetaData.TopGridRank; dim++)
-		NumberOfSubgridDims[dim] += 2*DEFAULT_GHOST_ZONES;
-	      Subgrid[lev]->GridData = new grid;
-	      Subgrid[lev]->GridData->InheritProperties(TopGrid.GridData);
-	      Subgrid[lev]->GridData->PrepareGrid(MetaData.TopGridRank, 
-						  NumberOfSubgridDims,
-						  ThisLeftEdge,
-						  ThisRightEdge, 0);
-
-
-	      if (Subgrid[lev]->GridData->CollapseTestInitializeGrid(
-	          CollapseTestNumberOfSpheres, CollapseTestSphereRadius,
-		  CollapseTestSphereCoreRadius, CollapseTestSphereDensity,
-		  CollapseTestSphereTemperature, CollapseTestSphereMetallicity,
-		  CollapseTestSpherePosition, CollapseTestSphereVelocity,
-		  CollapseTestFracKeplerianRot, CollapseTestSphereTurbulence,
-		  CollapseTestSphereDispersion,
-		  CollapseTestSphereCutOff, CollapseTestSphereAng1,
-		  CollapseTestSphereAng2, CollapseTestSphereRotationPeriod,
-		  CollapseTestSphereNumShells,
-		  CollapseTestSphereType, CollapseTestUseParticles,
-		  CollapseTestParticleMeanDensity,
-		  CollapseTestUniformVelocity, CollapseTestUseColour,
-		  CollapseTestUseMetals,
-		  CollapseTestInitialTemperature, CollapseTestInitialDensity,
-		  lev-1) == FAIL) {
-		ENZO_FAIL("Error in CollapseTestInitializeGrid.");
-	      }
-	      
-	    } // ENDIF zones exist
-	  } // ENDFOR levels
-	} // ENDIF max_level > 0
-      } // ENDFOR spheres
-    } // ENDIF MaxInitialLevel > 0
-
-    /* Declare, initialize and fill out the LevelArray. */
-
-    LevelHierarchyEntry *LevelArray[MAX_DEPTH_OF_HIERARCHY];
-    for (level = 0; level < MAX_DEPTH_OF_HIERARCHY; level++)
-      LevelArray[level] = NULL;
-    AddLevel(LevelArray, &TopGrid, 0);
-
-    /* Add levels to the maximum depth or until no new levels are created,
-       and re-initialize the level after it is created. */
-
-    if (MaxInitialLevel == 0) {
-      for (level = 0; level < MaximumRefinementLevel; level++) {
-	if (RebuildHierarchy(&MetaData, LevelArray, level) == FAIL) {
-	  ENZO_FAIL("Error in RebuildHierarchy.");
-	}
-	if (LevelArray[level+1] == NULL)
-	  break;
-	LevelHierarchyEntry *Temp = LevelArray[level+1];
-	while (Temp != NULL) {
-	  if (Temp->GridData->CollapseTestInitializeGrid(
-		 CollapseTestNumberOfSpheres, CollapseTestSphereRadius,
-		 CollapseTestSphereCoreRadius, CollapseTestSphereDensity,
-		 CollapseTestSphereTemperature, CollapseTestSphereMetallicity,
-		 CollapseTestSpherePosition, CollapseTestSphereVelocity,
-		 CollapseTestFracKeplerianRot, CollapseTestSphereTurbulence,
-		 CollapseTestSphereDispersion,
-		 CollapseTestSphereCutOff, CollapseTestSphereAng1,
-		 CollapseTestSphereAng2, CollapseTestSphereRotationPeriod,
-		 CollapseTestSphereNumShells,
-		 CollapseTestSphereType, CollapseTestUseParticles,
-		 CollapseTestParticleMeanDensity,
-		 CollapseTestUniformVelocity, CollapseTestUseColour,
-		 CollapseTestUseMetals,
-		 CollapseTestInitialTemperature, CollapseTestInitialDensity,
-		 level+1) == FAIL) {
-	    ENZO_FAIL("Error in CollapseTestInitializeGrid.");
-	  }
-	  Temp = Temp->NextGridThisLevel;
-	}
-      } // end: loop over levels
-    } // ENDELSE manually set refinement levels
-
-      /* Loop back from the bottom, restoring the consistency among levels. */
-
-    for (level = MaximumRefinementLevel; level > 0; level--) {
-      LevelHierarchyEntry *Temp = LevelArray[level];
-      while (Temp != NULL) {
-	if (Temp->GridData->ProjectSolutionToParentGrid(
-			      *LevelArray[level-1]->GridData) == FAIL) {
-	  ENZO_FAIL("Error in grid->ProjectSolutionToParentGrid.");
-	}
-	Temp = Temp->NextGridThisLevel;
-      }
-    }
-
-  } // end: if (CollapseTestRefineAtStart)
-
-  /* set up field names and units */
-
-  int count = 0;
-  DataLabel[count++] = (char*) DensName;
-  DataLabel[count++] = (char*) TEName;
-  if (DualEnergyFormalism)
-    DataLabel[count++] = (char*) GEName;
-  DataLabel[count++] = (char*) Vel1Name;
-  DataLabel[count++] = (char*) Vel2Name;
-  DataLabel[count++] = (char*) Vel3Name;
-  if (MultiSpecies) {
-    DataLabel[count++] = (char*) ElectronName;
-    DataLabel[count++] = (char*) HIName;
-    DataLabel[count++] = (char*) HIIName;
-    DataLabel[count++] = (char*) HeIName;
-    DataLabel[count++] = (char*) HeIIName;
-    DataLabel[count++] = (char*) HeIIIName;
-    if (MultiSpecies > 1) {
-      DataLabel[count++] = (char*) HMName;
-      DataLabel[count++] = (char*) H2IName;
-      DataLabel[count++] = (char*) H2IIName;
-    }
-    if (MultiSpecies > 2) {
-      DataLabel[count++] = (char*) DIName;
-      DataLabel[count++] = (char*) DIIName;
-      DataLabel[count++] = (char*) HDIName;
-    }
-  }  // if Multispecies
-  if (CollapseTestUseColour)
-    DataLabel[count++] = (char*) ColourName;
-  if (CollapseTestUseMetals)
-    DataLabel[count++] = (char*) MetalName;
-
-  for (i = 0; i < count; i++)
-    DataUnits[i] = NULL;
-
-  /* Write parameters to parameter output file */
-
-  if (MyProcessorNumber == ROOT_PROCESSOR) {
-    fprintf(Outfptr, "CollapseTestNumberOfSpheres    = %"ISYM"\n",
-	    CollapseTestNumberOfSpheres);
-    fprintf(Outfptr, "CollapseTestRefineAtStart      = %"ISYM"\n",
-	    CollapseTestRefineAtStart);
-    fprintf(Outfptr, "CollapseTestUseParticles       = %"ISYM"\n",
-	    CollapseTestUseParticles);
-    fprintf(Outfptr, "CollapseTestUseColour          = %"ISYM"\n",
-	    CollapseTestUseColour);
-    fprintf(Outfptr, "CollapseTestUseMetals          = %"ISYM"\n",
-	    CollapseTestUseMetals);
-    fprintf(Outfptr, "CollapseTestInitialTemperature = %"FSYM"\n",
-	    CollapseTestInitialTemperature);
-    fprintf(Outfptr, "CollapseTestInitialDensity     = %"FSYM"\n",
-	    CollapseTestInitialDensity);
-    fprintf(Outfptr, "CollapseTestUniformVelocity    = %"FSYM" %"FSYM" %"FSYM"\n",
-	    CollapseTestUniformVelocity[0], CollapseTestUniformVelocity[1],
-	    CollapseTestUniformVelocity[2]);
-    for (sphere = 0; sphere < CollapseTestNumberOfSpheres; sphere++) {
-      fprintf(Outfptr, "CollapseTestSphereType[%"ISYM"] = %"ISYM"\n", sphere,
-	      CollapseTestSphereType[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereRadius[%"ISYM"] = %"GOUTSYM"\n", sphere,
-	      CollapseTestSphereRadius[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereCoreRadius[%"ISYM"] = %"GOUTSYM"\n", sphere,
-	      CollapseTestSphereCoreRadius[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereDensity[%"ISYM"] = %"FSYM"\n", sphere,
-	      CollapseTestSphereDensity[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereTemperature[%"ISYM"] = %"FSYM"\n", sphere,
-	      CollapseTestSphereTemperature[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereMetallicity[%"ISYM"] = %"FSYM"\n", sphere,
-	      CollapseTestSphereMetallicity[sphere]);
-      fprintf(Outfptr, "CollapseTestSpherePosition[%"ISYM"] = ", sphere);
-      WriteListOfFloats(Outfptr, MetaData.TopGridRank,
-			CollapseTestSpherePosition[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereVelocity[%"ISYM"] = ", sphere);
-      WriteListOfFloats(Outfptr, MetaData.TopGridRank,
-			CollapseTestSphereVelocity[sphere]);
-      fprintf(Outfptr, "CollapseTestFracKeplerianRot[%"ISYM"] = %"GOUTSYM"\n", sphere,
-              CollapseTestFracKeplerianRot[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereTurbulence[%"ISYM"] = %"GOUTSYM"\n", sphere,
-              CollapseTestSphereTurbulence[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereCutOff[%"ISYM"] = %"GOUTSYM"\n", sphere,
-              CollapseTestSphereCutOff[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereAng1[%"ISYM"] = %"GOUTSYM"\n", sphere,
-              CollapseTestSphereAng1[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereAng2[%"ISYM"] = %"GOUTSYM"\n", sphere,
-              CollapseTestSphereAng2[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereRotationPeriod[%"ISYM"] = %"GOUTSYM"\n", sphere,
-	      CollapseTestSphereRotationPeriod[sphere]);
-      fprintf(Outfptr, "CollapseTestSphereNumShells[%"ISYM"] = %"ISYM"\n", sphere,
-              CollapseTestSphereNumShells[sphere]);
-    }
-  }
-
-  return SUCCESS;
-
-}