Exemplo n.º 1
0
void main(void) 
{
    int k;
    Queue* q = qCreate(10);
    for (int i = 0; i < 16; ++i) {
        qEnqueue(q, i);
    }
    while (!qEmpty(q)) {
        printf("%d ", qDequeue(q));
        printf(" (size left = %d)\n",  qSize(q));
    }
    for (int i = 0; i < 16; ++i) {
        qEnqueue(q, i);
        printf("(size = %d)\n",  qSize(q));
    }

    Stack s;
    stackCreate(&s, 128);

    for (int i = 0; i < 255; ++i) {
        stackPush(&s, i);
    }

    while (!stackEmpty(&s)) {
        printf("%d ", stackTop(&s));
        stackPop(&s);
    }
}
Exemplo n.º 2
0
int
setSize(SET set)
{
    if (SET_Ord(set))
	return avlSize(set->telts);

    return qSize(set->qelts);
}
Exemplo n.º 3
0
/* Removes the element on top of the stack */
void stackPop(Stack *stack) {
    int qsize = qSize(stack->q);
    int buf[qsize];

    int i = 0;
    while (!qEmpty(stack->q)) {
        buf[i++] = qDequeue(stack->q);
    }

    for (i = 0; i < qsize -1; ++i) {
        qEnqueue(stack->q, buf[i]);
    }
}
Exemplo n.º 4
0
/* Get the top element */
int stackTop(Stack *stack) {
    int qsize = qSize(stack->q);
    int buf[qsize];

    int i = 0;
    while (!qEmpty(stack->q)) {
        buf[i++] = qDequeue(stack->q);
    }

    for (i = 0; i < qsize; ++i) {
        qEnqueue(stack->q, buf[i]);
    }

    return buf[i - 1];
}
void peano::applications::latticeboltzmann::blocklatticeboltzmann::cca::BlockLatticeBoltzmannBatchJobForRegularGridImplementation::getData(const long long& scope, const double* boundingBoxOffset,long boundingBoxOffset_len, const double* boundingBox,long boundingBox_len, const long long* resolution,long resolution_len, double* data,long data_len){
  std::cout<<"execute 3d query"<<std::endl;
  tarch::la::Vector<DIMENSIONS,double> qOffset(0.0);
  tarch::la::Vector<DIMENSIONS,double> qSize(0.0);
  tarch::la::Vector<DIMENSIONS,int> dims(0.0);
  for(int i=0;i<DIMENSIONS;i++){
      qOffset[i]=boundingBoxOffset[i];
      qSize[i]=boundingBox[i];
      dims[i]=(int)resolution[i];
  }
  int records_per_entry=DIMENSIONS;
  peano::integration::dataqueries::DataQuery query;
  //_queryid++;
  query.setId(0);
  query.setBoundingBoxOffset(qOffset);
  query.setBoundingBox(qSize);
  query.setResolution(dims);
  if (scope==0) {

      query.setRecordsPerEntry(DIMENSIONS);
      query.setScope( peano::applications::latticeboltzmann::blocklatticeboltzmann::mappings::RegularGrid2BlockCCAOutput::Velocity);
  }
  else if (scope==1) {
      query.setRecordsPerEntry(DIMENSIONS);
      query.setScope( peano::applications::latticeboltzmann::blocklatticeboltzmann::mappings::RegularGrid2BlockCCAOutput::Density);
      records_per_entry=1;
  }
  else {

      return;
  }

  tarch::plotter::griddata::regular::cca::CCAGridArrayWriter writer(
      query.getResolution(),
      query.getBoundingBox(),
      query.getBoundingBoxOffset()
  );

  peano::integration::dataqueries::QueryServer::getInstance().addQuery(
      "query",records_per_entry ,query, writer
  );
  switchToRegularBlockSolverAdapter();
  _repository->iterate();
  switchToBlockCCAOutputAdapter();
  _repository->iterate();
  scenario::latticeboltzmann::blocklatticeboltzmann::services::ReceiveBoundaryDataService::getInstance().advance(_repository->getRegularGridState().getDt());

  //std::cout<<"starting cAdapter"<<std::endl;

  //    runner.runCartesianGridAdapter();
  writer.writeToVertexArray(data,data_len);
  //  //  writer.writeToFile(
  //  //      "/home_local/atanasoa/query.vtk");
  //    if (scope==1){
  //        if(_queryid<=3)
  //          for(int i=0;i<10;i++)
  //            runner.runOneStep();
  //        else
  //          runner.runOneStep();
  //    }
}