Beispiel #1
0
// #################################################################
// DFIファイル:ファイル名要素を出力する
bool DFI::Write_OutFileName(FILE* fp, const unsigned tab, const std::string prefix, const unsigned step, const int id, const bool mio)
{
  char fname[FB_FILE_PATH_LENGTH];
  memset(fname, 0, sizeof(char)*FB_FILE_PATH_LENGTH);
  std::string tmp = Generate_FileName(prefix, step, id, mio);

  //if( !path_util::GetFullPathName(tmp.c_str(), fname, FB_FILE_PATH_LENGTH) ) {
  //  return false;
  //}
  strcpy(fname, tmp.c_str());

  if (fp) Write_Tab(fp, tab+1);
  if (fp) fprintf(fp, "FileName[@] = \"%s\"\n", fname);

  return true;
}
Beispiel #2
0
// #################################################################
// 座標値データファイルの出力
bool cio_DFI_AVS::write_avs_cord(double min_ext[3],
                                 double max_ext[3])
{

  FILE* fp=NULL;

  //ファイル名の作成
  bool mio = false;
  if( DFI_MPI.NumberOfRank > 1 ) mio = true;
  
  std::string fname,tmp;
  tmp = Generate_FileName("cord",m_RankID,-1,"cod",m_output_fname,mio,
                          DFI_Finfo.TimeSliceDirFlag);
  if( CIO::cioPath_isAbsolute(DFI_Finfo.DirectoryPath) ){
    fname = DFI_Finfo.DirectoryPath + "/" + tmp;
  } else {
    fname = m_directoryPath + "/" + DFI_Finfo.DirectoryPath +"/"+ tmp;
  }

  //printf("cord file name : %s\n",fname.c_str());

  //座標値データファイルオープン
  if( (fp = fopen(fname.c_str(),"w"))  == NULL ) {
    printf("\tCan't open file.(%s)\n",fname.c_str());
    return false;
  }

  //座標値データ(min,max)の出力
  fprintf(fp,"#### X #####\n");
  fprintf(fp,"%.6f\n",min_ext[0]);
  fprintf(fp,"%.6f\n",max_ext[0]);
  fprintf(fp,"#### Y #####\n");
  fprintf(fp,"%.6f\n",min_ext[1]);
  fprintf(fp,"%.6f\n",max_ext[1]);
  fprintf(fp,"#### Z #####\n");
  fprintf(fp,"%.6f\n",min_ext[2]);
  fprintf(fp,"%.6f\n",max_ext[2]);

  //座標値データファイルクローズ
  fclose(fp);

  return true;

}
Beispiel #3
0
// #################################################################
// fileld data 出力
CIO::E_CIO_ERRORCODE
cio_DFI::WriteData(const unsigned step,
                   const int gc,
                   double time,
                   cio_Array* val,
                   double* minmax,
                   const bool avr_mode,
                   const unsigned step_avr,
                   double time_avr)
{

  //printf("WriteData RankID : %d\n",m_RankID);

  bool mio=false;
  if( DFI_MPI.NumberOfRank > 1 ) mio=true;

  std::string outFile,tmp;
//FCONV 20131128.s
  if( m_output_fname != CIO::E_CIO_FNAME_RANK_STEP ) {
    tmp = Generate_FieldFileName(m_RankID,step,mio);
    if( CIO::cioPath_isAbsolute(DFI_Finfo.DirectoryPath) ){
      outFile = tmp;
    } else {
      outFile = m_directoryPath + "/"+ tmp;
    }
  } else {
    std::string ext;
    if( DFI_Finfo.FileFormat == CIO::E_CIO_FMT_SPH ) {
      ext = D_CIO_EXT_SPH;
    } else if( DFI_Finfo.FileFormat == CIO::E_CIO_FMT_BOV ) {
      ext = D_CIO_EXT_BOV;
    } else if( DFI_Finfo.FileFormat == CIO::E_CIO_FMT_AVS ) {
      //ext = D_CIO_EXT_SPH;
      ext = D_CIO_EXT_BOV;
    } else if( DFI_Finfo.FileFormat == CIO::E_CIO_FMT_VTK ) {
      ext = D_CIO_EXT_VTK;
    } else if( DFI_Finfo.FileFormat == CIO::E_CIO_FMT_PLOT3D ) {
      ext = D_CIO_EXT_FUNC;
    }
    tmp = Generate_FileName(DFI_Finfo.Prefix,
                            m_RankID,
                            step,ext,
                            m_output_fname,
                            mio,
                            DFI_Finfo.TimeSliceDirFlag);
    if( CIO::cioPath_isAbsolute(DFI_Finfo.DirectoryPath) ){
      outFile = DFI_Finfo.DirectoryPath +"/"+ tmp;
    } else {
      outFile = m_directoryPath + "/" + DFI_Finfo.DirectoryPath +"/"+ tmp;
    }
  }
//FCONV 20131128.e

  std::string dir = CIO::cioPath_DirName(outFile);

  if( MakeDirectory(dir) != 1 ) return CIO::E_CIO_ERROR_MAKEDIRECTORY;

  cio_Array *outArray = val;
  if( gc != DFI_Finfo.GuideCell ) {
    //出力用バッファのインスタンス
    outArray = cio_Array::instanceArray
               ( DFI_Finfo.DataType
               , DFI_Finfo.ArrayShape
               , DFI_Process.RankList[m_RankID].VoxelSize
               , DFI_Finfo.GuideCell
               , DFI_Finfo.Component); 
    //配列のコピー val -> outArray
    int ret = val->copyArray(outArray);
  }

  // フィールドデータの出力
  CIO::E_CIO_ERRORCODE err = CIO::E_CIO_SUCCESS;
  err = WriteFieldData(outFile, step, time, outArray, avr_mode, step_avr, time_avr);

  //出力バッファのメモリ解放
  if( val != outArray ) {
    delete outArray;
  }

  if( err != CIO::E_CIO_SUCCESS ) return err;

//FCONV 20131218.s
  if( m_indexDfiName != "" ) {
    //index dfi ファイルのディレクトリ作成
    cio_DFI::MakeDirectory(m_directoryPath);
    std::string dfiname = CIO::cioPath_FileName(m_indexDfiName,".dfi");
    std::string fname = CIO::cioPath_ConnectPath( m_directoryPath, dfiname );

    //Slice へのセット
    DFI_TimeSlice.AddSlice(step, time, minmax, DFI_Finfo.Component, avr_mode,
                           step_avr, time_avr);

    //index dfi のファイル出力
    if( m_RankID == 0 ) {
      err = WriteIndexDfiFile(fname);
    }
  }
//FCONV 20131218.e
//FCONV 20131125.s
  if( !write_ascii_header(step,time) ) return CIO::E_CIO_ERROR;
//FCONV 20131125.e

  return err;
}
Beispiel #4
0
// #################################################################
// ヘッダーデータファイルの出力
bool cio_DFI_AVS::write_avs_header()
{
  FILE* fp=NULL;
  std::string dType;
  std::string out_fname;

  bool mio=false;

  //データタイプのセット
  if( GetDataType() == CIO::E_CIO_INT8 ) {
    dType = "byte";
  } else if( GetDataType() == CIO::E_CIO_INT16 ) {
    dType = "short";
  } else if( GetDataType() == CIO::E_CIO_INT32 ) {
    dType = "integer";
  } else if( GetDataType() == CIO::E_CIO_FLOAT32 ) {
    dType = "float";
  } else if( GetDataType() == CIO::E_CIO_FLOAT64 ) {
    dType = "double";
  } else {
    dType = GetDataTypeString();
    printf("\tillergal data type.(%s)\n",dType.c_str());
    return false;
  }

  //ファイル名生成

  if( DFI_MPI.NumberOfRank > 1 ) mio = true;
  std::string fname,tmp;
  tmp = Generate_FileName(DFI_Finfo.Prefix,m_RankID,-1,"fld",m_output_fname,mio,
                          DFI_Finfo.TimeSliceDirFlag);
  if( CIO::cioPath_isAbsolute(DFI_Finfo.DirectoryPath) ){
    fname = DFI_Finfo.DirectoryPath +"/"+ tmp;
  } else {
    fname = m_directoryPath + "/" + DFI_Finfo.DirectoryPath +"/"+ tmp;
  }

  //printf("fld file name : %s\n",fname.c_str());

  //出力ヘッダーファイルオープン
  if( (fp = fopen(fname.c_str(),"w"))  == NULL ) {
    printf("\tCan't open file.(%s)\n",fname.c_str());
    return false;
  }

  int ndim = 3;
  int nspace = 3;
  //dims = DFI_Process.RankList[m_RankID].VoxelSize[0]

  //先頭レコードの出力
  fprintf(fp,"# AVS field file\n");

  //計算空間の次元数を出力
  fprintf(fp,"ndim=%d\n",ndim);

  //計算空間サイズを出力
  fprintf(fp,"dim1=%d\n",DFI_Process.RankList[m_RankID].VoxelSize[0]+1);
  fprintf(fp,"dim2=%d\n",DFI_Process.RankList[m_RankID].VoxelSize[1]+1);
  fprintf(fp,"dim3=%d\n",DFI_Process.RankList[m_RankID].VoxelSize[2]+1);

  //物理空間の次元数を出力
  fprintf(fp,"nspace=%d\n",nspace);

  //成分数の出力
  fprintf(fp,"veclen=%d\n",DFI_Finfo.Component);

  //データのタイプ出力
  fprintf(fp,"data=%s\n",dType.c_str());

  //座標定義情報の出力
  fprintf(fp,"field=uniform\n");

  //labelの出力
  for(int i=0; i<DFI_Finfo.Component; i++) {
    std::string label=getComponentVariable(i);
    if( label == "" ) continue;
    fprintf(fp,"label=%s\n",label.c_str());
  }

  //step毎の出力
  if( DFI_TimeSlice.SliceList.size()>1 ) {
    fprintf(fp,"nstep=%d\n",(int)DFI_TimeSlice.SliceList.size());
  }
  for(int i=0; i<DFI_TimeSlice.SliceList.size(); i++) {
    fprintf(fp,"time value=%.6f\n",DFI_TimeSlice.SliceList[i].time);

    //field data file name 出力
    for(int j=1; j<=DFI_Finfo.Component; j++) {
      int skip;
      if( dType == "float" ) {
        skip=96+(j-1)*4;
      } else {
        skip=140+(j-1)*8;
      }
      out_fname=Generate_FileName(DFI_Finfo.Prefix,
                                  m_RankID,
                                  DFI_TimeSlice.SliceList[i].step,
                                  "sph",
                                  m_output_fname,
                                  mio,
                                  DFI_Finfo.TimeSliceDirFlag);
      //std::string xxx = CIO::cioPath_FileName(out_fname,"sph");
      fprintf(fp,"variable %d file=%s filetype=binary skip=%d stride=%d\n",
              j,out_fname.c_str(),skip,DFI_Finfo.Component);
    }

    //coord data file name 出力
    tmp = Generate_FileName("cord",m_RankID,-1,"cod",m_output_fname,mio,
                            DFI_Finfo.TimeSliceDirFlag);
    fprintf(fp,"coord 1 file=%s filetype=ascii skip=1\n",tmp.c_str());
    fprintf(fp,"coord 2 file=%s filetype=ascii skip=4\n",tmp.c_str());
    fprintf(fp,"coord 3 file=%s filetype=ascii skip=7\n",tmp.c_str());
    fprintf(fp,"EOT\n");
    
  }

  //出力ヘッダーファイルクローズ
  fclose(fp);

  //if( tmp ) delete tmp;

  return true;
}