GeoTree.cpp (getdp-3.4.0-source.tgz) | : | GeoTree.cpp (getdp-3.5.0-source.tgz) | ||
---|---|---|---|---|
// GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege | // GetDP - Copyright (C) 1997-2022 P. Dular and C. Geuzaine, University of Liege | |||
// | // | |||
// See the LICENSE.txt file for license information. Please report all | // See the LICENSE.txt file for license information. Please report all | |||
// issues on https://gitlab.onelab.info/getdp/getdp/issues. | // issues on https://gitlab.onelab.info/getdp/getdp/issues. | |||
#include <math.h> | ||||
#include <stdlib.h> | ||||
#include "GeoData.h" | #include "GeoData.h" | |||
#include "ProData.h" | #include "ProData.h" | |||
#include "TreeUtils.h" | #include "TreeUtils.h" | |||
#include "Get_Geometry.h" | #include "Get_Geometry.h" | |||
#include <math.h> | #include "Message.h" | |||
#include <stdlib.h> | ||||
static int Tree_IndexToChange, Tree_NewIndex; | static int Tree_IndexToChange, Tree_NewIndex; | |||
static void Geo_ChangeTreeIndex(void *a, void *b) | static void Geo_ChangeTreeIndex(void *a, void *b) | |||
{ | { | |||
if(((struct EntityInTree *)a)->Index == Tree_IndexToChange) | if(((struct EntityInTree *)a)->Index == Tree_IndexToChange) | |||
((struct EntityInTree *)a)->Index = Tree_NewIndex; | ((struct EntityInTree *)a)->Index = Tree_NewIndex; | |||
} | } | |||
/* ------------------------------------------------------------------------ */ | /* ------------------------------------------------------------------------ */ | |||
/* G e o _ G e n e r a t e E d g e s O f T r e e */ | /* G e o _ G e n e r a t e E d g e s O f T r e e */ | |||
/* ------------------------------------------------------------------------ */ | /* ------------------------------------------------------------------------ */ | |||
static bool testEdgeAlignedWith(double *x, double *y, double *z, int *Entity_P, | static bool testEdgeAlignedWith(double *x, double *y, double *z, int *Entity_P, | |||
int SuppListType2) | int SuppListType2) | |||
{ | { | |||
bool aligned = false; | bool aligned = false; | |||
double val1 = 0, val2 = 0; | ||||
double tol = 1e-7; | double tol = 1e-7; | |||
switch(SuppListType2) { | switch(SuppListType2) { | |||
case -1: // aligned with Cartesian X direction | case -1: // aligned with Cartesian X direction "X" | |||
aligned = fabs(x[abs(Entity_P[0]) - 1] - x[abs(Entity_P[1]) - 1]) < tol; | val1 = x[abs(Entity_P[0]) - 1]; | |||
val2 = x[abs(Entity_P[1]) - 1]; | ||||
break; | ||||
case -2: // aligned with Cartesian Y direction "Y" | ||||
val1 = y[abs(Entity_P[0]) - 1]; | ||||
val2 = y[abs(Entity_P[1]) - 1]; | ||||
break; | ||||
case -3: // aligned with Cartesian Z direction "Z" | ||||
val1 = z[abs(Entity_P[0]) - 1]; | ||||
val2 = z[abs(Entity_P[1]) - 1]; | ||||
break; | ||||
case -4: // aligned with radius around X axis "Rx" | ||||
val1 = atan2(y[abs(Entity_P[0]) - 1], z[abs(Entity_P[0]) - 1]); | ||||
val2 = atan2(y[abs(Entity_P[1]) - 1], z[abs(Entity_P[1]) - 1]); | ||||
break; | break; | |||
case -2: // aligned with Cartesian Y direction | case -5: // aligned with radius around Y axis "Ry" | |||
aligned = fabs(y[abs(Entity_P[0]) - 1] - y[abs(Entity_P[1]) - 1]) < tol; | val1 = atan2(z[abs(Entity_P[0]) - 1], x[abs(Entity_P[0]) - 1]); | |||
val2 = atan2(z[abs(Entity_P[1]) - 1], x[abs(Entity_P[1]) - 1]); | ||||
break; | break; | |||
case -3: // aligned with Cartesian Z direction | case -6: // aligned with radius around Z axis "Rz" | |||
aligned = fabs(z[abs(Entity_P[0]) - 1] - z[abs(Entity_P[1]) - 1]) < tol; | val1 = atan2(x[abs(Entity_P[0]) - 1], y[abs(Entity_P[0]) - 1]); | |||
val2 = atan2(x[abs(Entity_P[1]) - 1], y[abs(Entity_P[1]) - 1]); | ||||
break; | break; | |||
default: printf("Unknown 'AlignedWith parameter' %d\n", SuppListType2); | default: Message::Error("Unknown 'AlignedWith parameter' %d", SuppListType2); | |||
} | } | |||
aligned = fabs(val2 - val1) < tol; | ||||
return aligned; | return aligned; | |||
} | } | |||
static void Geo_GenerateTreeOnSlidingSurface(List_T *InitialList, | static void Geo_GenerateTreeOnSlidingSurface(List_T *InitialList, | |||
List_T *ExtendedList, | List_T *ExtendedList, | |||
Tree_T *EntitiesInTree_T, | Tree_T *EntitiesInTree_T, | |||
int SuppListType2) | int SuppListType2) | |||
{ | { | |||
int Nbr_Element, Nbr_Edges, i_Element, i_Edge, Num_Edge; | int Nbr_Element, Nbr_Edges, i_Element, i_Edge, Num_Edge; | |||
struct Geo_Element *Geo_Element; | struct Geo_Element *Geo_Element; | |||
skipping to change at line 98 | skipping to change at line 116 | |||
} | } | |||
List_Copy(Tree2List(EdgesInTree_T), ExtendedList); | List_Copy(Tree2List(EdgesInTree_T), ExtendedList); | |||
} | } | |||
static void Geo_GenerateEdgesOfTreeByDimension(int dim, List_T *List, | static void Geo_GenerateEdgesOfTreeByDimension(int dim, List_T *List, | |||
bool isElementList, | bool isElementList, | |||
List_T *ExtendedList, | List_T *ExtendedList, | |||
Tree_T *EntitiesInTree_T) | Tree_T *EntitiesInTree_T) | |||
{ | { | |||
int Nbr_Element, Num_Element, i_Element, Nbr_Entities2, i, Num_Entity1, Dim_El | int Nbr_Element, Num_Element, i_Element, Nbr_Entities2, i, Num_Entity1, | |||
ement; | Dim_Element; | |||
struct Geo_Element *Geo_Element; | struct Geo_Element *Geo_Element; | |||
int i_Entity2, Num_Entity2, *D_Element, *Entity_P, Entity, Flag_Change; | int i_Entity2, Num_Entity2, *D_Element, *Entity_P, Entity, Flag_Change; | |||
struct EntityInTree *EntitiesInTree_P[NBR_MAX_ENTITIES_IN_ELEMENT]; | struct EntityInTree *EntitiesInTree_P[NBR_MAX_ENTITIES_IN_ELEMENT]; | |||
struct EntityInTree EntityInTree_S; | struct EntityInTree EntityInTree_S; | |||
Nbr_Element = isElementList ? List_Nbr(List) : Geo_GetNbrGeoElements(); | Nbr_Element = isElementList ? List_Nbr(List) : Geo_GetNbrGeoElements(); | |||
for(i_Element = 0; i_Element < Nbr_Element; i_Element++) { | for(i_Element = 0; i_Element < Nbr_Element; i_Element++) { | |||
if( isElementList ){ | if(isElementList) { | |||
List_Read(List,i_Element, &Num_Element); | List_Read(List, i_Element, &Num_Element); | |||
Geo_Element = Geo_GetGeoElementOfNum(Num_Element); | Geo_Element = Geo_GetGeoElementOfNum(Num_Element); | |||
} | } | |||
else{ | else { | |||
Geo_Element = Geo_GetGeoElement(i_Element); | Geo_Element = Geo_GetGeoElement(i_Element); | |||
if(!List_Search(List, &Geo_Element->Region, fcmp_int)) | if(!List_Search(List, &Geo_Element->Region, fcmp_int)) continue; | |||
continue; | ||||
} | } | |||
Get_JacobianFunction(JACOBIAN_VOL, Geo_Element->Type, &Dim_Element); | Get_JacobianFunction(JACOBIAN_VOL, Geo_Element->Type, &Dim_Element); | |||
if(dim < 0 || Dim_Element == dim) { | if(dim < 0 || Dim_Element == dim) { | |||
if(Geo_Element->NbrEdges == 0) Geo_CreateEdgesOfElement(Geo_Element); | if(Geo_Element->NbrEdges == 0) Geo_CreateEdgesOfElement(Geo_Element); | |||
D_Element = Geo_GetIM_Den(Geo_Element->Type, &Nbr_Entities2); | D_Element = Geo_GetIM_Den(Geo_Element->Type, &Nbr_Entities2); | |||
for(i = 0; i < Geo_Element->NbrNodes; i++) { | for(i = 0; i < Geo_Element->NbrNodes; i++) { | |||
Num_Entity1 = abs(Geo_Element->NumNodes[i]); | Num_Entity1 = abs(Geo_Element->NumNodes[i]); | |||
EntitiesInTree_P[i] = | EntitiesInTree_P[i] = | |||
skipping to change at line 151 | skipping to change at line 169 | |||
if(EntitiesInTree_P[--Entity] != NULL) { | if(EntitiesInTree_P[--Entity] != NULL) { | |||
if(EntitiesInTree_P[Entity]->Index != EntityInTree_S.Index) { | if(EntitiesInTree_P[Entity]->Index != EntityInTree_S.Index) { | |||
Tree_IndexToChange = EntitiesInTree_P[Entity]->Index; | Tree_IndexToChange = EntitiesInTree_P[Entity]->Index; | |||
Tree_NewIndex = EntityInTree_S.Index; | Tree_NewIndex = EntityInTree_S.Index; | |||
Tree_Action(EntitiesInTree_T, Geo_ChangeTreeIndex); | Tree_Action(EntitiesInTree_T, Geo_ChangeTreeIndex); | |||
Flag_Change = 1; | Flag_Change = 1; | |||
} | } | |||
} | } | |||
else { | else { | |||
EntityInTree_S.Num = abs(Geo_Element->NumNodes[Entity]); | EntityInTree_S.Num = abs(Geo_Element->NumNodes[Entity]); | |||
EntitiesInTree_P[Entity] = | EntitiesInTree_P[Entity] = (struct EntityInTree *)Tree_Add( | |||
(struct EntityInTree *)Tree_Add(EntitiesInTree_T, &EntityInTree_S) | EntitiesInTree_T, &EntityInTree_S); | |||
; | ||||
Flag_Change = 1; | Flag_Change = 1; | |||
} | } | |||
} | } | |||
if(Flag_Change) { | if(Flag_Change) { | |||
Num_Entity2 = abs(Geo_Element->NumEdges[i_Entity2]); | Num_Entity2 = abs(Geo_Element->NumEdges[i_Entity2]); | |||
List_Add(ExtendedList, &Num_Entity2); | List_Add(ExtendedList, &Num_Entity2); | |||
} | } | |||
} /* for i_Entity2 ... */ | } /* for i_Entity2 ... */ | |||
} /* if (Dim) */ | } /* if (Dim) */ | |||
} /* for i_Element ... */ | } /* for i_Element ... */ | |||
} | } | |||
void Geo_GenerateEdgesOfTree(List_T * InitialList, bool isInitialListEL, | void Geo_GenerateEdgesOfTree(List_T *InitialList, bool isInitialListEL, | |||
List_T * InitialSuppList, bool isInitialSuppListEL, | List_T *InitialSuppList, bool isInitialSuppListEL, | |||
List_T * InitialSuppList2, bool isInitialSuppList2E | List_T *InitialSuppList2, | |||
L, | bool isInitialSuppList2EL, int SuppListType2, | |||
int SuppListType2, List_T ** ExtendedList) | List_T **ExtendedList) | |||
{ | { | |||
Tree_T *EntitiesInTree_T; | Tree_T *EntitiesInTree_T; | |||
*ExtendedList = List_Create(2000, 2000, sizeof(int)); | *ExtendedList = List_Create(2000, 2000, sizeof(int)); | |||
EntitiesInTree_T = Tree_Create(2 * sizeof(int), fcmp_int); | EntitiesInTree_T = Tree_Create(2 * sizeof(int), fcmp_int); | |||
if(InitialSuppList2 != NULL) // SubRegion2 | if(InitialSuppList2 != NULL) // SubRegion2 | |||
Geo_GenerateTreeOnSlidingSurface(InitialSuppList2, *ExtendedList, | Geo_GenerateTreeOnSlidingSurface(InitialSuppList2, *ExtendedList, | |||
EntitiesInTree_T, SuppListType2); | EntitiesInTree_T, SuppListType2); | |||
End of changes. 15 change blocks. | ||||
25 lines changed or deleted | 41 lines changed or added |