⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pos_format.c

📁 cfd求解器使用与gmsh网格的求解
💻 C
📖 第 1 页 / 共 3 页
字号:
    if(NbrNodes > 1) fprintf(PostStream, "\n");    Free(TmpValues);  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  F o r m a t _ T a b u l a r                                             *//* ------------------------------------------------------------------------ */void  Format_Tabular(int Format, double Time, int TimeStep, int NbrTimeSteps,		     int NbrHarmonics, int HarmonicToTime, 		     int ElementType, int NumElement, int NbrNodes,		     double *x, double *y, double *z, double *Dummy,		     struct Value *Value){  static int  Size ;  int         i,j,k ;  double      TimeMH ;  struct Value  TmpValue ;  GetDP_Begin("Format_Tabular");  if(TimeStep == 0){    switch(Value->Type){    case SCALAR      : Size = 1 ; break ;    case VECTOR      : Size = 3 ; break ;    case TENSOR_DIAG : Size = 3 ; break ;    case TENSOR_SYM  : Size = 6 ; break ;    case TENSOR      : Size = 9 ; break ;    }  }  if(Format == FORMAT_SPACE_TABLE){    if(TimeStep == 0){      fprintf(PostStream, "%d %d ", Get_GmshElementType(ElementType), NumElement);      for(i=0 ; i<NbrNodes ; i++)	fprintf(PostStream, " %.16g %.16g %.16g ", x[i], y[i], z[i]);      if(Dummy) 	fprintf(PostStream, " %.16g %.16g %.16g ", Dummy[0], Dummy[1],  Dummy[2]);      else	fprintf(PostStream, " 0 0 0 ");    }  }  if (HarmonicToTime == 1) {    if(Format == FORMAT_TIME_TABLE){      fprintf(PostStream, "%d %.16g ", TimeStep, Time);      for(i=0 ; i<NbrNodes ; i++)	fprintf(PostStream, " %.16g %.16g %.16g ", x[i], y[i], z[i]);    }    for(k = 0 ; k < NbrHarmonics ; k++) {      for(i = 0 ; i < NbrNodes ; i++){	for(j = 0 ; j < Size ; j++){	  fprintf(PostStream, " %.16g", Value[i].Val[MAX_DIM*k+j]);	}	fprintf(PostStream, " ");      }      fprintf(PostStream, " ");    }  }  else {    for(k = 0 ; k < HarmonicToTime ; k++){      for(i = 0 ; i < NbrNodes ; i++){	F_MHToTime0(k+i, &Value[i], &TmpValue, k, HarmonicToTime, &TimeMH) ;	if (!i && Format == FORMAT_TIME_TABLE) {	  fprintf(PostStream, "%d %.16g ", TimeStep, TimeMH);	  for(i=0 ; i<NbrNodes ; i++)	    fprintf(PostStream, " %.16g %.16g %.16g ", x[i], y[i], z[i]);	}	for(j = 0 ; j < Size ; j++)	  fprintf(PostStream, " %.16g", TmpValue.Val[j]) ;	fprintf(PostStream, " ");      }      if(Format == FORMAT_TIME_TABLE)	fprintf(PostStream, "\n");    }  }  if(TimeStep == NbrTimeSteps-1 || Format == FORMAT_TIME_TABLE)    fprintf(PostStream, "\n");  GetDP_End ;}void  Format_Adapt(double * Dummy){  GetDP_Begin("Format_Adapt");  if(Dummy[4]) fprintf(PostStream, "%d\n", (int)Dummy[4]) ;  fprintf(PostStream, "%d %g %g %g\n", 	  (int)Dummy[0], Dummy[1], Dummy[2], Dummy[3]);  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  F o r m a t _ P o s t E l e m e n t                                     *//* ------------------------------------------------------------------------ */void  Format_PostElement(int Format, int Contour, int Store, 			 double Time, int TimeStep, int NbTimeStep, 			 int NbrHarmonics, int HarmonicToTime, double *Dummy,			 struct PostElement * PE, 			 int *ChangeOfCoordinates,			 List_T *ChangeOfValues){  int    i, j, k, l, Num_Element ;  struct PostElement  * PE2 ;  struct Value          Value ;  static int Warning_FirstHarmonic = 0 ;  GetDP_Begin("Format_PostElement");  if(PE->Index != NO_ELEMENT)    Num_Element = Geo_GetGeoElement(PE->Index)->Num ;  else    Num_Element = 0 ;  if(Contour){    if(PE->Value[0].Type != SCALAR)      Msg(GERROR, "Non scalar Element %d in contour creation", Num_Element);    if(NbTimeStep != 1)      Msg(GERROR, "Contour creation not allowed for multiple time steps");    if(Current.NbrHar != 1 && !Warning_FirstHarmonic){      Msg(WARNING, "Contour creation done only for first harmonic (use Re[] or Im[])");      Warning_FirstHarmonic = 1 ;    }    if(Store)      List_Add(PostElement_L, &PE) ;    else{      PE2 = PartialCopy_PostElement(PE) ;      List_Add(PostElement_L, &PE2) ;    }    GetDP_End ;  }  if(ChangeOfCoordinates && ChangeOfCoordinates[0] >= 0){    for(i=0 ; i<PE->NbrNodes ; i++){      Current.x = PE->x[i];      Current.y = PE->y[i];      Current.z = PE->z[i];      for(j = 0; j<9 ; j++) Current.Val[j] = PE->Value[i].Val[j];      Get_ValueOfExpressionByIndex(ChangeOfCoordinates[0], NULL, 0., 0., 0., &Value) ;       PE->x[i] = Value.Val[0];      Get_ValueOfExpressionByIndex(ChangeOfCoordinates[1], NULL, 0., 0., 0., &Value) ;       PE->y[i] = Value.Val[0];      Get_ValueOfExpressionByIndex(ChangeOfCoordinates[2], NULL, 0., 0., 0., &Value) ;       PE->z[i] = Value.Val[0];    }  }  if(ChangeOfValues && List_Nbr(ChangeOfValues) > 0){    for(i=0 ; i<PE->NbrNodes ; i++){      Current.x = PE->x[i];      Current.y = PE->y[i];      Current.z = PE->z[i];      for(k=0 ; k<Current.NbrHar ; k++){	for(j = 0; j<9 ; j++) Current.Val[j] = PE->Value[i].Val[MAX_DIM*k+j];	for(l=0 ; l<List_Nbr(ChangeOfValues) ; l++){	  Get_ValueOfExpressionByIndex(*(int*)List_Pointer(ChangeOfValues, l), 				       NULL, 0., 0., 0., &Value) ; 	  PE->Value[i].Val[MAX_DIM*k+l] = Value.Val[0];	}      }    }  }  switch(Format){  case FORMAT_GMSH_PARSED :    Format_GmshParsed(Time, TimeStep, NbTimeStep, NbrHarmonics, HarmonicToTime,		      PE->Type, PE->NbrNodes, PE->x, PE->y, PE->z, 		      PE->Value) ;    break ;  case FORMAT_GMSH :    if(Flag_BIN){/* bricolage */      Format_Gmsh(Time, TimeStep, NbTimeStep, NbrHarmonics, HarmonicToTime,		  PE->Type, PE->NbrNodes, PE->x, PE->y, PE->z, 		  PE->Value) ;    }    else{      Format_GmshParsed(Time, TimeStep, NbTimeStep, NbrHarmonics, HarmonicToTime,			PE->Type, PE->NbrNodes, PE->x, PE->y, PE->z, 			PE->Value) ;    }    break ;  case FORMAT_GNUPLOT :    Format_Gnuplot(Format, Time, TimeStep, NbTimeStep, NbrHarmonics, HarmonicToTime,		   PE->Type, Num_Element, PE->NbrNodes, PE->x, PE->y, PE->z, Dummy, 		   PE->Value) ;    break ;  case FORMAT_SPACE_TABLE :  case FORMAT_TIME_TABLE :    Format_Tabular(Format, Time, TimeStep, NbTimeStep, NbrHarmonics, HarmonicToTime,		   PE->Type, Num_Element, PE->NbrNodes, PE->x, PE->y, PE->z, Dummy, 		   PE->Value) ;    break ;  case FORMAT_ADAPT:    Format_Adapt(Dummy) ;    break ;  default :    Msg(GERROR, "Unknown format in Format_PostElement");  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  F o r m a t _ P o s t V a l u e                                         *//* ------------------------------------------------------------------------ */void  Format_PostValue(int Format, int Flag_Comma, int Group_FunctionType,		       double Time, int iRegion, int numRegion, int NbrRegion,		       int NbrHarmonics, int HarmonicToTime, int Flag_NoNewLine,		       struct Value * Value) {  static int  Size ;  int  j, k ;  double TimeMH, Freq ;  double x, y, z ;  static struct Value  TmpValue, *TmpValues ;  GetDP_Begin("Format_PostValue");  if(iRegion == 0){    switch(Value->Type){    case SCALAR      : Size = 1 ; break ;    case VECTOR      : Size = 3 ; break ;    case TENSOR_DIAG : Size = 3 ; break ;    case TENSOR_SYM  : Size = 6 ; break ;    case TENSOR      : Size = 9 ; break ;    }  }  if (Format == FORMAT_REGION_TABLE) {    if(iRegion == 0){      fprintf(PostStream, "%d\n", NbrRegion) ;    }    fprintf(PostStream, "%d", numRegion) ;    for (k = 0 ; k < NbrHarmonics ; k++) {      for(j = 0 ; j < Size ; j++) {	if (Flag_Comma) fprintf(PostStream, ",");	fprintf(PostStream, " %.16g", Value->Val[MAX_DIM*k+j]) ;      }      fprintf(PostStream, "\n") ;    }  }  else if (Format == FORMAT_GMSH) {    if (Group_FunctionType == NODESOF)      Geo_GetNodesCoordinates(1, &numRegion, &x, &y, &z) ;    else {      x=y=z=0.;      Msg(WARNING,	  "Post Format \'Gmsh\' not adapted for global quantities supported"	  " by Regions. Zero coordinates are considered.") ;    }    Format_GmshParsed(Time, 0, 1, NbrHarmonics, HarmonicToTime,		      POINT, 1, &x, &y, &z,		      Value) ;  }  else {    if(iRegion == 0){      TmpValues = (struct Value*) Malloc(NbrRegion*sizeof(struct Value)) ;    }    Cal_CopyValue(Value, &TmpValues[iRegion]) ;    if (iRegion == NbrRegion-1) {      if (HarmonicToTime == 1) {	switch (Format) {	case FORMAT_FREQUENCY_TABLE :	  if (NbrHarmonics == 1)	    Msg(GERROR, "FrequencyTable format not allowed (only one harmonic)") ;	  break ;	default :	  fprintf(PostStream, "%.16g ", Time) ;	  break ;	}	for (iRegion = 0 ; iRegion < NbrRegion ; iRegion++)	  for (k = 0 ; k < NbrHarmonics ; k++) {	    if (Format == FORMAT_FREQUENCY_TABLE && !(k%2) && iRegion==0) {	      Freq = Current.DofData->Val_Pulsation[0] / TWO_PI ;	      fprintf(PostStream, "%.16g ", Freq) ;	    }	    for(j = 0 ; j < Size ; j++)	      fprintf(PostStream, " %.16g", TmpValues[iRegion].Val[MAX_DIM*k+j]) ;	  }	if (Flag_NoNewLine)	  fprintf(PostStream, "  ") ;	else	  fprintf(PostStream, "\n") ;      }      else {	for(k = 0 ; k < HarmonicToTime ; k++) {	  for (iRegion = 0 ; iRegion < NbrRegion ; iRegion++) {	    F_MHToTime0(k+iRegion, &TmpValues[iRegion], &TmpValue, 			k, HarmonicToTime, &TimeMH) ;	    if (iRegion == 0)  fprintf(PostStream, "%.16g ", TimeMH) ;	    for(j = 0 ; j < Size ; j++)	      fprintf(PostStream, " %.16g", TmpValue.Val[j]) ;	  }	  fprintf(PostStream, "\n") ;	}      }      Free(TmpValues) ;    }  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  F o r m a t _ O O 1                                                     *//* ------------------------------------------------------------------------ */void  Format_OO1(int Format, double Time, int TimeStep, int NbrTimeSteps,		 int NbrHarmonics, int HarmonicToTime, 		 int ElementType, int NumElement, int NbrNodes,		 double *x, double *y, double *z, double *Dummy,		 struct Value *Value){  static int  Size ;  int         i,j,k ;  GetDP_Begin("Format_OO1");  if(TimeStep == 0){    switch(Value->Type){    case SCALAR      : Size = 1 ; break ;    case VECTOR      : Size = 3 ; break ;    case TENSOR_DIAG : Size = 3 ; break ;    case TENSOR_SYM  : Size = 6 ; break ;    case TENSOR      : Size = 9 ; break ;    }  }  if(Format == FORMAT_SPACE_TABLE){    if(TimeStep == 0){      fprintf(PostStream, "%d %d ", Get_GmshElementType(ElementType), NumElement);      for(i=0 ; i<NbrNodes ; i++)	fprintf(PostStream, " %.16g %.16g %.16g ", x[i], y[i], z[i]);      if(Dummy) 	fprintf(PostStream, " %.16g %.16g %.16g ", Dummy[0], Dummy[1],  Dummy[2]);      else	fprintf(PostStream, " 0 0 0 ");    }  }  if (HarmonicToTime == 1) {    if(Format == FORMAT_TIME_TABLE){      fprintf(PostStream, "%d %.16g ", TimeStep, Time);      for(i=0 ; i<NbrNodes ; i++)	fprintf(PostStream, " %.16g %.16g %.16g ", x[i], y[i], z[i]);    }    for(k = 0 ; k < NbrHarmonics ; k++) {      for(i = 0 ; i < NbrNodes ; i++){	for(j = 0 ; j < Size ; j++){	  fprintf(PostStream, " %.16g", Value[i].Val[MAX_DIM*k+j]);	}	fprintf(PostStream, " ");      }      fprintf(PostStream, " ");    }  }  if(TimeStep == NbrTimeSteps-1 || Format == FORMAT_TIME_TABLE)    fprintf(PostStream, "\n");  GetDP_End ;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -