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

merge DIFFPACK patch from Jacques Lechelle

parent 6f063866
No related branches found
No related tags found
No related merge requests found
......@@ -299,6 +299,9 @@ int MergeFile(std::string fileName, bool warnIfMissing)
else if(ext == ".mesh" || ext == ".MESH"){
status = GModel::current()->readMESH(fileName);
}
else if(ext == ".diff" || ext == ".DIFF"){
status = GModel::current()->readDIFF(fileName);
}
else if(ext == ".med" || ext == ".MED" || ext == ".mmed" || ext == ".MMED" ||
ext == ".rmed" || ext == ".RMED"){
status = GModel::readMED(fileName);
......
......
......@@ -3059,8 +3059,7 @@ int GModel::readDIFF(const std::string &name)
std::map<int, MVertex*> vertexMap;
std::vector<MVertex*> vertexVector;
while(1) {
{
while(strstr(str, "Number of space dim. =") == NULL){
if(!fgets(str, sizeof(str), fp) || feof(fp))
break;
......@@ -3100,20 +3099,23 @@ int GModel::readDIFF(const std::string &name)
bool several_subdomains;
if(!fgets(str, sizeof(str), fp) || feof(fp)) return 0;
while(strstr(str, "Only one subdomain el :") == NULL){
if(!fgets(str, sizeof(str), fp) || feof(fp))
break;
if(!strncmp(&str[2], "Only one material", 17) ||
!strncmp(&str[2], "Only one subdomain", 18)){
if(!strncmp(&str[37], "dpTRUE", 6) || !strncmp(&str[37], "true", 4) ||
!strncmp(&str[36], "dpTRUE", 6) || !strncmp(&str[36], "true", 4)){
several_subdomains = false;
}
if(!strncmp(&str[39], "dpFALSE", 6))
else{
several_subdomains = true;
else
several_subdomains = false;
Msg::Info("several_subdomains %x", several_subdomains);
}
Msg::Info("several_subdomains %x %s", several_subdomains, str);
}
int nbi;
std::vector<int> bi;
if(!fgets(str, sizeof(str), fp) || feof(fp)) return 0;
while(strstr(str, "Boundary indicators:") == NULL){
while(strstr(str, "Boundary indicators:") == NULL &&
strstr(str, "boundary indicators:") == NULL){
if(!fgets(str, sizeof(str), fp) || feof(fp))
break;
}
......@@ -3148,8 +3150,8 @@ int GModel::readDIFF(const std::string &name)
if(!fgets(str, sizeof(str), fp)) return 0;
double xyz[3];
int tmp;
if(sscanf(str, "%d ( %lf , %lf , %lf ) [%d]", &num, &xyz[0], &xyz[1], &xyz[2],
&tmp) != 5) return 0;
if(sscanf(str, "%d ( %lf , %lf , %lf ) [%d]", &num,
&xyz[0], &xyz[1], &xyz[2], &tmp) != 5) return 0;
elementary[i].resize(tmp + 1);
elementary[i][0] = tmp;
minVertex = std::min(minVertex, num);
......@@ -3160,7 +3162,7 @@ int GModel::readDIFF(const std::string &name)
vertexMap[num] = new MVertex(xyz[0], xyz[1], xyz[2], 0, num);
if(numVertices > 100000)
Msg::ProgressMeter(i + 1, numVertices, "Reading nodes");
// If the vertex numbering is dense, transfer the map into a
// If the vertex numbering is dense, tranfer the map into a
// vector to speed up element creation
if((int)vertexMap.size() == numVertices &&
((minVertex == 1 && maxVertex == numVertices) ||
......@@ -3197,7 +3199,7 @@ int GModel::readDIFF(const std::string &name)
}
std::vector<int> material(numElements);
std::vector<std::vector<int> > ElementsNodes(numElements);
for(int i = 0; i < numVertices; i++){
for(int i = 0; i < numElements; i++){
ElementsNodes[i].resize(numVerticesPerElement);
}
char eleTypec[20]="";
......@@ -3412,7 +3414,7 @@ int GModel::writeDIFF(const std::string &name, bool binary, bool saveAll,
fprintf(fp, " Number of nodes = %d\n\n", numVertices);
fprintf(fp, " All elements are of the same type : dpTRUE\n");
fprintf(fp, " Max number of nodes in an element: %d \n", maxNumNodesPerElement);
fprintf(fp, " Only one subdomain el : dpFALSE\n");
fprintf(fp, " Only one subdomain : dpFALSE\n");
fprintf(fp, " Lattice data ? 0\n\n\n\n");
fprintf(fp, " %d Boundary indicators: ", (int)boundaryIndicators.size());
for(std::list<int>::iterator it = boundaryIndicators.begin();
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment