예제 #1
0
파일: kv.c 프로젝트: nsutter/SE_projet
/*
 * @brief Gestion du .blk lors de l'ajout d'un couple key/val
 *
 * Si un index de bloc existe déjà :
 *  -> écriture de offset_key dans ce bloc (avec gestion de bloc plein)
 * Sinon :
 * -> création d'un nouveau bloc et écriture de l'index de ce bloc dans le .h
 * -> écriture de offset_key dans ce bloc (avec gestion de bloc plein)
 *
 * @param kv descripteur d'accès à la base
 * @param key clé
 * @param offset_key index du couple dans le .kv
 */
int kv_put_blk(KV *kv, const kv_datum *key, len_t *offset_key)
{
    len_t val_h, offset_h;

    int offset_int = hash(key->ptr, kv);

    if(offset_int == -1)
    {
        return -1;
    }
    else
    {
        offset_h = offset_int;
    }

    int n = read_h(kv, offset_h, &val_h);

    if(n == -1) {
        return -1;
    }

    if(!n || val_h == 0) // clé pas hachée
    {
        len_t offset_new_bloc;

        if(new_bloc(kv, &offset_new_bloc) == -1) {
            return -1;
        }
        if(write_h(kv, offset_h, offset_new_bloc) == -1) {
            return -1;
        }
        if(write_bloc(kv, offset_new_bloc, offset_key) == -1) {
            return -1;
        }
    }
    else // clé déjà hachée
    {
        if(write_bloc(kv, val_h, offset_key) == -1) {
            return -1;
        }
    }

    return 42;
}
예제 #2
0
// TODO make it more general
void Foam::calcTypes::fieldMap2d::calc
(
  const argList& args,
  const Time& runTime,
  const fvMesh& mesh
)
{
  // coordinates of points on the surface of the fracture walls
  //memInfo mf;
  
  // print what is calculated
  if(processingType_ == "all")
    Info << "Processing all fields..." << endl;
  else if(processingType_ == "surf")
    Info << "Calculating csurf and h" << endl;
  else if(processingType_ == "int")
    Info << "Calculating C, qx and qy" << endl;
  else if(processingType_ == "h")
    Info << "Processing the aperture of the fracture..." << endl;
  else if(processingType_ == "U")
    Info << "Processing the flux qx and qy..." << endl;
  else if(processingType_ == "p")
    FatalError<<"p processing is not implemented yet"<<nl<<exit(FatalError);
  else if(processingType_ == "C")
    Info << "Processing the concentration field..." << endl;
  else if(processingType_ == "csurf")
    Info << "Calculating concentration on the surface" << endl;
  else if(processingType_ == "temp")
    Info << "Running temporary function..." << endl;
  else if(processingType_ == "ccAll")
    Info << "Processing all fields for concentric cylinder geometry" << endl;
  else
    FatalError<<"Unable to process "<<processingType_<<nl<<exit(FatalError);
  
  for(int cI=0; cI<totNumLoop; cI++)
  {
    curNum = cI;
    curBlock = thisTimeSize * curNum;
    
    sizeAA = thisTimeSize;
    if(cI==totNumLoop-1){
      sizeAA = N1M1 - (totNumLoop-1)*thisTimeSize;
    }

    Info << "Find the points on the surface"<<nl;
    pointsXYonsurface.clear();
    pointsXYonsurface.setSize( expNI * sizeAA );
    
    if(geometry=="flat")
    {
      build_surface_points( mesh );
    }
    else if(geometry=="concentricCylinders")
    {
      build_surface_pointsCC( mesh );
    }
    Info << "build_surface_points done"<<nl;
    
    fileName current_dissolCalc_dir;
    current_dissolCalc_dir = "postProcessing/dissolCalc" / runTime.timeName();
    if ( !isDir(current_dissolCalc_dir) ) mkDir(current_dissolCalc_dir);
    
    if(processingType_ == "all"){
      write_all(mesh, runTime);
    }
    else if(processingType_ == "surf"){
      write_surf(mesh, runTime);
    }
    else if(processingType_ == "int"){
      write_int(mesh, runTime);
    }
    else if(processingType_ == "h"){
      write_h(mesh, runTime);
    }
    else if(processingType_ == "U"){
      write_q(mesh, runTime);
    }
    else if(processingType_ == "C"){
      write_Ccup(mesh, runTime);
    }
    else if(processingType_ == "csurf"){
      write_csurf(mesh, runTime);
    }
    else if(processingType_ == "temp"){
      write_temp(mesh, runTime);
    }
    else if(processingType_ == "ccAll"){
      write_ccAll(mesh, runTime);
    }
    else{
      FatalError<<"Unable to process "<<processingType_<<nl<<nl<<exit(FatalError);
    }
  }
}