int main(int argc, char **argv) { int errflag = 0; int sts; int c; __pmSetProgname(argv[0]); indomp = (__pmInDom_int *)&indom; while ((c = getopt(argc, argv, "D:")) != EOF) { switch (c) { #ifdef PCP_DEBUG case 'D': /* debug flag */ sts = __pmParseDebug(optarg); if (sts < 0) { fprintf(stderr, "%s: unrecognized debug flag specification (%s)\n", pmProgname, optarg); errflag++; } else pmDebug |= sts; break; #endif case '?': default: errflag++; break; } } if (errflag) { fprintf(stderr, "Usage: %s [-D...] [a|b|c|d|...|i 1|2|3}\n", pmProgname); exit(1); } while (optind < argc) { if (strcmp(argv[optind], "a") == 0) _a(0, 1, 1); else if (strcmp(argv[optind], "b") == 0) _b(); else if (strcmp(argv[optind], "c") == 0) _c(); else if (strcmp(argv[optind], "d") == 0) _a(1, 0, 1); else if (strcmp(argv[optind], "e") == 0) _e(0); else if (strcmp(argv[optind], "f") == 0) _e(3600); else if (strcmp(argv[optind], "g") == 0) _g(); else if (strcmp(argv[optind], "h") == 0) _h(); else if (strcmp(argv[optind], "i") == 0) { optind++; _i(atoi(argv[optind])); } else if (strcmp(argv[optind], "j") == 0) _j(); else fprintf(stderr, "torture_cache: no idea what to do with option \"%s\"\n", argv[optind]); optind++; } exit(0); }
/** * Calculates key value for cell. * * @param Map::Cell* cell to calculate for * @return pair<double,double> key value */ pair<double,double> Planner::_k(Map::Cell* u) { double g = _g(u); double rhs = _rhs(u); double min = (g < rhs) ? g : rhs; return pair<double,double>((min + _h(_start, u) + _km), min); }
/** * set water height h in all interior grid cells (i.e. except ghost layer) * to values specified by parameter function _h */ void SWE_Block::setWaterHeight(float (*_h)(float, float)) { for(int i=nghosts; i<nx+nghosts; i++) for(int j=nghosts; j<ny+nghosts; j++) { h[i][j] = _h(offsetX + (i-nghosts+0.5f)*dx, offsetY + (j-nghosts+0.5f)*dy); }; synchWaterHeightAfterWrite(); }
/** * set water height h in all interior grid cells (i.e. except ghost layer) * to values specified by parameter function _h */ void SWE_Block::setWaterHeight(float (*_h)(float, float)) { for(int i=1; i<=nx; i++) for(int j=1; j<=ny; j++) { h[i][j] = _h(offsetX + (i-0.5f)*dx, offsetY + (j-0.5f)*dy); }; synchWaterHeightAfterWrite(); }
void SWE::setInitialValues(float(*_h)(float, float), float _u, float _v) { #pragma omp parallel for for (int i = 0; i < nx + 2; i++) { for (int j = 0; j < ny + 2; j++) { h[li(nx + 2, i, j)] = _h((i - 0.5f) * dx, (j - 0.5f) * dy); hu[li(nx + 2, i, j)] = h[li(nx + 2, i, j)] * _u; hv[li(nx + 2, i, j)] = h[li(nx + 2, i, j)] * _v; } } }
/** * Constructor. * * @param Map* map * @param Map::Cell* start cell * @param Map::Cell* goal cell */ Planner::Planner(Map* map, Map::Cell* start, Map::Cell* goal) { // Clear lists _open_list.clear(); _open_hash.clear(); _path.clear(); _km = 0; _map = map; _start = start; _goal = goal; _last = _start; _rhs(_goal, 0.0); _list_insert(_goal, pair<double,double>(_h(_start, _goal), 0)); }
void Mono_Posix_Stdlib_InvokeSignalHandler (int signum, void *handler) { mph_sighandler_t _h = (mph_sighandler_t) handler; _h (signum); }
inline std::size_t hash_value(const ctorTeller& t) { //ctorTeller::display("in const hash"); boost::hash<const std::string&> _h; return _h(t.name()); }
/** * Update map. * * @param Map::Cell* cell to update * @param double new cost of the cell * @return void */ void Planner::update(Map::Cell* u, double cost) { if (u == _goal) return; // Update km _km += _h(_last, _start); _last = _start; _cell(u); double cost_old = u->cost; double cost_new = cost; u->cost = cost; Map::Cell** nbrs = u->nbrs(); double tmp_cost_old, tmp_cost_new; double tmp_rhs, tmp_g; // Update u for (unsigned int i = 0; i < Map::Cell::NUM_NBRS; i++) { if (nbrs[i] != NULL) { u->cost = cost_old; tmp_cost_old = _cost(u, nbrs[i]); u->cost = cost_new; tmp_cost_new = _cost(u, nbrs[i]); tmp_rhs = _rhs(u); tmp_g = _g(nbrs[i]); if (Math::greater(tmp_cost_old, tmp_cost_new)) { if (u != _goal) { _rhs(u, min(tmp_rhs, (tmp_cost_new + tmp_g))); } } else if (Math::equals(tmp_rhs, (tmp_cost_old + tmp_g))) { if (u != _goal) { _rhs(u, _min_succ(u).second); } } } } _update(u); // Update neighbors for (unsigned int i = 0; i < Map::Cell::NUM_NBRS; i++) { if (nbrs[i] != NULL) { u->cost = cost_old; tmp_cost_old = _cost(u, nbrs[i]); u->cost = cost_new; tmp_cost_new = _cost(u, nbrs[i]); tmp_rhs = _rhs(nbrs[i]); tmp_g = _g(u); if (Math::greater(tmp_cost_old, tmp_cost_new)) { if (nbrs[i] != _goal) { _rhs(nbrs[i], min(tmp_rhs, (tmp_cost_new + tmp_g))); } } else if (Math::equals(tmp_rhs, (tmp_cost_old + tmp_g))) { if (nbrs[i] != _goal) { _rhs(nbrs[i], _min_succ(nbrs[i]).second); } } _update(nbrs[i]); } } }
void peano::applications::faxen::lbf::mappings::RegularGrid2BlockVTKOutput::touchVertexFirstTime( peano::applications::faxen::lbf::RegularGridBlockVertex& vertex, const tarch::la::Vector<DIMENSIONS,double>& x ) { logTraceInWith2Arguments( "touchVertexFirstTime()", x, vertex ); peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance(). loadVertex(vertex.getVertexNumber()); std::bitset<LB_BLOCK_NUMBER_OF_CELLS>& inner(peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getInner()); tarch::la::Vector<LB_BLOCK_NUMBER_OF_CELLS*DIMENSIONS,double >& velocity(peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVelocity()); tarch::la::Vector<DIMENSIONS,double> velocityBuffer(0.0); tarch::la::Vector<LB_BLOCK_NUMBER_OF_CELLS,double>& density(peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getDensity()); tarch::la::Vector<DIMENSIONS,double> position(0.0); tarch::la::Vector<DIMENSIONS,double> currentVertexPosition(0.0); int vertexIndex[TWO_POWER_D]; int cellCounter = 0; int vertexCounter = 0; int cellNumber; #if (DIMENSIONS == 3) for (int zc = 0; zc < LB_BLOCKSIZE; zc++){ position(2) = x(2) - 0.5*LB_BLOCKSIZE*_h(2) + zc*_h(2); #endif for (int yc= 0; yc < LB_BLOCKSIZE; yc++){ position(1) = x(1) - 0.5*LB_BLOCKSIZE*_h(1) + yc*_h(1); for (int xc=0; xc < LB_BLOCKSIZE; xc++){ position(0) = x(0) - 0.5*LB_BLOCKSIZE*_h(0) + xc*_h(0); // if the current cell is inner, plot it and its vertices if (inner[cellCounter]){ logDebug("touchVertexFirstTime()", "Cell " << cellCounter << " at position " << position << "," << _h << " is an inner cell"); // vertex plotting vertexCounter = 0; #if (DIMENSIONS == 3) for (int zv = 0; zv < 2; zv++){ currentVertexPosition(2) = position(2) + _h(2)*zv; #endif for (int yv = 0; yv < 2; yv++){ currentVertexPosition(1) = position(1) + _h(1)*yv; for (int xv = 0; xv < 2; xv++){ currentVertexPosition(0) = position(0) + _h(0)*xv; // if this vertex is not already in map, put it in and plot it if (_vertex2IndexMap.find(currentVertexPosition) == _vertex2IndexMap.end()){ int vertexNumber = _vertexWriter->plotVertex(currentVertexPosition); _vertex2IndexMap[currentVertexPosition] = vertexNumber; vertexIndex[vertexCounter] = vertexNumber; // otherwise: just get its number } else { vertexIndex[vertexCounter] = _vertex2IndexMap.find(currentVertexPosition)->second; } vertexCounter++; } } #if (DIMENSIONS == 3) } #endif // cell plotting #if (DIMENSIONS == 2) cellNumber = _cellWriter->plotQuadrangle(vertexIndex); #elif (DIMENSIONS == 3) cellNumber = _cellWriter->plotHexahedron(vertexIndex); #else #error "Only 2D/ 3D supported!" #endif // get velocity and put it into buffer for (int d = 0; d < DIMENSIONS; d++){ velocityBuffer[d] = velocity[cellCounter*DIMENSIONS+d]; } _densityWriter->plotCell(cellNumber,density[cellCounter]); _velocityWriter->plotCell(cellNumber,velocityBuffer); //#if defined(Debug) && (!defined(Parallel)) // write block id _blockIdWriter->plotCell(cellNumber,_blockCounter); //#endif } // end is inner cell cellCounter++; } } #if (DIMENSIONS == 3) } #endif //#if defined(Debug) && (!defined(Parallel)) // increment blockCounter _blockCounter++; //#endif logTraceOutWith1Argument( "touchVertexFirstTime()", vertex ); }