double scenario::diffusionequation::CornerPointField::getPorosityFromDataSet(const tarch::la::Vector<3,double>& x) const { logTraceInWith3Arguments( "getPorosityFromDataSet(vector)", x, _hexahedron.getBoundingBox(), _hexahedron.getOffset() ); const double depth = x(2); const double pillarSizeX = getCornerPointPillarWidth()(0); assertion1( pillarSizeX>0.0, pillarSizeX ); int inArrayX = std::floor( (x(0)-_hexahedron.getOffset()(0)) / pillarSizeX ); if (inArrayX==_pillars(0)) inArrayX--; assertion3( inArrayX>=0, pillarSizeX, inArrayX, _pillars ); assertion3( inArrayX<_pillars(0), pillarSizeX, inArrayX, _pillars ); #if defined(Dim3) const double pillarSizeY = getCornerPointPillarWidth()(1); assertion4( pillarSizeY>0.0, pillarSizeX, pillarSizeY, inArrayX, _pillars ); int inArrayY = std::floor( (x(1)-_hexahedron.getOffset()(1)) / pillarSizeY ); if (inArrayY==_pillars(1)) inArrayY--; assertion5( inArrayY>=0, pillarSizeX, pillarSizeY, inArrayX, inArrayY, _pillars ); assertion5( inArrayY<_pillars(1), pillarSizeX, pillarSizeY, inArrayX, inArrayY, _pillars ); #elif defined(Dim2) const int inArrayY = _pillars(1) / 2; #endif const int entry = inArrayX + inArrayY * _pillars(0); assertion6( entry < static_cast<int>(_entries.size()), pillarSizeX, inArrayX, inArrayY, _pillars, entry, _entries.size() ); double result = _entries[entry].getPermeability(depth); logTraceOutWith1Argument( "getPorosityFromDataSet(vector)", result ); return result; }
void peanoclaw::parallel::MasterWorkerAndForkJoinCommunicator::receivePatch(int localCellDescriptionIndex) { logTraceInWith3Arguments("receivePatch", localCellDescriptionIndex, _position, _level); #ifdef Parallel std::vector<CellDescription> remoteCellDescriptionVector = CellDescriptionHeap::getInstance().receiveData(_remoteRank, _position, _level, _messageType); assertionEquals2(remoteCellDescriptionVector.size(), 1, _position, _level); CellDescription remoteCellDescription = remoteCellDescriptionVector[0]; assertion3(localCellDescriptionIndex >= 0, localCellDescriptionIndex, _position, _level); CellDescription localCellDescription = CellDescriptionHeap::getInstance().getData(localCellDescriptionIndex).at(0); #ifdef Asserts assertionNumericalEquals2(remoteCellDescription.getPosition(), localCellDescription.getPosition(), localCellDescription.toString(), remoteCellDescription.toString()); assertionNumericalEquals2(remoteCellDescription.getSize(), localCellDescription.getSize(), localCellDescription.toString(), remoteCellDescription.toString()); assertionEquals2(remoteCellDescription.getLevel(), localCellDescription.getLevel(), localCellDescription.toString(), remoteCellDescription.toString()); #endif //Load arrays and stores according indices in cell description if(remoteCellDescription.getUIndex() != -1) { remoteCellDescription.setUIndex(_subgridCommunicator.receiveDataArray()); } //Reset undesired values remoteCellDescription.setNumberOfTransfersToBeSkipped(0); //Copy remote cell description to local cell description deleteArraysFromPatch(localCellDescriptionIndex); remoteCellDescription.setCellDescriptionIndex(localCellDescriptionIndex); CellDescriptionHeap::getInstance().getData(localCellDescriptionIndex).at(0) = remoteCellDescription; assertionEquals(CellDescriptionHeap::getInstance().getData(localCellDescriptionIndex).size(), 1); Patch subgrid(localCellDescriptionIndex); subgrid.initializeNonParallelFields(); //TODO unterweg debug // std::cout << "Received cell description on rank " << tarch::parallel::Node::getInstance().getRank() // << " from rank " << _remoteRank << ": " << remoteCellDescription.toString() << std::endl << subgrid.toStringUNew() << std::endl; #if defined(AssertForPositiveValues) && defined(Asserts) if(subgrid.isLeaf() || subgrid.isVirtual()) { assertion4(!subgrid.containsNonPositiveNumberInUnknownInUNew(0), tarch::parallel::Node::getInstance().getRank(), _remoteRank, subgrid, subgrid.toStringUNew()); } #endif assertionEquals(CellDescriptionHeap::getInstance().getData(localCellDescriptionIndex).at(0).getCellDescriptionIndex(), localCellDescriptionIndex); #endif logTraceOut("receivePatch"); }
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 particles::pidt::mappings::MoveParticles::touchVertexLastTime( 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 ) { for ( ParticleHeap::HeapEntries::const_iterator p = ParticleHeap::getInstance().getData(fineGridVertex.getVertexIndex()).begin(); p != ParticleHeap::getInstance().getData(fineGridVertex.getVertexIndex()).end(); p++ ) { assertion4( p->getMovedParticle() == particles::pidt::records::Particle::Moved, p->toString(), fineGridVertex.toString(), fineGridX, fineGridH ); } }
clock_t tarch::parallel::Node::getDeadlockTimeOutTimeStamp() const { clock_t result = clock() + _deadlockTimeOut * CLOCKS_PER_SEC; assertion4( result>=0, result, clock(), _timeOutWarning, CLOCKS_PER_SEC); return result; }
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; }