enzo-3.0 / src / enzo / grid / solvers / Grid_ComputeAccelerations.C

The active_particles branch has multiple heads

/***********************************************************************
/
/  GRID CLASS (COMPUTE PARTICLE AND GRID ACCELERATIONS)
/
/  written by: Greg Bryan
/  date:       January, 1998
/  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 "LevelHierarchy.h"
#include "TopGridData.h"
 
/* function prototypes */
 
 
/* EvolveHierarchy function */
 
int grid::ComputeAccelerations(int level)
{
 
  /* Return if this grid is not on this processor. */
 
  if (MyProcessorNumber != ProcessorNumber)
    return SUCCESS;
 
  int DiffType;

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

    DiffType = DIFFERENCE_TYPE_NORMAL;
    //    DiffType = DIFFERENCE_TYPE_STAGGERED;

    /* Compute the acceleration field for particles from potential. */
 
    if (this->ComputeAccelerationField(DiffType, level) == FAIL) {
      ENZO_FAIL("Error in grid->ComputeAccelerationField.\n");
    }
 
    /* Add any fixed (external) acceleration to field. */
/*
    if (this->AddExternalAcceleration() == FAIL) {
      ENZO_FAIL("Error in grid->AddFixedAcceleration.\n");
    }
*/
    /* Clear particle accelerations. */
 
    this->DeleteParticleAcceleration();
    this->ClearParticleAccelerations();
 
    /* Move particles 1/2 step forward in preparation for interpolation. */
 
    this->UpdateParticlePosition(0.5*dtFixed);
 
    /* Interpolate the accelerations back to the grid and particles. */
 
    this->InterpolateParticlePositions(this, DiffType);
 
    /* Move particles 1/2 step backwards to return to original positions. */
 
    this->UpdateParticlePosition(-0.5*dtFixed);
 
    /* Clean up. */
 
    this->DeleteAccelerationField();
 
  } // end: if (NumberOfParticles > 0)
 
  /* Compute acceleration field for cells. */
 
  if (NumberOfBaryonFields > 0){

    /* Zeus hydro requires the acceleration field to be face-centered,
       while ppm assumed it is cell-centered. */

    DiffType = (HydroMethod == Zeus_Hydro) ? 
      DIFFERENCE_TYPE_STAGGERED : DIFFERENCE_TYPE_NORMAL;

     if (this->ComputeAccelerationField(DiffType, level) == FAIL) {
      ENZO_FAIL("Error in grid->ComputeAccelerationField.\n");
    }

  } // end: if (NumberOfBaryonFields > 0)


  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 ProjectModifiedEvent.java.
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.