Skip to content
Snippets Groups Projects
Commit 76a25730 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

*** empty log message ***

parent 46932675
No related branches found
No related tags found
No related merge requests found
...@@ -2346,7 +2346,7 @@ int GModel::readDIFF(const std::string &name) ...@@ -2346,7 +2346,7 @@ int GModel::readDIFF(const std::string &name)
vertexVector[it->first] = it->second; vertexVector[it->first] = it->second;
vertexMap.clear(); vertexMap.clear();
} }
Msg::Info("%d ( %lf , %lf , %lf ) [%d]", i, xyz[0], xyz[1], xyz[2], Msg::Info("%d ( %lf , %lf , %lf ) [%d]",i, xyz[0], xyz[1], xyz[2],
elementary[i][0]); elementary[i][0]);
std::string format_read_bi = "%*d ( %*lf , %*lf , %*lf ) [%*d]"; std::string format_read_bi = "%*d ( %*lf , %*lf , %*lf ) [%*d]";
for(int j = 0; j < elementary[i][0]; j++){ for(int j = 0; j < elementary[i][0]; j++){
...@@ -2356,7 +2356,7 @@ int GModel::readDIFF(const std::string &name) ...@@ -2356,7 +2356,7 @@ int GModel::readDIFF(const std::string &name)
} }
else else
format_read_bi += " %d"; format_read_bi += " %d";
if(sscanf(str, format_read_bi.c_str(), &(elementary[i][j + 1])) != 1) if(sscanf(str, format_read_bi.c_str(), &(elementary[i][j + 1])) != 1)
return 0; return 0;
Msg::Info("elementary[%d][%d]=%d", i + 1, j + 1, elementary[i][j + 1]); Msg::Info("elementary[%d][%d]=%d", i + 1, j + 1, elementary[i][j + 1]);
} }
...@@ -2365,78 +2365,79 @@ int GModel::readDIFF(const std::string &name) ...@@ -2365,78 +2365,79 @@ int GModel::readDIFF(const std::string &name)
if(!fgets(str, sizeof(str), fp) || feof(fp)) if(!fgets(str, sizeof(str), fp) || feof(fp))
break; break;
} }
std::vector<int> material(numElements); std::vector<int> material(numElements);
std::vector<std::vector<int> > ElementsNodes(numElements); std::vector<std::vector<int> > ElementsNodes(numElements);
for(int i = 0; i < numVertices; i++){ for(int i = 0; i < numVertices; i++){
ElementsNodes[i].resize(numVerticesPerElement); ElementsNodes[i].resize(numVerticesPerElement);
} }
char eleType[20]=""; char eleTypec[20]="";
std::string eleType;
Msg::ResetProgressMeter(); Msg::ResetProgressMeter();
std::vector<int> mapping; std::vector<int> mapping;
for(int i = 1; i <= numElements; i++){ for(int i = 1; i <= numElements; i++){
if(!fgets(str, sizeof(str), fp)) return 0; if(!fgets(str, sizeof(str), fp)) return 0;
int num, type, physical = 0, partition = 0; int num, type, physical = 0, partition = 0;
int indices[60]; int indices[60];
if(sscanf(str, "%*d %s %d", eleType, &material[i-1])!=2) return 0; if(sscanf(str, "%*d %s %d", eleTypec, &material[i-1])!=2) return 0;
eleType=std::string(eleTypec);
int k2; // local number for the element int k2; // local number for the element
int NoVertices; // number of vertices per element int NoVertices; // number of vertices per element
if(eleType=="ElmT3n2D"){ if(eleType.compare("ElmT3n2D")==0){
NoVertices=3; NoVertices=3;
static int map[3]={0, 1, 2}; // identical to gmsh static int map[3]={0, 1, 2}; // identical to gmsh
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_TRI_3; type= MSH_TRI_3;
} }
else if(eleType=="ElmT6n2D"){ else if(eleType.compare("ElmT6n2D")==0){
NoVertices=6; NoVertices=6;
static int map[6]={0, 1, 2, 3, 4, 5}; // identical to gmsh static int map[6]={0, 1, 2, 3, 4, 5}; // identical to gmsh
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_TRI_6; type= MSH_TRI_6;
} }
else if(eleType=="ElmB4n2D"){ else if(eleType.compare("ElmB4n2D")==0){
NoVertices=4; NoVertices=4;
static int map[4]={0, 1, 3, 2}; // local numbering static int map[4]={0, 1, 3, 2}; // local numbering
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_QUA_4; type= MSH_QUA_4;
} }
else if(eleType=="ElmB8n2D"){ else if(eleType.compare("ElmB8n2D")==0){
NoVertices=8; NoVertices=8;
static int map[8]={0, 1, 3, 2, 4, 6, 7, 5}; // local numbering static int map[8]={0, 1, 3, 2, 4, 6, 7, 5}; // local numbering
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_QUA_8; type= MSH_QUA_8;
} }
else if(eleType=="ElmB9n2D"){ else if(eleType.compare("ElmB9n2D")==0){
NoVertices=9; NoVertices=9;
static int map[9]={0, 4, 1, 7, 8, 5, 3, 6, 2}; // local numbering static int map[9]={0, 4, 1, 7, 8, 5, 3, 6, 2}; // local numbering
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_QUA_9; type= MSH_QUA_9;
} }
else if(eleType=="ElmT4n3D"){ else if(eleType.compare("ElmT4n3D")==0){
NoVertices=4; NoVertices=4;
static int map[4]={0, 1, 2, 3}; // identical to gmsh static int map[4]={0, 1, 2, 3}; // identical to gmsh
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_TET_4; type= MSH_TET_4;
} }
else if(eleType=="ElmT10n3D"){ else if(eleType.compare("ElmT10n3D")==0){
NoVertices=10; NoVertices=10;
static int map[10]={1, 0, 2, 3, 4, 6, 5, 9, 7, 8}; // local numbering static int map[10]={1, 0, 2, 3, 4, 6, 5, 9, 7, 8}; // local numbering
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_TET_10; type= MSH_TET_10;
} }
else if(eleType=="ElmB8n3D"){ else if(eleType.compare("ElmB8n3D")==0){
NoVertices=8; NoVertices=8;
static int map[8]={4, 5, 0, 1, 7, 6, 3, 2}; static int map[8]={4, 5, 0, 1, 7, 6, 3, 2};
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_HEX_8; type= MSH_HEX_8;
} }
else if(eleType=="ElmB20n3D"){ else if(eleType.compare("ElmB20n3D")==0){
NoVertices=20; NoVertices=20;
static int map[20]={4, 5, 0, 1, 7, 6, 3, 2, 16, 8, 19, static int map[20]={4, 5, 0, 1, 7, 6, 3, 2, 16, 8, 19, 13, 15, 12, 14,
13, 15, 12, 14, 17, 18, 9, 11}; 17, 18, 9, 11};
mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) ); mapping=std::vector<int> (map, map + sizeof(map) / sizeof(int) );
type= MSH_HEX_20; type= MSH_HEX_20;
} }
else if(eleType=="ElmB27n3D"){ else if(eleType.compare("ElmB27n3D")==0){
NoVertices=27; NoVertices=27;
static int map[27]={4, 16, 5, 10, 21, 12, 0, 8, 1, 17, 25, 18, 22, static int map[27]={4, 16, 5, 10, 21, 12, 0, 8, 1, 17, 25, 18, 22,
26, 23, 9, 20, 11, 7, 19, 6, 15, 24, 14, 3, 13, 2}; 26, 23, 9, 20, 11, 7, 19, 6, 15, 24, 14, 3, 13, 2};
...@@ -2444,7 +2445,9 @@ int GModel::readDIFF(const std::string &name) ...@@ -2444,7 +2445,9 @@ int GModel::readDIFF(const std::string &name)
type= MSH_HEX_27; type= MSH_HEX_27;
} }
else else
{
return 0; return 0;
}
std::string format_read_vertices = "%*d %*s %*d"; std::string format_read_vertices = "%*d %*s %*d";
for(int k = 0; k < NoVertices; k++){ for(int k = 0; k < NoVertices; k++){
if(format_read_vertices[format_read_vertices.size()-2] != '*') { if(format_read_vertices[format_read_vertices.size()-2] != '*') {
...@@ -2454,7 +2457,7 @@ int GModel::readDIFF(const std::string &name) ...@@ -2454,7 +2457,7 @@ int GModel::readDIFF(const std::string &name)
else else
format_read_vertices += " %d"; format_read_vertices += " %d";
k2=mapping[k]; k2=mapping[k];
if(sscanf(str, format_read_vertices.c_str(), &ElementsNodes[i-1][k2]) != 1) if(sscanf(str, format_read_vertices.c_str(), &ElementsNodes[i-1][k2]) != 1)
return 0; return 0;
} }
mapping.clear(); mapping.clear();
...@@ -2462,11 +2465,11 @@ int GModel::readDIFF(const std::string &name) ...@@ -2462,11 +2465,11 @@ int GModel::readDIFF(const std::string &name)
indices[j] = ElementsNodes[i - 1][j]; indices[j] = ElementsNodes[i - 1][j];
std::vector<MVertex*> vertices; std::vector<MVertex*> vertices;
if(vertexVector.size()){ if(vertexVector.size()){
if(!getVertices(numVerticesPerElement, indices, vertexVector, vertices)) if(!getVertices(numVerticesPerElement, indices, vertexVector, vertices))
return 0; return 0;
} }
else{ else{
if(!getVertices(numVerticesPerElement, indices, vertexMap, vertices)) if(!getVertices(numVerticesPerElement, indices, vertexMap, vertices))
return 0; return 0;
} }
createElementMSH(this, num, type, physical, elementary[i-1][1], partition, createElementMSH(this, num, type, physical, elementary[i-1][1], partition,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment