void peano::kernel::spacetreegrid::SingleLevelEnumerator::setOffset(const LocalVertexIntegerIndex& gridPointOffset) { for (int d=0; d<DIMENSIONS; d++) { assertion2( gridPointOffset(d)>=0, gridPointOffset, toString() ); assertion2( gridPointOffset(d)<=3, gridPointOffset, toString() ); } _discreteOffset = gridPointOffset; }
void peanoclaw::native::scenarios::CalmOcean::initializePatch(peanoclaw::Patch& patch) { const tarch::la::Vector<DIMENSIONS, double> patchPosition = patch.getPosition(); const tarch::la::Vector<DIMENSIONS, double> meshWidth = patch.getSubcellSize(); peanoclaw::grid::SubgridAccessor& accessor = patch.getAccessor(); tarch::la::Vector<DIMENSIONS, int> subcellIndex; for (int yi = 0; yi < patch.getSubdivisionFactor()(1); yi++) { for (int xi = 0; xi < patch.getSubdivisionFactor()(0); xi++) { subcellIndex(0) = xi; subcellIndex(1) = yi; double X = patchPosition(0) + xi*meshWidth(0); double Y = patchPosition(1) + yi*meshWidth(1); double q0 = getWaterHeight(X, Y); double q1 = 0.0; double q2 = 0.0; accessor.setValueUNew(subcellIndex, 0, q0); accessor.setValueUNew(subcellIndex, 1, q1); accessor.setValueUNew(subcellIndex, 2, q2); accessor.setParameterWithGhostlayer(subcellIndex, 0, 0.0); assertion2(tarch::la::equals(accessor.getValueUNew(subcellIndex, 0), q0, 1e-5), accessor.getValueUNew(subcellIndex, 0), q0); assertion2(tarch::la::equals(accessor.getValueUNew(subcellIndex, 1), q1, 1e-5), accessor.getValueUNew(subcellIndex, 1), q1); assertion2(tarch::la::equals(accessor.getValueUNew(subcellIndex, 2), q2, 1e-5), accessor.getValueUNew(subcellIndex, 2), q2); } } }
void peano::applications::poisson::multigrid::mappings::SpacetreeGrid2PlotSolution::enterCell( peano::applications::poisson::multigrid::SpacetreeGridCell& fineGridCell, peano::applications::poisson::multigrid::SpacetreeGridVertex * const fineGridVertices, const peano::kernel::gridinterface::VertexEnumerator& fineGridVerticesEnumerator, peano::applications::poisson::multigrid::SpacetreeGridVertex const * const coarseGridVertices, const peano::kernel::gridinterface::VertexEnumerator& coarseGridVerticesEnumerator, const peano::applications::poisson::multigrid::SpacetreeGridCell& coarseGridCell, const tarch::la::Vector<DIMENSIONS,int>& fineGridPositionOfCell ) { logTraceInWith4Arguments( "enterCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell ); if (!fineGridCell.isRefined()) { #ifdef SharedTBB Vertex2IndexMapSemaphore::scoped_lock localLock(_vertex2IndexMapSemaphore); #elif SharedOMP assertionMsg( false, "here should be a critical section, but I don't know how to implement this. If you implement it, please add it to the templates, too." ); #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 if (DIMENSIONS==2) { _cellWriter->plotQuadrangle(vertexIndex); } if (DIMENSIONS==3) { _cellWriter->plotHexahedron(vertexIndex); } }
void precicef_action_write_initial_data_( char* nameAction, int lengthNameAction ) { const std::string& name = precice::constants::actionWriteInitialData(); assertion2(name.size() < (size_t) lengthNameAction, name.size(), lengthNameAction); for (size_t i=0; i < name.size(); i++){ nameAction[i] = name[i]; } }
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); }
void precicef_action_read_sim_checkp_ ( char* nameAction, int lengthNameAction ) { const std::string& name = precice::constants::actionReadSimulationCheckpoint(); assertion2(name.size() < (size_t) lengthNameAction, name.size(), lengthNameAction); for (size_t i=0; i < name.size(); i++){ nameAction[i] = name[i]; } }
void precicef_name_config_ ( char* nameConfig, int lengthNameConfig ) { const std::string& name = precice::constants::nameConfiguration(); assertion2(name.size() < (size_t) lengthNameConfig, name.size(), lengthNameConfig); for (size_t i=0; i < name.size(); i++){ nameConfig[i] = name[i]; } }
void peanoclaw::parallel::MasterWorkerAndForkJoinCommunicator::deleteArraysFromPatch(int cellDescriptionIndex) { logTraceInWith1Argument("deleteArraysFromPatch", cellDescriptionIndex); if(cellDescriptionIndex != -1) { assertion2(CellDescriptionHeap::getInstance().isValidIndex(cellDescriptionIndex), _position, _level); CellDescription cellDescription = CellDescriptionHeap::getInstance().getData(cellDescriptionIndex).at(0); if(cellDescription.getUIndex() != -1) { DataHeap::getInstance().deleteData(cellDescription.getUIndex()); } } logTraceOut("deleteArraysFromPatch"); }
const tarch::la::Vector<LB_PDFS_ON_BLOCKBOUNDARY*2,int> peano::applications::latticeboltzmann::blocklatticeboltzmann::parallel::BlockBoundaryIndex4Pdfs:: initBoundaryIndex() const{ int index = 0; tarch::la::Vector<LB_PDFS_ON_BLOCKBOUNDARY*2,int> boundaryIndex(0); const peano::applications::latticeboltzmann::LatticeVelocities<LB_CURRENT_DIR> latVel(createLatticeVelocities<LB_CURRENT_MODEL,LB_CURRENT_DIR>()); #if (DIMENSIONS == 3) for (int z = 0; z < LB_BLOCKSIZE; z++){ #endif for (int y = 0; y < LB_BLOCKSIZE; y++){ for (int x = 0; x < LB_BLOCKSIZE; x++){ for (int q = 0; q < LB_CURRENT_DIR; q++){ // if pdf points to a cell outside of the local block... double X = x+latVel._entries[q](0); double Y = y+latVel._entries[q](1); #if (DIMENSIONS == 3) double Z = z+latVel._entries[q](2); #endif if ( (X < 0.0) || (X > LB_BLOCKSIZE-1.0) || (Y < 0.0) || (Y > LB_BLOCKSIZE-1.0) #if (DIMENSIONS == 3) || (Z < 0.0) || (Z > LB_BLOCKSIZE-1.0) #endif ){ // save the incoming direction boundaryIndex(2*index) = LB_CURRENT_DIR-1-q + x*LB_CURRENT_DIR+y*LB_BLOCKSIZE*LB_CURRENT_DIR #if (DIMENSIONS == 3) + z*LB_BLOCKSIZE*LB_BLOCKSIZE*LB_CURRENT_DIR #endif ; // save the outgoing direction boundaryIndex(2*index+1) = q + x*LB_CURRENT_DIR+y*LB_BLOCKSIZE*LB_CURRENT_DIR #if (DIMENSIONS == 3) + z*LB_BLOCKSIZE*LB_BLOCKSIZE*LB_CURRENT_DIR #endif ; index++; assertion(index < LB_PDFS_ON_BLOCKBOUNDARY+1); } } // pdfs } // x } // y #if (DIMENSIONS == 3) } // z #endif assertion2(index == LB_PDFS_ON_BLOCKBOUNDARY,index,LB_PDFS_ON_BLOCKBOUNDARY); return boundaryIndex; }
Edge:: Edge ( Vertex& vertexOne, Vertex& vertexTwo, int id ) : PropertyContainer (), _vertices ( boost::assign::list_of(&vertexOne)(&vertexTwo).to_array(_vertices) ), _id ( id ), _normal ( vertexOne.getDimensions(), 0.0 ), _center ( vertexOne.getDimensions(), 0.0 ), _enclosingRadius ( 0.0 ) { assertion2 ( vertexOne.getDimensions() == vertexTwo.getDimensions(), vertexOne.getDimensions(), vertexTwo.getDimensions() ); }
FindVoxelContent:: FindVoxelContent ( const VECTORA_T& voxelCenter, const VECTORB_T& halflengths, BoundaryInclusion boundaryInclusion ) : _voxelCenter ( voxelCenter ), _voxelHalflengths ( halflengths ), _boundaryInclusion ( boundaryInclusion ), _dimensions ( voxelCenter.size() ), _content () { assertion2 ( voxelCenter.size() == halflengths.size(), voxelCenter.size(), halflengths.size() ); assertion1 ( (_dimensions == 2) || (_dimensions == 3), _dimensions ); }
void peano::applications::latticeboltzmann::blocklatticeboltzmann::RegularGridBlockVertex::mergeDensityOnBoundary(const RegularGridBlockVertex& neighbour) { assertion2((getVertexNumber()==0) || (getVertexNumber()==peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber()),getVertexNumber(),peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber()); tarch::la::Vector<LB_BLOCK_NUMBER_OF_CELLS,double> &density = peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getDensity(); // merge density values in outer close-to-boundary cells for (int i = 0; i < LB_BLOCK_NUMBER_OF_CELLS_ON_BLOCKBOUNDARY; i++){ int index = peano::applications::latticeboltzmann::blocklatticeboltzmann::BLOCKBOUNDARYINDEX.getBlockIndex(i); if ( (!peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getInner()[index]) && peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getBoundary()[index]){ #ifdef Debug assertion4 ( (Base::_vertexData.getLbDensityOnBoundary(i) == 0.0) || (neighbour.getDensityOnBoundary(i) == 0.0),Base::_vertexData.getLbDensityOnBoundary(i),neighbour.getDensityOnBoundary(i),index,getX() ); #endif density(index) += neighbour.getDensityOnBoundary(i); } } }
void peano::applications::latticeboltzmann::blocklatticeboltzmann::RegularGridBlockVertex::mergePdfDiff(const RegularGridBlockVertex& neighbour) { assertion2((getVertexNumber()==0) || (getVertexNumber()==peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber()),getVertexNumber(),peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber()); tarch::la::Vector<LB_BLOCK_NUMBER_OF_CELLS*LB_CURRENT_DIR,double>& pdf = peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getPdf(); // add difference to pdfs for (int i = 0; i < LB_PDFS_ON_BLOCKBOUNDARY; i++){ // if the current pdf-field has not changed // -> either the same amount was transfered from some neighbour cell; in this case, adding the difference (which should also // equal zero) should not matter at all // -> or: there was no transfer, as the process boundary passes through here; in this case, adding the difference // will just make everything right ;-) if (Base::_vertexData.getLbPdfDiff(i) == 0.0){ pdf(peano::applications::latticeboltzmann::blocklatticeboltzmann::parallel::BLOCKBOUNDARYINDEX4PDFS.getIncomingPdf(i)) = pdf( peano::applications::latticeboltzmann::blocklatticeboltzmann::parallel::BLOCKBOUNDARYINDEX4PDFS.getIncomingPdf(i) ) + neighbour.getPdfDiff(i); } } }
void NearestNeighborMapping:: map ( int inputDataID, int outputDataID ) { preciceTrace2 ( "map()", inputDataID, outputDataID ); const utils::DynVector& inputValues = input()->data(inputDataID)->values(); utils::DynVector& outputValues = output()->data(outputDataID)->values(); //assign(outputValues) = 0.0; int valueDimensions = input()->data(inputDataID)->getDimensions(); assertion2 ( valueDimensions == output()->data(outputDataID)->getDimensions(), valueDimensions, output()->data(outputDataID)->getDimensions() ); assertion3 ( inputValues.size() / valueDimensions == (int)input()->vertices().size(), inputValues.size(), valueDimensions, input()->vertices().size() ); assertion3 ( outputValues.size() / valueDimensions == (int)output()->vertices().size(), outputValues.size(), valueDimensions, output()->vertices().size() ); if (getConstraint() == CONSISTENT){ preciceDebug("Map consistent"); size_t outSize = output()->vertices().size(); for ( size_t i=0; i < outSize; i++ ){ int inputIndex = _vertexIndices[i] * valueDimensions; for ( int dim=0; dim < valueDimensions; dim++ ){ outputValues[(i*valueDimensions)+dim] = inputValues[inputIndex+dim]; } } } else { assertion1(getConstraint() == CONSERVATIVE, getConstraint()); preciceDebug("Map conservative"); size_t inSize = input()->vertices().size(); for ( size_t i=0; i < inSize; i++ ){ int outputIndex = _vertexIndices[i] * valueDimensions; for ( int dim=0; dim < valueDimensions; dim++ ){ outputValues[outputIndex+dim] += inputValues[(i*valueDimensions)+dim]; } } } }
void peanoclaw::interSubgridCommunication::GridLevelTransfer::restrictDestroyedSubgrid( const Patch& destroyedSubgrid, Patch& coarseSubgrid, peanoclaw::Vertex * const fineGridVertices, const peano::grid::VertexEnumerator& fineGridVerticesEnumerator ) { assertion2(tarch::la::greaterEquals(coarseSubgrid.getTimeIntervals().getTimestepSize(), 0.0), destroyedSubgrid, coarseSubgrid); //Fix timestep size assertion1(tarch::la::greaterEquals(coarseSubgrid.getTimeIntervals().getTimestepSize(), 0), coarseSubgrid); coarseSubgrid.getTimeIntervals().setTimestepSize(std::max(0.0, coarseSubgrid.getTimeIntervals().getTimestepSize())); //Set indices on coarse adjacent vertices for(int i = 0; i < TWO_POWER_D; i++) { fineGridVertices[fineGridVerticesEnumerator(i)].setAdjacentCellDescriptionIndex(i, coarseSubgrid.getCellDescriptionIndex()); } //Skip update for coarse patch in next grid iteration coarseSubgrid.setSkipNextGridIteration(2); //Set demanded mesh width for coarse cell to coarse cell size. Otherwise //the coarse patch might get refined immediately. coarseSubgrid.setDemandedMeshWidth(coarseSubgrid.getSubcellSize()); }
int peanoclaw::Area::getAreasOverlappedByRemoteGhostlayers( const tarch::la::Vector<THREE_POWER_D_MINUS_ONE, int>& adjacentRanks, tarch::la::Vector<THREE_POWER_D_MINUS_ONE, int> overlapOfRemoteGhostlayers, const tarch::la::Vector<DIMENSIONS, int>& subdivisionFactor, int rank, Area areas[THREE_POWER_D_MINUS_ONE] ) { logTraceInWith2Arguments("getAreasOverlappedByRemoteGhostlayers(...)", adjacentRanks, overlapOfRemoteGhostlayers); int numberOfAreas = 0; bool oneAreaCoversCompleteSubgrid = false; for(int dimensionality = 0; dimensionality < DIMENSIONS; dimensionality++) { int numberOfManifolds = getNumberOfManifolds(dimensionality); for(int manifoldIndex = 0; manifoldIndex < numberOfManifolds; manifoldIndex++) { tarch::la::Vector<DIMENSIONS, int> manifoldPosition = getManifold(dimensionality, manifoldIndex); int manifoldEntry = linearizeManifoldPosition(manifoldPosition); logDebug("getAreasOverlappedByRemoteGhostlayers(...)", "Manifold " << manifoldPosition << " of dimensions " << dimensionality << ": entry=" << manifoldEntry << ", rank=" << adjacentRanks[manifoldEntry] << ", overlap=" << overlapOfRemoteGhostlayers[manifoldEntry]); if(adjacentRanks[manifoldEntry] == rank && overlapOfRemoteGhostlayers[manifoldEntry] > 0) { //Reduce lower-dimensional manifolds bool canBeOmitted = checkHigherDimensionalManifoldForOverlap( adjacentRanks, overlapOfRemoteGhostlayers, manifoldPosition, dimensionality, manifoldEntry, rank ); //Restrict size and offset by higher-dimensional manifolds logDebug("getAreasOverlappedByRemoteGhostlayers(...)","Testing manifold " << manifoldPosition << " of dimensions " << dimensionality << ": " << (canBeOmitted ? "omitting" : "consider")); if(!canBeOmitted) { tarch::la::Vector<DIMENSIONS, int> size; tarch::la::Vector<DIMENSIONS, int> offset; //Initialise size and offset for(int d = 0; d < DIMENSIONS; d++) { size(d) = (manifoldPosition(d) == 0) ? subdivisionFactor(d) : std::min(subdivisionFactor(d), overlapOfRemoteGhostlayers[manifoldEntry]); offset(d) = (manifoldPosition(d) == 1) ? subdivisionFactor(d) - size(d) : 0; } //TODO unterweg debug // std::cout << "offset: " << offset << ", size: " << size << std::endl; for(int adjacentDimensionality = dimensionality - 1; adjacentDimensionality >= 0; adjacentDimensionality--) { int numberOfAdjacentManifolds = getNumberOfAdjacentManifolds(manifoldPosition, dimensionality, adjacentDimensionality); for(int adjacentManifoldIndex = 0; adjacentManifoldIndex < numberOfAdjacentManifolds; adjacentManifoldIndex++) { tarch::la::Vector<DIMENSIONS, int> adjacentManifoldPosition = getIndexOfAdjacentManifold( manifoldPosition, dimensionality, adjacentDimensionality, adjacentManifoldIndex ); //TODO unterweg debug // std::cout << "adj. manifold " << adjacentManifoldPosition << std::endl; int adjacentEntry = linearizeManifoldPosition(adjacentManifoldPosition); if(adjacentRanks[adjacentEntry] == rank) { for(int d = 0; d < DIMENSIONS; d++) { if(manifoldPosition(d) == 0) { if(adjacentManifoldPosition(d) < 0) { int overlap = std::max(0, overlapOfRemoteGhostlayers[adjacentEntry] - offset(d)); offset(d) += overlap; size(d) -= overlap; //TODO unterweg debug // std::cout << "Reducing bottom " << overlap << std::endl; } else if(adjacentManifoldPosition(d) > 0) { assertion2(adjacentManifoldPosition(d) > 0, adjacentManifoldPosition, d); int overlap = std::max(0, offset(d) + size(d) - (subdivisionFactor(d) - overlapOfRemoteGhostlayers[adjacentEntry])); size(d) -= overlap; //TODO unterweg debug // std::cout << "Reducing top " << overlap << std::endl; } } } } } } logDebug("getAreasOverlappedByRemoteGhostlayers(...)", "offset: " << offset << ", size: " << size << ", dimensionality=" << dimensionality << ", manifoldIndex=" << manifoldIndex << ", manifoldEntry=" << manifoldEntry); if(tarch::la::allGreater(size, 0)) { areas[numberOfAreas++] = Area(offset, size); oneAreaCoversCompleteSubgrid |= (tarch::la::volume(size) >= tarch::la::volume(subdivisionFactor)); assertion1(tarch::la::allGreaterEquals(offset, 0), offset); assertion3(tarch::la::allGreaterEquals(subdivisionFactor, offset + size), offset, size, subdivisionFactor); } } } } } //Optimize areas if(oneAreaCoversCompleteSubgrid) { numberOfAreas = 1; areas[0] = Area(0, subdivisionFactor); } logTraceOutWith2Arguments("getAreasOverlappedByRemoteGhostlayers(...)", numberOfAreas, areas); return numberOfAreas; }
void peanoclaw::interSubgridCommunication::GridLevelTransfer::restrictToOverlappingVirtualSubgrids( Patch& subgrid, ParallelSubgrid& parallelSubgrid ) { tarch::multicore::Lock lock(_virtualPatchListSemaphore); //Restrict to all //for(int i = 0; i < (int)_virtualPatchDescriptionIndices.size(); i++) { for(VirtualSubgridMap::iterator i = _virtualPatchDescriptionIndices.begin(); i != _virtualPatchDescriptionIndices.end(); i++) { int virtualSubgridDescriptionIndex = i->second; CellDescription& virtualSubgridDescription = CellDescriptionHeap::getInstance().getData(virtualSubgridDescriptionIndex).at(0); Patch virtualSubgrid(virtualSubgridDescription); ParallelSubgrid virtualParallelSubgrid(virtualSubgridDescription); // Restrict only if coarse patches can advance in time bool areAllCoarseSubgridsBlocked = tarch::la::smaller( subgrid.getTimeIntervals().getCurrentTime() + subgrid.getTimeIntervals().getTimestepSize(), virtualSubgrid.getTimeIntervals().getMinimalLeafNeighborTimeConstraint() ); // Restrict only if this patch is overlapped by neighboring ghostlayers bool isOverlappedByCoarseGhostlayers = tarch::la::oneGreater(virtualSubgrid.getUpperNeighboringGhostlayerBounds(), subgrid.getPosition()) || tarch::la::oneGreater(subgrid.getPosition() + subgrid.getSize(), virtualSubgrid.getLowerNeighboringGhostlayerBounds()); bool subgridOverlapsVirtualSubgrid = !tarch::la::oneGreater(virtualSubgrid.getPosition(), subgrid.getPosition()) && !tarch::la::oneGreater(subgrid.getPosition() + subgrid.getSize(), virtualSubgrid.getPosition() + virtualSubgrid.getSize()); //TODO unterweg debug // if(tarch::la::equals(subgrid.getPosition()(0), 10.0*2.0/3.0) // &&tarch::la::equals(subgrid.getPosition()(1), 10.0*2.0/3.0)) { // std::cout << "Restricting from " << subgrid // << ", isOverlapped=" << isOverlappedByCoarseGhostlayers // << ", areAllCoarseSubgridsBlocked=" << areAllCoarseSubgridsBlocked // << ", willCoarsen=" << virtualSubgrid.willCoarsen() // << std::endl << subgrid.toStringUNew() << std::endl // << " to " << virtualSubgrid << std::endl << virtualSubgrid.toStringUNew() << std::endl; // } if( subgridOverlapsVirtualSubgrid && ( // Restrict if virtual subgrid is coarsening or if the data on the virtual subgrid is required for timestepping virtualSubgrid.willCoarsen() || (!areAllCoarseSubgridsBlocked && isOverlappedByCoarseGhostlayers) //TODO unterweg dissertation: Es kann sein, dass ein Nachbarsubgitter vom groben Subgitter noch nicht angekommen ist, wenn //das Gitter gerade verteilt wurde. || subgrid.getAge() < 2 //|| true ) ) { assertion2(virtualSubgrid.isVirtual(), subgrid.toString(), virtualSubgrid.toString()); assertion2(!tarch::la::oneGreater(virtualSubgrid.getPosition(), subgrid.getPosition()) && !tarch::la::oneGreater(subgrid.getPosition() + subgrid.getSize(), virtualSubgrid.getPosition() + virtualSubgrid.getSize()), subgrid.toString(), virtualSubgrid.toString()); int numberOfRestrictedCells = _numerics.restrictSolution(subgrid, virtualSubgrid, !virtualSubgrid.willCoarsen()); _subgridStatistics.addRestrictedCells(numberOfRestrictedCells, subgrid.getLevel()); virtualSubgrid.getTimeIntervals().setEstimatedNextTimestepSize( subgrid.getTimeIntervals().getEstimatedNextTimestepSize() ); } if(!parallelSubgrid.wasCurrentStateSent()) { //virtualParallelSubgrid.markCurrentStateAsSent(virtualParallelSubgrid.wasCurrentStateSent() || parallelSubgrid.wasCurrentStateSent()); virtualParallelSubgrid.markCurrentStateAsSent(false); } } }
Quad:: Quad ( Edge& edgeOne, Edge& edgeTwo, Edge& edgeThree, Edge& edgeFour, int id ) : PropertyContainer(), _edges( boost::assign::list_of(&edgeOne)(&edgeTwo)(&edgeThree)(&edgeFour).to_array(_edges) ), _vertexMap(), _id( id ), _normal( edgeOne.getDimensions() ), _center( edgeOne.getDimensions() ), _enclosingRadius ( 0.0 ) { assertion2(edgeOne.getDimensions() == edgeTwo.getDimensions(), edgeOne.getDimensions(), edgeTwo.getDimensions() ); assertion2(edgeTwo.getDimensions() == edgeThree.getDimensions(), edgeTwo.getDimensions(), edgeThree.getDimensions() ); assertion2(edgeThree.getDimensions() == edgeFour.getDimensions(), edgeThree.getDimensions(), edgeFour.getDimensions() ); assertion1(getDimensions() == 3, getDimensions()); // Determine vertex map Vertex& v0 = edge(0).vertex(0); Vertex& v1 = edge(0).vertex(1); // Check for edges 0 and 1 which vertex establishes connection if (&edge(1).vertex(0) == &v0){ _vertexMap[0] = 1; _vertexMap[1] = 0; } else if (&edge(1).vertex(1) == &v0){ _vertexMap[0] = 1; _vertexMap[1] = 1; } else if (&edge(1).vertex(0) == &v1){ _vertexMap[0] = 0; _vertexMap[1] = 0; } else { assertion(&edge(1).vertex(1) == &v1); _vertexMap[0] = 0; _vertexMap[1] = 1; } // Check for edges 1 and 2 which vertex establishes connection if (_vertexMap[1] == 0){ if (&edge(2).vertex(0) == &edge(1).vertex(1)){ _vertexMap[2] = 0; } else { assertion(&edge(2).vertex(1) == &edge(1).vertex(1)); _vertexMap[2] = 1; } } else if (_vertexMap[1] == 1){ if (&edge(2).vertex(0) == &edge(1).vertex(0)){ _vertexMap[2] = 0; } else { assertion(&edge(2).vertex(1) == &edge(1).vertex(0)); _vertexMap[2] = 1; } } // Check for edges 2 and 3 which vertex establishes connection if (_vertexMap[2] == 0){ if (&edge(3).vertex(0) == &edge(2).vertex(1)){ _vertexMap[3] = 0; } else { assertion(&edge(3).vertex(1) == &edge(2).vertex(1)); _vertexMap[3] = 1; } } else if (_vertexMap[2] == 1){ if (&edge(3).vertex(0) == &edge(2).vertex(0)){ _vertexMap[3] = 0; } else { assertion(&edge(3).vertex(1) == &edge(2).vertex(0)); _vertexMap[3] = 1; } } assertion(&vertex(0) != &vertex(1)); assertion(&vertex(0) != &vertex(2)); assertion(&vertex(0) != &vertex(3)); assertion(&vertex(1) != &vertex(2)); assertion(&vertex(1) != &vertex(3)); assertion(&vertex(2) != &vertex(3)); assertion1((_vertexMap[0] == 0) || (_vertexMap[0] == 1), _vertexMap[0]); assertion1((_vertexMap[1] == 0) || (_vertexMap[1] == 1), _vertexMap[1]); assertion1((_vertexMap[2] == 0) || (_vertexMap[2] == 1), _vertexMap[2]); assertion1((_vertexMap[2] == 0) || (_vertexMap[2] == 1), _vertexMap[3]); }
void peanoclaw::parallel::MasterWorkerAndForkJoinCommunicator::mergeCellDuringForkOrJoin( peanoclaw::Cell& localCell, const peanoclaw::Cell& remoteCell, tarch::la::Vector<DIMENSIONS, double> cellSize, const peanoclaw::State& state ) { #ifdef Parallel bool isForking = !tarch::parallel::Node::getInstance().isGlobalMaster() && _remoteRank == tarch::parallel::NodePool::getInstance().getMasterRank(); if(localCell.isInside() && ( ( isForking && !remoteCell.isAssignedToRemoteRank()) || (!isForking && remoteCell.getRankOfRemoteNode() == _remoteRank) ) ) { if(localCell.isRemote(state, false, false)) { if(tarch::parallel::NodePool::getInstance().getMasterRank() != 0) { assertionEquals2(localCell.getCellDescriptionIndex(), -2, _position, _level); } Patch temporaryPatch( _position - cellSize * 0.5, cellSize, 0, 0, 0, 1, 1, 0.0, _level ); receivePatch(temporaryPatch.getCellDescriptionIndex()); temporaryPatch.reloadCellDescription(); if(temporaryPatch.isLeaf()) { temporaryPatch.switchToVirtual(); } if(temporaryPatch.isVirtual()) { temporaryPatch.switchToNonVirtual(); } CellDescriptionHeap::getInstance().deleteData(temporaryPatch.getCellDescriptionIndex()); } else { assertion2(localCell.getCellDescriptionIndex() != -1, _position, _level); Patch localPatch(localCell); assertion2( (!localPatch.isLeaf() && !localPatch.isVirtual()) || localPatch.getUIndex() >= 0, _position, _level ); receivePatch(localPatch.getCellDescriptionIndex()); localPatch.loadCellDescription(localCell.getCellDescriptionIndex()); assertion1(!localPatch.isRemote(), localPatch); //TODO unterweg dissertation: Wenn auf dem neuen Knoten die Adjazenzinformationen auf den // Vertices noch nicht richtig gesetzt sind koennen wir nicht gleich voranschreiten. // U.U. brauchen wir sogar 2 Iterationen ohne Aktion... (Wegen hin- und herlaufen). localPatch.setSkipNextGridIteration(2); assertionEquals1(localPatch.getLevel(), _level, localPatch); } } #endif }