Commits

Nathan Goldbaum committed 6fc25ff

Getting rid of active particle mirroring. This has been tested but may need more work.

Comments (0)

Files changed (31)

src/enzo/control/EvolveHierarchy.C

  
 int RebuildHierarchy(TopGridData *MetaData,
 		     LevelHierarchyEntry *LevelArray[], int level);
-int DetachActiveParticles(LevelHierarchyEntry *LevelArray[], int level);
 
 int EvolveLevel(TopGridData *MetaData, LevelHierarchyEntry *LevelArray[],
 		int level, float dtLevelAbove, ExternalBoundary *Exterior
   /* Do the first grid regeneration. */
  
   if(CheckpointRestart == FALSE) {
-    // Temporarily attach active particles for first rebuild
-    for (i = 0; i < MAX_DEPTH_OF_HIERARCHY; i++)
-      for (Temp = LevelArray[i]; Temp; Temp = Temp->NextGridThisLevel)
-	Temp->GridData->AppendActiveParticles();
     RebuildHierarchy(&MetaData, LevelArray, 0);
-    DetachActiveParticles(LevelArray, 0);
   }
 
   PrintMemoryUsage("1st rebuild");
  
     if (ProblemType != 25 && Restart == FALSE) {
       RebuildHierarchy(&MetaData, LevelArray, 0);
-      DetachActiveParticles(LevelArray, 0);
     }
 
     PrintMemoryUsage("Post loop rebuild");

src/enzo/control/EvolveLevel.C

 		      LevelHierarchyEntry **SUBlingList);
 #endif
 
-int DetachActiveParticles(LevelHierarchyEntry *LevelArray[], int level);
 int ActiveParticleInitialize(HierarchyEntry *Grids[], TopGridData *MetaData,
 			     int NumberOfGrids, LevelHierarchyEntry *LevelArray[], 
 			     int ThisLevel);
  
     if (dtThisLevelSoFar[level] < dtLevelAbove) {
       RebuildHierarchy(MetaData, LevelArray, level);
-      DetachActiveParticles(LevelArray, level);
     }
 
     cycle++;

src/enzo/grid/Make.module.objects

 	Grid_AddMassAndMomentumToAccretingParticle.o \
 	Grid_AddOneParticleFromList.o \
 	Grid_AddParticlesFromList.o \
-	Grid_AppendActiveParticles.o \
 	Grid_AppendActiveParticlesToList.o \
-	Grid_AppendNewActiveParticles.o \
 	Grid_ApplyGalaxyParticleFeedback.o \
 	Grid_ApplyGalaxyParticleGravity.o \
 	Grid_ChangeParticleTypeBeforeSN.o \
 	Grid_CollectParticles.o \
 	Grid_DebugActiveParticles.o \
 	Grid_DepositMustRefineParticles.o \
-	Grid_DetachActiveParticles.o \
 	Grid_FindAllStarParticles.o \
 	Grid_FindMassiveParticles.o \
 	Grid_FindMinimumParticleMass.o \
 	Grid_FindNewStarParticles.o \
+	Grid_GetActiveParticlePosition.o \
+	Grid_GetActiveParticleVelocity.o \
 	Grid_InterpolateParticlePositions.o \
-	Grid_MirrorActiveParticles.o \
 	Grid_MirrorStarParticles.o \
 	Grid_MoveAllParticles.o \
 	Grid_MoveAllStars.o \

src/enzo/grid/particles/Grid_ActiveParticleHandler.C

   if (NumberOfBaryonFields == 0)
     return SUCCESS;
 
-  /* Get the current particle positions and velocities */
-  
-  this->MirrorActiveParticles();
-
   /*fprintf(stderr, "G_APH: Currently have %"ISYM"\n",
           this->NumberOfActiveParticles);*/
  
    * array */
 
   if (NumberOfNewParticles > 0) {
-    // Add new particles to "normal" particle arrays and ActiveParticles
-    this->AppendNewActiveParticles(supplemental_data.NewParticles, 
-				   NumberOfNewParticles);
     this->AddActiveParticles(supplemental_data.NewParticles,
 			     NumberOfNewParticles);
     if (debug2)

src/enzo/grid/particles/Grid_AddActiveParticle.C

 
   delete [] OldActiveParticles;
   
-  /* Update arrays for the non-active particles*/
-
-  /* If the particle is already on the list then overwrite it. */
-  int SavedIndex = -1;
-  for (i = 0; i < NumberOfParticles; i++) 
-    if (ParticleNumber[i] == ThisParticle->Identifier) {
-      SavedIndex = i;
-    }
-
-  int OldNumberOfParticles = NumberOfParticles;
-
-  if (SavedIndex != -1)
-    NumberOfParticles--;
-  
-    NumberOfParticles += 1;
-
-  /* Create new particle arrays */
-
-  int index, dim;
-  FLOAT *pos[MAX_DIMENSION];
-  float *vel[MAX_DIMENSION];
-  float *Mass;
-  PINT *Number;
-  
-  for (dim = 0; dim < MAX_DIMENSION; dim++) {
-    pos[dim] = new FLOAT[NumberOfParticles];
-    vel[dim] = new float[NumberOfParticles];
-  }
-  Mass = new float[NumberOfParticles];
-  Number = new PINT[NumberOfParticles];
-
-  /* Copy existing particles */
-
-  j = 0;
-  for (i = 0; i < OldNumberOfParticles; i++) {
-    if (i == SavedIndex)
-      continue;
-    else {
-      for (dim = 0; dim < MAX_DIMENSION; dim++) {
-	pos[dim][j] = ParticlePosition[dim][i];
-	vel[dim][j] = ParticleVelocity[dim][i];
-      }
-    Mass[j] = ParticleMass[i];
-    Number[j] = ParticleNumber[i];
-    j++;
-    }
-  }
-
-  /* Copy new active particle data */
-
-  for (dim = 0; dim < MAX_DIMENSION; dim++) {
-    pos[dim][NumberOfParticles-1] = ThisParticle->pos[dim];
-    vel[dim][NumberOfParticles-1] = ThisParticle->vel[dim];
-  }
-  Mass[NumberOfParticles-1] = ThisParticle->Mass;
-  Number[NumberOfParticles-1] = ThisParticle->Identifier;
-
-  /* Delete old particle arrays and copy new ones */
-
-  this->DeleteParticles();
-  this->SetParticlePointers(Mass, Number, pos, vel);
-
   return SUCCESS;
 }

src/enzo/grid/particles/Grid_AppendActiveParticles.C

-/***********************************************************************
-/
-/  GRID CLASS (APPEND ACTIVE PARTICLE DATA TO PARTICLE ARRAYS)
-/
-/  written by: John Wise
-/  date:       December, 2011
-/  modified1:  
-/
-/  PURPOSE:
-/
-************************************************************************/
-#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 "TopGridData.h"
-#include "fortran.def"
-#include "CosmologyParameters.h"
-
-#include "ActiveParticle.h"
-
-int grid::AppendActiveParticles(void)
-{
-
-  if (NumberOfActiveParticles == 0)
-    return SUCCESS;
-
-  if (ProcessorNumber != MyProcessorNumber) {
-    this->NumberOfParticles += NumberOfActiveParticles;
-    return SUCCESS;
-  }
-
-  int OldNumberOfParticles = NumberOfParticles;
-  NumberOfParticles += NumberOfActiveParticles;
-
-  /* Create new particle arrays */
-
-  int i, index, dim;
-  FLOAT *pos[MAX_DIMENSION];
-  float *vel[MAX_DIMENSION];
-  float *Mass;
-  PINT *Number;
-  
-  for (dim = 0; dim < MAX_DIMENSION; dim++) {
-    pos[dim] = new FLOAT[NumberOfParticles];
-    vel[dim] = new float[NumberOfParticles];
-  }
-  Mass = new float[NumberOfParticles];
-  Number = new PINT[NumberOfParticles];
-
-  /* Copy existing particles */
-
-  for (i = 0; i < OldNumberOfParticles; i++) {
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      pos[dim][i] = ParticlePosition[dim][i];
-      vel[dim][i] = ParticleVelocity[dim][i];
-    }
-    Mass[i] = ParticleMass[i];
-    Number[i] = ParticleNumber[i];
-  }
-
-  /* Copy active particle data */
-
-  for (i = 0, index = OldNumberOfParticles; i < NumberOfActiveParticles;
-       i++, index++) {
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      pos[dim][index] = ActiveParticles[i]->pos[dim];
-      vel[dim][index] = ActiveParticles[i]->vel[dim];
-    }
-    Mass[index] = ActiveParticles[i]->Mass;
-    Number[index] = ActiveParticles[i]->Identifier;
-  }
-
-  /* Delete old particle arrays and copy new ones */
-
-  this->DeleteParticles();
-  this->SetParticlePointers(Mass, Number, pos, vel);
-
-  return SUCCESS;
-
-}

src/enzo/grid/particles/Grid_AppendActiveParticlesToList.C

 
   int PNum, count=0;
 
-    for (PNum = 0; PNum < NumberOfActiveParticles; PNum++) 
-      if (search_id == ActiveParticles[PNum]->ReturnType()) 
-	APArray[offset+count++] = ActiveParticles[PNum];
+  for (PNum = 0; PNum < NumberOfActiveParticles; PNum++) 
+    if (search_id == ActiveParticles[PNum]->ReturnType()) 
+      APArray[offset+count++] = ActiveParticles[PNum];
       
   return SUCCESS;
 } 

src/enzo/grid/particles/Grid_AppendNewActiveParticles.C

-/***********************************************************************
-/
-/  GRID CLASS (APPEND NEW ACTIVE PARTICLE DATA TO PARTICLE ARRAYS)
-/
-/  written by: John Wise
-/  date:       December, 2011
-/  modified1:  
-/
-/  PURPOSE:
-/
-************************************************************************/
-#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 "TopGridData.h"
-#include "fortran.def"
-#include "CosmologyParameters.h"
-
-#include "ActiveParticle.h"
-
-int grid::AppendNewActiveParticles(ActiveParticleType **NewParticles,
-				   int NumberOfNewParticles)
-{
-
-  if (NumberOfNewParticles == 0)
-    return SUCCESS;
-
-  int OldNumberOfParticles = NumberOfParticles;
-  NumberOfParticles += NumberOfNewParticles;
-
-  /* Create new particle arrays */
-
-  int i, index, dim;
-  FLOAT *pos[MAX_DIMENSION];
-  float *vel[MAX_DIMENSION];
-  float *Mass;
-  PINT *Number;
-  
-  for (dim = 0; dim < MAX_DIMENSION; dim++) {
-    pos[dim] = new FLOAT[NumberOfParticles];
-    vel[dim] = new float[NumberOfParticles];
-  }
-  Mass = new float[NumberOfParticles];
-  Number = new PINT[NumberOfParticles];
-
-  /* Copy existing particles */
-
-  for (i = 0; i < OldNumberOfParticles; i++) {
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      pos[dim][i] = ParticlePosition[dim][i];
-      vel[dim][i] = ParticleVelocity[dim][i];
-    }
-    Mass[i] = ParticleMass[i];
-    Number[i] = ParticleNumber[i];
-  }
-
-  /* Copy new active particle data */
-
-  for (i = 0, index = OldNumberOfParticles; i < NumberOfNewParticles;
-       i++, index++) {
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      pos[dim][index] = NewParticles[i]->pos[dim];
-      vel[dim][index] = NewParticles[i]->vel[dim];
-    }
-    Mass[index] = NewParticles[i]->Mass;
-    Number[index] = NewParticles[i]->Identifier;
-  }
-
-  /* Delete old particle arrays and copy new ones */
-
-  this->DeleteParticles();
-  this->SetParticlePointers(Mass, Number, pos, vel);
-
-  return SUCCESS;
-
-}

src/enzo/grid/particles/Grid_DetachActiveParticles.C

-/***********************************************************************
-/
-/  GRID CLASS (DETACH ACTIVE PARTICLE DATA FROM PARTICLE ARRAYS)
-/
-/  written by: John Wise
-/  date:       December, 2011
-/  modified1:  
-/
-/  PURPOSE:
-/
-************************************************************************/
-#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 "TopGridData.h"
-#include "fortran.def"
-#include "CosmologyParameters.h"
-
-#include "ActiveParticle.h"
-
-int grid::DetachActiveParticles(void)
-{
-
-  if (NumberOfActiveParticles == 0)
-    return SUCCESS;
-
-  if (MyProcessorNumber != ProcessorNumber) {
-    this->NumberOfParticles -= NumberOfActiveParticles;
-    return SUCCESS;
-  }
-
-  /* Sort the particles by ID, so the active particles are at the end
-     of the arrays. */
-
-  this->SortParticlesByNumber();
-  this->SortActiveParticlesByNumber();
-
-  int NewNumberOfParticles = NumberOfParticles - NumberOfActiveParticles;
-
-  /* Create new particle arrays */
-
-  int i, index, dim;
-  FLOAT *pos[MAX_DIMENSION];
-  float *vel[MAX_DIMENSION];
-  float *Mass;
-  PINT *Number;
-
-  if (NewNumberOfParticles > 0) {
-  
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      pos[dim] = new FLOAT[NewNumberOfParticles];
-      vel[dim] = new float[NewNumberOfParticles];
-    }
-    Mass = new float[NewNumberOfParticles];
-    Number = new PINT[NewNumberOfParticles];
-
-    /* Copy normal particles.  All active particles are located at the
-       end of the arrays. */
-    
-    for (i = 0; i < NewNumberOfParticles; i++) {
-      for (dim = 0; dim < MAX_DIMENSION; dim++) {
-	pos[dim][i] = ParticlePosition[dim][i];
-	vel[dim][i] = ParticleVelocity[dim][i];
-      }
-      Mass[i] = ParticleMass[i];
-      Number[i] = ParticleNumber[i];
-    }
-  } // ENDIF NumberOfParticles > 0
-  else {
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      pos[dim] = NULL;
-      vel[dim] = NULL;
-    }
-    Mass = NULL;
-    Number = NULL;
-  }
-
-  /* Copy active particle data in the normal particle arrays to
-     ActiveParticle variable */
-
-  
-  for (i = 0, index = NewNumberOfParticles; i < NumberOfActiveParticles; 
-       i++, index++) {
-    if (ParticleNumber[index] != ActiveParticles[i]->Identifier)
-      ENZO_FAIL("Particle IDs are inconsistent!");
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      ActiveParticles[i]->pos[dim] = ParticlePosition[dim][index];
-      ActiveParticles[i]->vel[dim] = ParticleVelocity[dim][index];
-    }
-    ActiveParticles[i]->Mass = ParticleMass[index];
-  }
-       
-  this->DeleteParticles();
-  this->SetParticlePointers(Mass, Number, pos, vel);
-
-  NumberOfParticles -= NumberOfActiveParticles;
-
-  return SUCCESS;
-
-}

src/enzo/grid/particles/Grid_GetActiveParticlePosition.C

+/***********************************************************************
+/
+/  GRID CLASS (RETURN ACTIVE PARTICLE POSITIONS AS A 2D POINTER ARRAY)
+/
+/  written by: Nathan Goldbaum
+/  date:       November, 2012
+/  modified1:  
+/
+/
+************************************************************************/
+#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 "TopGridData.h"
+#include "fortran.def"
+#include "CosmologyParameters.h"
+
+#include "ActiveParticle.h"
+
+void grid::GetActiveParticlePosition(FLOAT *ActiveParticlePosition[]) 
+{
+  int i, dim;
+
+  for (i = 0; i < NumberOfActiveParticles; i++) {
+    FLOAT* pos = ActiveParticles[i]->ReturnPosition();
+    for (dim = 0; dim < GridRank; dim++)
+      ActiveParticlePosition[dim][i] = pos[dim];
+  }
+
+}

src/enzo/grid/particles/Grid_GetActiveParticleVelocity.C

+/***********************************************************************
+/
+/  GRID CLASS (RETURN ACTIVE PARTICLE VELOCITIES AS A 2D POINTER ARRAY)
+/
+/  written by: Nathan Goldbaum
+/  date:       November, 2012
+/  modified1:  
+/
+/
+************************************************************************/
+#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 "TopGridData.h"
+#include "fortran.def"
+#include "CosmologyParameters.h"
+
+#include "ActiveParticle.h"
+
+void grid::GetActiveParticleVelocity(float *ActiveParticleVelocity[]) 
+{
+  int i, dim;
+
+  for (i = 0; i < NumberOfActiveParticles; i++) {
+    FLOAT* vel = ActiveParticles[i]->ReturnVelocity();
+    for (dim = 0; dim < GridRank; dim++)
+      ActiveParticleVelocity[dim][i] = vel[dim];
+  }
+
+}

src/enzo/grid/particles/Grid_InterpolateParticlePositions.C

 /
 /  written by: Greg Bryan
 /  date:       March, 1995
-/  modified1:
+/  modified1:  Nathan Goldbaum
+/  date:       November 2012
+/              Active particle support.
 /
 /  PURPOSE:
 /
  
   /* Loop over all active dimensions */
  
-  if (NumberOfParticles > 0)
-    for (int dim = 0; dim < GridRank+ComputePotential; dim++) {
+  int dim, dim1;
+
+  for (dim = 0; dim < GridRank+ComputePotential; dim++) {
+    
+    /* Adjust the grid position if the acceleration is face-centered. */
+    
+    if (DifferenceType == DIFFERENCE_TYPE_STAGGERED &&
+	dim != GridRank) {
+      HoldLeftEdge[dim] = FromGrid->CellLeftEdge[dim][0];
+      FromGrid->CellLeftEdge[dim][0] -= 0.5*FromGrid->CellWidth[dim][0];
+    }
  
-      /* Adjust the grid position if the acceleration is face-centered. */
- 
-      if (DifferenceType == DIFFERENCE_TYPE_STAGGERED &&
-	  dim != GridRank) {
-	HoldLeftEdge[dim] = FromGrid->CellLeftEdge[dim][0];
-	FromGrid->CellLeftEdge[dim][0] -= 0.5*FromGrid->CellWidth[dim][0];
-      }
- 
+    if (NumberOfParticles > 0) 
       if (FromGrid->InterpolatePositions(ParticlePosition, dim,
 					 ParticleAcceleration[dim],
 					 NumberOfParticles) == FAIL) {
 	ENZO_FAIL("Error in grid->InterpolatePositions.\n");
       }
  
-      if(ProblemType==29){
-	for(int i=0; i<NumberOfParticles; i++)
-	  printf("%"PISYM"  particle accelerations:  %e %e %e\n", ParticleNumber[i],
-		 ParticleAcceleration[0][i],
-		 ParticleAcceleration[1][i],
-		 ParticleAcceleration[2][i]);
-	fflush(stdout);
+    if(ProblemType==29){
+      for(int i=0; i<NumberOfParticles; i++)
+	printf("%"PISYM"  particle accelerations:  %e %e %e\n", ParticleNumber[i],
+	       ParticleAcceleration[0][i],
+	       ParticleAcceleration[1][i],
+	       ParticleAcceleration[2][i]);
+      fflush(stdout);
+    }
+  
+    if (NumberOfActiveParticles > 0) {
+
+      FLOAT **ActiveParticlePosition = new FLOAT*[GridRank];
+      for (dim1 = 0; dim1 < GridRank; dim1++)
+	ActiveParticlePosition[dim1] = new FLOAT[NumberOfActiveParticles];
+      this->GetActiveParticlePosition(ActiveParticlePosition);
+      
+      if (FromGrid->InterpolatePositions(ActiveParticlePosition, dim,
+					 ActiveParticleAcceleration[dim],
+					 NumberOfActiveParticles) == FAIL) {
+	ENZO_FAIL("Error in grid->InterpolatePositions.\n");
       }
 
-      /* Adjust back. */
- 
-      if ( DifferenceType == DIFFERENCE_TYPE_STAGGERED &&
-
-	  dim != GridRank)
-	FromGrid->CellLeftEdge[dim][0] = HoldLeftEdge[dim];
+      for (dim1 = 0; dim1 < GridRank; dim1++)
+	delete [] ActiveParticlePosition[dim1];
+      delete [] ActiveParticlePosition;
     }
- 
+    
+    /* Adjust back. */
+    
+    if ( DifferenceType == DIFFERENCE_TYPE_STAGGERED &&
+	 
+	 dim != GridRank)
+      FromGrid->CellLeftEdge[dim][0] = HoldLeftEdge[dim];
+  }
+  
   return SUCCESS;
 }

src/enzo/grid/particles/Grid_MirrorActiveParticles.C

-/***********************************************************************
-/
-/  GRID CLASS (MIRROR ACTIVE AND NORMAL PARTICLE INFO)
-/
-/  written by: John Wise
-/  date:       November, 2011
-/  modified1:  
-/
-/  PURPOSE:
-/
-************************************************************************/
- 
-#include "preincludes.h"
-#include "ErrorExceptions.h"
-#include "performance.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 "fortran.def"
-#include "CosmologyParameters.h"
-#include "ActiveParticle.h"
-
-int grid::MirrorActiveParticles(void)
-{
-
-  if ((NumberOfActiveParticles == 0) || (NumberOfParticles == 0))
-    return SUCCESS;
-
-  int i, n, dim, lastID;
-
-  LCAPERF_START("grid_MirrorActiveParticles");
-
-  this->SortParticlesByNumber();
-  this->SortActiveParticlesByNumber();
-  
-  // Now sorted, mark duplicates.
-  lastID = ParticleNumber[0];
-  for (i = 1; i < NumberOfParticles; i++) {
-    if (ParticleNumber[i] == lastID) {
-      ParticleMass[i] = FLOAT_UNDEFINED;
-    }
-    lastID = ParticleNumber[i];
-  }
-  
-  // Clear them.
-  this->CleanUpMovedParticles();
-
-  // Normal -> active particles (position, velocity only!)  Should be
-  // used before ActiveParticleHandler to get the correct position and
-  // velocity for feedback
-
-  n = NumberOfParticles - NumberOfActiveParticles;
-  for (i = 0; i < NumberOfActiveParticles; i++) {
-    for (dim = 0; dim < MAX_DIMENSION; dim++) {
-      if (this->ActiveParticles[i]->Identifier != ParticleNumber[n]) 
-	ENZO_FAIL("Particle identifiers are inconsistent!");
-      this->ActiveParticles[i]->pos[dim] = ParticlePosition[dim][n];
-      this->ActiveParticles[i]->vel[dim] = ParticleVelocity[dim][n];
-    }
-    n++;
-  }
-
-  LCAPERF_STOP("grid_MirrorActiveParticles");
-  return SUCCESS;
-
-}

src/enzo/grid/particles/Grid_SetNewParticleIndex.C

 		<< std::endl;
 #endif
     }
-  // Do the same for mirrored particles.  The normal and active new
-  // particles are still in the same order as they were created.
-  for (n = NumberOfParticles-NumberOfActiveParticles; 
-       n < NumberOfParticles; n++)
-    if (ParticleNumber[n] == INT_UNDEFINED)
-      ParticleNumber[n] = ori_count++;
+
   return;
 }

src/enzo/grid/particles/Grid_UpdateParticlePosition.C

 /              before being interpolated into the Parent grid's
 /              GravitatingMassFieldParticles, and the Parent may
 /              be on a different process.
-/           
+/  modified2:  Nathan Goldbaum
+/  date:       November 2012  
+/              Active Particle Support
 /
 /  PURPOSE:
 /
   if (ProcessorNumber != MyProcessorNumber && OffProcessorUpdate == FALSE)
     return SUCCESS;
  
-  if (NumberOfParticles == 0) return SUCCESS;
+  if (NumberOfParticles == 0 && NumberOfActiveParticles == 0) return SUCCESS;
  
   FLOAT a = 1.0, dadt;
   int i, dim;
 	== FAIL) {
             ENZO_FAIL("Error in CsomologyComputeExpansionFactors.");
     }
+
+  float Coefficient = TimeStep/a;
  
   /* Loop over dimensions. */
- 
-  for (dim = 0; dim < GridRank; dim++) {
- 
-    /* Error check. */
- 
-    if (ParticleVelocity[dim] == NULL) {
+  
+  if (NumberOfParticles > 0) 
+    for (dim = 0; dim < GridRank; dim++) {
+      
+      /* Error check. */
+      
+      if (ParticleVelocity[dim] == NULL) {
             ENZO_FAIL("No ParticleVelocity present.");
+      }
+      
+      /* update positions. */
+      
+      for (i = 0; i < NumberOfParticles; i++)
+	ParticlePosition[dim][i] += Coefficient*ParticleVelocity[dim][i];
+      
     }
- 
-    /* update velocities. */
- 
-    float Coefficient = TimeStep/a;
-    for (i = 0; i < NumberOfParticles; i++)
-      ParticlePosition[dim][i] += Coefficient*ParticleVelocity[dim][i];
- 
-    /* wrap particle positions for periodic case.
-       (now done in CommunicationTransferParticles) */
- 
-#ifdef UNUSED
-    FLOAT Width = DomainRightEdge[dim] - DomainLeftEdge[dim];
-    for (i = 0; i < NumberOfParticles; i++) {
-      if (ParticlePosition[dim][i] > DomainRightEdge[dim])
-	ParticlePosition[dim][i] -= Width;
-      if (ParticlePosition[dim][i] < DomainLeftEdge[dim])
-	ParticlePosition[dim][i] += Width;
+  
+  if (NumberOfActiveParticles > 0)
+    for (i = 0; i < NumberOfActiveParticles; i++) {
+      float* apvel;
+      FLOAT* appos;
+      apvel = ActiveParticles[i]->ReturnVelocity();
+      appos = ActiveParticles[i]->ReturnPosition();
+      for (dim = 0; dim < GridRank; dim++) {
+	
+	/* update positions. */
+
+	appos[dim] += Coefficient*apvel[dim];
+
+      }
+      ActiveParticles[i]->SetPosition(appos);
     }
-#endif /* UNUSED */
- 
-  }
- 
+
   return SUCCESS;
 }

src/enzo/grid/particles/Grid_UpdateParticleVelocity.C

   if (ProcessorNumber != MyProcessorNumber)
     return SUCCESS;
  
-  if (NumberOfParticles == 0 || SelfGravity == FALSE) return SUCCESS;
+  if ((NumberOfParticles == 0 && NumberOfActiveParticles == 0) || SelfGravity == FALSE) return SUCCESS;
  
   FLOAT a = 1.0, dadt;
 #if defined(VELOCITY_METHOD1) || defined(VELOCITY_METHOD2)
   float VelocityMidStep;
 #endif
-  int i;
+  int i, dim, dim1;
  
   /* If using comoving coordinates, divide by a(t) first. */
  
  
   /* Loop over dimensions. */
  
-  for (int dim = 0; dim < GridRank; dim++) {
+  for (dim = 0; dim < GridRank; dim++) {
  
     /* Error check. */
- 
-    if (ParticleAcceleration[dim] == NULL) {
+   
+    if ((NumberOfParticles > 0) && (ParticleAcceleration[dim] == NULL)) {
             ENZO_FAIL("No ParticleAccleration present.");
     }
  
+    if (NumberOfParticles > 0 && ParticleAcceleration[dim] == NULL) {
+            ENZO_FAIL("No ParticleAccleration present.");
+    }
+ 
+
     /* Update velocities.  */
  
     if (ComovingCoordinates) {
- 
+      
       FLOAT coef = 0.5*dadt/a*TimeStep;
       FLOAT coef1 = 1.0 - coef;
       FLOAT coef2 = 1.0 / (1.0 + coef);
- 
+      
       /* If using comoving coordinates, subtract the (time-centered)
 	 drag-like term and add the acceleration. The acceleration has
 	 already been divided by a(t). */
- 
+      
       for (i = 0; i < NumberOfParticles; i++) {
- 
+	
 #ifdef VELOCITY_METHOD1
- 
+	
         /* i) partially time-centered. */
- 
+	
 	VelocityMidStep = ParticleVelocity[dim][i] +
-	                  ParticleAcceleration[dim][i]*0.5*TimeStep;
- 
+	  ParticleAcceleration[dim][i]*0.5*TimeStep;
+	
 	ParticleVelocity[dim][i] +=
 	  (-VelocityMidStep*dadt/a + ParticleAcceleration[dim][i]) * TimeStep;
- 
+	
 #endif /* VELOCITY_METHOD1 */
- 
+	
 #ifdef VELOCITY_METHOD2
- 
+	
         /* ii) partially backward. */
- 
+	
 	VelocityMidStep = ParticleVelocity[dim][i] ;
- 
+	
 	ParticleVelocity[dim][i] +=
 	  (-VelocityMidStep*dadt/a + ParticleAcceleration[dim][i]) * TimeStep;
- 
+	
 #endif /* VELOCITY_METHOD2 */
- 
+	
 #ifdef VELOCITY_METHOD3
- 
+	
         /* iii) Semi-implicit way */
- 
+	
         ParticleVelocity[dim][i] = (coef1*ParticleVelocity[dim][i] +
                                     ParticleAcceleration[dim][i]*TimeStep)*coef2;
+	
+#endif /* VELOCITY_METHOD3 */
+	
+      }
 
+      if (NumberOfActiveParticles > 0) {
+	  
+	float **ActiveParticleVelocity = new float*[GridRank];
+	for (dim1 = 0; dim1 < GridRank; dim1++)
+	  ActiveParticleVelocity[dim1] = new float[NumberOfActiveParticles];
+	this->GetActiveParticleVelocity(ActiveParticleVelocity);
+	
+	for (i = 0; i < NumberOfActiveParticles; i++) {
+	
+#ifdef VELOCITY_METHOD1
+	
+          /* i) partially time-centered. */
+	
+	  VelocityMidStep = ActiveParticleVelocity[dim][i] +
+	    ActiveParticleAcceleration[dim][i]*0.5*TimeStep;
+	
+	  ActiveParticleVelocity[dim][i] +=
+	    (-VelocityMidStep*dadt/a + ActiveParticleAcceleration[dim][i]) * TimeStep;
+	
+#endif /* VELOCITY_METHOD1 */
+	  
+#ifdef VELOCITY_METHOD2
+	  
+	  /* ii) partially backward. */
+	  
+	  VelocityMidStep = ActiveParticleVelocity[dim][i] ;
+	  
+	  ActiveParticleVelocity[dim][i] +=
+	    (-VelocityMidStep*dadt/a + ActiveParticleAcceleration[dim][i]) * TimeStep;
+	  
+#endif /* VELOCITY_METHOD2 */
+	  
+#ifdef VELOCITY_METHOD3
+	  
+	  /* iii) Semi-implicit way */
+	  
+	  ActiveParticleVelocity[dim][i] = (coef1*ActiveParticleVelocity[dim][i] +
+	                         ActiveParticleAcceleration[dim][i]*TimeStep)*coef2;
+	  
  
 #endif /* VELOCITY_METHOD3 */
- 
+	  
+        }
+	for (dim1 = 0; dim1 < GridRank; dim1++)
+	  delete [] ActiveParticleVelocity[dim1];
+	delete [] ActiveParticleVelocity;
       }
     }
     else
  
       /* Otherwise, just add the acceleration. */
  
-      for (i = 0; i < NumberOfParticles; i++)
-	ParticleVelocity[dim][i] += ParticleAcceleration[dim][i] * TimeStep;
- 
+    for (i = 0; i < NumberOfParticles; i++)
+      ParticleVelocity[dim][i] += ParticleAcceleration[dim][i] * TimeStep;
+    for (i = 0; i < NumberOfActiveParticles; i++) {
+      float **ActiveParticleVelocity = new float*[GridRank];
+      for (dim1 = 0; dim1 < GridRank; dim1++)
+	ActiveParticleVelocity[dim1] = new float[NumberOfActiveParticles];
+
+      this->GetActiveParticleVelocity(ActiveParticleVelocity);
+
+      ActiveParticleVelocity[dim][i] += ActiveParticleAcceleration[dim][i] * TimeStep;
+
+      for (int dim = 0; dim1 < GridRank; dim1++)
+	delete [] ActiveParticleVelocity[dim1];
+      delete [] ActiveParticleVelocity;
+    }
   }
 
 

src/enzo/grid/solvers/Grid_ComputeAccelerations.C

  
   int DiffType;
 
-  if (NumberOfParticles > 0) {
+  if (NumberOfParticles > 0 || NumberOfActiveParticles > 0) {
   
     /* Set differencing type to be used (normal, face-centered) or
        staggered (cell-centered).  Staggered will generate a self-force. */

src/enzo/grid/utilities/Grid_ClearParticleAccelerations.C

 	ParticleAcceleration[dim][i] = 0.0;
  
     }
+
+  if (NumberOfActiveParticles > 0)
+    
+    /* Loop over active dimension */
+ 
+    for (dim = 0; dim < GridRank+ComputePotential; dim++) {
+ 
+      /* Error check. */
+ 
+      if (ActiveParticleAcceleration[dim] != NULL)
+	fprintf(stderr, "ClearParticleAccelerations: Field not NULL.\n");
+ 
+      /* Allocate accleration field. */
+ 
+      ActiveParticleAcceleration[dim] = new float[NumberOfActiveParticles];
+ 
+      /* Clear it. */
+ 
+      for (i = 0; i < NumberOfActiveParticles; i++)
+	ActiveParticleAcceleration[dim][i] = 0.0;
+ 
+    }
+
  
   return SUCCESS;
 }

src/enzo/grid/utilities/Grid_DepositParticlePositions.C

   /* Return if this doesn't concern us. */
  
   if (TargetGrid->CommunicationMethodShouldExit(this) ||
-      NumberOfParticles == 0)
+      (NumberOfParticles == 0 && NumberOfActiveParticles == 0))
     return SUCCESS;
  
 //  fprintf(stderr, "----DPP: MyPN = %"ISYM", PN = %"ISYM", TGPN = %"ISYM", DIR (R=1,S=2) = %"ISYM", NP = %"ISYM"\n",
     this->UpdateParticlePosition(TimeDifference, TRUE);
 
     /*
-       If using sink particles, then create a second field of
-       unsmoothed sink particles (since we don't want sink particles
-       smoothed -- they are stellar sized).
-       
-       The active particles will all be concentrated at the end of the
-       particle arrays.
-
-       Note that several types of particles may be appropriate for this,
-       but they will have to be added if needed.
+       If using active particles, then create a second field of
+       unsmoothed active particles (since we may not want active
+       particles smoothed).
     */
 
     if (NumberOfActiveParticles > 0 && SmoothField == TRUE) {
-      ParticleMassPointerSink = new float[NumberOfParticles];
-      for (i = NumberOfParticles-NumberOfActiveParticles; i < NumberOfParticles; i++) {
-	ParticleMassPointerSink[i] = ParticleMassPointer[i];
-	ParticleMassPointer[i] = 0;
+      FLOAT** ActiveParticlePosition = new FLOAT*[GridRank];
+      for (dim = 0; dim < GridRank; dim++)
+	ActiveParticlePosition[dim] = new FLOAT[NumberOfActiveParticles];
+      this->GetActiveParticlePosition(ActiveParticlePosition);
+
+      float ActiveParticleMassPointer[NumberOfActiveParticles];
+      for (i = NumberOfActiveParticles; i < NumberOfParticles+NumberOfActiveParticles; i++) {
+	ActiveParticleMassPointer[i] = ActiveParticles[i]->ReturnMass()*MassFactor;
       }
 
-      /* Deposit sink particles (only) to field using CIC. */
-
       PFORTRAN_NAME(cic_deposit)(
-           ParticlePosition[0], ParticlePosition[1], ParticlePosition[2], 
-	   &GridRank, &NumberOfParticles, ParticleMassPointerSink, DepositFieldPointer, 
+           ActiveParticlePosition[0], ActiveParticlePosition[1], ActiveParticlePosition[2], 
+	   &GridRank, &NumberOfActiveParticles, ActiveParticleMassPointer, DepositFieldPointer, 
 	   LeftEdge, Dimension, Dimension+1, Dimension+2, &CellSize, &addaspoints);
 
-      delete [] ParticleMassPointerSink;
-
+      for (dim = 0; dim < GridRank; dim++)
+	delete [] ActiveParticlePosition[dim];
+      delete [] ActiveParticlePosition;
     }
  
     /* Deposit particles. */
 	 &DepositPositionsParticleSmoothRadius);
     }
     
-    if (this->NumberOfActiveParticles > 0 && SmoothField == TRUE) {
-      for (i = NumberOfParticles-NumberOfActiveParticles; i < NumberOfParticles; i++) {
-	ParticleMassPointer[i] = ParticleMassPointerSink[i];
-      }
-      delete [] ParticleMassPointerSink;
-    }
-
-
   } // ENDIF this processor
  
   /* If on different processors, copy deposited field back to the

src/enzo/grid/utilities/Grid_DepositParticlePositionsLocal.C

   /* Declarations. */
  
   int dim, i;
-  float MassFactor = 1.0, *ParticleMassTemp, *ParticleMassPointer;
+  float MassFactor = 1.0, *ParticleMassTemp, 
+    *ParticleMassPointer;
  
   /* If there are no particles, don't deposit anything. */
  
-  if (NumberOfParticles == 0)
+  if (NumberOfParticles == 0 && NumberOfActiveParticles == 0)
     return SUCCESS;
  
   /* If the Target is this grid and the DepositField is MassFlaggingField,
   } else
     ParticleMassPointer = ParticleMass;
  
+  /* Allocate and fill the ActiveParticleMassPointer, obtain ActiveParticlePosition
+     from the grid object */
+
+  float ActiveParticleMassPointer[NumberOfActiveParticles];
+  for (i = 0; i < NumberOfActiveParticles; i++)
+    ActiveParticleMassPointer[i] = ActiveParticles[i]->ReturnMass()*MassFactor;
+    
+  FLOAT** ActiveParticlePosition = new FLOAT*[GridRank];
+  for (dim = 0; dim < GridRank; dim++)
+    ActiveParticlePosition[dim] = new FLOAT[NumberOfActiveParticles];
+  
+  this->GetActiveParticlePosition(ActiveParticlePosition);
+  
   /* If the target field is MASS_FLAGGING_FIELD, then set masses of
      particles which are too large to zero (to prevent run-away refinement). */
  
   if ((DepositField == MASS_FLAGGING_FIELD ||
        DepositField == PARTICLE_MASS_FLAGGING_FIELD) &&
-      DepositParticleMaximumParticleMass > 0 && MassFactor != 1.0)
+      DepositParticleMaximumParticleMass > 0 && MassFactor != 1.0) {
     for (i = 0; i < NumberOfParticles; i++)
       ParticleMassPointer[i] = min(DepositParticleMaximumParticleMass,
 				   ParticleMassPointer[i]);
- 
+    for (i = 0; i < NumberOfActiveParticles; i++)
+      ActiveParticleMassPointer[i] = min(DepositParticleMaximumParticleMass,
+					 ActiveParticleMassPointer[i]);
+  }
+
   /* Compute difference between current time and DepositTime. */
  
   float TimeDifference = DepositTime - Time;
 			     NumberOfParticles, DepositField) == FAIL) {
     ENZO_FAIL("Error in grid->DepositPositions\n");
   }
- 
+
+  if (this->DepositPositions(ActiveParticlePosition, ActiveParticleMassPointer,
+			     NumberOfActiveParticles, DepositField, true) == FAIL) {
+    ENZO_FAIL("Error in grid->DepositPositions\n");
+  }
+
+  /* Delete the ActiveParticlePosition array */
+  
+  for (dim = 0; dim < GridRank; dim++)
+    delete [] ActiveParticlePosition[dim];
+  delete [] ActiveParticlePosition;
+
   /* If necessary, delete the particle mass temporary. */
  
   if (MassFactor != 1.0)
-
     delete [] ParticleMassTemp;
  
   /* Return particles to positions at Time. */

src/enzo/grid/utilities/Grid_DepositPositions.C

  
  
 int grid::DepositPositions(FLOAT *Position[], float *Mass, int Number,
-			   int DepositField)
+			   int DepositField, bool NeverSmooth)
 {
   if (Number == 0) return SUCCESS;
 
     ENZO_FAIL("New gravity module currently supports only 3d.\n");
   }
  
-  if (DepositPositionsParticleSmoothRadius < CellSize)
+  if (DepositPositionsParticleSmoothRadius < CellSize || NeverSmooth)
 
   {
     /* Deposit to field using CIC. */

src/enzo/grid/utilities/Grid_InterpolatePositions.C

     return SUCCESS;
  
   /* Set the pointer to the AccelerationField or the PotentialField. */
- 
+
+  int i;
+
   float *InterpolationField = AccelerationField[dim];
   if (dim == GridRank)
     InterpolationField = PotentialField;
   /* Set the left edge of the field. */
  
   FLOAT LeftEdge[MAX_DIMENSION];
-  for (int i = 0; i < GridRank; i++)
+  for (i = 0; i < GridRank; i++)
     LeftEdge[i] = CellLeftEdge[i][0];
 //    LeftEdge[i] = CellLeftEdge[i][0] - ((dim == i)? (0.5*CellWidth[i][0]) : 0);
  

src/enzo/grid/utilities/Grid_constructor.C

     ParticlePosition[i]              = NULL;
     ParticleVelocity[i]              = NULL;
     ParticleAcceleration[i]          = NULL;
+    ActiveParticleAcceleration[i]    = NULL;
     AccelerationField[i]             = NULL;
     GravitatingMassFieldDimension[i] = 0;
     RandomForcingField[i]            = NULL;

src/enzo/headers/ActiveParticle.h

   void  AdjustMassByFactor(double factor) { Mass *= factor; };
   void  AdjustVelocity(float VelocityIncrement[]);
   void  SetVelocity(float NewVelocity[]);
+  void  SetPosition(FLOAT NewPosition[]);
   void  SetPositionPeriod(FLOAT period[]);
 
   FLOAT *ReturnPosition(void) { return pos; };

src/enzo/headers/Grid.h

 //  Active particle data
 //
   int NumberOfActiveParticles;
+  float* ActiveParticleAcceleration[MAX_DIMENSION+1];
   ActiveParticleType **ActiveParticles;
   class ParticleBufferHandler **GetParticleBuffers();
   class ParticleBufferHandler **GetParticleBuffers(bool *mask);
    GravitatingMassFieldParticles depending on the value of DepositField). */
 
    int DepositPositions(FLOAT *Positions[], float *Mass, int Number, 
-			int DepositField);
+			int DepositField, bool NeverSmooth=false);
 
 /* deposit particles/grids to grid (if they are on the grid). */
 
      for (int dim = 0; dim < GridRank+ComputePotential; dim++) {
        delete [] ParticleAcceleration[dim];
        ParticleAcceleration[dim] = NULL;
+       delete [] ActiveParticleAcceleration[dim];
+       ActiveParticleAcceleration[dim] = NULL;
      }
    };
 
   int AddActiveParticles(ActiveParticleType **NewParticles,
 			 int NumberOfNewParticles, int start=0);
   int AddActiveParticle(ActiveParticleType* ThisParticle);
-  int AppendActiveParticles(void);
   int AppendActiveParticlesToList(ActiveParticleType** APArray, 
 				  int offset, int search_id);
-  int AppendNewActiveParticles(ActiveParticleType **NewParticles,
-			       int NumberOfNewParticles);
-  int DetachActiveParticles(void);
-  int MirrorActiveParticles(void);
   int DebugActiveParticles(int level);
   
+  /* Create flat arrays of active particle data */
+
+  void GetActiveParticlePosition(FLOAT *ActiveParticlePosition[]);
+  void GetActiveParticleVelocity(float *ActiveParticleVelocity[]);
+
   /* Returns averaged velocity from the 6 neighbor cells and itself */
 
   float* AveragedVelocityAtCell(int index, int DensNum, int Vel1Num);

src/enzo/particles/Make.module.objects

         ActiveParticleRoutines.o \
         ActiveParticle_AccretingParticle.o \
         AssignActiveParticlesToGrids.o \
-        DetachActiveParticles.o \
         RecordTotalActiveParticleCount.o \
         ActiveParticle_DisableParticle.o \
         ActiveParticle_CenOstriker.o \

src/enzo/particles/active_particles/ActiveParticleInitialize.C

   if (NextActiveParticleID == INT_UNDEFINED)
     NextActiveParticleID = NumberOfOtherParticles + NumberOfActiveParticles;
   
-  /* Active particle initialization
-     1. copy quantities from active to normal particles
-  */
-
-  int grid_num;
-  for (grid_num = 0; grid_num < NumberOfGrids; grid_num++) {
-    Grids[grid_num]->GridData->AppendActiveParticles();
-  } // ENDFOR grids
-
-  /* 2. Call initialization routines for each active particle type */
+  /* Call initialization routines for each active particle type */
 
   int ActiveParticleID;
 

src/enzo/particles/active_particles/ActiveParticleRoutines.C

   return;
 }
 
+void ActiveParticleType::SetPosition(FLOAT NewPosition[])
+{
+  int i;
+  for (i = 0; i<3; i++)
+    pos[i] = NewPosition[i];
+  return;
+}
+
 void ActiveParticleType::SetPositionPeriod(FLOAT period[])
 {
   int i;

src/enzo/particles/active_particles/ActiveParticle_DisableParticle.C

   for (i = 0; i < NumberOfGrids; i++) {
     ID = this->ReturnID();
     foundAP = Grids[i]->GridData->RemoveActiveParticle(ID, NewProcessorNumber);
-    foundP = Grids[i]->GridData->RemoveParticle(ID);
-    if (foundP && foundAP) {
+    if (foundAP) {
       changedGrid = i;
       break;
     }
-    else if (foundP || foundAP)
-      return FAIL;
   } // ENDFOR grids
 
-  // RemoveActiveParticle decrements NumberOfActiveParticles
-  
-  if (foundP)
-    Grids[changedGrid]->GridData->CleanUpMovedParticles();
-  
   delete [] Grids;
 
   return SUCCESS;

src/enzo/particles/active_particles/AssignActiveParticlesToGrids.C

       // If the particle moved we need to add it to the new grid and remove
       // it from the old grid.
       if (OldGrid != LevelGrids[SavedGrid]->GridData) {
-	    if (LevelGrids[SavedGrid]->GridData->AddActiveParticle(static_cast<ActiveParticleType*>(ParticleList[i])) == FAIL)
+	    if (LevelGrids[SavedGrid]->GridData->AddActiveParticle(
+			     static_cast<ActiveParticleType*>(ParticleList[i])) == FAIL)
 	      ENZO_FAIL("Active particle grid assignment failed!\n");
 	    if (SavedGrid != -1) {
-	      foundAP = OldGrid->RemoveActiveParticle(ID,LevelGrids[SavedGrid]->GridData->ReturnProcessorNumber());
-	      foundP = OldGrid->RemoveParticle(ID);
-	      if ((foundP != TRUE) || (foundAP != TRUE))
+	      foundAP = OldGrid->RemoveActiveParticle(ID,
+			       LevelGrids[SavedGrid]->GridData->ReturnProcessorNumber());
+	      if ((foundAP != TRUE))
 	        return FAIL;
-	      OldGrid->CleanUpMovedParticles();
 	    }
       }
-      // If the particle didn't change grids, we still need to mirror the AP data to the particle list.
-      else {
-	LevelGrids[SavedGrid]->GridData->UpdateParticleWithActiveParticle(ParticleList[i]->ReturnID());
-      }
     }
     else {
 #ifdef USE_MPI
       grid* OldGrid = ParticleList[i]->ReturnCurrentGrid();
       int ID = ParticleList[i]->ReturnID();
       OldGrid->RemoveActiveParticle(ID,LevelGrids[SavedGridOffProc]->GridData->ReturnProcessorNumber());
-      OldGrid->RemoveParticle(ID);
-	  OldGrid->CleanUpMovedParticles();
       // if this is the receiving proc, add it.
       if (LevelMax == recvbuf.value) {
 	    if (LevelGrids[SavedGrid]->GridData->AddActiveParticle(static_cast<ActiveParticleType*>(ParticleList[i])) == FAIL) {
 	      ENZO_FAIL("Active particle grid assignment failed"); 
 	    } 
-	    // Still need to mirror the AP data to the particle list.
-	    else {
-	      LevelGrids[SavedGrid]->GridData->UpdateParticleWithActiveParticle(ParticleList[i]->ReturnID());
-	    }
       }
       LevelMax = recvbuf.value;
 #endif // endif parallel

src/enzo/particles/active_particles/DetachActiveParticles.C

-/***********************************************************************
-/
-/  DETACH MIRRORED ACTIVE PARTICLES FROM GRIDS
-/
-/  written by: John Wise
-/  date:       February, 2011
-/  modified1:
-/
-/  PURPOSE: For the gravity solver and mass refinement fields, we
-/           mirrored the active particles' positions, velocities, and 
-/           masses to normal particles.  Here we remove them.
-/
-************************************************************************/
-
-#include "preincludes.h"
-#include "performance.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 "TopGridData.h"
-#include "LevelHierarchy.h"
-
-int DetachActiveParticles(LevelHierarchyEntry *LevelArray[], int level)
-{
-
-  if (EnabledActiveParticlesCount == 0)
-    return SUCCESS;
-
-  int i, grid1;
-  LevelHierarchyEntry *Temp;
-  
-  for (i = level; i < MAX_DEPTH_OF_HIERARCHY; i++)
-    for (Temp = LevelArray[i]; Temp; Temp = Temp->NextGridThisLevel)
-      Temp->GridData->DetachActiveParticles();
-
-  return SUCCESS;
-
-}