Commits

Nathan Goldbaum committed c9a6c2d

Active particles are now read from data dumps.

Comments (0)

Files changed (9)

src/enzo/ActiveParticle.C

 }
 
 int ActiveParticleType::ReadDataset(int ndims, hsize_t *dims, char *name, hid_t group,
-				    hid_t data_type, void *read_to);
+				    hid_t data_type, void *read_to)
 {
   hid_t file_dsp_id;
   hid_t dset_id;

src/enzo/ActiveParticle.h

    int (*ifunc)(),
    int (*feedfunc)(grid *thisgrid_orig, ActiveParticleFormationData &data),
    int (*writefunc)(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id),
-   int (*readfunc)(ActiveParticleType *particles_on_disk, int n, int GridRank, hid_t group_id),
+   int (*readfunc)(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id),
    ActiveParticleType *particle
    ){
     this->formation_function = ffunc;
   int (*formation_function)(grid *thisgrid_orig, ActiveParticleFormationData &data);
   int (*feedback_function)(grid *thisgrid_orig, ActiveParticleFormationData &data);
   int (*write_function)(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id);
-  int (*read_function)(ActiveParticleType *particles_on_disk, int n, int GridRank, hid_t group_id);
+  int (*read_function)(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id);
   void (*describe_data_flags)(ActiveParticleFormationDataFlags &flags);
   ParticleBufferHandler* (*allocate_buffers)(int NumberOfParticles);
   ActiveParticleType* particle_instance;
      (&active_particle_class::AllocateBuffers),
      (&active_particle_class::InitializeParticleType),
      (&active_particle_class::EvaluateFeedback),
-     (&active_particle_class::WriteToOutput)
+     (&active_particle_class::WriteToOutput),
      (&active_particle_class::ReadFromOutput),
      pp);
   return pinfo;

src/enzo/ActiveParticle_CenOstriker.C

   static int EvaluateFeedback(grid *thisgrid_orig, ActiveParticleFormationData &data);
   static void DescribeSupplementalData(ActiveParticleFormationDataFlags &flags);
   static int WriteToOutput(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id);
+  static int ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id);
   static ParticleBufferHandler *AllocateBuffers(int NumberOfParticles);
   static int InitializeParticleType();
   ENABLED_PARTICLE_ID_ACCESSOR
   flags.MetalField = true;
 }
 
-int ActiveParticleType_CenOstriker::ReadFromOutput(ActiveParticleType *particles_to_read, int n, int GridRank, hid_t group_id)
+int ActiveParticleType_CenOstriker::ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id)
 {
   /* Open the subgroup within the active particle for active particles of type CenOstriker */
 
   hid_t CenOstrikerGroupID = H5Gopen(group_id,"CenOstriker");
 
-  readScalarAttribute(CenOstrikerGroupID,HDF5_INT,"number_of_active_particles_of_this_type",&n);
-
-  *particles_to_read = new 
+  readAttribute(CenOstrikerGroupID,HDF5_INT,"number_of_active_particles_of_this_type",n);
 
   char *ParticlePositionLabel[] =
      {"position_x", "position_y", "position_z"};
   char *ParticleVelocityLabel[] =
      {"velocity_x", "velocity_y", "velocity_z"};
 
-  FLOAT Position[GridRank][n];
-  float Velocity[GridRank][n]; 
-  double Mass[n];
-  float BirthTime[n];
-  float DynamicalTime[n];
-  float Metallicity[n];
+  FLOAT Position[GridRank][*n];
+  float Velocity[GridRank][*n]; 
+  double Mass[*n];
+  float BirthTime[*n];
+  float DynamicalTime[*n];
+  float Metallicity[*n];
   
   int i,dim;
 
   hsize_t TempInt;
-  TempInt = n;
+  TempInt = *n;
   
   for (dim = 0; dim < GridRank; dim++) {
     ReadDataset(1,&TempInt,ParticlePositionLabel[dim],
   ReadDataset(1,&TempInt,"dynamical_time",CenOstrikerGroupID,HDF5_FILE_REAL,(VOIDP) DynamicalTime);
   ReadDataset(1,&TempInt,"metallicity_fraction",CenOstrikerGroupID,HDF5_FILE_REAL,(VOIDP) Metallicity);
 
-  ActiveParticleType_CenOstriker *np = new ActiveParticleType_CenOstriker[];
-
-  for (i = 0; i < n; i++) {
-    *np[i] = new ActiveParticleType_CenOsriker();
-    np[i]->Mass = Mass[i];
-    np[i]->type = CenOstriker;
-    np[i]->BirthTime = DynamicalTime[i];
+  for (i = 0; i < *n; i++) {
+    ActiveParticleType_CenOstriker *np = new ActiveParticleType_CenOstriker;
+    particles_to_read[i] = np;
+    np = new ActiveParticleType_CenOstriker();
+    np->Mass = Mass[i];
+    np->type = CenOstriker;
+    np->BirthTime = DynamicalTime[i];
+    np->Metallicity = Metallicity[i];
     for (dim = 0; dim < GridRank; dim++){
-      np[i]->pos[dim] = Position[dim][i];
-      np[i]->vel[dim] = Velocity[dim][i];
+      np->pos[dim] = Position[dim][i];
+      np->vel[dim] = Velocity[dim][i];
     }
-
-    np[i]->Metallicity = Metallicity[i];
   }
-
-  particles_to_read = np
-
+  return SUCCESS;
 }
 
 int ActiveParticleType_CenOstriker::WriteToOutput(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id)
   WriteDataset(1,&TempInt,"creation_time",CenOstrikerGroupID,HDF5_FILE_REAL,(VOIDP) BirthTime);
   WriteDataset(1,&TempInt,"dynamical_time",CenOstrikerGroupID,HDF5_FILE_REAL,(VOIDP) DynamicalTime);
   WriteDataset(1,&TempInt,"metallicity_fraction",CenOstrikerGroupID,HDF5_FILE_REAL,(VOIDP) Metallicity);
+
+  return SUCCESS;
 }
 
 class CenOstrikerBufferHandler : public ParticleBufferHandler

src/enzo/ActiveParticle_Kravtsov.C

   static int EvaluateFormation(grid *thisgrid_orig, ActiveParticleFormationData &data);
   static void DescribeSupplementalData(ActiveParticleFormationDataFlags &flags);
   static int WriteToOutput(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id);
+  static int ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id);
   static ParticleBufferHandler *AllocateBuffers(int NumberOfParticles);
   static int InitializeParticleType();
   static int EvaluateFeedback(grid *thisgrid_orig, ActiveParticleFormationData &data);
   return SUCCESS;
 }
 
+int ActiveParticleType_Kravtsov::ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id)
+{
+
+
+  return SUCCESS;
+}
+
 class KravtsovParticleBufferHandler : public ParticleBufferHandler
 {
   public:

src/enzo/ActiveParticle_PopIII.C

   static int EvaluateFormation(grid *thisgrid_orig, ActiveParticleFormationData &data);
   static void DescribeSupplementalData(ActiveParticleFormationDataFlags &flags);
   static int WriteToOutput(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id);
+  static int ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id);
   static ParticleBufferHandler *AllocateBuffers(int NumberOfParticles);
   static int InitializeParticleType();
   static int EvaluateFeedback(grid *thisgrid_orig, ActiveParticleFormationData &data);
   return SUCCESS;
 }
 
+int ActiveParticleType_PopIII::ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id)
+{
+
+
+  return SUCCESS;
+}
+
 class PopIIIParticleBufferHandler : public ParticleBufferHandler
 {
   public:

src/enzo/ActiveParticle_SampleParticle.C

   static int EvaluateFormation(grid *thisgrid_orig, ActiveParticleFormationData &data);
   static void DescribeSupplementalData(ActiveParticleFormationDataFlags &flags);
   static int WriteToOutput(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id);
+  static int ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id);
   static ParticleBufferHandler *AllocateBuffers(int NumberOfParticles);
   static int EvaluateFeedback(grid *thisgrid_orig, ActiveParticleFormationData &data);
   static int InitializeParticleType(void);
   return SUCCESS;
 }
 
+int ActiveParticleType_SampleParticle::ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id)
+{
+
+  return SUCCESS;
+}
+
 class SampleParticleBufferHandler : public ParticleBufferHandler
 {
   public:

src/enzo/ActiveParticle_SinkParticle.C

 public:
   static int EvaluateFormation(grid *thisgrid_orig, ActiveParticleFormationData &data);
   static int WriteToOutput(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id);
+  static int ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id);
   static void DescribeSupplementalData(ActiveParticleFormationDataFlags &flags);
   static ParticleBufferHandler *AllocateBuffers(int NumberOfParticles);
   static int EvaluateFeedback(grid *thisgrid_orig, ActiveParticleFormationData &data);
   return SUCCESS;
 }
 
+int ActiveParticleType_SinkParticle::ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id)
+{
+
+
+  return SUCCESS;
+}
+
+
 class SinkParticleBufferHandler : public ParticleBufferHandler
 {
   public:

src/enzo/ActiveParticle_SpringelHernquist.C

   static int EvaluateFormation(grid *thisgrid_orig, ActiveParticleFormationData &data);
   static void DescribeSupplementalData(ActiveParticleFormationDataFlags &flags);
   static int WriteToOutput(ActiveParticleType *these_particles, int n, int GridRank, hid_t group_id);
+  static int ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id);
   static ParticleBufferHandler *AllocateBuffers(int NumberOfParticles);
   static int InitializeParticleType();
   static int EvaluateFeedback(grid *thisgrid_orig, ActiveParticleFormationData &data);
   return SUCCESS;
 }
 
+int ActiveParticleType_SpringelHernquist::ReadFromOutput(ActiveParticleType **particles_to_read, int *n, int GridRank, hid_t group_id)
+{
+
+
+  return SUCCESS;
+}
+
 class SpringelHernquistParticleBufferHandler : public ParticleBufferHandler
 {
 public:

src/enzo/New_Grid_ReadGrid.C

 //  Input a grid from file pointer fpt
  
 #include <hdf5.h>
+#include <map>
+#include <iostream>
+#include <stdexcept>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <math.h>
 #include <assert.h>
+#include <vector>
 #include "h5utilities.h"
  
 #include "ErrorExceptions.h"
 #include "GridList.h"
 #include "ExternalBoundary.h"
 #include "Grid.h"
+#include "fortran.def"
+#include "CosmologyParameters.h"
+#include "ActiveParticle.h"
+
 void my_exit(int status);
  
 #ifdef PROTO /* Remove troublesome HDF PROTO declaration. */