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
......@@ -649,7 +649,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
std::vector<onelab::number> ps;
_onelabClient->get(ps, name);
bool noRange = true, noChoices = true, noLoop = true, noGraph = true;
if(ps.size()){
if(ps.size()){
if(ps[0].getReadOnly())
ps[0].setValue(val[0]); // use value from gmsh
else
......@@ -697,6 +697,34 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
#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()
{
#if defined(HAVE_ONELAB)
......
......@@ -90,6 +90,7 @@ class Msg {
std::vector<double> &val,
std::map<std::string, std::vector<double> > &fopt,
std::map<std::string, std::vector<std::string> > &copt);
static void ImportPhysicalsAsOnelabRegions();
};
#endif
......@@ -425,6 +425,8 @@ int MergeFile(std::string fileName, bool warnIfMissing)
}
#endif
Msg::ImportPhysicalsAsOnelabRegions();
if(!status) Msg::Error("Error loading '%s'", fileName.c_str());
Msg::StatusBar(2, true, "Done reading '%s'", fileName.c_str());
......
......@@ -673,31 +673,6 @@ static void updateOnelabGraphs()
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)
{
onelab::server::citer it = onelab::server::instance()->findClient("Gmsh");
......@@ -712,7 +687,6 @@ static void runGmshClient(const std::string &action)
// first pass is special to prevent model reload, as well as
// remeshing if a mesh file already exists on disk
modelName = GModel::current()->getName();
importPhysicalGroups(c, GModel::current());
if(!StatFile(mshFileName))
onelab::server::instance()->setChanged(false, "Gmsh");
}
......@@ -724,7 +698,6 @@ static void runGmshClient(const std::string &action)
// the model name has changed
modelName = GModel::current()->getName();
geometry_reload_cb(0, 0);
importPhysicalGroups(c, GModel::current());
}
}
else if(action == "compute"){
......@@ -735,7 +708,6 @@ static void runGmshClient(const std::string &action)
// changed
modelName = GModel::current()->getName();
geometry_reload_cb(0, 0);
importPhysicalGroups(c, GModel::current());
if(FlGui::instance()->onelab->meshAuto()){
mesh_3d_cb(0, 0);
CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment