enzo-3.0 / src / enzo / particles / active_particles / ActiveParticleInitialize.C

The active_particles branch has multiple heads

/  written by: John Wise
/  date:       March, 2009
/  modified1:  November, 2011 (JHW) -- Converted to active particles.
/  PURPOSE: Contains all routines to initialize the star particles.

#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"
#include "ActiveParticle.h"

#define NO_DEBUG

int FindTotalNumberOfParticles(LevelHierarchyEntry *LevelArray[]);
void RecordTotalActiveParticleCount(HierarchyEntry *Grids[], int NumberOfGrids,
				    int TotalActiveParticleCountPrevious[]);

int ActiveParticleInitialize(HierarchyEntry *Grids[], TopGridData *MetaData,
			     int NumberOfGrids, LevelHierarchyEntry *LevelArray[], 
			     int ThisLevel)

  int i;

  /* Return if this does not concern us */
  if (EnabledActiveParticlesCount == 0) return SUCCESS;


  int *TotalActiveParticleCount = new int[NumberOfGrids]();

  MetaData->NumberOfParticles = FindTotalNumberOfParticles(LevelArray);
  NumberOfOtherParticles = MetaData->NumberOfParticles;// - NumberOfActiveParticles;

  if (NextActiveParticleID == INT_UNDEFINED)
    NextActiveParticleID = NumberOfOtherParticles + NumberOfActiveParticles;
  /* Call initialization routines for each active particle type */

  int ActiveParticleID;

  for (i = 0 ; i < EnabledActiveParticlesCount; i++) {
    ActiveParticleType_info *ActiveParticleTypeToEvaluate = EnabledActiveParticles[i];
    ActiveParticleID = ActiveParticleTypeToEvaluate->GetEnabledParticleID();



#ifdef DEBUG

  int nParticles;
  ActiveParticleType** ParticleList = NULL;

  ParticleList = ActiveParticleFindAll(LevelArray, &nParticles, 0);

  if (nParticles > 0) {
    PINT IDList[nParticles];
    for (i = 0; i < nParticles; i++)
      IDList[i] = ParticleList[i]->ReturnID();
    std::sort(IDList, IDList + sizeof(IDList)/sizeof(IDList[0]));
    for (i = 0; i < nParticles-1; i++)
      if (IDList[i] == IDList[i+1]) {
	ENZO_FAIL("Two active particles have identical IDs"); }

  if (NumberOfProcessors > 1)
    for (i = 0; i < nParticles; i++)
      delete ParticleList[i];

  delete [] ParticleList;


  delete [] TotalActiveParticleCount;

  return SUCCESS;

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.