示例#1
0
/**
 * @brief Subdivides all of the Cells within this Universe into rings
 *        and angular sectors.
 */
void Universe::subdivideCells() {

  log_printf(DEBUG, "Subdividing Cells for Universe %d", _id);

  std::map<int, Cell*>::iterator iter1;

  while (iter1 != _cells.end()) {

    for (iter1 = _cells.begin(); iter1 != _cells.end(); ++iter1) {

      if ((*iter1).second->getType() == MATERIAL) {
        CellBasic* cell = static_cast<CellBasic*>((*iter1).second);

        if (cell->getNumRings() > 0 || cell->getNumSectors() > 0) {
          std::vector<CellBasic*> newcells = cell->subdivideCell();

          log_printf(DEBUG, "Cell %d in Universe %d has %d subcells",
                     cell->getId(), _id, newcells.size());

          std::vector<CellBasic*>::iterator iter2;
          for (iter2=newcells.begin(); iter2!=newcells.end(); ++iter2)
            addCell((*iter2));

          _cells.erase(iter1);
          break;
        }
      }
    }
  }
}
示例#2
0
/**
 * @brief Returns a CellBasic in this Universe.
 * @param cell_id the integer the cell_id
 * @return Returns the CellFill pointer.
 */
CellBasic* Universe::getCellBasic(int cell_id) {

  CellBasic* cell = NULL;
  if (_cells.find(cell_id) == _cells.end())
    log_printf(ERROR, "Unable to return Cell with ID = %d from Universe with "
               "ID = %d since the it does not contain this Cell", cell_id, _id);

  cell = static_cast<CellBasic*>(_cells.at(cell_id));
  if (cell->getType() != MATERIAL)
    log_printf(WARNING, "Retrieving Cell %d from Universe %d, but it "
               "is not a MATERIAL type Cell", cell->getId(), _id);

  return cell;
}
示例#3
0
/**
 * @brief Subdivides the Cell into clones for fuel pin angular sectors.
 */
void CellBasic::sectorize() {

  /* If the user didn't request any sectors, don't make any */
  if (_num_sectors == 0)
    return;

  double azim_angle;
  double delta_azim = 2. * M_PI / _num_sectors;
  double A, B;

  /* A container for each of the bouding planes for the sector Cells */
  std::vector<Plane*> planes;

  log_printf(DEBUG, "Sectorizing Cell %d with %d sectors",_id, _num_sectors);

  /* Create each of the bounding planes for the sector Cells */
  for (int i=0; i < _num_sectors; i++) {

    /* Figure out the angle for this plane */
    azim_angle = i * delta_azim;

    /* Instantiate the plane */
    A = cos(azim_angle);
    B = sin(azim_angle);
    Plane* plane = new Plane(A, B, 0.);
    planes.push_back(plane);

    log_printf(DEBUG, "Created sector Plane id = %d, angle = %f, A = %f, "
               "B = %f", i, azim_angle, A, B);
  }

  /* Create sectors using disjoint halfspaces of pairing Planes */
  for (int i=0; i < _num_sectors; i++) {

    /* Create new CellBasic clone for this sector Cell */
    CellBasic* sector = clone();

    sector->setNumSectors(0);
    sector->setNumRings(0);

    log_printf(DEBUG, "Creating a new sector Cell %d for Cell %d",
               sector->getId(), _id);

    /* Add new bounding planar Surfaces to the clone */
    sector->addSurface(+1, planes.at(i));

    if (_num_sectors != 2) {
      if (i+1 < _num_sectors)
        sector->addSurface(-1, planes.at(i+1));
      else
        sector->addSurface(-1, planes.at(0));
    }

    /* Store the clone in the parent Cell's container of sector Cells */
    _sectors.push_back(sector);
  }

  /* Store all of the sectors in the parent Cell's subcells container */
  _subcells.clear();
  _subcells.insert(_subcells.end(), _sectors.begin(), _sectors.end());
}
示例#4
0
/**
 * @brief Initializes the FSR volumes and Materials array.
 * @details This method assigns each FSR a unique, monotonically increasing
 *          ID, sets the Material for each FSR, and assigns a volume based on
 *          the cumulative length of all of the segments inside the FSR.
 */
void CPUSolver::initializeFSRs() {

  log_printf(INFO, "Initializing flat source regions...");

  /* Delete old FSR arrays if they exist */
  if (_FSR_volumes != NULL)
    delete [] _FSR_volumes;

  if (_FSR_materials != NULL)
    delete [] _FSR_materials;

  _FSR_volumes = (FP_PRECISION*)calloc(_num_FSRs, sizeof(FP_PRECISION));
  _FSR_materials = new Material*[_num_FSRs];
  _FSR_locks = new omp_lock_t[_num_FSRs];

  int num_segments;
  segment* curr_segment;
  segment* segments;
  FP_PRECISION volume;
  CellBasic* cell;
  Material* material;
  Universe* univ_zero = _geometry->getUniverse(0);

  /* Set each FSR's "volume" by accumulating the total length of all Tracks
   * inside the FSR. Loop over azimuthal angles, Tracks and Track segments. */
  for (int i=0; i < _tot_num_tracks; i++) {

    int azim_index = _tracks[i]->getAzimAngleIndex();
    num_segments = _tracks[i]->getNumSegments();
    segments = _tracks[i]->getSegments();

    for (int s=0; s < num_segments; s++) {
      curr_segment = &segments[s];
      volume = curr_segment->_length * _azim_weights[azim_index];
      _FSR_volumes[curr_segment->_region_id] += volume;
    }
  }

  /* Loop over all FSRs to extract FSR material pointers */
  #pragma omp parallel for private(cell, material) schedule(guided)
  for (int r=0; r < _num_FSRs; r++) {

    /* Get the Cell corresponding to this FSR from the geometry */
    cell = _geometry->findCellContainingFSR(r);

    /* Get the Cell's Material and assign it to the FSR */
    material = _geometry->getMaterial(cell->getMaterial());
    _FSR_materials[r] = material;

    log_printf(DEBUG, "FSR ID = %d has Cell ID = %d and Material ID = %d "
               "and volume = %f", r, cell->getId(),
                _FSR_materials[r]->getUid(), _FSR_volumes[r]);
  }

  /* Loop over all FSRs to initialize OpenMP locks */
  #pragma omp parallel for schedule(guided)
  for (int r=0; r < _num_FSRs; r++)
    omp_init_lock(&_FSR_locks[r]);

  return;
}