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

better handling of mesh reuse + automatic display of onelab window if the model is parametric

parent fd3199c5
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
CTX::CTX() CTX::CTX()
{ {
// initialize everything that has no default value in // initialize everything that has no default value in DefaultOptions.h
// DefaultOptions.h
short int word = 0x0001; short int word = 0x0001;
char *byte = (char*)&word; char *byte = (char*)&word;
bigEndian = (byte[0] ? 0 : 1); bigEndian = (byte[0] ? 0 : 1);
...@@ -40,6 +39,7 @@ CTX::CTX() ...@@ -40,6 +39,7 @@ CTX::CTX()
outputFileName = ""; outputFileName = "";
bgmFileName = ""; bgmFileName = "";
createAppendMeshStatReport = 0; createAppendMeshStatReport = 0;
launchOnelabAtStartup = -2;
lc = 1.; lc = 1.;
min[0] = min[1] = min[2] = max[2] = 0.; min[0] = min[1] = min[2] = max[2] = 0.;
max[0] = max[1] = 1.; // for nice view when adding point in new model max[0] = max[1] = 1.; // for nice view when adding point in new model
......
...@@ -82,6 +82,8 @@ class CTX { ...@@ -82,6 +82,8 @@ class CTX {
std::vector<std::string> recentFiles; std::vector<std::string> recentFiles;
// create mesh statistics report (0: do nothing, 1: create, 2: append) // create mesh statistics report (0: do nothing, 1: create, 2: append)
int createAppendMeshStatReport; int createAppendMeshStatReport;
// should we launch the onelab interface at startup?
int launchOnelabAtStartup ;
// save session/option file on exit? // save session/option file on exit?
int sessionSave, optionsSave; int sessionSave, optionsSave;
// ask confirmation when overwriting files? // ask confirmation when overwriting files?
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "FlGui.h" #include "FlGui.h"
#include "menuWindow.h" #include "menuWindow.h"
#include "drawContext.h" #include "drawContext.h"
#include "onelabWindow.h"
#endif #endif
int GmshInitialize(int argc, char **argv) int GmshInitialize(int argc, char **argv)
...@@ -255,12 +256,15 @@ int GmshFLTK(int argc, char **argv) ...@@ -255,12 +256,15 @@ int GmshFLTK(int argc, char **argv)
Msg::Error("Invalid background mesh (no view)"); Msg::Error("Invalid background mesh (no view)");
} }
// listen to external solvers
#if defined(HAVE_ONELAB) #if defined(HAVE_ONELAB)
// listen to external solvers
if(CTX::instance()->solver.listen){ if(CTX::instance()->solver.listen){
onelab::localNetworkClient *c = new onelab::localNetworkClient("Listen", ""); onelab::localNetworkClient *c = new onelab::localNetworkClient("Listen", "");
c->run(); c->run();
} }
if(CTX::instance()->launchOnelabAtStartup != -2){
solver_cb(0, (void*)CTX::instance()->launchOnelabAtStartup);
}
#endif #endif
// loop // loop
......
...@@ -791,6 +791,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key, ...@@ -791,6 +791,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
{ {
#if defined(HAVE_ONELAB) #if defined(HAVE_ONELAB)
if(!_onelabClient || val.empty()) return; if(!_onelabClient || val.empty()) return;
CTX::instance()->launchOnelabAtStartup = -1;
std::string name = _getParameterName(key, copt); std::string name = _getParameterName(key, copt);
...@@ -872,6 +873,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key, ...@@ -872,6 +873,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
{ {
#if defined(HAVE_ONELAB) #if defined(HAVE_ONELAB)
if(!_onelabClient || val.empty()) return; if(!_onelabClient || val.empty()) return;
CTX::instance()->launchOnelabAtStartup = -1;
std::string name = _getParameterName(key, copt); std::string name = _getParameterName(key, copt);
......
...@@ -376,12 +376,10 @@ int MergeFile(const std::string &fileName, bool warnIfMissing) ...@@ -376,12 +376,10 @@ int MergeFile(const std::string &fileName, bool warnIfMissing)
#endif #endif
#if defined(HAVE_ONELAB) && defined(HAVE_FLTK) #if defined(HAVE_ONELAB) && defined(HAVE_FLTK)
else if(ext == ".pro" && opt_solver_name(0, GMSH_GET, "") == "GetDP"){ else if(ext == ".pro" && opt_solver_name(0, GMSH_GET, "") == "GetDP"){
// FIXME: this is a hack -- think about a better way
std::vector<std::string> split = SplitFileName(fileName); std::vector<std::string> split = SplitFileName(fileName);
GModel::current()->setName(""); GModel::current()->setName("");
status = MergeFile(split[0] + split[1] + ".geo"); status = MergeFile(split[0] + split[1] + ".geo");
CTX::instance()->lock = 0; // "uber hack for OpenProject in runGmshClient CTX::instance()->launchOnelabAtStartup = 0;
solver_cb(0, 0);
return status; return status;
} }
#endif #endif
......
...@@ -179,7 +179,7 @@ namespace onelabUtils { ...@@ -179,7 +179,7 @@ namespace onelabUtils {
recompute = true; recompute = true;
} }
else else
numbers[i].setIndex(numbers[i].getMax()); numbers[i].setIndex(numbers[i].getMax());
} }
else if(numbers[i].getStep() < 0){ else if(numbers[i].getStep() < 0){
int j = numbers[i].getIndex() + 1; int j = numbers[i].getIndex() + 1;
...@@ -283,6 +283,10 @@ namespace onelabUtils { ...@@ -283,6 +283,10 @@ namespace onelabUtils {
return changed; return changed;
} }
static bool _firstComputation = true;
void setFirstComputationFlag(bool val){ _firstComputation = val; }
bool getFirstComputationFlag(){ return _firstComputation; }
bool runGmshClient(const std::string &action, bool meshAuto) bool runGmshClient(const std::string &action, bool meshAuto)
{ {
bool redraw = false; bool redraw = false;
...@@ -294,13 +298,12 @@ namespace onelabUtils { ...@@ -294,13 +298,12 @@ namespace onelabUtils {
std::string mshFileName = onelabUtils::getMshFileName(c); std::string mshFileName = onelabUtils::getMshFileName(c);
static std::string modelName = GModel::current()->getName(); static std::string modelName = GModel::current()->getName();
static bool firstComputation = true;
if(action == "initialize"){ if(action == "initialize"){
// nothing to do // nothing to do
} }
else if(action == "reset"){ else if(action == "reset"){
firstComputation = false; setFirstComputationFlag(false);
OpenProject(GModel::current()->getFileName()); OpenProject(GModel::current()->getFileName());
} }
else if(action == "check"){ else if(action == "check"){
...@@ -321,7 +324,7 @@ namespace onelabUtils { ...@@ -321,7 +324,7 @@ namespace onelabUtils {
modelName = GModel::current()->getName(); modelName = GModel::current()->getName();
redraw = true; redraw = true;
OpenProject(GModel::current()->getFileName()); OpenProject(GModel::current()->getFileName());
if(firstComputation && !StatFile(mshFileName)){ if(getFirstComputationFlag() && !StatFile(mshFileName)){
Msg::Info("Skipping mesh generation: assuming '%s' is up-to-date", Msg::Info("Skipping mesh generation: assuming '%s' is up-to-date",
mshFileName.c_str()); mshFileName.c_str());
} }
...@@ -338,7 +341,7 @@ namespace onelabUtils { ...@@ -338,7 +341,7 @@ namespace onelabUtils {
CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat); CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
} }
} }
firstComputation = false; setFirstComputationFlag(false);
onelab::server::instance()->setChanged(false, "Gmsh"); onelab::server::instance()->setChanged(false, "Gmsh");
} }
......
...@@ -20,6 +20,8 @@ namespace onelabUtils { ...@@ -20,6 +20,8 @@ namespace onelabUtils {
std::vector<double> getRange(onelab::number &p); std::vector<double> getRange(onelab::number &p);
bool updateGraph(const std::string &graphNum); bool updateGraph(const std::string &graphNum);
bool runGmshClient(const std::string &action, bool meshAuto); bool runGmshClient(const std::string &action, bool meshAuto);
bool getFirstComputationFlag();
void setFirstComputationFlag(bool val);
} }
#endif #endif
...@@ -792,6 +792,11 @@ static bool getFlColor(const std::string &str, Fl_Color &c) ...@@ -792,6 +792,11 @@ static bool getFlColor(const std::string &str, Fl_Color &c)
template<class T> template<class T>
static void autoCheck(const T &pold, const T &pnew, bool force=false) static void autoCheck(const T &pold, const T &pnew, bool force=false)
{ {
if(onelabUtils::getFirstComputationFlag()){
if(pold.getValue() != pnew.getValue())
onelabUtils::setFirstComputationFlag(false);
}
if((CTX::instance()->solver.autoCheck && pnew.getAttribute("AutoCheck") != "0") || if((CTX::instance()->solver.autoCheck && pnew.getAttribute("AutoCheck") != "0") ||
pnew.getAttribute("AutoCheck") == "1"){ pnew.getAttribute("AutoCheck") == "1"){
if(force || pold.getValue() != pnew.getValue()) if(force || pold.getValue() != pnew.getValue())
......
...@@ -12,7 +12,7 @@ DefineConstant ...@@ -12,7 +12,7 @@ DefineConstant
rt2 = {0.092, Label "Tube external radius"}, rt2 = {0.092, Label "Tube external radius"},
lb = {1, Label "Infinite box width"}, lb = {1, Label "Infinite box width"},
left = {1, Choices{0,1}, Label "Terminals on the left?"} left = {1, Choices{0,1}, Label "Terminals on the left?"}
// macro = {"aa.pos", Label "Run my macro!", Kind "macro", Path "Actions"}, //macro = {"aa.pos", Label "Run my macro!", Kind "macro", Path "Actions"},
// showLines = {1, Choices {0,1}, Label "Show lines?"} // showLines = {1, Choices {0,1}, Label "Show lines?"}
]; ];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment