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

import physical groups as onelab regions

parent 81261931
No related branches found
No related tags found
No related merge requests found
...@@ -697,6 +697,34 @@ void Msg::ExchangeOnelabParameter(const std::string &key, ...@@ -697,6 +697,34 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
#endif #endif
} }
void Msg::ImportPhysicalsAsOnelabRegions()
{
#if defined(HAVE_ONELAB)
if(_onelabClient){
std::map<int, std::vector<GEntity*> > groups[4];
GModel::current()->getPhysicalGroups(groups);
for(int dim = 0; dim < 3; dim++){
for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin();
it != groups[dim].end(); it++){
// create "read-only" onelab region
std::string name = GModel::current()->getPhysicalName(dim, it->first);
std::ostringstream num;
num << it->first;
if(name.empty())
name = std::string("Physical") +
((dim == 3) ? "Volume" : (dim == 2) ? "Surface" :
(dim == 1) ? "Line" : "Point") + num.str();
name.insert(0, "Gmsh/Physical groups/");
onelab::region p(name, num.str());
p.setDimension(dim);
p.setReadOnly(true);
_onelabClient->set(p);
}
}
}
#endif
}
void Msg::FinalizeOnelab() void Msg::FinalizeOnelab()
{ {
#if defined(HAVE_ONELAB) #if defined(HAVE_ONELAB)
......
...@@ -90,6 +90,7 @@ class Msg { ...@@ -90,6 +90,7 @@ class Msg {
std::vector<double> &val, std::vector<double> &val,
std::map<std::string, std::vector<double> > &fopt, std::map<std::string, std::vector<double> > &fopt,
std::map<std::string, std::vector<std::string> > &copt); std::map<std::string, std::vector<std::string> > &copt);
static void ImportPhysicalsAsOnelabRegions();
}; };
#endif #endif
...@@ -425,6 +425,8 @@ int MergeFile(std::string fileName, bool warnIfMissing) ...@@ -425,6 +425,8 @@ int MergeFile(std::string fileName, bool warnIfMissing)
} }
#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(2, true, "Done reading '%s'", fileName.c_str()); Msg::StatusBar(2, true, "Done reading '%s'", fileName.c_str());
......
...@@ -673,31 +673,6 @@ static void updateOnelabGraphs() ...@@ -673,31 +673,6 @@ static void updateOnelabGraphs()
drawContext::global()->draw(); drawContext::global()->draw();
} }
static void importPhysicalGroups(onelab::client *c, GModel *m)
{
std::map<int, std::vector<GEntity*> > groups[4];
m->getPhysicalGroups(groups);
for(int dim = 0; dim < 3; dim++){
for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin();
it != groups[dim].end(); it++){
// create "read-only" onelab region
std::string name = m->getPhysicalName(dim, it->first);
std::ostringstream num;
num << it->first;
if(name.empty())
name = std::string("Physical") +
((dim == 3) ? "Volume" : (dim == 2) ? "Surface" :
(dim == 1) ? "Line" : "Point") + num.str();
name.insert(0, "Gmsh/Physical groups/");
onelab::region p(name, num.str());
p.setDimension(dim);
p.setReadOnly(true);
//p.setVisible(false);
c->set(p);
}
}
}
static void runGmshClient(const std::string &action) static void runGmshClient(const std::string &action)
{ {
onelab::server::citer it = onelab::server::instance()->findClient("Gmsh"); onelab::server::citer it = onelab::server::instance()->findClient("Gmsh");
...@@ -712,7 +687,6 @@ static void runGmshClient(const std::string &action) ...@@ -712,7 +687,6 @@ static void runGmshClient(const std::string &action)
// first pass is special to prevent model reload, as well as // first pass is special to prevent model reload, as well as
// remeshing if a mesh file already exists on disk // remeshing if a mesh file already exists on disk
modelName = GModel::current()->getName(); modelName = GModel::current()->getName();
importPhysicalGroups(c, GModel::current());
if(!StatFile(mshFileName)) if(!StatFile(mshFileName))
onelab::server::instance()->setChanged(false, "Gmsh"); onelab::server::instance()->setChanged(false, "Gmsh");
} }
...@@ -724,7 +698,6 @@ static void runGmshClient(const std::string &action) ...@@ -724,7 +698,6 @@ static void runGmshClient(const std::string &action)
// the model name has changed // the model name has changed
modelName = GModel::current()->getName(); modelName = GModel::current()->getName();
geometry_reload_cb(0, 0); geometry_reload_cb(0, 0);
importPhysicalGroups(c, GModel::current());
} }
} }
else if(action == "compute"){ else if(action == "compute"){
...@@ -735,7 +708,6 @@ static void runGmshClient(const std::string &action) ...@@ -735,7 +708,6 @@ static void runGmshClient(const std::string &action)
// changed // changed
modelName = GModel::current()->getName(); modelName = GModel::current()->getName();
geometry_reload_cb(0, 0); geometry_reload_cb(0, 0);
importPhysicalGroups(c, GModel::current());
if(FlGui::instance()->onelab->meshAuto()){ if(FlGui::instance()->onelab->meshAuto()){
mesh_3d_cb(0, 0); mesh_3d_cb(0, 0);
CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat); CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment