Commit 127e0f05 authored by Christophe Geuzaine's avatar Christophe Geuzaine

tentative solution for multiple physical groups for a given element

parent 274fd0c3
Pipeline #1960 passed with stage
in 9 minutes 35 seconds
......@@ -498,9 +498,11 @@ static void Geo_ReadFileWithGmsh(struct GeoData * GeoData_P)
std::vector< std::vector<int> > elementNodeTags;
gmsh::model::mesh::getElements(elementTypes, elementTags, elementNodeTags, -1, -1);
int nbr = 0;
int nbr = 0, maxTag = 0;
for(unsigned int i = 0; i < elementTypes.size(); i++){
nbr += elementTags[i].size();
for(unsigned int j = 0; j < elementTags[i].size(); j++)
maxTag = std::max(maxTag, elementTags[i][j]);
}
if (GeoData_P->Elements == NULL)
......@@ -518,23 +520,25 @@ static void Geo_ReadFileWithGmsh(struct GeoData * GeoData_P)
gmsh::model::getPhysicalGroupsForEntity(dimTags[entity].first,
dimTags[entity].second, physicalsTags);
if(physicalsTags.size() == 0) continue;
for(int phys = 0; phys < physicalsTags.size(); phys++){
for(unsigned int i = 0; i < elementTypes.size(); i++){
Geo_Element.Type = Geo_GetElementType(FORMAT_GMSH, elementTypes[i]) ;
Geo_Element.NbrNodes = elementNodeTags[i].size()/elementTags[i].size();
for(unsigned int j = 0; j < elementTags[i].size(); j++){
Geo_Element.Num = elementTags[i][j];
Geo_Element.Region = physicalsTags[0];
// if more than one physical group, create new elements (with new
// tags) for all additional groups - this is consistent with the
// behavior of the old MSH2 file format
Geo_Element.Num = (phys == 0) ? elementTags[i][j] : ++maxTag;
Geo_Element.Region = physicalsTags[phys];
Geo_Element.ElementaryRegion = dimTags[i].second;
Geo_Element.NumNodes = (int *)Malloc(Geo_Element.NbrNodes * sizeof(int)) ;
for (unsigned int k = 0; k < Geo_Element.NbrNodes; k++)
Geo_Element.NumNodes[k] = elementNodeTags[i][Geo_Element.NbrNodes*j + k];
List_Add(GeoData_P->Elements, &Geo_Element) ;
}
}
}
}
List_Sort(GeoData_P->Elements, fcmp_Elm) ;
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment