예제 #1
0
void peanoclaw::mappings::ValidateGrid::mergeWithMaster(
  const peanoclaw::Cell&           workerGridCell,
  peanoclaw::Vertex * const        workerGridVertices,
 const peano::grid::VertexEnumerator& workerEnumerator,
  peanoclaw::Cell&                 fineGridCell,
  peanoclaw::Vertex * const        fineGridVertices,
  const peano::grid::VertexEnumerator&                fineGridVerticesEnumerator,
  peanoclaw::Vertex * const        coarseGridVertices,
  const peano::grid::VertexEnumerator&                coarseGridVerticesEnumerator,
  peanoclaw::Cell&                 coarseGridCell,
  const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfCell,
  int                                                                  worker,
  const peanoclaw::State&          workerState,
  peanoclaw::State&                masterState
) {
  logTraceIn( "mergeWithMaster(...)" );

  std::vector<PatchDescription> remoteData = PatchDescriptionHeap::getInstance().receiveData(
    worker,
    fineGridVerticesEnumerator.getVertexPosition(0),
    fineGridVerticesEnumerator.getLevel(),
    peano::heap::MasterWorkerCommunication
  );

  std::vector<PatchDescription>& localData = PatchDescriptionHeap::getInstance().getData(_patchDescriptionsIndex);
  localData.insert(localData.end(), remoteData.begin(), remoteData.end());

  logInfo("mergeWithMaster(...)", "Merged " << remoteData.size() << " patches: " << PatchDescriptionHeap::getInstance().getData(_patchDescriptionsIndex).size() << " entries.");

  logTraceOut( "mergeWithMaster(...)" );
}
예제 #2
0
void peanoclaw::mappings::ValidateGrid::destroyCell(
      const peanoclaw::Cell&           fineGridCell,
      peanoclaw::Vertex * const        fineGridVertices,
      const peano::grid::VertexEnumerator&                fineGridVerticesEnumerator,
      peanoclaw::Vertex * const        coarseGridVertices,
      const peano::grid::VertexEnumerator&                coarseGridVerticesEnumerator,
      peanoclaw::Cell&                 coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfCell
) {
  logTraceInWith4Arguments( "destroyCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );

  //TODO unterweg debug
//  std::cout<< "Destroying cell " << fineGridVerticesEnumerator.getVertexPosition(0) << ", "
//      << fineGridVerticesEnumerator.getCellSize()
//      << ", index=" << fineGridCell.getCellDescriptionIndex()
//      #ifdef Parallel
//      << ", rank=" << tarch::parallel::Node::getInstance().getRank()
//      #endif
//      << std::endl;

  _validator.deletePatchIfNotRemote(
    fineGridVerticesEnumerator.getVertexPosition(0),
    fineGridVerticesEnumerator.getLevel()
  );

  logTraceOutWith1Argument( "destroyCell(...)", fineGridCell );
}
void particles::pit::adapters::MoveParticlesAndPlot2VTKGridVisualiser_0::leaveCell(
      particles::pit::Cell&           fineGridCell,
      particles::pit::Vertex * const  fineGridVertices,
      const peano::grid::VertexEnumerator&          fineGridVerticesEnumerator,
      particles::pit::Vertex * const  coarseGridVertices,
      const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
      particles::pit::Cell&           coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                       fineGridPositionOfCell
) {
  #ifdef Parallel
  if (fineGridCell.isLeaf() && !fineGridCell.isAssignedToRemoteRank()) {
  #else
  if (fineGridCell.isLeaf()) {
  #endif
    assertion( DIMENSIONS==2 || DIMENSIONS==3 );
    int vertexIndex[TWO_POWER_D];
     dfor2(i)
      tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = fineGridVerticesEnumerator.getVertexPosition(i);
      assertion2 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition, fineGridVertices[ fineGridVerticesEnumerator(i) ].toString() );
      vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
    enddforx
  
    int cellIndex;
    if (DIMENSIONS==2) {
      cellIndex = _cellWriter->plotQuadrangle(vertexIndex);
    }
    if (DIMENSIONS==3) {
      cellIndex = _cellWriter->plotHexahedron(vertexIndex);
    }
    
    _cellStateWriter->plotCell(cellIndex,fineGridVerticesEnumerator.getCellFlags());
    _cellNormWriterX->plotCell(cellIndex,(fineGridCell.getMyNorm())[0]);
    _cellNormWriterY->plotCell(cellIndex,(fineGridCell.getMyNorm())[1]);
  }
}


void particles::pit::adapters::MoveParticlesAndPlot2VTKGridVisualiser_0::beginIteration(
  particles::pit::State&  solverState
) {
  assertion( _vtkWriter==0 );
  
  _vtkWriter = new tarch::plotter::griddata::unstructured::vtk::VTKTextFileWriter();
  
  _vertexWriter     = _vtkWriter->createVertexWriter();
  _cellWriter       = _vtkWriter->createCellWriter();
  
  _vertexTypeWriter               = _vtkWriter->createVertexDataWriter(particles::pit::Vertex::Records::getInsideOutsideDomainMapping()+"/Hanging=-1" ,1);
  _vertexRefinementControlWriter  = _vtkWriter->createVertexDataWriter(particles::pit::Vertex::Records::getRefinementControlMapping() ,1);
  _vertexAdjacentCellsHeight      = _vtkWriter->createVertexDataWriter( peano::grid::getCellFlagsLegend(),1);

  _cellStateWriter                = _vtkWriter->createCellDataWriter( "cell-flag(>=-1=stationary,-1=parallel-boundary,<=-2=not-stationary" ,1);
  _cellNormWriterX                = _vtkWriter->createCellDataWriter( "Norm,X-direction" ,1);
  _cellNormWriterY                = _vtkWriter->createCellDataWriter( "Norm,Y-direction" ,1);
}
예제 #4
0
void particles::pidt::mappings::MoveParticles::enterCell(
  particles::pidt::Cell&                    fineGridCell,
  particles::pidt::Vertex * const           fineGridVertices,
  const peano::grid::VertexEnumerator&      fineGridVerticesEnumerator,
  particles::pidt::Vertex * const           coarseGridVertices,
  const peano::grid::VertexEnumerator&      coarseGridVerticesEnumerator,
  particles::pidt::Cell&                    coarseGridCell,
  const tarch::la::Vector<DIMENSIONS,int>&  fineGridPositionOfCell
) {
  logTraceInWith4Arguments( "enterCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );

  if (fineGridCell.isRefined()) {
    fineGridCell.clearMaxVComponent();
  }
  else {
    #if defined(SharedTBB) && !defined(__WIN32__)
    tbb::atomic<int>     numberOfParticlesMoved;
    #elif defined(SharedTBB) && defined(__WIN32__)
    static tarch::multicore::BooleanSemaphore  semaphore;
    int    numberOfParticlesMoved;
    #elif SharedOMP
      #error not implemented yet
    #else
    int    numberOfParticlesMoved;
    #endif
    numberOfParticlesMoved = 0;

    pdfor2(k)
      const int sourceVertexIndex = fineGridVertices[ fineGridVerticesEnumerator(k) ].getVertexIndex();

      #ifdef MOVE_USES_SORTED_PARTICLES
      const int resultOfOneVertex = moveParticlesOfOneVertexWithinCellIfTheyAreSorted(
        sourceVertexIndex,
        fineGridVerticesEnumerator
      );
      #else
      const int resultOfOneVertex = moveParticlesOfOneVertexWithinCell(
        sourceVertexIndex,
        fineGridVerticesEnumerator
      );
      #endif

      #if defined(SharedTBB) && defined(__WIN32__)
      tarch::multicore::Lock lock(semaphore);
      #endif
      numberOfParticlesMoved += resultOfOneVertex;
    endpdforx

    _state.updateParticleStatisticsInLeaf(numberOfParticlesMoved,fineGridVerticesEnumerator.getCellSize());
  }

  logTraceOutWith1Argument( "enterCell(...)", fineGridCell );
}
예제 #5
0
void peanoclaw::mappings::ValidateGrid::destroyHangingVertex(
      const peanoclaw::Vertex&   fineGridVertex,
      const tarch::la::Vector<DIMENSIONS,double>&                    fineGridX,
      const tarch::la::Vector<DIMENSIONS,double>&                    fineGridH,
      peanoclaw::Vertex * const  coarseGridVertices,
      const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
      peanoclaw::Cell&           coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                       fineGridPositionOfVertex
) {
  logTraceInWith6Arguments( "destroyHangingVertex(...)", fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex );
  if(tarch::la::allGreaterEquals(fineGridX, _domainOffset)
    && tarch::la::allGreaterEquals(_domainOffset+_domainSize, fineGridX)) {
    _validator.findAdjacentPatches(
      fineGridVertex,
      fineGridX,
      coarseGridVerticesEnumerator.getLevel() + 1,
      #ifdef Parallel
      tarch::parallel::Node::getInstance().getRank()
      #else
      0
      #endif
    );
  }
  logTraceOutWith1Argument( "destroyHangingVertex(...)", fineGridVertex );
}
예제 #6
0
void peanoclaw::mappings::ValidateGrid::createCell(
      peanoclaw::Cell&                 fineGridCell,
      peanoclaw::Vertex * const        fineGridVertices,
      const peano::grid::VertexEnumerator&                fineGridVerticesEnumerator,
      peanoclaw::Vertex * const        coarseGridVertices,
      const peano::grid::VertexEnumerator&                coarseGridVerticesEnumerator,
      peanoclaw::Cell&                 coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfCell
) {
  logTraceInWith4Arguments( "createCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );

  //TODO unterweg debug
  logInfo("", "Creating cell " << fineGridVerticesEnumerator.getVertexPosition(0) << ", "
      << fineGridVerticesEnumerator.getCellSize()
      << ", index=" << fineGridCell.getCellDescriptionIndex()
      << ",level=" << fineGridVerticesEnumerator.getLevel()
      );

  logTraceOutWith1Argument( "createCell(...)", fineGridCell );
}
예제 #7
0
void peanoclaw::mappings::Cleanup::ascend(
    peanoclaw::Cell * const    fineGridCells,
    peanoclaw::Vertex * const  fineGridVertices,
    const peano::grid::VertexEnumerator&          fineGridVerticesEnumerator,
    peanoclaw::Vertex * const  coarseGridVertices,
    const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
    peanoclaw::Cell&           coarseGridCell
) {
    logTraceInWith2Arguments( "ascend(...)", coarseGridCell.toString(), coarseGridVerticesEnumerator.toString() );
    // @todo Insert your code here
    logTraceOut( "ascend(...)" );
}
예제 #8
0
void peanoclaw::mappings::Cleanup::prepareSendToMaster(
    peanoclaw::Cell&                       localCell,
    peanoclaw::Vertex *                    vertices,
    const peano::grid::VertexEnumerator&       verticesEnumerator,
    const peanoclaw::Vertex * const        coarseGridVertices,
    const peano::grid::VertexEnumerator&       coarseGridVerticesEnumerator,
    const peanoclaw::Cell&                 coarseGridCell,
    const tarch::la::Vector<DIMENSIONS,int>&   fineGridPositionOfCell
) {
    logTraceInWith2Arguments( "prepareSendToMaster(...)", localCell, verticesEnumerator.toString() );
    // @todo Insert your code here
    logTraceOut( "prepareSendToMaster(...)" );
}
예제 #9
0
void peanoclaw::mappings::Cleanup::leaveCell(
    peanoclaw::Cell&           fineGridCell,
    peanoclaw::Vertex * const  fineGridVertices,
    const peano::grid::VertexEnumerator&          fineGridVerticesEnumerator,
    peanoclaw::Vertex * const  coarseGridVertices,
    const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
    peanoclaw::Cell&           coarseGridCell,
    const tarch::la::Vector<DIMENSIONS,int>&                       fineGridPositionOfCell
) {
    logTraceInWith4Arguments( "leaveCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );
    // @todo Insert your code here
    logTraceOutWith1Argument( "leaveCell(...)", fineGridCell );
}
예제 #10
0
void particles::pidt::mappings::MoveParticles::leaveCell(
  particles::pidt::Cell&                    fineGridCell,
  particles::pidt::Vertex * const           fineGridVertices,
  const peano::grid::VertexEnumerator&      fineGridVerticesEnumerator,
  particles::pidt::Vertex * const           coarseGridVertices,
  const peano::grid::VertexEnumerator&      coarseGridVerticesEnumerator,
  particles::pidt::Cell&                    coarseGridCell,
  const tarch::la::Vector<DIMENSIONS,int>&  fineGridPositionOfCell
) {
  logTraceInWith4Arguments( "leaveCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );

  double maxVComponentInCell = 0.0;

  dfor2(k)
    const int sourceVertexIndex = fineGridVertices[ fineGridVerticesEnumerator(k) ].getVertexIndex();

    ParticleHeap::HeapEntries& sourceVertexParticles = ParticleHeap::getInstance().getData(sourceVertexIndex);

    for (
      ParticleHeap::HeapEntries::iterator p = sourceVertexParticles.begin();
      p!=sourceVertexParticles.end();
    ) {
      const tarch::la::Vector<DIMENSIONS,int> newDualCellOfParticle = Vertex::getDualCellOfParticle(
        fineGridVerticesEnumerator,
        p->_persistentRecords._x
      );

      const double maxVComponentOfParticle = tarch::la::maxAbs(p->_persistentRecords._v);
      maxVComponentInCell = maxVComponentInCell > maxVComponentOfParticle ? maxVComponentInCell : maxVComponentOfParticle;

      const bool MoveParticleToDifferentDualCell = newDualCellOfParticle!=k;
      if (MoveParticleToDifferentDualCell) {
        Vertex& newVertexOfParticles = fineGridVertices[ fineGridVerticesEnumerator(newDualCellOfParticle) ];
        newVertexOfParticles.particlesWereAddedToThisVertex();
        const int destinationVertexIndex = newVertexOfParticles.getVertexIndex();
        ParticleHeap::getInstance().getData(destinationVertexIndex).push_back(*p);
        p = ParticleHeap::getInstance().getData(sourceVertexIndex).erase(p);
        logDebug( "leaveCell(...)", "reassign particle " << p->toString() << " to vertex " << newDualCellOfParticle );
      }
      else {
        p++;
      }
    }
  enddforx

  if (!fineGridCell.isRefined()) {
    fineGridCell.setMaxVComponent( maxVComponentInCell );
  }

  logTraceOut( "leaveCell(...)" );
}
예제 #11
0
void peanoclaw::mappings::ValidateGrid::destroyVertex(
      const peanoclaw::Vertex&   fineGridVertex,
      const tarch::la::Vector<DIMENSIONS,double>&                    fineGridX,
      const tarch::la::Vector<DIMENSIONS,double>&                    fineGridH,
      peanoclaw::Vertex * const  coarseGridVertices,
      const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
      peanoclaw::Cell&           coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                       fineGridPositionOfVertex
) {
  logTraceInWith6Arguments( "destroyVertex(...)", fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex );

  //TODO unterweg debug
//  std::cout<< "Destroying vertex " << fineGridX << ", "
//      << fineGridH
//      << ", level=" << (coarseGridVerticesEnumerator.getLevel()+1)
//      #ifdef Parallel
//      << ", rank=" << tarch::parallel::Node::getInstance().getRank()
//      #endif
//      << fineGridVertex.toString()
//      << std::endl;

  //We need to call this method here, since it seems that touchVertexLastTime
  //is not called in the iteration where a vertex is destroyed.
  _validator.findAdjacentPatches(
      fineGridVertex,
      fineGridX,
      coarseGridVerticesEnumerator.getLevel() + 1,
      #ifdef Parallel
      tarch::parallel::Node::getInstance().getRank()
      #else
      0
      #endif
    );

//  if(fineGridVertex.isRemote(_state, true, true)) {
//    _validator.deleteNonRemoteAdjacentPatches(
//      fineGridVertex,
//      fineGridX,
//      coarseGridVerticesEnumerator.getLevel() + 1,
//      #ifdef Parallel
//      tarch::parallel::Node::getInstance().getRank()
//      #else
//      0
//      #endif
//    );
//  }

  logTraceOutWith1Argument( "destroyVertex(...)", fineGridVertex );
}
예제 #12
0
void particles::pidt::mappings::MoveParticles::ascend(
  particles::pidt::Cell * const         fineGridCells,
  particles::pidt::Vertex * const       fineGridVertices,
  const peano::grid::VertexEnumerator&  fineGridVerticesEnumerator,
  particles::pidt::Vertex * const       coarseGridVertices,
  const peano::grid::VertexEnumerator&  coarseGridVerticesEnumerator,
  particles::pidt::Cell&                coarseGridCell
) {
  logTraceIn( "ascend(...)" );

  dfor3(i)
    coarseGridCell.restrictMaxVComponent( fineGridCells[ fineGridVerticesEnumerator.cell(i) ] );
  enddforx

  logTraceOut( "ascend(...)" );
}
예제 #13
0
int particles::pidt::mappings::MoveParticles::moveParticlesOfOneVertexWithinCell(
  int                                   vertexIndex,
  const peano::grid::VertexEnumerator&  fineGridVerticesEnumerator
) {
  #if defined(SharedTBB) && !defined(__WIN32__)
  tbb::atomic<int>     numberOfParticlesMoved;
  #elif SharedOMP
    #error not implemented yet
  #else
  int    numberOfParticlesMoved;
  #endif

  numberOfParticlesMoved = 0;

  ParticleHeap::HeapEntries& sourceVertexParticles = ParticleHeap::getInstance().getData(vertexIndex);
  pfor(i,0,static_cast<int>(sourceVertexParticles.size()),200)
    particles::pidt::records::Particle& currentParticle = sourceVertexParticles.at(i);

    const bool particleHasNotBeenMovedYet =
      currentParticle.getMovedParticle() != particles::pidt::records::Particle::Moved;

    const bool particleIsContainedInCell = fineGridVerticesEnumerator.overlaps(
      currentParticle._persistentRecords._x,
      0.0
    );

    if (particleHasNotBeenMovedYet && particleIsContainedInCell) {
      currentParticle._persistentRecords._x             += (_state.getTimeStepSize() * currentParticle._persistentRecords._v);
      currentParticle.setMovedParticle( particles::pidt::records::Particle::Moved );

      reflectParticle(currentParticle);

      numberOfParticlesMoved++;
    }
  endpfor

  return numberOfParticlesMoved;
}
예제 #14
0
void peanoclaw::mappings::ValidateGrid::touchVertexLastTime(
      peanoclaw::Vertex&         fineGridVertex,
      const tarch::la::Vector<DIMENSIONS,double>&                    fineGridX,
      const tarch::la::Vector<DIMENSIONS,double>&                    fineGridH,
      peanoclaw::Vertex * const  coarseGridVertices,
      const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
      peanoclaw::Cell&           coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                       fineGridPositionOfVertex
) {
  logTraceInWith6Arguments( "touchVertexLastTime(...)", fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex );

  _validator.findAdjacentPatches(
    fineGridVertex,
    fineGridX,
    coarseGridVerticesEnumerator.getLevel() + 1,
    #ifdef Parallel
    tarch::parallel::Node::getInstance().getRank()
    #else
    0
    #endif
  );

  logTraceOutWith1Argument( "touchVertexLastTime(...)", fineGridVertex );
}
예제 #15
0
void particles::pidt::mappings::MoveParticles::touchVertexFirstTime(
  particles::pidt::Vertex&                     fineGridVertex,
  const tarch::la::Vector<DIMENSIONS,double>&  fineGridX,
  const tarch::la::Vector<DIMENSIONS,double>&  fineGridH,
  particles::pidt::Vertex * const              coarseGridVertices,
  const peano::grid::VertexEnumerator&         coarseGridVerticesEnumerator,
  particles::pidt::Cell&                       coarseGridCell,
  const tarch::la::Vector<DIMENSIONS,int>&     fineGridPositionOfVertex
) {
  logTraceInWith6Arguments( "touchVertexFirstTime(...)", fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex );

  #ifdef Parallel
  if (fineGridVertex.isAdjacentToRemoteRank()) {
    fineGridVertex.particlesWereAddedToThisVertex();
  }
  else {
    fineGridVertex.noParticlesWereAddedToThisVertex();
  }
  #else
  fineGridVertex.noParticlesWereAddedToThisVertex();
  #endif

  const int vertexIndex = fineGridVertex.getVertexIndex();
  typedef std::vector<particles::pidt::records::Particle>  ParticleContainer;
  ParticleContainer& sourceVertexParticles = ParticleHeap::getInstance().getData(vertexIndex);

  pfor(i,0,static_cast<int>(sourceVertexParticles.size()),100)
    particles::pidt::records::Particle& currentParticle = sourceVertexParticles.at(i);
    assertion(
      currentParticle.getMovedParticle() == particles::pidt::records::Particle::New ||
      currentParticle.getMovedParticle() == particles::pidt::records::Particle::Moved
    );
    assertion1(
      tarch::la::allGreaterEquals(currentParticle._persistentRecords._x,0.0),
      currentParticle.toString()
    );
    assertion1(
      tarch::la::allSmallerEquals(currentParticle._persistentRecords._x,1.0),
      currentParticle.toString()
    );

    currentParticle.setMovedParticle( particles::pidt::records::Particle::NotMovedYet );
  endpfor

  logTraceOutWith1Argument( "touchVertexFirstTime(...)", fineGridVertex );
}
예제 #16
0
void particles::pit::myfunctions::RepresentationChange::ascend(
  particles::pit::Cell * const    fineGridCells,
  particles::pit::Vertex * const  fineGridVertices,
  const peano::grid::VertexEnumerator&          fineGridVerticesEnumerator,
  particles::pit::Vertex * const  coarseGridVertices,
  const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
  particles::pit::Cell&           coarseGridCell
) {
  particles::pit::myfunctions::CoordinatesRepresentationChange::ascend(
    fineGridCells,
    fineGridVertices,
    fineGridVerticesEnumerator,
    coarseGridVertices,
    coarseGridVerticesEnumerator,
    coarseGridCell);

  dfor3(k)
    particles::pit::Cell fineGridCell = fineGridCells[ fineGridVerticesEnumerator.cell(k) ];
    const tarch::la::Vector<DIMENSIONS,double> cellOffset     = fineGridVerticesEnumerator.getVertexPosition(k);
    const tarch::la::Vector<DIMENSIONS,double> meanVelocity = fineGridCell.getMeanVelocity();
    bool isLeaf = fineGridCell.isLeaf();
    const int cellIndex = fineGridCell.getCellIndex();
    const int NumberOfParticles = ParticleHeap::getInstance().getData(cellIndex).size();

    if( isLeaf && NumberOfParticles>1 ) {
      // Compute Max-Norm
      double maxRelativeError = computeMaxRelativeError( fineGridCell );
      // Save maximal maxRelativeError in _globalMaxRelativeError
      if (_globalMaxRelativeError < maxRelativeError) {
        _globalMaxRelativeError = maxRelativeError;
      }
      double maxError = computeMaxError( fineGridCell );
      if(_global_max_error < maxError) {
          _global_max_error = maxError;
      }
      double maxOffset = computeMaxOffset( fineGridCell );
      double minOffset = computeMinOffset( fineGridCell );
      if(_globalMaxOffset < maxOffset) {
        _globalMaxOffset = maxOffset;
      }
      // Compute RMSD
      tarch::la::Vector<DIMENSIONS,double> rmsd = computeRMSD( fineGridCell );
      // Computer L2-Norm
      tarch::la::Vector<DIMENSIONS,double>
        l2ErrorNorm = computeL2ErrorNorm( fineGridCell );
      tarch::la::Vector<DIMENSIONS,double>
        l2Norm = computeL2Norm( fineGridCell );
      //std::cout << "ascend() l2ErrorNorm: " << l2ErrorNorm << std::endl;


      // Save maximal l2ErrorNorm in _globalMaxL2ErrorNorm
      for(int d = 0; d<DIMENSIONS; d++) {
        if(_globalMaxL2ErrorNorm < l2ErrorNorm[d]) {
          _globalMaxL2ErrorNorm = l2ErrorNorm[d];
        }
      }
      // Add l2ErrorNorm to _globalL2ErrorNorm
      _globalL2ErrorNorm += l2ErrorNorm;
      // Add l2Norm to _globalL2OffsetNorm
      _globalL2OffsetNorm += l2Norm;
      // Don't forget to increment _globalNormAdditions to divide _globalL2Norm
      //by it at the end of iteration before writing it in the file!
      ++_globalNormAdditions;


      // Output for checking
      if(VERBOSE) {
          printParticlesInfo( fineGridCell, "l2ErrorNorm", l2ErrorNorm );
      }

      /* All computations put in output */
      _maxRelativeErrorOut << maxRelativeError << " ";
      _maxErrorOut << maxError << " ";
      _maxOffsetOut << maxOffset << " ";
      _minOffsetOut << minOffset << " ";

      // Histogram process
      l2_error_norm_histogram_->processHistogram(l2ErrorNorm);
      max_error_norm_histogram_->processHistogram(maxError);
      max_offset_norm_histogram_->processHistogram(maxOffset);

      for(int d=0; d<DIMENSIONS; d++) {
        _RMSDOut << rmsd[d] << " ";
        _L2ErrorNormOut << l2ErrorNorm[d] << " ";
        _L2NormOut << l2Norm[d] << " ";
        _meanVelocityOut << meanVelocity[d] << " ";
      }
      /* Write coordinates of each cell near the value of the Norm(offset) */
      for(int d=0; d<DIMENSIONS; d++) {
        _maxRelativeErrorOut << cellOffset[d] << " ";
    	_maxErrorOut << cellOffset[d] << " ";
        _maxOffsetOut << cellOffset[d] << " ";
        _minOffsetOut << cellOffset[d] << " ";
        _RMSDOut << cellOffset[d] << " ";
        _L2ErrorNormOut << cellOffset[d] << " ";
        _L2NormOut << cellOffset[d] << " ";
        _meanVelocityOut << cellOffset[d] << " ";
      }
      /* Put the new line character to have one cell per line */
      _maxRelativeErrorOut << std::endl;
      _maxErrorOut << std::endl;
      _maxOffsetOut << std::endl;
      _minOffsetOut << std::endl;
      _RMSDOut << std::endl;
      _L2ErrorNormOut << std::endl;
      _L2NormOut << std::endl;
      _meanVelocityOut << std::endl;
    }
  enddforx
}
예제 #17
0
void peanoclaw::interSubgridCommunication::GridLevelTransfer::stepUp(
  Patch*                               coarseSubgrid,
  Patch&                               finePatch,
  ParallelSubgrid&                     fineParallelSubgrid,
  bool                                 isPeanoCellLeaf,
  peanoclaw::Vertex * const            fineGridVertices,
  const peano::grid::VertexEnumerator& fineGridVerticesEnumerator
) {

  //Correct time intervals for virtual subgrid or going-to-be virtual subgrid
  if(!finePatch.isLeaf() || !isPeanoCellLeaf) {
    finePatch.switchValuesAndTimeIntervalToMinimalFineGridTimeInterval();
    assertion1(tarch::la::greaterEquals(finePatch.getTimeIntervals().getTimestepSize(), 0) || !isPeanoCellLeaf, finePatch);
  }

  //Update fine grid time interval on next coarser patch if possible
  if(coarseSubgrid != 0) {
    //Patch coarsePatch(coarseCellDescriptionIndex);
    coarseSubgrid->getTimeIntervals().updateMinimalFineGridTimeInterval(
      finePatch.getTimeIntervals().getCurrentTime(),
      finePatch.getTimeIntervals().getTimestepSize()
    );
  }

  if(finePatch.isLeaf()) {
    restrictToOverlappingVirtualSubgrids(finePatch, fineParallelSubgrid);

    //TODO unterweg dissertation:
    //If the patch is leaf, but the Peano cell is not, it got refined.
    //Thus, the patch was not turned to a virtual patch to avoid
    //restriction to this patch, which would lead to invalid data, since
    //the patch is not initialized with zeros. So, the patch needs to
    //be switched to refined (i.e. non-virtual) here...
    if(!isPeanoCellLeaf) {
      finePatch.switchToVirtual();

      //Fill ghostlayer
      for(int i = 0; i < TWO_POWER_D; i++) {

        fineGridVertices[fineGridVerticesEnumerator(i)].fillAdjacentGhostLayers(
          finePatch.getLevel(),
          _useDimensionalSplitting,
          _numerics,
          #ifdef PEANOCLAW_USE_ASCEND_FOR_RESTRICTION
          tarch::la::multiplyComponents(peano::utils::dDelinearised(i, 2).convertScalar<double>(), finePatch.getSize()) + finePatch.getPosition(),
          #else
          fineGridVerticesEnumerator.getVertexPosition(i),
          #endif
          _subgridStatistics
        );
      }

      finePatch.switchToNonVirtual();

      ParallelSubgrid parallelSubgrid(finePatch);
      parallelSubgrid.markCurrentStateAsSent(false);
    }
  } else if (finePatch.isVirtual()) {
    finalizeVirtualSubgrid(
      finePatch,
      fineGridVertices,
      fineGridVerticesEnumerator,
      isPeanoCellLeaf
    );
  }

  //If patch wasn't refined -> look if veto for coarsening is necessary
  if(!finePatch.isLeaf()) {
    vetoCoarseningIfNecessary(
      finePatch,
      fineGridVertices,
      fineGridVerticesEnumerator
    );
  }

  //Reset time constraint for optimization of ghostlayer filling
//  finePatch.resetMinimalNeighborTimeConstraint();
}
예제 #18
0
void peanoclaw::interSubgridCommunication::GridLevelTransfer::stepDown(
  Patch*                               coarseSubgrid,
  Patch&                               fineSubgrid,
  peanoclaw::Vertex * const            fineGridVertices,
  const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
  bool                                 isInitializing,
  bool                                 isPeanoCellLeaf
) {

  //Switch to virtual subgrid if necessary
  if(shouldBecomeVirtualSubgrid(
      fineSubgrid,
      fineGridVertices,
      fineGridVerticesEnumerator,
      isInitializing,
      isPeanoCellLeaf
  )) {
    switchToAndAddVirtualSubgrid(fineSubgrid);
  } else if(fineSubgrid.isVirtual()) {
    //Switch to non-virtual if still virtual
    fineSubgrid.switchToNonVirtual();
  }

  //Prepare flags for subgrid
  if(!fineSubgrid.isLeaf()) {
    fineSubgrid.setWillCoarsen(peano::grid::aspects::VertexStateAnalysis::doesOneVertexCarryRefinementFlag
      (
        fineGridVertices,
        fineGridVerticesEnumerator,
        peanoclaw::records::Vertex::Erasing
      )
    );
  }
  fineSubgrid.getTimeIntervals().resetMinimalNeighborTimeConstraint();
  fineSubgrid.getTimeIntervals().resetMaximalNeighborTimeInterval();
  fineSubgrid.resetNeighboringGhostlayerBounds();
  fineSubgrid.getTimeIntervals().resetMinimalFineGridTimeInterval();

  //Get data from neighbors:
  //  - Ghostlayers data
  //  - Ghostlayer bounds
  //  - Neighbor times
  for(int i = 0; i < TWO_POWER_D; i++) {
    assertion1(fineSubgrid.getCellDescriptionIndex() != -1, fineSubgrid);
    fineGridVertices[fineGridVerticesEnumerator(i)].setAdjacentCellDescriptionIndex(i, fineSubgrid.getCellDescriptionIndex());
    fineGridVertices[fineGridVerticesEnumerator(i)].fillAdjacentGhostLayers(
      fineGridVerticesEnumerator.getLevel(),
      _useDimensionalSplitting,
      _numerics,
      fineGridVerticesEnumerator.getVertexPosition(peano::utils::dDelinearised(i, 2)),
      _subgridStatistics,
//      fineGridVerticesEnumerator.getVertexPosition(i),
      i
    );
  }

  //Data from coarse patch:
  // -> Update minimal time constraint of coarse neighbors
  if(coarseSubgrid != 0) {
    //Patch coarsePatch(coarseCellDescriptionIndex);
    if(coarseSubgrid->getTimeIntervals().shouldFineGridsSynchronize()) {
      //Set time constraint of fine grid to time of coarse grid to synch
      //on that time.
      fineSubgrid.getTimeIntervals().updateMinimalNeighborTimeConstraint(
        coarseSubgrid->getTimeIntervals().getCurrentTime() + coarseSubgrid->getTimeIntervals().getTimestepSize(),
        coarseSubgrid->getCellDescriptionIndex()
      );
    }
  }
}
예제 #19
0
void peanoclaw::interSubgridCommunication::GridLevelTransfer::finalizeVirtualSubgrid(
  Patch&                               subgrid,
  peanoclaw::Vertex * const            fineGridVertices,
  const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
  bool                                 isPeanoCellLeaf
) {
  tarch::multicore::Lock lock(_virtualPatchListSemaphore);
  assertion1(_virtualPatchDescriptionIndices.size() >= 0, subgrid.toString());

  tarch::la::Vector<DIMENSIONS_PLUS_ONE, double> virtualSubgridKey = createVirtualSubgridKey(subgrid.getPosition(), subgrid.getLevel());
  int virtualPatchDescriptionIndex = _virtualPatchDescriptionIndices[virtualSubgridKey];
  _virtualPatchDescriptionIndices.erase(virtualSubgridKey);
//  _virtualPatchTimeConstraints.erase(virtualSubgridKey);
  CellDescription& virtualPatchDescription = CellDescriptionHeap::getInstance().getData(virtualPatchDescriptionIndex).at(0);
  Patch virtualPatch(virtualPatchDescription);

  //Assert that we're working on the correct virtual patch
  assertionEquals3(subgrid.getCellDescriptionIndex(), virtualPatchDescriptionIndex, subgrid, virtualPatch, _virtualPatchDescriptionIndices.size());
  assertionNumericalEquals(subgrid.getPosition(), virtualPatch.getPosition());
  assertionNumericalEquals(subgrid.getSize(), virtualPatch.getSize());
  assertionEquals(subgrid.getLevel(), virtualPatch.getLevel());
  assertionEquals(subgrid.getUIndex(), virtualPatch.getUIndex());
//    assertionEquals(finePatch.getUOldIndex(), virtualPatch.getUOldIndex());

  #ifndef PEANOCLAW_USE_ASCEND_FOR_RESTRICTION
  _numerics.postProcessRestriction(subgrid, !subgrid.willCoarsen());
  #endif

  //Fill ghostlayer
  for(int i = 0; i < TWO_POWER_D; i++) {
    fineGridVertices[fineGridVerticesEnumerator(i)].fillAdjacentGhostLayers(
      subgrid.getLevel(),
      _useDimensionalSplitting,
      _numerics,
      #ifdef PEANOCLAW_USE_ASCEND_FOR_RESTRICTION
      tarch::la::multiplyComponents(peano::utils::dDelinearised(i, 2).convertScalar<double>(), subgrid.getSize()) + subgrid.getPosition(),
      #else
      fineGridVerticesEnumerator.getVertexPosition(i),
      #endif
      _subgridStatistics
    );
  }

  //Switch to leaf or non-virtual
  if(isPeanoCellLeaf) {
    assertion1(tarch::la::greaterEquals(subgrid.getTimeIntervals().getTimestepSize(), 0.0), subgrid);
    subgrid.switchToLeaf();
    _numerics.update(subgrid);
    ParallelSubgrid parallelSubgrid(subgrid);
    parallelSubgrid.markCurrentStateAsSent(false);
  } else {
    if(!isPatchAdjacentToRemoteRank(
      fineGridVertices,
      fineGridVerticesEnumerator
    )) {
      subgrid.switchToNonVirtual();
    }
  }

  assertion1(!subgrid.isVirtual()
    || isPatchAdjacentToRemoteRank(
        fineGridVertices,
        fineGridVerticesEnumerator),
    subgrid);
}
예제 #20
0
void peanoclaw::mappings::Cleanup::createHangingVertex(
    peanoclaw::Vertex&     fineGridVertex,
    const tarch::la::Vector<DIMENSIONS,double>&                fineGridX,
    const tarch::la::Vector<DIMENSIONS,double>&                fineGridH,
    peanoclaw::Vertex * const   coarseGridVertices,
    const peano::grid::VertexEnumerator&      coarseGridVerticesEnumerator,
    peanoclaw::Cell&       coarseGridCell,
    const tarch::la::Vector<DIMENSIONS,int>&                   fineGridPositionOfVertex
) {
    logTraceInWith6Arguments( "createHangingVertex(...)", fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex );
    // @todo Insert your code here
    logTraceOutWith1Argument( "createHangingVertex(...)", fineGridVertex );
}
예제 #21
0
void peanoclaw::mappings::ValidateGrid::createInnerVertex(
      peanoclaw::Vertex&               fineGridVertex,
      const tarch::la::Vector<DIMENSIONS,double>&                          fineGridX,
      const tarch::la::Vector<DIMENSIONS,double>&                          fineGridH,
      peanoclaw::Vertex * const        coarseGridVertices,
      const peano::grid::VertexEnumerator&                coarseGridVerticesEnumerator,
      peanoclaw::Cell&                 coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfVertex
) {
  logTraceInWith6Arguments( "createInnerVertex(...)", fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex );

  //TODO unterweg debug
//  std::cout<< "Create inner vertex " << fineGridX << ", "
//      << fineGridH
//      #ifdef Parallel
//      << ", rank=" << tarch::parallel::Node::getInstance().getRank()
//      #endif
//      << std::endl;

  logTraceOutWith1Argument( "createInnerVertex(...)", fineGridVertex );
}
예제 #22
0
int particles::pidt::mappings::MoveParticles::moveParticlesOfOneVertexWithinCellIfTheyAreSorted(
  int                                   vertexIndex,
  const peano::grid::VertexEnumerator&  fineGridVerticesEnumerator
) {
  ParticleHeap::HeapEntries& sourceVertexParticles = ParticleHeap::getInstance().getData(vertexIndex);

  int numberOfParticlesMoved = 0;

  int biggestIndexPointingToUnmovedParticle  = static_cast<int>(sourceVertexParticles.size())-1;
  int smallestIndexPointingToUnmovedParticle = 0;

  while (
    biggestIndexPointingToUnmovedParticle>=0 &&
    sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle).getMovedParticle() == particles::pidt::records::Particle::Moved
  ) {
    biggestIndexPointingToUnmovedParticle--;
  }

  #ifdef Asserts
  for (int i=0; i<biggestIndexPointingToUnmovedParticle; i++) {
    assertion3(
      sourceVertexParticles.at(i).getMovedParticle() != particles::pidt::records::Particle::Moved,
      i,
      biggestIndexPointingToUnmovedParticle,
      sourceVertexParticles.at(i).toString()
    );
  }
  #endif

  logDebug(
    "moveParticlesOfOneVertexWithinCellIfTheyAreSorted(...)",
    "moved index from " << static_cast<int>(sourceVertexParticles.size())-1 <<
    " to " << biggestIndexPointingToUnmovedParticle <<
    ": " << sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle).toString() <<
    " with first element " << sourceVertexParticles.at(smallestIndexPointingToUnmovedParticle).toString()
  );

  // has to be equals as the two might just have been exchanged
  while (biggestIndexPointingToUnmovedParticle >= smallestIndexPointingToUnmovedParticle) {
    particles::pidt::records::Particle& currentParticle = sourceVertexParticles.at(smallestIndexPointingToUnmovedParticle);

    assertion( biggestIndexPointingToUnmovedParticle>=0 );
    assertion( smallestIndexPointingToUnmovedParticle>=0 );
    assertion( biggestIndexPointingToUnmovedParticle<static_cast<int>(sourceVertexParticles.size()) );
    assertion( smallestIndexPointingToUnmovedParticle<static_cast<int>(sourceVertexParticles.size()) );

    assertion4(
      currentParticle.getMovedParticle() != particles::pidt::records::Particle::Moved ||
      (smallestIndexPointingToUnmovedParticle==biggestIndexPointingToUnmovedParticle),
      smallestIndexPointingToUnmovedParticle,
      biggestIndexPointingToUnmovedParticle,
      sourceVertexParticles.at(smallestIndexPointingToUnmovedParticle).toString(),
      sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle).toString()
    );

    const bool particleIsContainedInCell = fineGridVerticesEnumerator.overlaps(
      currentParticle._persistentRecords._x,
      0.0
    );

    if (particleIsContainedInCell) {
      currentParticle._persistentRecords._x             += (_state.getTimeStepSize() * currentParticle._persistentRecords._v);
      currentParticle.setMovedParticle( particles::pidt::records::Particle::Moved );
      reflectParticle(currentParticle);

      if (smallestIndexPointingToUnmovedParticle!=biggestIndexPointingToUnmovedParticle) {
        particles::pidt::records::Particle tmp                        =  currentParticle;
        currentParticle                                               =  sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle);
        sourceVertexParticles[biggestIndexPointingToUnmovedParticle]  =  tmp;
      }

      numberOfParticlesMoved++;
      biggestIndexPointingToUnmovedParticle--;
    }
    else {
      smallestIndexPointingToUnmovedParticle++;
    }
  }

  return numberOfParticlesMoved;
}
void particles::pit::myfunctions::CoordinatesRepresentationChange::ascend(
  particles::pit::Cell * const    fineGridCells,
  particles::pit::Vertex * const  fineGridVertices,
  const peano::grid::VertexEnumerator&          fineGridVerticesEnumerator,
  particles::pit::Vertex * const  coarseGridVertices,
  const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
  particles::pit::Cell&           coarseGridCell
) {

  dfor3(k)
	particles::pit::Cell fineGridCell = fineGridCells[ fineGridVerticesEnumerator.cell(k) ];
    const tarch::la::Vector<DIMENSIONS,double> cellOffset     = fineGridVerticesEnumerator.getVertexPosition(k);
    const tarch::la::Vector<DIMENSIONS,double> MeanCoordinate = fineGridCell.getMeanCoordinate();
    bool isLeaf = fineGridCell.isLeaf();
    const int cellIndex = fineGridCell.getCellIndex();
    const int NumberOfParticles = ParticleHeap::getInstance().getData(cellIndex).size();

    if( isLeaf && NumberOfParticles>1 ) {
      // Compute Max-Norm
      double maxRelativeError = computeMaxRelativeError( fineGridCell );
      // Save maximal maxRelativeError in _globalMaxRelativeError
      if (_globalMaxRelativeError < maxRelativeError) {
        _globalMaxRelativeError = maxRelativeError;
      }
      double maxError = computeMaxError( fineGridCell );
      if(_global_max_error < maxError) {
          _global_max_error = maxError;
      }
      double maxOffset = computeMaxOffset( fineGridCell );
      // Compute RMSD
      tarch::la::Vector<DIMENSIONS,double> rmsd = computeRMSD( fineGridCell );
      // Computer L2-Norm
      tarch::la::Vector<DIMENSIONS,double> l2ErrorNorm = computeL2ErrorNorm( fineGridCell );
      tarch::la::Vector<DIMENSIONS,double> l2Norm = computeL2Norm( fineGridCell );

      // Save maximal l2ErrorNorm in _globalMaxL2ErrorNorm
      for(int d = 0; d<DIMENSIONS; d++) {
        if(_globalMaxL2ErrorNorm < l2ErrorNorm[d]) {
          _globalMaxL2ErrorNorm = l2ErrorNorm[d];
        }
      }
      // Add l2Norm to _globalL2Norm
      _globalL2ErrorNorm += l2ErrorNorm;
      // Don't forget to increment _globalNormAdditions to divide _globalL2Norm by it
      // at the end of iteration before writing it in the file!
      ++_globalNormAdditions;
      //std::cout << "_globalNormAdditions: " << _globalNormAdditions << std::endl;

      // Output for checking
      //printParticlesInfo( fineGridCell, "maxError", maxError );

      _maxRelativeErrorOut << maxRelativeError << " ";
      _maxErrorOut << maxError << " ";
      _maxOffsetOut << maxOffset << " ";

      // Histogram process
      l2_error_norm_histogram_->processHistogram(l2ErrorNorm);
      max_error_norm_histogram_->processHistogram(maxError);
      max_offset_norm_histogram_->processHistogram(maxOffset);

      for(int d=0; d<DIMENSIONS; d++) {
        _RMSDOut << rmsd[d] << " ";
        _L2ErrorNormOut << l2ErrorNorm[d] << " ";
        _L2NormOut << l2Norm[d] << " ";
        _MeanCoordinateOut << MeanCoordinate[d] << " ";
      }
      for(int d=0; d<DIMENSIONS; d++) {
        _maxRelativeErrorOut << cellOffset[d] << " ";
    	_maxErrorOut << cellOffset[d] << " ";
        _maxOffsetOut << cellOffset[d] << " ";
        _RMSDOut << cellOffset[d] << " ";
        _L2ErrorNormOut << cellOffset[d] << " ";
        _L2NormOut << cellOffset[d] << " ";
        _MeanCoordinateOut << cellOffset[d] << " ";
      }
      _maxRelativeErrorOut << std::endl;
      _maxErrorOut << std::endl;
      _maxOffsetOut << std::endl;
      _RMSDOut << std::endl;
      _L2ErrorNormOut << std::endl;
      _L2NormOut << std::endl;
      _MeanCoordinateOut << std::endl;
    }
  enddforx
}
예제 #24
0
void peanoclaw::mappings::ValidateGrid::prepareSendToMaster(
  peanoclaw::Cell&                       localCell,
  peanoclaw::Vertex *                    vertices,
  const peano::grid::VertexEnumerator&       verticesEnumerator, 
  const peanoclaw::Vertex * const        coarseGridVertices,
  const peano::grid::VertexEnumerator&       coarseGridVerticesEnumerator,
  const peanoclaw::Cell&                 coarseGridCell,
  const tarch::la::Vector<DIMENSIONS,int>&   fineGridPositionOfCell
) {
  logTraceInWith2Arguments( "prepareSendToMaster(...)", localCell, verticesEnumerator.toString() );

  //Assemble vector to send to master
  std::vector<PatchDescription>& workerAndLocalData = PatchDescriptionHeap::getInstance().getData(_patchDescriptionsIndex);
  std::vector<PatchDescription> localData = _validator.getAllPatches();
  for(int i = 0; i < (int)localData.size(); i++) {

    //TODO unterweg debug
//    assertion(localData[i].getIsReferenced());

    workerAndLocalData.push_back(localData[i]);
  }

//  for(size_t i = 0; i < PatchDescriptionHeap::getInstance().getData(_patchDescriptionsIndex).size(); i++) {
//    //TODO unterweg debug
////    logError("", "Prepare Send to " << tarch::parallel::NodePool::getInstance().getMasterRank() << " -- " << i << ": " << PatchDescriptionHeap::getInstance().getData(_patchDescriptionsIndex)[i].toString());
//    assertion(PatchDescriptionHeap::getInstance().getData(_patchDescriptionsIndex)[i].getIsReferenced());
//  }

  //Add non-referenced patches
//  int index = 0;
//  int numberOfEntries = 0;
//  while(numberOfEntries < CellDescriptionHeap::getInstance().getNumberOfAllocatedEntries()) {
//    if(CellDescriptionHeap::getInstance().isValidIndex(index)) {
//      if(_descriptions.find(index) == _descriptions.end()) {
//        //Found non-referenced patch
//        CellDescription& cellDescription = CellDescriptionHeap::getInstance().getData(index).at(0);
//        PatchDescription patchDescription;
//        patchDescription.setPosition(cellDescription.getPosition());
//        patchDescription.setSize(cellDescription.getSize());
//        patchDescription.setLevel(cellDescription.getLevel());
//        patchDescription.setIsRemote(cellDescription.getIsRemote());
//        patchDescription.setIsReferenced(false);
//        patchDescription.setCellDescriptionIndex(index);
//        patchDescription.setRank(tarch::parallel::Node::getInstance().getRank());
//        descriptionVector.push_back(patchDescription);
//      }
//      numberOfEntries++;
//    }
//    index++;
//  }

  //Send
  PatchDescriptionHeap::getInstance().sendData(
    _patchDescriptionsIndex,
    tarch::parallel::NodePool::getInstance().getMasterRank(),
    verticesEnumerator.getVertexPosition(0),
    verticesEnumerator.getLevel(),
    peano::heap::MasterWorkerCommunication
  );

  #ifdef Parallel
  PatchDescriptionHeap::getInstance().finishedToSendSynchronousData();
  #endif

  logTraceOut( "prepareSendToMaster(...)" );
}