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

onelab: better mesh+save logic

parent 9ea87754
No related branches found
No related tags found
No related merge requests found
...@@ -281,12 +281,12 @@ bool onelab::localNetworkClient::kill() ...@@ -281,12 +281,12 @@ bool onelab::localNetworkClient::kill()
return false; return false;
} }
static void saveMesh(onelab::client *c) static std::string getMshFileName(onelab::client *c)
{ {
std::vector<onelab::string> ps; std::vector<onelab::string> ps;
c->get(ps, "Gmsh/MshFileName"); c->get(ps, "Gmsh/MshFileName");
if(ps.size()){ if(ps.size()){
CreateOutputFile(ps[0].getValue(), CTX::instance()->mesh.fileFormat); return ps[0].getValue();
} }
else{ else{
std::string name = CTX::instance()->outputFileName; std::string name = CTX::instance()->outputFileName;
...@@ -298,7 +298,7 @@ static void saveMesh(onelab::client *c) ...@@ -298,7 +298,7 @@ static void saveMesh(onelab::client *c)
} }
onelab::string o("Gmsh/MshFileName", name, "Mesh name"); onelab::string o("Gmsh/MshFileName", name, "Mesh name");
c->set(o); c->set(o);
CreateOutputFile(o.getValue(), CTX::instance()->mesh.fileFormat); return name;
} }
} }
...@@ -340,23 +340,39 @@ void onelab_cb(Fl_Widget *w, void *data) ...@@ -340,23 +340,39 @@ void onelab_cb(Fl_Widget *w, void *data)
// can assume this) // can assume this)
onelab::server::citer it = onelab::server::instance()->findClient("Gmsh"); onelab::server::citer it = onelab::server::instance()->findClient("Gmsh");
if(it != onelab::server::instance()->lastClient()){ if(it != onelab::server::instance()->lastClient()){
static std::string gmshModelName = GModel::current()->getName(); onelab::client *c = it->second;
// reload geometry and/or mesh it if Gmsh parameters have been std::string mshFileName = getMshFileName(c);
// modified or if the geometrical model has changed static std::string modelName = GModel::current()->getName();
if(onelab::server::instance()->getChanged("Gmsh") || if(action == "check"){
gmshModelName != GModel::current()->getName()){ if(onelab::server::instance()->getChanged("Gmsh") ||
gmshModelName = GModel::current()->getName(); modelName != GModel::current()->getName()){
if(action == "check"){ // reload geometry if Gmsh parameters have been modified or if
// the model name has changed
modelName = GModel::current()->getName();
geometry_reload_cb(0, 0); geometry_reload_cb(0, 0);
} }
else if(action == "compute"){ }
else if(action == "compute"){
if(onelab::server::instance()->getChanged("Gmsh") ||
modelName != GModel::current()->getName()){
// reload the geometry, mesh it and save the mesh if Gmsh
// parameters have been modified or if the model name has
// changed
modelName = GModel::current()->getName();
geometry_reload_cb(0, 0); geometry_reload_cb(0, 0);
if(FlGui::instance()->onelab->meshAuto()){ if(FlGui::instance()->onelab->meshAuto()){
mesh_3d_cb(0, 0); mesh_3d_cb(0, 0);
saveMesh(it->second); CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
}
}
else if(StatFile(mshFileName)){
// mesh+save if the mesh file does not exist
if(FlGui::instance()->onelab->meshAuto()){
mesh_3d_cb(0, 0);
CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
} }
onelab::server::instance()->setChanged(false, "Gmsh");
} }
onelab::server::instance()->setChanged(false, "Gmsh");
} }
} }
......
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