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

📄 geoentity.c

📁 cfd求解器使用与gmsh网格的求解
💻 C
📖 第 1 页 / 共 2 页
字号:
    Nbr_Entities1 = 0 ;    while ((Entity = *(Entity_P++)))      Num_Entities1[Nbr_Entities1++] = (Entity > 0)?	Geo_Element_NumEntities1[Entity-1] : - Geo_Element_NumEntities1[-Entity-1] ;    qsort(Num_Entities1, Nbr_Entities1, sizeof(int), fcmp_absint) ;    if (Num_Entities1[0] < 0) {      Sign_Entity2 = -1 ;      for (j = 0 ; j < Nbr_Entities1 ; j++)  Num_Entities1[j] *= -1 ;    }    else      Sign_Entity2 = 1 ;    Entity2XEntities1.NbrEntities = Nbr_Entities1 ;    Entity2XEntities1.NumEntities = Num_Entities1 ;    if ((Entity2XEntities1_P = (struct Entity2XEntity1*)	 Tree_PQuery(Geo_Entities2XEntities1, &Entity2XEntities1)) == NULL) {      Entity2XEntities1.Num         = ++(*Geo_NumCurrentEntity2) ;      Entity2XEntities1.NumEntities = (int *)Malloc(Nbr_Entities1*sizeof(int)) ;      for (j = 0 ; j < Nbr_Entities1 ; j++)	Entity2XEntities1.NumEntities[j] = Num_Entities1[j] ;      Tree_Add(Geo_Entities2XEntities1, &Entity2XEntities1) ;      (*Geo_Element_NumEntities2)[i] = Entity2XEntities1.Num    * Sign_Entity2 ;    }    else      (*Geo_Element_NumEntities2)[i] = Entity2XEntities1_P->Num * Sign_Entity2 ;  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  f c m p _ E 2 X E 1                                                     *//* ------------------------------------------------------------------------ */int  fcmp_E2XE1(const void * a, const void * b) {  int  i ;  if (((struct Entity2XEntity1 *)a)->NbrEntities !=      ((struct Entity2XEntity1 *)b)->NbrEntities)    return      ((struct Entity2XEntity1 *)a)->NbrEntities -      ((struct Entity2XEntity1 *)b)->NbrEntities ;  for (i = 0 ; i < ((struct Entity2XEntity1 *)a)->NbrEntities ; i++) {    if (((struct Entity2XEntity1 *)a)->NumEntities[i] >	((struct Entity2XEntity1 *)b)->NumEntities[i])   return  1 ;    if (((struct Entity2XEntity1 *)a)->NumEntities[i] <	((struct Entity2XEntity1 *)b)->NumEntities[i])   return -1 ;  }  return 0 ;}/* ------------------------------------------------------------------------ *//*  G e o _ W r i t e F i l e P R E                                         *//* ------------------------------------------------------------------------ */void  Geo_WriteFilePRE(struct GeoData * GeoData_P, List_T * Group_L) {  int  i, Nbr_Elements, j, Index_Group, Nbr_Entities, * Num_Entities ;  struct Geo_Element  * Geo_Element_P0, * Geo_Element_P ;  struct Group  * Group_P ;  GetDP_Begin("Geo_WriteFilePRE");  Nbr_Elements = List_Nbr(GeoData_P->Elements) ;  /*  E l e m e n t s X E d g e s  */  if (Nbr_Elements && GeoData_P->NumCurrentEdge) {    fprintf(File_PRE, "$ElementsXEdges\n") ;    fprintf(File_PRE, "%d %d\n", GeoData_P->Num, GeoData_P->NbrElementsWithEdges) ;    Geo_Element_P0 = (struct Geo_Element*)List_Pointer(GeoData_P->Elements, 0) ;    for (i = 0 ; i < Nbr_Elements ; i++) {      if ((Geo_Element_P0 + i)->NbrEdges) {	Geo_Element_P = Geo_Element_P0 + i ;	fprintf(File_PRE, "%d %d", i, Geo_Element_P->NbrEdges) ;	for (j = 0 ; j < Geo_Element_P->NbrEdges ; j++)	  fprintf(File_PRE, " %d", Geo_Element_P->NumEdges[j]) ;	fprintf(File_PRE, "\n") ;      }    }    fprintf(File_PRE, "$EndElementsXEdges\n") ;    if (Flag_XDATA) {      fprintf(File_PRE, "$EdgesXNodes  /* Never used, only for test */\n") ;      fprintf(File_PRE, "%d %d\n", GeoData_P->Num, Tree_Nbr(GeoData_P->EdgesXNodes)) ;      Tree_Action(GeoData_P->EdgesXNodes, Geo_WriteEntities2XEntities1) ;      fprintf(File_PRE, "$EndEdgesXNodes\n") ;    }  }  /*  E l e m e n t s X F a c e t s  */  if (Nbr_Elements && GeoData_P->NumCurrentFacet) {    fprintf(File_PRE, "$ElementsXFacets\n") ;    fprintf(File_PRE, "%d %d\n", GeoData_P->Num, GeoData_P->NbrElementsWithFacets) ;    Geo_Element_P0 = (struct Geo_Element*)List_Pointer(GeoData_P->Elements, 0) ;    for (i = 0 ; i < Nbr_Elements ; i++) {      if ((Geo_Element_P0 + i)->NbrFacets) {	Geo_Element_P = Geo_Element_P0 + i ;	fprintf(File_PRE, "%d %d", i, Geo_Element_P->NbrFacets) ;	for (j = 0 ; j < Geo_Element_P->NbrFacets ; j++)	  fprintf(File_PRE, " %d", Geo_Element_P->NumFacets[j]) ;	fprintf(File_PRE, "\n") ;      }    }    fprintf(File_PRE, "$EndElementsXFacets\n") ;    if (Flag_XDATA) {      fprintf(File_PRE, "$FacetsXEdges  /* Never used, only for test */\n") ;      fprintf(File_PRE, "%d %d\n", GeoData_P->Num, Tree_Nbr(GeoData_P->FacetsXEdges)) ;      Tree_Action(GeoData_P->FacetsXEdges, Geo_WriteEntities2XEntities1) ;      fprintf(File_PRE, "$EndFacetsXEdges\n") ;    }  }  /*  E x t e n d e d G r o u p  */  if (GeoData_P->GroupForPRE != NULL) {    for (i = 0 ; i < List_Nbr(GeoData_P->GroupForPRE) ; i++) {      List_Read(GeoData_P->GroupForPRE, i, &Index_Group) ;      Group_P = (struct Group*)List_Pointer(Group_L, Index_Group) ;      fprintf(File_PRE, "$ExtendedGroup  /* %s */\n", Group_P->Name) ;      fprintf(File_PRE, "%d %d\n",	      Index_Group, Nbr_Entities = List_Nbr(Group_P->ExtendedList)) ;      if (Nbr_Entities) {	Num_Entities = (int*)List_Pointer(Group_P->ExtendedList, 0) ;	  for (j = 0 ; j < Nbr_Entities ; j++) {	    fprintf(File_PRE, (j%10)? " %d" : "%d", Num_Entities[j]) ;	    if (j%10 == 9)  fprintf(File_PRE, "\n") ;	  }	if (j%10)  fprintf(File_PRE, "\n") ;	fprintf(File_PRE, "$EndExtendedGroup\n") ;      }    }  }  GetDP_End ;}/* --------------------------------------------------------- *//*  G e o _ W r i t e E n t i t i e s 2 X E n t i t i e s 1  *//* --------------------------------------------------------- */void  Geo_WriteEntities2XEntities1(void * a, void * b) {  int  i ;  GetDP_Begin("Geo_WriteEntities2XEntities1");  fprintf(File_PRE, "%d %d", ((struct Entity2XEntity1 *)a)->Num,	  ((struct Entity2XEntity1 *)a)->NbrEntities) ;  for (i = 0 ; i < ((struct Entity2XEntity1 *)a)->NbrEntities ; i++)    fprintf(File_PRE, " %d", ((struct Entity2XEntity1 *)a)->NumEntities[i]) ;  fprintf(File_PRE, "\n") ;  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  G e o _ R e a d F i l e P R E                                           *//* ------------------------------------------------------------------------ */void  Geo_ReadFilePRE(struct GeoData * GeoData_P0, int NbrGeoData, 		      List_T * Group_L) {  struct GeoData      * GeoData_P ;  struct Geo_Element  * Geo_Element_P0, * Geo_Element_P ;  struct Group        * Group_P ;  int   i, Index_Element, Nbr_Entities, j, Index_Group, Num_Entity ;  int   GeoDataIndex ;  char  String[MAX_STRING_LENGTH] ;  GetDP_Begin("Geo_ReadFilePRE");    for(GeoDataIndex = 0 ; GeoDataIndex < NbrGeoData ; GeoDataIndex++){        if(!(GeoData_P0 + GeoDataIndex)->Elements){      Msg(WARNING, "No Element in GeoData %d", GeoDataIndex);       GetDP_End;    }  }  while (1) {    do {       fgets(String, MAX_STRING_LENGTH, File_PRE) ;       if (feof(File_PRE))  break ;    } while (String[0] != '$') ;      if (feof(File_PRE))  break ;    /*  E l e m e n t s X E d g e s  */    if (!strncmp(&String[1], "ElementsXEdges", 14)) {      fscanf(File_PRE, "%d", &GeoDataIndex) ;      if(GeoDataIndex > NbrGeoData-1) 	Msg(GERROR, "Unknown GeoData: %d", GeoDataIndex);      GeoData_P = GeoData_P0 + GeoDataIndex ;      Geo_Element_P0 = (struct Geo_Element*)List_Pointer(GeoData_P->Elements, 0) ;      fscanf(File_PRE, "%d", &GeoData_P->NbrElementsWithEdges) ;      for (i = 0 ; i < GeoData_P->NbrElementsWithEdges ; i++) {	fscanf(File_PRE, "%d %d", &Index_Element, &Nbr_Entities) ;	Geo_Element_P = Geo_Element_P0 + Index_Element ;	Geo_Element_P->NbrEdges = Nbr_Entities ;	Geo_Element_P->NumEdges = (int *)Malloc(Nbr_Entities * sizeof(int)) ;	for (j = 0 ; j < Geo_Element_P->NbrEdges ; j++)	  fscanf(File_PRE, "%d", &Geo_Element_P->NumEdges[j]) ;      }    }    /*  E l e m e n t s X F a c e t s  */    else if (!strncmp(&String[1], "ElementsXFacets", 15)) {      fscanf(File_PRE, "%d", &GeoDataIndex) ;      if(GeoDataIndex > NbrGeoData-1)	Msg(GERROR, "Unknown GeoData: %d", GeoDataIndex);      GeoData_P = GeoData_P0 + GeoDataIndex ;      Geo_Element_P0 = (struct Geo_Element*)List_Pointer(GeoData_P->Elements, 0) ;      fscanf(File_PRE, "%d", &GeoData_P->NbrElementsWithFacets) ;      for (i = 0 ; i < GeoData_P->NbrElementsWithFacets ; i++) {	fscanf(File_PRE, "%d %d", &Index_Element, &Nbr_Entities) ;	Geo_Element_P = Geo_Element_P0 + Index_Element ;	Geo_Element_P->NbrFacets = Nbr_Entities ;	Geo_Element_P->NumFacets = (int *)Malloc(Nbr_Entities * sizeof(int)) ;	for (j = 0 ; j < Geo_Element_P->NbrFacets ; j++)	  fscanf(File_PRE, "%d", &Geo_Element_P->NumFacets[j]) ;      }    }    /*  E x t e  n d e d G r o u p  */    else if (!strncmp(&String[1], "ExtendedGroup", 13)) {      fscanf(File_PRE, "%d %d", &Index_Group, &Nbr_Entities) ;      Group_P = (struct Group*)List_Pointer(Group_L, Index_Group) ;      Group_P->ExtendedList = List_Create(Nbr_Entities, 1, sizeof(int)) ;      for (i = 0 ; i < Nbr_Entities ; i++) {	fscanf(File_PRE, "%d", &Num_Entity) ;	List_Add(Group_P->ExtendedList, &Num_Entity) ;      }    }    do {      fgets(String, MAX_STRING_LENGTH, File_PRE) ;      if (feof(File_PRE)) Msg(GERROR, "Prematured end of file");    } while (String[0] != '$') ;  }   /* while 1 ... */  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  G e o  _ A d d G r o u p F o r P R E                                    *//* ------------------------------------------------------------------------ */void  Geo_AddGroupForPRE(int Num) {  GetDP_Begin("Geo_AddGroupForPRE");  if (CurrentGeoData->GroupForPRE == NULL)    CurrentGeoData->GroupForPRE = List_Create( 2, 2, sizeof(int)) ;  List_Add(CurrentGeoData->GroupForPRE, &Num) ;  GetDP_End ;}

⌨️ 快捷键说明

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