本文整理汇总了C++中peano::grid::VertexEnumerator类的典型用法代码示例。如果您正苦于以下问题:C++ VertexEnumerator类的具体用法?C++ VertexEnumerator怎么用?C++ VertexEnumerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VertexEnumerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logTraceIn
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:
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 );
}
示例3: assertion
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: defined
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: logInfo
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 );
}
示例6: logTraceOut
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(...)" );
}
示例7:
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 );
}
示例8: fineGridVerticesEnumerator
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(...)" );
}
示例9: logTraceIn
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(...)" );
}
示例10: pfor
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 );
}
示例11: computeMaxRelativeError
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;
//.........这里部分代码省略.........
示例12: parallelSubgrid
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();
}
示例13: switchToAndAddVirtualSubgrid
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()
);
}
}
}
示例14: virtualPatch
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);
}
示例15: while
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;
}