Commits

Brian O'Shea committed dde3bf7 Merge

Merged in samskillman/enzo-dev (pull request #223)

Adding MHDCT to CosmologySimulation

Comments (0)

Files changed (2)

src/enzo/CosmologySimulationInitialize.C

   for (j = 0; j < i; j++)
     DataUnits[j] = NULL;
  
+  if ( UseMHDCT ){
+      MHDcLabel[0] = "Bx";
+      MHDcLabel[1] = "By";
+      MHDcLabel[2] = "Bz";
+
+      MHDLabel[0] = "BxF";
+      MHDLabel[1] = "ByF";
+      MHDLabel[2] = "BzF";
+
+      MHDeLabel[0] = "Ex";
+      MHDeLabel[1] = "Ey";
+      MHDeLabel[2] = "Ez";
+
+      MHDUnits[0] = "None";
+      MHDUnits[1] = "None";
+      MHDUnits[2] = "None";
+
+      MHDeUnits[0] = "None";
+      MHDeUnits[1] = "None";
+      MHDeUnits[2] = "None";
+  }
+
+
   // Write parameters to parameter output file
  
   if (MyProcessorNumber == ROOT_PROCESSOR) {

src/enzo/Grid_CosmologySimulationInitializeGrid.C

     printf("Allocating %"ISYM" baryon fields of size %"ISYM"\n", NumberOfBaryonFields, size);
  
   if (ReadData == TRUE)
-    for (int field = 0; field < NumberOfBaryonFields; field++)
-      BaryonField[field] = new float[size];
- 
+    this->AllocateGrids();  
  
   // Read the density field
  
 
     if (CosmologySimulationTotalEnergyName == NULL)
       for (i = 0; i < size; i++)
-	BaryonField[iTE][i] = CosmologySimulationInitialTemperature/
-	                      TemperatureUnits/DEFAULT_MU/(Gamma-1.0);
- 
-/*          * POW(BaryonField[0][i]/CosmologySimulationOmegaBaryonNow,Gamma-1)
-	                    / (Gamma-1); */
- 
+        BaryonField[iTE][i] = CosmologySimulationInitialTemperature/
+            TemperatureUnits/DEFAULT_MU/(Gamma-1.0);
+
+    /*          * POW(BaryonField[0][i]/CosmologySimulationOmegaBaryonNow,Gamma-1)
+                / (Gamma-1); */
+
     if (CosmologySimulationGasEnergyName == NULL && DualEnergyFormalism)
       for (i = 0; i < size; i++)
-	BaryonField[iTE+1][i] = BaryonField[iTE][i];
- 
+        BaryonField[iTE+1][i] = BaryonField[iTE][i];
+
     if (CosmologySimulationTotalEnergyName == NULL &&
-	HydroMethod != Zeus_Hydro) {
+        HydroMethod != Zeus_Hydro) {
       for (dim = 0; dim < GridRank; dim++)
-	for (i = 0; i < size; i++) {
-	  BaryonField[iTE][i] +=
-	    0.5 * BaryonField[vel+dim][i] * BaryonField[vel+dim][i];
- 	  if (HydroMethod == MHD_RK) {
- 	    BaryonField[iBx  ][i] = CosmologySimulationInitialUniformBField[0];
- 	    BaryonField[iBy  ][i] = CosmologySimulationInitialUniformBField[1];
- 	    BaryonField[iBz  ][i] = CosmologySimulationInitialUniformBField[2];
- 	    BaryonField[iPhi ][i] = 0.0;
- 	    BaryonField[iTE][i] += 0.5*(BaryonField[iBx][i] * BaryonField[iBx][i]+
- 	  			  BaryonField[iBy][i] * BaryonField[iBy][i]+
- 	  			  BaryonField[iBz][i] * BaryonField[iBz][i])/
- 	  BaryonField[iden][i];
- 	 }
-   }
- 	 }
-   }
- 
+        for (i = 0; i < size; i++) {
+          BaryonField[iTE][i] +=
+              0.5 * BaryonField[vel+dim][i] * BaryonField[vel+dim][i];
+          if (HydroMethod == MHD_RK) {
+            BaryonField[iBx  ][i] = CosmologySimulationInitialUniformBField[0];
+            BaryonField[iBy  ][i] = CosmologySimulationInitialUniformBField[1];
+            BaryonField[iBz  ][i] = CosmologySimulationInitialUniformBField[2];
+            BaryonField[iPhi ][i] = 0.0;
+            BaryonField[iTE][i] += 0.5*(BaryonField[iBx][i] * BaryonField[iBx][i]+
+                                        BaryonField[iBy][i] * BaryonField[iBy][i]+
+                                        BaryonField[iBz][i] * BaryonField[iBz][i])/
+                BaryonField[iden][i];
+          }
+          if(UseMHDCT == TRUE){      
+            CenteredB[0][i] = CosmologySimulationInitialUniformBField[0];
+            CenteredB[1][i] = CosmologySimulationInitialUniformBField[1];
+            CenteredB[2][i] = CosmologySimulationInitialUniformBField[2];
+            BaryonField[iTE][i] += 0.5*(CenteredB[0][i] * CenteredB[0][i]+
+                                        CenteredB[1][i] * CenteredB[1][i]+
+                                        CenteredB[2][i] * CenteredB[2][i])/
+                BaryonField[0][i];
+          }
+
+
+        }
+
+      if(UseMHDCT == TRUE){
+        for(int field=0;field<3;field++)
+          for(int k=0; k<MagneticDims[field][2]; k++)
+            for(int j=0; j<MagneticDims[field][1]; j++)
+              for(int i=0; i<MagneticDims[field][0];i++){
+                int index = i+MagneticDims[field][0]*(j+MagneticDims[field][1]*k);
+                MagneticField[field][index] = 
+                    CosmologySimulationInitialUniformBField[field];
+              }                               
+      }  // if(UseMHDCT == TRUE)              
+    }
+  }
+
   } // end: if (NumberOfBaryonFields > 0)