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

name cl sizes when exporting unrolled geo files (thanks Laurent!)

parent cf7d2ef6
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// See the LICENSE.txt file for license information. Please report all // See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>. // bugs and problems to <gmsh@geuz.org>.
#include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include "GmshConfig.h" #include "GmshConfig.h"
#include "GmshMessage.h" #include "GmshMessage.h"
...@@ -31,7 +32,7 @@ void GModel::_createGEOInternals() ...@@ -31,7 +32,7 @@ void GModel::_createGEOInternals()
void GModel::_deleteGEOInternals() void GModel::_deleteGEOInternals()
{ {
delete _geo_internals; if(_geo_internals) delete _geo_internals;
_geo_internals = 0; _geo_internals = 0;
} }
...@@ -43,6 +44,7 @@ int GModel::readGEO(const std::string &name) ...@@ -43,6 +44,7 @@ int GModel::readGEO(const std::string &name)
int GModel::exportDiscreteGEOInternals() int GModel::exportDiscreteGEOInternals()
{ {
if(_geo_internals) delete _geo_internals;
_geo_internals = new GEO_Internals; _geo_internals = new GEO_Internals;
for(viter it = firstVertex(); it != lastVertex(); it++){ for(viter it = firstVertex(); it != lastVertex(); it++){
...@@ -329,8 +331,21 @@ int GModel::writeGEO(const std::string &name, bool printLabels) ...@@ -329,8 +331,21 @@ int GModel::writeGEO(const std::string &name, bool printLabels)
{ {
FILE *fp = fopen(name.c_str(), "w"); FILE *fp = fopen(name.c_str(), "w");
for(viter it = firstVertex(); it != lastVertex(); it++) std::map<double, std::string> meshSizeParameters;
(*it)->writeGEO(fp); int cpt = 0;
for(viter it = firstVertex(); it != lastVertex(); it++){
double val = (*it)->prescribedMeshSizeAtVertex();
if(meshSizeParameters.find(val) == meshSizeParameters.end()){
std::ostringstream paramName;
paramName << "cl" << ++cpt;
fprintf(fp, "%s = %.16g;\n", paramName.str().c_str(),val);
meshSizeParameters.insert(std::make_pair(val, paramName.str()));
}
}
for(viter it = firstVertex(); it != lastVertex(); it++){
double val = (*it)->prescribedMeshSizeAtVertex();
(*it)->writeGEO(fp, meshSizeParameters[val]);
}
for(eiter it = firstEdge(); it != lastEdge(); it++) for(eiter it = firstEdge(); it != lastEdge(); it++)
(*it)->writeGEO(fp); (*it)->writeGEO(fp);
for(fiter it = firstFace(); it != lastFace(); it++) for(fiter it = firstFace(); it != lastFace(); it++)
......
...@@ -60,10 +60,17 @@ std::string GVertex::getAdditionalInfoString() ...@@ -60,10 +60,17 @@ std::string GVertex::getAdditionalInfoString()
return sstream.str(); return sstream.str();
} }
void GVertex::writeGEO(FILE *fp) void GVertex::writeGEO(FILE *fp, const std::string &meshSizeParameter)
{ {
fprintf(fp, "Point(%d) = {%.16g, %.16g, %.16g, %.16g};\n", if(meshSizeParameter.size())
tag(), x(), y(), z(), prescribedMeshSizeAtVertex()); fprintf(fp, "Point(%d) = {%.16g, %.16g, %.16g, %s};\n",
tag(), x(), y(), z(), meshSizeParameter.c_str());
else if(prescribedMeshSizeAtVertex() != MAX_LC)
fprintf(fp, "Point(%d) = {%.16g, %.16g, %.16g, %.16g};\n",
tag(), x(), y(), z(), prescribedMeshSizeAtVertex());
else
fprintf(fp, "Point(%d) = {%.16g, %.16g, %.16g};\n",
tag(), x(), y(), z());
} }
unsigned int GVertex::getNumMeshElements() unsigned int GVertex::getNumMeshElements()
......
...@@ -66,7 +66,7 @@ class GVertex : public GEntity ...@@ -66,7 +66,7 @@ class GVertex : public GEntity
virtual std::string getAdditionalInfoString(); virtual std::string getAdditionalInfoString();
// export in GEO format // export in GEO format
virtual void writeGEO(FILE *fp); virtual void writeGEO(FILE *fp, const std::string &meshSizeParameter="");
// get number of elements in the mesh // get number of elements in the mesh
unsigned int getNumMeshElements(); unsigned int getNumMeshElements();
......
...@@ -3389,7 +3389,6 @@ void setVolumeSurfaces(Volume *v, List_T *loops) ...@@ -3389,7 +3389,6 @@ void setVolumeSurfaces(Volume *v, List_T *loops)
List_Add(v->SurfacesByTag, &is); List_Add(v->SurfacesByTag, &is);
} }
else{ else{
printf("surface %d is not in GModel !\n", abs(is));
Msg::Error("Unknown surface %d", is); Msg::Error("Unknown surface %d", is);
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment