📄 extendedgroup.c
字号:
Tree_Add(Entity_Tr, &Num_GroupOfNodes) ; /* Msg(INFO, " (%d, %d)", Num_GroupOfNodes.Int1, Num_GroupOfNodes.Int2); */ } } } } *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 E d g e s *//* ------------------------------------------------------------------------ */void Generate_GroupsOfEdges(List_T * InitialList, int Type_SuppList, List_T * InitialSuppList, List_T ** ExtendedList) { Tree_T * Entity_Tr ; struct Geo_Element * GeoElement ; int Nbr_Element, i_Element, i_Entity, Num_Element ; int * Num_Nodes, Num_Node ; struct TwoInt Num_GroupOfEdges, * Key1_P, * Key2_P ; List_T * ExtendedAuxList ; struct Group * GroupForSupport_P ; GetDP_Begin("Generate_GroupsOfEdges"); Entity_Tr = Tree_Create(sizeof (struct TwoInt), fcmp_absint2) ; switch (Type_SuppList) { case SUPPLIST_INSUPPORT : if (List_Nbr(InitialList)) { Generate_GroupsOfNodes(InitialList, &ExtendedAuxList) ; /* Attention : ici, le Support est une liste d'elements ! */ GroupForSupport_P = (struct Group*) List_Pointer(Problem_S.Group, *((int *)List_Pointer(InitialSuppList, 0))) ; if (!GroupForSupport_P->ExtendedList) Generate_ExtendedGroup(GroupForSupport_P) ; Nbr_Element = List_Nbr(GroupForSupport_P->ExtendedList) ; for (i_Element = 0 ; i_Element < Nbr_Element ; i_Element++) { List_Read(GroupForSupport_P->ExtendedList, i_Element, &Num_Element) ; GeoElement = Geo_GetGeoElementOfNum(Num_Element) ; if (GeoElement->NbrEdges == 0) Geo_CreateEdgesOfElement(GeoElement) ; for (i_Entity = 0 ; i_Entity < GeoElement->NbrEdges ; i_Entity++) { Num_Nodes = Geo_GetNodesOfEdgeInElement(GeoElement, i_Entity) ; Num_Node = GeoElement->NumNodes[abs(Num_Nodes[0])-1] ; Key1_P = (struct TwoInt*)List_PQuery(ExtendedAuxList, &Num_Node, fcmp_int) ; Num_Node = GeoElement->NumNodes[abs(Num_Nodes[1])-1] ; Key2_P = (struct TwoInt*)List_PQuery(ExtendedAuxList, &Num_Node, fcmp_int) ; if (Key1_P && (!Key2_P || (Key2_P->Int2 != Key1_P->Int2))) { Num_GroupOfEdges.Int1 = - GeoElement->NumEdges[i_Entity] ; Num_GroupOfEdges.Int2 = Key1_P->Int2 ; if ( ! Tree_Search(Entity_Tr, &Num_GroupOfEdges) ) Tree_Add(Entity_Tr, &Num_GroupOfEdges) ; } if (Key2_P && (!Key1_P || (Key1_P->Int2 != Key2_P->Int2))) { Num_GroupOfEdges.Int1 = GeoElement->NumEdges[i_Entity] ; Num_GroupOfEdges.Int2 = Key2_P->Int2 ; if ( ! Tree_Search(Entity_Tr, &Num_GroupOfEdges) ) Tree_Add(Entity_Tr, &Num_GroupOfEdges) ; } /* if (Key1_P && !Key2_P) { Num_GroupOfEdges.Int1 = - GeoElement->NumEdges[i_Entity] ; Num_GroupOfEdges.Int2 = Key1_P->Int2 ; if ( ! Tree_Search(Entity_Tr, &Num_GroupOfEdges) ) Tree_Add(Entity_Tr, &Num_GroupOfEdges) ; } else if (Key2_P && !Key1_P) { Num_GroupOfEdges.Int1 = GeoElement->NumEdges[i_Entity] ; Num_GroupOfEdges.Int2 = Key2_P->Int2 ; if ( ! Tree_Search(Entity_Tr, &Num_GroupOfEdges) ) Tree_Add(Entity_Tr, &Num_GroupOfEdges) ; } else { if (Key1_P && Key2_P && Key1_P->Int2 != Key2_P->Int2) { Num_GroupOfEdges.Int1 = - GeoElement->NumEdges[i_Entity] ; Num_GroupOfEdges.Int2 = Key1_P->Int2 ; if ( ! Tree_Search(Entity_Tr, &Num_GroupOfEdges) ) { Tree_Add(Entity_Tr, &Num_GroupOfEdges) ; fprintf(stderr, "ADD 1 <========= %d %d %d\n", GeoElement->NumNodes[abs(Num_Nodes[0])-1], Num_GroupOfEdges.Int1, Num_GroupOfEdges.Int2); } Num_GroupOfEdges.Int1 = GeoElement->NumEdges[i_Entity] ; Num_GroupOfEdges.Int2 = Key2_P->Int2 ; if ( ! Tree_Search(Entity_Tr, &Num_GroupOfEdges) ) { Tree_Add(Entity_Tr, &Num_GroupOfEdges) ; fprintf(stderr, "ADD 2 <========= %d %d %d \n", GeoElement->NumNodes[abs(Num_Nodes[1])-1], Num_GroupOfEdges.Int1, Num_GroupOfEdges.Int2); } } } */ } } List_Delete(ExtendedAuxList) ; } break ; default : Msg(GERROR, "Bad GroupsOfEdges (supplementary list missing)") ; } *ExtendedList = Tree2List(Entity_Tr) ; Tree_Delete(Entity_Tr) ; /* for (i_Entity = 0 ; i_Entity < List_Nbr(*ExtendedList) ; i_Entity++) { List_Read(*ExtendedList, i_Entity, &Num_GroupOfEdges) ; Msg(INFO, " (%d, %d)", Num_GroupOfEdges.Int1, Num_GroupOfEdges.Int2) ; } */ GetDP_End ;}/* ------------------------------------------------------------------------ *//* G e n e r a t e _ E l e m e n t s *//* ------------------------------------------------------------------------ */void Generate_Elements(List_T * InitialList, int Type_SuppList, List_T * InitialSuppList, List_T ** ExtendedList) { Tree_T * Entity_Tr ; struct Geo_Element * GeoElement, * GeoElement2 ; struct TwoInt Pair ; int k ; int Nbr_Element, i_Element, i_Element2, Nbr_Node, i_Node, i_Node2 ; List_T * ExtendedSuppList ; GetDP_Begin("Generate_Elements"); Nbr_Element = Geo_GetNbrGeoElements() ; switch (Type_SuppList) { case SUPPLIST_ONONESIDEOF : Entity_Tr = Tree_Create(sizeof(int), fcmp_int) ; if (List_Nbr(InitialSuppList)) { Generate_GroupsOfNodes(InitialSuppList, &ExtendedSuppList) ; for (i_Element = 0 ; i_Element < Nbr_Element ; i_Element++) { GeoElement = Geo_GetGeoElement(i_Element) ; if (List_Search(InitialList, &GeoElement->Region, fcmp_int)) { Nbr_Node = GeoElement->NbrNodes ; for (i_Node = 0 ; i_Node < Nbr_Node ; i_Node++) if (List_Search(ExtendedSuppList, &(GeoElement->NumNodes[i_Node]), fcmp_int)) { Tree_Add(Entity_Tr, &GeoElement->Num) ; break ; /* at least one node of element is on surface Supp */ } } } /* + ne conserver que certains des elements qui viennent d'etre groupes ... ! */ List_Delete(ExtendedSuppList) ; } break ; case SUPPLIST_CONNECTEDTO : Entity_Tr = Tree_Create(sizeof(struct TwoInt), fcmp_int2) ; ExtendedSuppList = List_Create(100,100,sizeof(int)); for (i_Element = 0 ; i_Element < Nbr_Element ; i_Element++) { GeoElement = Geo_GetGeoElement(i_Element) ; if (List_Search(InitialSuppList, &GeoElement->Region, fcmp_int)) List_Add(ExtendedSuppList, &i_Element); } for (i_Element = 0 ; i_Element < Nbr_Element ; i_Element++) { GeoElement = Geo_GetGeoElement(i_Element) ; if (List_Search(InitialList, &GeoElement->Region, fcmp_int)){ for(i_Element2 = 0 ; i_Element2 < List_Nbr(ExtendedSuppList) ; i_Element2++){ GeoElement2 = Geo_GetGeoElement(*(int*)List_Pointer(ExtendedSuppList, i_Element2)) ; k = 0 ; for(i_Node2 = 0 ; i_Node2 < GeoElement2->NbrNodes ; i_Node2++){ for(i_Node = 0 ; i_Node < GeoElement->NbrNodes ; i_Node++){ if(GeoElement2->NumNodes[i_Node2] == GeoElement->NumNodes[i_Node]) k++; } } if(k == GeoElement2->NbrNodes){ Pair.Int1 = GeoElement2->Num ; /* Number of the the element on the boundary */ Pair.Int2 = i_Element ; /* Index of the element connected to all the nodes of the element on the boundary */ Tree_Add(Entity_Tr, &Pair); } } } } List_Delete(ExtendedSuppList) ; break ; case SUPPLIST_NONE : default : Entity_Tr = Tree_Create(sizeof(int), fcmp_int) ; for (i_Element = 0 ; i_Element < Nbr_Element ; i_Element++) { GeoElement = Geo_GetGeoElement(i_Element) ; if (List_Search(InitialList, &GeoElement->Region, fcmp_int)) Tree_Add(Entity_Tr, &GeoElement->Num) ; } break ; } *ExtendedList = Tree2List(Entity_Tr) ; Tree_Delete(Entity_Tr) ; GetDP_End ;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -