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

📄 extendedgroup.c

📁 cfd求解器使用与gmsh网格的求解
💻 C
📖 第 1 页 / 共 2 页
字号:
#define RCSID "$Id: ExtendedGroup.c,v 1.14 2006/02/26 00:42:54 geuzaine Exp $"/* * Copyright (C) 1997-2006 P. Dular, C. Geuzaine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. * * Please report all bugs and problems to <getdp@geuz.org>. */#include "GetDP.h"#include "ExtendedGroup.h"#include "Data_DefineE.h"#include "CurrentData.h"#include "GeoData.h"#include "Tools.h"int  fcmp_int2(const void * a, const void * b) {  static int result ;  if ( ( result = ((struct TwoInt *)a)->Int1                - ((struct TwoInt *)b)->Int1 ) != 0 )  return result ;  return  ((struct TwoInt *)a)->Int2 - ((struct TwoInt *)b)->Int2 ;}int  fcmp_absint2(const void * a, const void * b) {  static int result ;  if ( ( result = abs(((struct TwoInt *)a)->Int1)		- abs(((struct TwoInt *)b)->Int1) ) != 0 )  return result ;  return  abs(((struct TwoInt *)a)->Int2) - abs(((struct TwoInt *)b)->Int2) ;}/* ------------------------------------------------------------------------ *//*  C h e c k _ I s E n t i t y I n E x t e n d e d G r o u p               *//* ------------------------------------------------------------------------ */int  Check_IsEntityInExtendedGroup(struct Group * Group_P, int Entity, int Flag) {  GetDP_Begin("Check_IsEntityInExtendedGroup");  switch (Group_P->FunctionType) {  case NODESOF :  case EDGESOF :  case FACETSOF :  case VOLUMESOF :    if ((Group_P->InitialList && !Group_P->ExtendedList)  ||	(Group_P->InitialSuppList && !Group_P->ExtendedSuppList))      Generate_ExtendedGroup(Group_P) ;    GetDP_Return((!Group_P->InitialList ||		  (List_Search(Group_P->ExtendedList, &Entity, fcmp_int))) &&		 (!Group_P->InitialSuppList ||		  (! List_Search(Group_P->ExtendedSuppList, &Entity, fcmp_int)))) ;  case ELEMENTSOF :  case EDGESOFTREEIN :  case FACETSOFTREEIN :    if (!Group_P->ExtendedList) Generate_ExtendedGroup(Group_P) ;    GetDP_Return( List_Search(Group_P->ExtendedList, &Entity, fcmp_int) ) ;  case GROUPSOFNODESOF :  case GROUPSOFEDGESOF :  case REGION :  case GLOBAL :    GetDP_Return( (Flag)? List_Search(Group_P->InitialList, &Entity, fcmp_int) : 1 ) ;  case GROUPSOFEDGESONNODESOF :    if (!Group_P->InitialSuppList){      GetDP_Return(1) ;    }    GetDP_Return (! List_Search(Group_P->ExtendedSuppList, &Entity, fcmp_int)) ;  default :    Msg(GERROR, "Unknown function type for Group '%s'", Group_P->Name);    GetDP_Return(-1) ;  }}/* ------------------------------------------------------------------------ *//*  G e n e r a t e _ E x t e n d e d G r o u p                             *//* ------------------------------------------------------------------------ */void  Generate_ExtendedGroup(struct Group * Group_P) {  GetDP_Begin("Generate_ExtendedGroup");  Msg(INFO, "  Generate ExtendedGroup '%s' (%s)", Group_P->Name,      Get_StringForDefine(FunctionForGroup_Type, Group_P->FunctionType)) ;  switch (Group_P->FunctionType) {  case NODESOF :  case EDGESOF :  case FACETSOF :  case VOLUMESOF :    Generate_ElementaryEntities(Group_P->InitialList,				&Group_P->ExtendedList, Group_P->FunctionType) ;    Generate_ElementaryEntities(Group_P->InitialSuppList,				&Group_P->ExtendedSuppList, Group_P->FunctionType) ;    break ;  case GROUPSOFEDGESONNODESOF :    Generate_ElementaryEntities(Group_P->InitialList,				&Group_P->ExtendedList, EDGESOF) ;    Generate_ElementaryEntities(Group_P->InitialSuppList,				&Group_P->ExtendedSuppList, NODESOF) ;    break ;  case GROUPSOFNODESOF :    Generate_GroupsOfNodes(Group_P->InitialList, &Group_P->ExtendedList) ;    break ;  case ELEMENTSOF :    Generate_Elements(Group_P->InitialList,		      Group_P->SuppListType, Group_P->InitialSuppList,		      &Group_P->ExtendedList) ;    break ;  case GROUPSOFEDGESOF :    Generate_GroupsOfEdges(Group_P->InitialList,			   Group_P->SuppListType, Group_P->InitialSuppList,			   &Group_P->ExtendedList) ;    break ;  case EDGESOFTREEIN :    Geo_GenerateEdgesOfTree(Group_P->InitialList, Group_P->InitialSuppList,			    &Group_P->ExtendedList) ;    Geo_AddGroupForPRE(Group_P->Num) ;    break ;  case FACETSOFTREEIN :    Geo_GenerateFacetsOfTree(Group_P->InitialList, Group_P->InitialSuppList,			     &Group_P->ExtendedList) ;    Geo_AddGroupForPRE(Group_P->Num) ;    break ;  default :    Msg(GERROR, "Unknown function type for Group '%s'", Group_P->Name) ;    break;  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  G e n e r a t e _ E l e m e n t a r y E n t i t i e s                   *//* ------------------------------------------------------------------------ */void  Generate_ElementaryEntities  (List_T * InitialList, List_T ** ExtendedList, int Type_Entity) {  Tree_T  * Entity_Tr ;  struct Geo_Element  * GeoElement ;  int     Nbr_Element, i_Element, Num_Entity ;  int     Nbr_Entity = 0, i_Entity, * Num_Entities = NULL;  GetDP_Begin("Generate_ElementaryEntities");  if (InitialList != NULL) {    Entity_Tr = Tree_Create(sizeof (int), fcmp_int) ;    Nbr_Element = Geo_GetNbrGeoElements() ;    for (i_Element = 0 ; i_Element < Nbr_Element ; i_Element++) {      GeoElement = Geo_GetGeoElement(i_Element) ;      if (List_Search(InitialList, &GeoElement->Region, fcmp_int) ) {	switch (Type_Entity) {	case NODESOF :	  Nbr_Entity = GeoElement->NbrNodes  ; Num_Entities = GeoElement->NumNodes ;	  break ;	case EDGESOF :	  if (GeoElement->NbrEdges == 0)  Geo_CreateEdgesOfElement(GeoElement) ;	  Nbr_Entity = GeoElement->NbrEdges  ; Num_Entities = GeoElement->NumEdges ;	  break ;	case FACETSOF :	  if (GeoElement->NbrEdges == 0)  Geo_CreateEdgesOfElement(GeoElement) ;	  if (GeoElement->NbrFacets == 0) Geo_CreateFacetsOfElement(GeoElement) ;	  Nbr_Entity = GeoElement->NbrFacets ; Num_Entities = GeoElement->NumFacets ;	  break ;	case VOLUMESOF :	  Nbr_Entity = 1                     ; Num_Entities = &GeoElement->Num ;	  break ;	}	for (i_Entity = 0; i_Entity < Nbr_Entity ; i_Entity++) {	  Num_Entity = abs(Num_Entities[i_Entity]) ;	  if ( ! Tree_Search(Entity_Tr, &Num_Entity) )	    Tree_Add(Entity_Tr, &Num_Entity) ;	}      }    }    *ExtendedList = Tree2List(Entity_Tr) ;    Tree_Delete(Entity_Tr) ;  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  G e n e r a t e _ G r o u p s O f N o d e s                             *//* ------------------------------------------------------------------------ */void  Generate_GroupsOfNodes(List_T * InitialList, List_T ** ExtendedList) {  Tree_T  * Entity_Tr ;  struct Geo_Element  * GeoElement ;  int     Nbr_Element, i_Element,  i_Entity ;  struct TwoInt  Num_GroupOfNodes ;  GetDP_Begin("Generate_GroupsOfNodes");  Entity_Tr = Tree_Create(sizeof (struct TwoInt), fcmp_int2) ;  Nbr_Element = Geo_GetNbrGeoElements() ;  /*  Msg(INFO, "  Add Node :"); */  for (i_Element = 0 ; i_Element < Nbr_Element ; i_Element++) {    GeoElement = Geo_GetGeoElement(i_Element) ;    if (List_Search(InitialList, &GeoElement->Region, fcmp_int) ) {      Num_GroupOfNodes.Int2 = GeoElement->Region ;      for (i_Entity = 0 ; i_Entity < GeoElement->NbrNodes ; i_Entity++) {	Num_GroupOfNodes.Int1 = GeoElement->NumNodes[i_Entity] ;	if ( ! Tree_Search(Entity_Tr, &Num_GroupOfNodes) ) {

⌨️ 快捷键说明

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