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

better export of physical groups to onelab

parent aae54ca3
No related branches found
No related tags found
No related merge requests found
...@@ -1255,30 +1255,54 @@ void Msg::UndefineOnelabParameter(const std::string &name) ...@@ -1255,30 +1255,54 @@ void Msg::UndefineOnelabParameter(const std::string &name)
#endif #endif
} }
void Msg::ImportPhysicalsAsOnelabRegions() void Msg::ImportPhysicalGroupsInOnelab()
{ {
#if defined(HAVE_ONELAB) #if defined(HAVE_ONELAB)
if(_onelabClient){ if(_onelabClient){
std::map<int, std::vector<GEntity*> > groups[4]; std::map<int, std::vector<GEntity*> > groups[4];
GModel::current()->getPhysicalGroups(groups); GModel::current()->getPhysicalGroups(groups);
int size = 0;
for(int dim = 0; dim <= 3; dim++)
size += groups[dim].size();
onelab::number n("Gmsh/Number of physical groups", size);
n.setReadOnly(true);
n.setVisible(false);
n.setAttribute("Closed", "1");
_onelabClient->set(n);
onelab::number nd("Gmsh/Model dimension", GModel::current()->getDim());
nd.setReadOnly(true);
nd.setVisible(false);
nd.setAttribute("Closed", "1");
_onelabClient->set(nd);
int index = 1;
for(int dim = 0; dim <= 3; dim++){ for(int dim = 0; dim <= 3; dim++){
for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin(); for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin();
it != groups[dim].end(); it++){ it != groups[dim].end(); it++){
// create "read-only" onelab region int num = it->first;
std::string name = GModel::current()->getPhysicalName(dim, it->first); std::string name = GModel::current()->getPhysicalName(dim, it->first);
std::ostringstream num; char tmp[256];
num << it->first; if(name.empty()){
if(name.empty()) sprintf(tmp, "Physical %s %d", (dim == 3) ? "Volume " : (dim == 2) ? "Surface " :
name = std::string("Physical") + (dim == 1) ? "Line " : "Point ", num);
((dim == 3) ? "Volume" : (dim == 2) ? "Surface" : name = tmp;
(dim == 1) ? "Line" : "Point") + num.str(); }
name.insert(0, "Gmsh/Physical groups/"); sprintf(tmp, "Gmsh/Physical group %d/", index);
onelab::region p(name, num.str()); std::string str = tmp;
p.setDimension(dim); onelab::number n1(str + "Dimension", dim);
p.setReadOnly(true); n1.setReadOnly(true);
p.setVisible(false); n1.setVisible(false);
p.setAttribute("Closed", "1"); _onelabClient->set(n1);
_onelabClient->set(p); onelab::number n2(str + "Number", num);
n2.setReadOnly(true);
n2.setVisible(false);
_onelabClient->set(n2);
onelab::string s(str + "Name", name);
s.setReadOnly(true);
s.setVisible(false);
_onelabClient->set(s);
index++;
} }
} }
} }
......
...@@ -146,7 +146,7 @@ class Msg { ...@@ -146,7 +146,7 @@ class Msg {
std::map<std::string, std::vector<std::string> > &copt); std::map<std::string, std::vector<std::string> > &copt);
static void UndefineOnelabParameter(const std::string &name); static void UndefineOnelabParameter(const std::string &name);
static void RunOnelabClient(const std::string &name, const std::string &exe=""); static void RunOnelabClient(const std::string &name, const std::string &exe="");
static void ImportPhysicalsAsOnelabRegions(); static void ImportPhysicalGroupsInOnelab();
}; };
#endif #endif
...@@ -361,7 +361,6 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit ...@@ -361,7 +361,6 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit
CTX::instance()->launchSolverAtStartup = num; CTX::instance()->launchSolverAtStartup = num;
CTX::instance()->solverToRun = num; // used in ONELAB2 CTX::instance()->solverToRun = num; // used in ONELAB2
return 1; return 1;
} }
else if(ext == ".py" || ext == ".PY" || else if(ext == ".py" || ext == ".PY" ||
ext == ".m" || ext == ".M" || ext == ".m" || ext == ".M" ||
...@@ -518,6 +517,8 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit ...@@ -518,6 +517,8 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit
CTX::instance()->geom.draw = 1; CTX::instance()->geom.draw = 1;
CTX::instance()->mesh.changed = ENT_ALL; CTX::instance()->mesh.changed = ENT_ALL;
Msg::ImportPhysicalGroupsInOnelab();
#if defined(HAVE_FLTK) && defined(HAVE_POST) #if defined(HAVE_FLTK) && defined(HAVE_POST)
if(FlGui::available()){ if(FlGui::available()){
// go directly to the first non-empty step after the one that is requested // go directly to the first non-empty step after the one that is requested
...@@ -529,8 +530,6 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit ...@@ -529,8 +530,6 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit
} }
#endif #endif
Msg::ImportPhysicalsAsOnelabRegions();
if(!status) Msg::Error("Error loading '%s'", fileName.c_str()); if(!status) Msg::Error("Error loading '%s'", fileName.c_str());
Msg::StatusBar(true, "Done reading '%s'", fileName.c_str()); Msg::StatusBar(true, "Done reading '%s'", fileName.c_str());
......
...@@ -1326,6 +1326,8 @@ static void action_point_line_surface_volume(int action, int mode, const char *w ...@@ -1326,6 +1326,8 @@ static void action_point_line_surface_volume(int action, int mode, const char *w
FlGui::instance()->physicalContext->append, FlGui::instance()->physicalContext->append,
FlGui::instance()->physicalContext->mode); FlGui::instance()->physicalContext->mode);
FlGui::instance()->physicalContext->show(action == 7 ? false : true); FlGui::instance()->physicalContext->show(action == 7 ? false : true);
// ask clients to update the tree using the new physical definition
onelab_cb(0, (void*)"check");
break; break;
case 8: case 8:
add_charlength(List1, GModel::current()->getFileName(), add_charlength(List1, GModel::current()->getFileName(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment