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

propagate -setnumber/-setstring command line options to subclients, as well as to new open models

parent 8a4d1819
No related branches found
No related tags found
No related merge requests found
...@@ -534,6 +534,7 @@ void GetOptions(int argc, char *argv[]) ...@@ -534,6 +534,7 @@ void GetOptions(int argc, char *argv[])
i++; i++;
if (i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') { if (i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') {
gmsh_yystringsymbols[argv[i]] = argv[i + 1]; gmsh_yystringsymbols[argv[i]] = argv[i + 1];
Msg::GetCommandLineStrings()[argv[i]] = argv[i + 1];
i += 2; i += 2;
} }
else else
...@@ -542,8 +543,8 @@ void GetOptions(int argc, char *argv[]) ...@@ -542,8 +543,8 @@ void GetOptions(int argc, char *argv[])
else if (!strcmp(argv[i]+1, "setnumber")) { else if (!strcmp(argv[i]+1, "setnumber")) {
i++; i++;
if (i + 1 < argc && argv[i][0] != '-') { if (i + 1 < argc && argv[i][0] != '-') {
std::vector<double> val(1, atof(argv[i + 1])); gmsh_yysymbols[argv[i]].value = std::vector<double>(1, atof(argv[i + 1]));
gmsh_yysymbols[argv[i]].value = val; Msg::GetCommandLineNumbers()[argv[i]] = atof(argv[i + 1]);
i += 2; i += 2;
} }
else else
... ...
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#include "extraDialogs.h" #include "extraDialogs.h"
#endif #endif
int Msg::_commRank = 0; int Msg::_commRank = 0;
int Msg::_commSize = 1; int Msg::_commSize = 1;
int Msg::_verbosity = 5; int Msg::_verbosity = 5;
...@@ -65,6 +64,8 @@ std::string Msg::_firstError; ...@@ -65,6 +64,8 @@ std::string Msg::_firstError;
GmshMessage *Msg::_callback = 0; GmshMessage *Msg::_callback = 0;
std::string Msg::_commandLine; std::string Msg::_commandLine;
std::string Msg::_launchDate; std::string Msg::_launchDate;
std::map<std::string, double> Msg::_commandLineNumbers;
std::map<std::string, std::string> Msg::_commandLineStrings;
#if !defined(HAVE_ONELAB2) #if !defined(HAVE_ONELAB2)
GmshClient *Msg::_client = 0; GmshClient *Msg::_client = 0;
#endif #endif
... ...
......
...@@ -47,6 +47,9 @@ class Msg { ...@@ -47,6 +47,9 @@ class Msg {
static GmshMessage *_callback; static GmshMessage *_callback;
// command-line and startup time // command-line and startup time
static std::string _commandLine, _launchDate; static std::string _commandLine, _launchDate;
// command-line-specified numbers and strings
static std::map<std::string, double> _commandLineNumbers;
static std::map<std::string, std::string> _commandLineStrings;
#if !defined(HAVE_ONELAB2) #if !defined(HAVE_ONELAB2)
// communication with Gmsh when run remotely // communication with Gmsh when run remotely
static GmshClient *_client; static GmshClient *_client;
...@@ -80,6 +83,14 @@ class Msg { ...@@ -80,6 +83,14 @@ class Msg {
static int GetVerbosity(){ return _verbosity; } static int GetVerbosity(){ return _verbosity; }
static std::string GetLaunchDate(){ return _launchDate; } static std::string GetLaunchDate(){ return _launchDate; }
static std::string GetCommandLineArgs(){ return _commandLine; } static std::string GetCommandLineArgs(){ return _commandLine; }
static std::map<std::string, double> &GetCommandLineNumbers()
{
return _commandLineNumbers;
}
static std::map<std::string, std::string> &GetCommandLineStrings()
{
return _commandLineStrings;
}
static void Fatal(const char *fmt, ...); static void Fatal(const char *fmt, ...);
static void Error(const char *fmt, ...); static void Error(const char *fmt, ...);
static void Warning(const char *fmt, ...); static void Warning(const char *fmt, ...);
... ...
......
...@@ -661,28 +661,25 @@ void OpenProject(const std::string &fileName, bool setWindowTitle) ...@@ -661,28 +661,25 @@ void OpenProject(const std::string &fileName, bool setWindowTitle)
// reuse it // reuse it
GModel::current()->destroy(); GModel::current()->destroy();
GModel::current()->getGEOInternals()->destroy(); GModel::current()->getGEOInternals()->destroy();
// don't clear the parser variables if we just launched gmsh with the
// -string, -setstring or -setnumber command line options
#if defined(HAVE_PARSER)
std::string c = Msg::GetCommandLineArgs();
if(c.find("-string") == std::string::npos &&
c.find("-setstring") == std::string::npos &&
c.find("-setnumber") == std::string::npos){
gmsh_yysymbols.clear();
gmsh_yystringsymbols.clear();
}
#endif
} }
else{ else{
// if the current model is not empty make it invisible, clear the parser // if the current model is not empty make it invisible and add a new model
// variables and add a new model new GModel();
GModel::current(GModel::list.size() - 1);
}
// clear parser variables, but keep -setnumber/-setstrings command line
// definitions
#if defined(HAVE_PARSER) #if defined(HAVE_PARSER)
gmsh_yysymbols.clear(); gmsh_yysymbols.clear();
gmsh_yystringsymbols.clear(); gmsh_yystringsymbols.clear();
std::map<std::string, double> cln(Msg::GetCommandLineNumbers());
for(std::map<std::string, double>::iterator it = cln.begin(); it != cln.end(); it++)
gmsh_yysymbols[it->first].value = std::vector<double>(1, it->second);
std::map<std::string, std::string> cls(Msg::GetCommandLineStrings());
for(std::map<std::string, std::string>::iterator it = cls.begin(); it != cls.end(); it++)
gmsh_yystringsymbols[it->first] = it->second;
#endif #endif
new GModel();
GModel::current(GModel::list.size() - 1);
}
// temporary hack until we fill the current GModel on the fly during parsing // temporary hack until we fill the current GModel on the fly during parsing
ResetTemporaryBoundingBox(); ResetTemporaryBoundingBox();
... ...
......
...@@ -124,17 +124,17 @@ namespace onelabUtils { ...@@ -124,17 +124,17 @@ namespace onelabUtils {
args.push_back(" " + checkCommand) ; args.push_back(" " + checkCommand) ;
else if(action == "compute") else if(action == "compute")
args.push_back(" " + computeCommand); args.push_back(" " + computeCommand);
// Experimental: propagate -setnumber/-setnumber gmsh option to the // Propagate -setnumber/-setnumber gmsh option to the client. (Is this a
// client. Is this a good idea? // good idea?)
std::vector<std::string> gmshOptions = onelab::parameter::split std::ostringstream sstream;
(Msg::GetCommandLineArgs(), ' '); sstream.precision(16);
for(unsigned int i = 0; i < gmshOptions.size(); i++){ std::map<std::string, double> cln(Msg::GetCommandLineNumbers());
if((gmshOptions[i] == "-setnumber" || gmshOptions[i] == "-setstring") && for(std::map<std::string, double>::iterator it = cln.begin(); it != cln.end(); it++)
i < gmshOptions.size() - 2){ sstream << " -setnumber " << it->first << " " << it->second;
args.push_back(" " + gmshOptions[i] + " " + gmshOptions[i + 1] + std::map<std::string, std::string> cls(Msg::GetCommandLineStrings());
" " + gmshOptions[i + 2]); for(std::map<std::string, std::string>::iterator it = cls.begin(); it != cls.end(); it++)
} sstream << " -setstring " << it->first << " " << it->second;
} args.push_back(sstream.str());
} }
return args; return args;
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment