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

fix compute command + simplify onelab_cb logic

parent 4cdd27f7
Branches
Tags
No related merge requests found
...@@ -62,6 +62,8 @@ void drawContext::load(std::string filename) ...@@ -62,6 +62,8 @@ void drawContext::load(std::string filename)
// restore default options // restore default options
GmshRestoreDefaultOptions(); GmshRestoreDefaultOptions();
// output messages on console
GmshSetOption("General", "Terminal", 1.0); GmshSetOption("General", "Terminal", 1.0);
// open the file with Gmsh // open the file with Gmsh
...@@ -659,13 +661,12 @@ std::vector<std::string> commandToVector(const std::string cmd) ...@@ -659,13 +661,12 @@ std::vector<std::string> commandToVector(const std::string cmd)
ret.push_back(cmd.substr(last,pos-1-last)); ret.push_back(cmd.substr(last,pos-1-last));
last = pos; last = pos;
} }
ret.push_back(cmd.substr(last,cmd.size()-1)); ret.push_back(cmd.substr(last));
return ret; return ret;
} }
int onelab_cb(std::string action) int onelab_cb(std::string action)
{ {
Msg::Debug("Ask onlab to %s", action.c_str());
if(action == "stop"){ if(action == "stop"){
onelab::string o("GetDP/Action", "stop"); onelab::string o("GetDP/Action", "stop");
o.setVisible(false); o.setVisible(false);
...@@ -674,9 +675,10 @@ int onelab_cb(std::string action) ...@@ -674,9 +675,10 @@ int onelab_cb(std::string action)
onelabStop = true; onelabStop = true;
return 0; return 0;
} }
if(locked) return -1; if(locked) return -1;
locked = true; locked = true;
int redraw = 0;
if(action == "reset"){ if(action == "reset"){
onelab::server::instance()->clear(); onelab::server::instance()->clear();
onelabUtils::runGmshClient(action, true); onelabUtils::runGmshClient(action, true);
...@@ -692,12 +694,17 @@ int onelab_cb(std::string action) ...@@ -692,12 +694,17 @@ int onelab_cb(std::string action)
} }
do{ do{
if(onelabUtils::runGmshClient(action, true)) // run Gmsh (only if necessary)
redraw = 1; onelabUtils::runGmshClient(action, true);
if(redraw == 0 && !onelab::server::instance()->getChanged("GetDP")) // run GetDP (always -- to not confuse the user)
continue; onelab::string o("GetDP/Action", action);
o.setVisible(false);
o.setNeverChanged(true);
onelab::server::instance()->set(o);
std::vector<std::string> args;
args.push_back("getdp");
std::vector<onelab::string> ps; std::vector<onelab::string> ps;
onelab::server::instance()->get(ps, "GetDP/1ModelName"); onelab::server::instance()->get(ps, "GetDP/1ModelName");
if(ps.empty()){ if(ps.empty()){
...@@ -706,47 +713,25 @@ int onelab_cb(std::string action) ...@@ -706,47 +713,25 @@ int onelab_cb(std::string action)
onelab::string o("GetDP/1ModelName", name, "Model name"); onelab::string o("GetDP/1ModelName", name, "Model name");
o.setKind("file"); o.setKind("file");
onelab::server::instance()->set(o); onelab::server::instance()->set(o);
ps.push_back(o);
} }
onelab::string o("GetDP/Action", action); args.push_back(ps[0].getValue());
o.setVisible(false); if(action == "check")
o.setNeverChanged(true); onelab::server::instance()->get(ps, "GetDP/9CheckCommand");
onelab::server::instance()->set(o); else if(action == "compute")
onelab::server::instance()->get(ps, "GetDP/9ComputeCommand");
if(action == "compute" && (onelab::server::instance()->getChanged("Gmsh") || else
onelab::server::instance()->getChanged("GetDP"))){ ps.clear();
std::string filename = GModel::current()->getFileName(); std::vector<std::string> c = commandToVector(ps.empty() ? "" : ps[0].getValue().c_str());
std::vector<std::string> args; args.insert(args.end(), c.begin(), c.end());
args.push_back("getdp");
std::vector<onelab::string> onelabArgs;
onelab::server::instance()->get(onelabArgs, "GetDP/1ModelName");
args.push_back((onelabArgs.empty())? SplitFileName(filename)[0] +
SplitFileName(filename)[1] : onelabArgs[0].getValue());
onelab::server::instance()->get(onelabArgs, "GetDP/9ComputeCommand");
std::vector<std::string> compute = commandToVector((onelabArgs.empty())? "" :
onelabArgs[0].getValue().c_str());
args.insert( args.end(), compute.begin(), compute.end() );
args.push_back("-onelab");
args.push_back("GetDP");
GetDP(args, onelab::server::instance());
}
if(action == "check" && (onelab::server::instance()->getChanged("Gmsh") ||
onelab::server::instance()->getChanged("GetDP"))){
std::string filename = GModel::current()->getFileName();
std::vector<std::string> args;
args.push_back("getdp");
std::vector<onelab::string> onelabArgs;
args.push_back(SplitFileName(filename)[0] + SplitFileName(filename)[1]);
onelab::server::instance()->get(onelabArgs, "GetDP/9CheckCommand");
args.push_back((onelabArgs.empty())? "" : onelabArgs[0].getValue());
args.push_back("-onelab"); args.push_back("-onelab");
args.push_back("GetDP"); args.push_back("GetDP");
GetDP(args, onelab::server::instance()); GetDP(args, onelab::server::instance());
}
} while(action == "compute" && !onelabStop && (onelabUtils::incrementLoop("3") || } while(action == "compute" && !onelabStop && (onelabUtils::incrementLoop("3") ||
onelabUtils::incrementLoop("2") || onelabUtils::incrementLoop("2") ||
onelabUtils::incrementLoop("1"))); onelabUtils::incrementLoop("1")));
locked = false; locked = false;
return redraw || onelab::server::instance()->getChanged(); return onelab::server::instance()->getChanged();
} }
int number_of_animation() int number_of_animation()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment