gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
GmshMessage.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include "GmshConfig.h"
7 
8 #if defined(HAVE_MPI)
9 #include <mpi.h>
10 #endif
11 
12 #if !defined(WIN32) || defined(__CYGWIN__)
13 #include <unistd.h>
14 #endif
15 
16 #include <clocale>
17 #include <stdlib.h>
18 #include <stdio.h>
19 #include <math.h>
20 #include <string.h>
21 #include <time.h>
22 #include <sys/stat.h>
23 #include "GmshMessage.h"
24 #include "GmshSocket.h"
25 #include "GmshGlobal.h"
26 #include "GModel.h"
27 #include "Options.h"
28 #include "Context.h"
29 #include "OpenFile.h"
30 #include "StringUtils.h"
31 #include "OS.h"
32 
33 #if defined(HAVE_ONELAB)
34 #include "onelab.h"
35 #include "onelabUtils.h"
36 #endif
37 
38 #include "gmshLocalNetworkClient.h"
39 
40 #if defined(HAVE_PETSC)
41 #include <petsc.h>
42 #endif
43 
44 #if defined(HAVE_SLEPC)
45 #include <slepc.h>
46 #endif
47 
48 #if defined(HAVE_FLTK)
49 #include <FL/fl_ask.H>
50 #include "FlGui.h"
51 #include "extraDialogs.h"
52 #endif
53 
54 #if defined(_OPENMP)
55 #include <omp.h>
56 #endif
57 
58 int Msg::_commRank = 0;
59 int Msg::_commSize = 1;
60 int Msg::_verbosity = 5;
62 std::atomic<int> Msg::_progressMeterCurrent(-1);
64 std::map<std::string, double> Msg::_timers;
65 bool Msg::_infoCpu = false;
66 bool Msg::_infoMem = false;
67 double Msg::_startTime = 0.;
68 int Msg::_warningCount = 0;
69 int Msg::_errorCount = 0;
71 std::string Msg::_firstWarning;
72 std::string Msg::_firstError;
73 std::string Msg::_lastError;
74 GmshMessage *Msg::_callback = nullptr;
75 std::vector<std::string> Msg::_commandLineArgs;
76 std::string Msg::_launchDate;
77 std::map<std::string, std::vector<double> > Msg::_commandLineNumbers;
78 std::map<std::string, std::string> Msg::_commandLineStrings;
79 GmshClient *Msg::_client = nullptr;
80 std::string Msg::_execName;
81 #if defined(HAVE_ONELAB)
82 onelab::client *Msg::_onelabClient = nullptr;
84 #endif
85 std::string Msg::_logFileName;
86 FILE *Msg::_logFile = nullptr;
87 
88 #if defined(_MSC_VER) && (_MSC_VER >= 1310) //NET 2003
89 #define vsnprintf _vsnprintf
90 #else
91 #if defined(HAVE_NO_VSNPRINTF)
92 static int vsnprintf(char *str, size_t size, const char *fmt, va_list ap)
93 {
94  if (strlen(fmt) > size - 1) { // just copy the format
95  strncpy(str, fmt, size - 1);
96  str[size - 1] = '\0';
97  return size;
98  }
99  return vsprintf(str, fmt, ap);
100 }
101 #endif
102 #endif
103 
104 static void addGmshPathToEnvironmentVar(const std::string &name)
105 {
106  std::string gmshPath = SplitFileName(CTX::instance()->exeFileName)[0];
107  if(gmshPath.size()){
108  std::string tmp = GetEnvironmentVar(name);
109  if(tmp.find(gmshPath) != std::string::npos) return; // already there
110  std::string path;
111  if(tmp.empty()) {
112  path = gmshPath;
113  }
114  else {
115 #if defined(WIN32)
116  path = tmp + ";" + gmshPath;
117 #else
118  path = tmp + ":" + gmshPath;
119 #endif
120  }
121  SetEnvironmentVar(name, path);
122  }
123 }
124 
125 void Msg::Initialize(int argc, char **argv)
126 {
127  _startTime = TimeOfDay();
128 #if defined(HAVE_MPI)
129  int flag;
130  MPI_Initialized(&flag);
131  if(!flag) MPI_Init(&argc, &argv);
132  MPI_Comm_rank(MPI_COMM_WORLD, &_commRank);
133  MPI_Comm_size(MPI_COMM_WORLD, &_commSize);
134  MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
135 #endif
136 #if defined(HAVE_PETSC)
137  int sargc = 0;
138  char **sargv = new char*[argc + 1];
139  // prune argv from gmsh-specific options that make PETSc verbose
140  for(int i = 0; i < argc; i++){
141  std::string val(argv[i]);
142  if(val != "-info" && val != "-help" && val != "-version" && val != "-v")
143  sargv[sargc++] = argv[i];
144  }
145  sargv[sargc] = nullptr;
146  PetscInitialize(&sargc, &sargv, PETSC_NULL, PETSC_NULL);
147  PetscPopSignalHandler();
148 #if defined(HAVE_SLEPC)
149  SlepcInitialize(&sargc, &sargv, PETSC_NULL, PETSC_NULL);
150 #endif
151  delete [] sargv;
152 #endif
153  time_t now;
154  time(&now);
155  _launchDate = ctime(&now);
156  _launchDate.resize(_launchDate.size() - 1);
157 
158  bool _env = true, _locale = true;
159  _commandLineArgs.resize(argc);
160  for(int i = 0; i < argc; i++) {
161  _commandLineArgs[i] = argv[i];
162  if(_commandLineArgs[i] == "-noenv")
163  _env = false;
164  else if(_commandLineArgs[i] == "-nolocale")
165  _locale = false;
166  }
167 
169  if(CTX::instance()->exeFileName.empty() && _commandLineArgs.size())
171 
172  if(_env) {
173  // add the directory where the binary is installed to the path where Python
174  // looks for modules, and to the path for executables (this allows us to
175  // find the onelab.py module or subclients automatically)
176  addGmshPathToEnvironmentVar("PYTHONPATH");
178  }
179 
180  if(_locale) {
181  // make sure to use the "C" locale; in particular this ensures that we will
182  // use a dot for for the decimal separator when writing ASCII mesh files
183  std::setlocale(LC_ALL, "C.UTF-8");
184  std::setlocale(LC_NUMERIC, "C");
185  }
186 
187  InitializeOnelab("Gmsh");
188 
189 #if defined(_OPENMP)
190  // this is deprecated
191  //omp_set_nested(true);
192 #endif
193 }
194 
196 {
197  // close log file
198  if(_logFile){
199  fclose(_logFile);
200  _logFile = nullptr;
201  }
202 
203 #if defined(HAVE_SLEPC)
204  SlepcFinalize();
205 #endif
206 #if defined(HAVE_PETSC)
207  // this often crashes when called multiple times
208  //PetscFinalize();
209 #endif
210 #if defined(HAVE_MPI)
211  int finalized; // Some PETSc versions call MPI_FINALIZE
212  MPI_Finalized(&finalized);
213  if (!finalized)
214  MPI_Finalize();
215 #endif
216  FinalizeOnelab();
217 }
218 
220 {
221  return _commRank;
222 }
223 
225 {
226  return _commSize;
227 }
228 
229 void Msg::SetCommRank(int val)
230 {
231  _commRank = val;
232 }
233 
234 void Msg::SetCommSize(int val)
235 {
236  _commSize = val;
237 }
238 
240 {
241  _callback = callback;
242 }
243 
245 {
246  return _callback;
247 }
248 
249 void Msg::SetVerbosity(int val)
250 {
251  _verbosity = val;
252 }
253 
255 {
256  return _verbosity;
257 }
258 
259 void Msg::SetLogFile(const std::string &name)
260 {
261  _logFileName = name;
262  if(_logFile) fclose(_logFile);
263  if(name.size()){
264  _logFile = Fopen(name.c_str(), "w");
265  if(!_logFile)
266  Msg::Error("Could not open file '%s'", name.c_str());
267  }
268  else
269  _logFile = nullptr;
270 }
271 
272 std::string Msg::GetLaunchDate()
273 {
274  return _launchDate;
275 }
276 
277 std::vector<std::string> &Msg::GetCommandLineArgs()
278 {
279  return _commandLineArgs;
280 }
281 
283 {
284  std::string tmp;
285  for(std::size_t i = 0; i < _commandLineArgs.size(); i++){
286  if(i) tmp += " ";
287  tmp += _commandLineArgs[i];
288  }
289  return tmp;
290 }
291 
292 std::map<std::string, std::vector<double> > &Msg::GetCommandLineNumbers()
293 {
294  return _commandLineNumbers;
295 }
296 
297 std::map<std::string, std::string> &Msg::GetCommandLineStrings()
298 {
299  return _commandLineStrings;
300 }
301 
303 {
304  _progressMeterStep = step;
305 }
306 
308 {
309  return _progressMeterStep;
310 }
311 
312 void Msg::StartProgressMeter(int ntotal)
313 {
315  _progressMeterTotal = ntotal;
316 }
317 
319 {
322 #if defined(HAVE_FLTK)
323  if(FlGui::available()){
324  FlGui::instance()->setProgress("", 0, 0, 1);
325  FlGui::check(true);
326  }
327 #endif
328 }
329 
330 void Msg::SetInfoCpu(bool val)
331 {
332  _infoCpu = val;
333 }
334 
335 void Msg::SetInfoMem(bool val)
336 {
337  _infoMem = val;
338 }
339 
340 double &Msg::Timer(const std::string &str) { return _timers[str]; }
341 
343 {
344  return _warningCount;
345 }
346 
348 {
349  return _errorCount;
350 }
351 
352 std::string Msg::GetFirstWarning()
353 {
354  return _firstWarning;
355 }
356 
357 std::string Msg::GetFirstError()
358 {
359  return _firstError;
360 }
361 
362 std::string Msg::GetLastError()
363 {
364  return _lastError;
365 }
366 
367 void Msg::SetExecutableName(const std::string &name)
368 {
369  _execName.assign(name);
370 }
371 
373 {
374  return _execName;
375 }
376 
377 #if defined(HAVE_ONELAB)
378 onelab::client *Msg::GetOnelabClient()
379 {
380  return _onelabClient;
381 }
382 #endif
383 
384 void Msg::Exit(int level)
385 {
386  Finalize();
387 #if defined(HAVE_MPI)
388  if(level) MPI_Abort(MPI_COMM_WORLD, level);
389 #endif
390  exit(level ? level : _atLeastOneErrorInRun);
391 }
392 
393 static int streamIsFile(FILE *stream)
394 {
395  // the given stream is definitely not interactive if it is a regular file
396  struct stat stream_stat;
397  if(fstat(fileno(stream), &stream_stat) == 0){
398  if(stream_stat.st_mode & S_IFREG) return 1;
399  }
400  return 0;
401 }
402 
403 static int streamIsVT100(FILE *stream)
404 {
405  // on unix directly check if the file descriptor refers to a terminal
406 #if !defined(WIN32) || defined(__CYGWIN__)
407  return isatty(fileno(stream));
408 #endif
409 
410  // otherwise try to detect some known cases:
411 
412  // if running inside emacs the terminal is not VT100
413  const char* emacs = getenv("EMACS");
414  if(emacs && *emacs == 't') return 0;
415 
416  // list of known terminal names (from cmake)
417  static const char* names[] =
418  {"Eterm", "ansi", "color-xterm", "con132x25", "con132x30", "con132x43",
419  "con132x60", "con80x25", "con80x28", "con80x30", "con80x43", "con80x50",
420  "con80x60", "cons25", "console", "cygwin", "dtterm", "eterm-color", "gnome",
421  "gnome-256color", "konsole", "konsole-256color", "kterm", "linux", "msys",
422  "linux-c", "mach-color", "mlterm", "putty", "rxvt", "rxvt-256color",
423  "rxvt-cygwin", "rxvt-cygwin-native", "rxvt-unicode", "rxvt-unicode-256color",
424  "screen", "screen-256color", "screen-256color-bce", "screen-bce", "screen-w",
425  "screen.linux", "vt100", "xterm", "xterm-16color", "xterm-256color",
426  "xterm-88color", "xterm-color", "xterm-debian", nullptr};
427  const char** t = nullptr;
428  const char* term = getenv("TERM");
429  if(term){
430  for(t = names; *t && strcmp(term, *t) != 0; ++t) {}
431  }
432  if(!(t && *t)) return 0;
433  return 1;
434 }
435 
436 std::string Msg::PrintResources(bool printDate, bool printWallTime,
437  bool printCpu, bool printMem)
438 {
439  long mem = GetMemoryUsage();
440 
441  std::string pdate = "";
442  if(printDate){
443  time_t now;
444  time(&now);
445  pdate = ctime(&now);
446  pdate.resize(pdate.size() - 1);
447  if(printWallTime || printCpu || (printMem && mem))
448  pdate += ", ";
449  }
450 
451  std::string pwall = "";
452  if(printWallTime){
453  char tmp[128];
454  sprintf(tmp, "Wall %gs", TimeOfDay() - _startTime);
455  pwall = tmp;
456  if(printCpu || (printMem && mem))
457  pwall += ", ";
458  }
459 
460  std::string pcpu = "";
461  if(printCpu){
462  char tmp[128];
463  sprintf(tmp, "CPU %gs", Cpu());
464  pcpu = tmp;
465  if(printMem && mem)
466  pcpu += ", ";
467  }
468 
469  std::string pmem = "";
470  if(mem && printMem){
471  char tmp[128];
472  sprintf(tmp, "Mem %gMb", (double)mem / 1024. / 1024.);
473  pmem = tmp;
474  }
475 
476  std::string str;
477  if(pdate.size() || pwall.size() || pcpu.size() || pmem.size())
478  str += " (From start: " + pdate + pwall + pcpu + pmem + ")";
479  return str;
480 }
481 
482 void Msg::Error(const char *fmt, ...)
483 {
484 #pragma omp critical(MsgError)
485  {
486  _errorCount++;
488  }
489  char str[5000];
490  va_list args;
491  va_start(args, fmt);
492  vsnprintf(str, sizeof(str), fmt, args);
493  va_end(args);
494  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
495 
496 #pragma omp critical(MsgError)
497  {
498  if(_firstError.empty()) _firstError = str;
499  _lastError = str;
500  }
501 
502  if(GetVerbosity() >= 1) {
503  if(_logFile) fprintf(_logFile, "Error: %s\n", str);
504  if(_callback) (*_callback)("Error", str);
505  if(_client) _client->Error(str);
506 #if defined(HAVE_FLTK)
507  if(FlGui::available()){
508  std::string tmp = std::string(CTX::instance()->guiColorScheme ? "@B72@." : "@C1@.")
509  + "Error : " + str;
510  FlGui::instance()->addMessage(tmp.c_str());
511  FlGui::instance()->setLastStatus
512  (CTX::instance()->guiColorScheme ? FL_DARK_RED : FL_RED);
513  FlGui::check(true);
514  }
515 #endif
516  if(CTX::instance()->terminal){
517  const char *c0 = "", *c1 = "";
518  if(!streamIsFile(stderr) && streamIsVT100(stderr)){
519  c0 = "\33[1m\33[31m"; c1 = "\33[0m"; // bold red
520  }
521  if(_commSize > 1)
522  fprintf(stderr, "%sError : [rank %3d] %s%s\n", c0, GetCommRank(), str, c1);
523  else
524  fprintf(stderr, "%sError : %s%s\n", c0, str, c1);
525  fflush(stderr);
526  }
527  }
528 
529  if(CTX::instance()->abortOnError == 2) {
530 #if defined(HAVE_FLTK)
531  if(FlGui::available()) return; // don't throw if GUI is running
532 #endif
533  throw std::runtime_error(_lastError);
534  }
535  else if(CTX::instance()->abortOnError == 3) {
536  throw std::runtime_error(_lastError);
537  }
538  else if(CTX::instance()->abortOnError == 4) {
539  Exit(1);
540  }
541 }
542 
543 void Msg::Warning(const char *fmt, ...)
544 {
545 #pragma omp critical(MsgWarning)
546  {
547  _warningCount++;
548  }
549 
550  if(GetVerbosity() < 2) return;
551 
552  char str[5000];
553  va_list args;
554  va_start(args, fmt);
555  vsnprintf(str, sizeof(str), fmt, args);
556  va_end(args);
557  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
558 
559  if(_logFile) fprintf(_logFile, "Warning: %s\n", str);
560  if(_callback) (*_callback)("Warning", str);
561  if(_client) _client->Warning(str);
562 
563 #if defined(HAVE_FLTK)
564  if(FlGui::available()){
565  std::string tmp = std::string(CTX::instance()->guiColorScheme ? "@B152@." : "@C5@.")
566  + "Warning : " + str;
567  FlGui::instance()->addMessage(tmp.c_str());
568  if(_firstWarning.empty()) _firstWarning = str;
569  FlGui::instance()->setLastStatus();
570  FlGui::check(true);
571  }
572 #endif
573 
574  if(CTX::instance()->terminal){
575  const char *c0 = "", *c1 = "";
576  if(!streamIsFile(stderr) && streamIsVT100(stderr)){
577  c0 = "\33[35m"; c1 = "\33[0m"; // magenta
578  }
579  if(_commSize > 1)
580  fprintf(stderr, "%sWarning : [rank %3d] %s%s\n", c0, GetCommRank(), str, c1);
581  else
582  fprintf(stderr, "%sWarning : %s%s\n", c0, str, c1);
583  fflush(stderr);
584  }
585 }
586 
587 void Msg::Info(const char *fmt, ...)
588 {
589  if(GetVerbosity() < 4) return;
590 
591  char str[5000];
592  va_list args;
593  va_start(args, fmt);
594  vsnprintf(str, sizeof(str), fmt, args);
595  va_end(args);
596  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
597 
598  if(_infoCpu || _infoMem){
599  std::string res = PrintResources(false, _infoCpu, _infoCpu, _infoMem);
600  strcat(str, res.c_str());
601  }
602 
603  if(_logFile) fprintf(_logFile, "Info: %s\n", str);
604  if(_callback) (*_callback)("Info", str);
605  if(_client) _client->Info(str);
606 
607 #if defined(HAVE_FLTK)
608  if(FlGui::available()){
609  std::string tmp = std::string("Info : ") + str;
610  FlGui::instance()->addMessage(tmp.c_str());
611  FlGui::check(true);
612  }
613 #endif
614 
615  if(CTX::instance()->terminal){
617  _commSize == 1) {
618  int p = _progressMeterCurrent;
619  fprintf(stdout, "Info : [%3d%%] %s\n", p, str);
620  }
621  else if(_commSize > 1)
622  fprintf(stdout, "Info : [rank %3d] %s\n", GetCommRank(), str);
623  else
624  fprintf(stdout, "Info : %s\n", str);
625  fflush(stdout);
626  }
627 }
628 
630 {
631  if(_callback) (*_callback)("RequestRender", "");
632 }
633 
634 void Msg::Direct(const char *fmt, ...)
635 {
636  if(GetVerbosity() < 3) return;
637 
638  char str[5000];
639  va_list args;
640  va_start(args, fmt);
641  vsnprintf(str, sizeof(str), fmt, args);
642  va_end(args);
643  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
644 
645  if(_logFile) fprintf(_logFile, "Direct: %s\n", str);
646  if(_callback) (*_callback)("Direct", str);
647  if(_client) _client->Info(str);
648 
649 #if defined(HAVE_FLTK)
650  if(FlGui::available()){
651  std::string tmp = std::string(CTX::instance()->guiColorScheme ? "@B136@." : "@C4@.")
652  + str;
653  FlGui::instance()->addMessage(tmp.c_str());
654  FlGui::check(true);
655  }
656 #endif
657 
658  if(CTX::instance()->terminal){
659  const char *c0 = "", *c1 = "";
660  if(!streamIsFile(stdout) && streamIsVT100(stdout)){
661  c0 = "\33[34m"; c1 = "\33[0m"; // blue
662  }
663  if(_commSize > 1)
664  fprintf(stdout, "%s[rank %3d] %s%s\n", c0, GetCommRank(), str, c1);
665  else
666  fprintf(stdout, "%s%s%s\n", c0, str, c1);
667  fflush(stdout);
668  }
669 }
670 
671 void Msg::Auto(const char *fmt, ...)
672 {
673  char str[5000];
674  va_list args;
675  va_start(args, fmt);
676  vsnprintf(str, sizeof(str), fmt, args);
677  va_end(args);
678  if(strstr(str, "Error") || strstr(str, "error") || strstr(str, "ERROR"))
679  Msg::Error("%s", str);
680  else if(strstr(str, "Warning") || strstr(str, "warning") || strstr(str, "WARNING"))
681  Msg::Warning("%s", str);
682  else
683  Msg::Info("%s", str);
684 }
685 
686 void Msg::StatusBar(bool log, const char *fmt, ...)
687 {
688  if(GetVerbosity() < 4) return;
689 
690  char str[5000];
691  va_list args;
692  va_start(args, fmt);
693  vsnprintf(str, sizeof(str), fmt, args);
694  va_end(args);
695  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
696 
697  if(_infoCpu || _infoMem){
698  std::string res = PrintResources(false, _infoCpu, _infoCpu, _infoMem);
699  strcat(str, res.c_str());
700  }
701 
702  if(_logFile) fprintf(_logFile, "Info: %s\n", str);
703  if(_callback && log) (*_callback)("Info", str);
704  if(_client && log) _client->Info(str);
705 
706 #if defined(HAVE_FLTK)
707  if(FlGui::available()){
708  if(!log || GetVerbosity() > 4)
709  FlGui::instance()->setStatus(str);
710  if(log){
711  std::string tmp = std::string("Info : ") + str;
712  FlGui::instance()->addMessage(tmp.c_str());
713  FlGui::check(true);
714  }
715  }
716 #endif
717 
718  if(log && CTX::instance()->terminal){
719  if(_commSize > 1)
720  fprintf(stdout, "Info : [rank %3d] %s\n", GetCommRank(), str);
721  else
722  fprintf(stdout, "Info : %s\n", str);
723  fflush(stdout);
724  }
725 }
726 
727 void Msg::StatusGl(const char *fmt, ...)
728 {
729 #if defined(HAVE_FLTK)
730  if(GetCommRank()) return;
731  char str[5000];
732  va_list args;
733  va_start(args, fmt);
734  vsnprintf(str, sizeof(str), fmt, args);
735  va_end(args);
736  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
737 
738  if(FlGui::available())
739  FlGui::instance()->setStatus(str, true);
740 #endif
741 }
742 
743 void Msg::SetWindowTitle(const std::string &title)
744 {
745 #if defined(HAVE_FLTK)
746  if(FlGui::available()){
747  FlGui::instance()->setGraphicTitle(title);
748  }
749 #endif
750 }
751 
752 void Msg::Debug(const char *fmt, ...)
753 {
754  if(GetVerbosity() < 99) return;
755 
756  char str[5000];
757  va_list args;
758  va_start(args, fmt);
759  vsnprintf(str, sizeof(str), fmt, args);
760  va_end(args);
761  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
762 
763  if(_logFile) fprintf(_logFile, "Debug: %s\n", str);
764  if(_callback) (*_callback)("Debug", str);
765  if(_client) _client->Info(str);
766 
767 #if defined(HAVE_FLTK)
768  if(FlGui::available()){
769  std::string tmp = std::string("Debug : ") + str;
770  FlGui::instance()->addMessage(tmp.c_str());
771  }
772 #endif
773 
774  if(CTX::instance()->terminal){
775  if(_commSize > 1)
776  fprintf(stdout, "Debug : [rank %3d] %s\n", GetCommRank(), str);
777  else
778  fprintf(stdout, "Debug : %s\n", str);
779  fflush(stdout);
780  }
781 }
782 
783 void Msg::ProgressMeter(int n, bool log, const char *fmt, ...)
784 {
785  if(GetCommRank() || GetVerbosity() < 4) return;
786  if(_progressMeterStep <= 0 || _progressMeterStep >= 100) return;
787  if(_progressMeterTotal <= 0) return;
788 
789  int N = _progressMeterTotal;
790  double percent = 100. * (double)n / (double)N;
791 
792  if(percent >= _progressMeterCurrent || n > N - 1){
793  int p = _progressMeterCurrent;
794  while(p < percent) p += _progressMeterStep;
795  if(p >= 100) p = 100;
796 
798 
799  // TODO With C++11 use std::string (contiguous layout) and avoid all these C
800  // problems
801  // str2 needs to have at least 5018 bytes or buffer overflow will occur
802  char str[5000], str2[5100];
803  va_list args;
804  va_start(args, fmt);
805  vsnprintf(str, sizeof(str), fmt, args);
806  va_end(args);
807  int l = strlen(str); if(str[l - 1] == '\n') str[l - 1] = '\0';
808  sprintf(str2, "Info : [%3d%%] %s", p, str);
809 
810  if(_client) _client->Progress(str2);
811 
812 #if defined(HAVE_FLTK)
813  if(FlGui::available() && GetVerbosity() > 4){
814  FlGui::instance()->setProgress(str, (n > N - 1) ? 0 : n, 0, N);
815  FlGui::check(true);
816  }
817 #endif
818  if(_logFile) fprintf(_logFile, "Progress: %s\n", str);
819  if(_callback) (*_callback)("Progress", str);
820  if(!streamIsFile(stdout) && log && CTX::instance()->terminal){
821  fprintf(stdout, "%s \r",
822  (n > N - 1) ? "" : str2);
823  fflush(stdout);
824  }
825  }
826 }
827 
829 {
830  // do a single stdio call!
831  std::string str;
832  for(auto it = _timers.begin();
833  it != _timers.end(); it++){
834  if(it != _timers.begin()) str += ", ";
835  char tmp[256];
836  sprintf(tmp, "%s = %gs ", it->first.c_str(), it->second);
837  str += std::string(tmp);
838  }
839  if(!str.size()) return;
840 
841  if(CTX::instance()->terminal){
842  if(_commSize > 1)
843  fprintf(stdout, "Timers : [rank %3d] %s\n", GetCommRank(), str.c_str());
844  else
845  fprintf(stdout, "Timers : %s\n", str.c_str());
846  fflush(stdout);
847  }
848 }
849 
851 {
852  _warningCount = 0; _errorCount = 0;
853  _firstWarning.clear(); _firstError.clear(); _lastError.clear();
854 #if defined(HAVE_FLTK)
855  if(FlGui::available()) FlGui::instance()->setLastStatus();
856 #endif
857 }
858 
859 void Msg::PrintErrorCounter(const char *title)
860 {
861  if(GetCommRank() || GetVerbosity() < 1) return;
862  if(!GetWarningCount() && !GetErrorCount()) return;
863 
864  std::string prefix = GetErrorCount() ? "Error : " : "Warning : ";
865  std::string help("Check the full log for details");
866  std::string line(std::max(strlen(title), help.size()), '-');
867  char warn[128], err[128];
868  sprintf(warn, "%5d warning%s", GetWarningCount(), GetWarningCount() == 1 ? "" : "s");
869  sprintf(err, "%5d error%s", GetErrorCount(), GetErrorCount() == 1 ? "" : "s");
870 
871 #if defined(HAVE_FLTK)
872  if(FlGui::available()){
873  std::string col = GetErrorCount() ?
874  std::string(CTX::instance()->guiColorScheme ? "@B72@." : "@C1@.") :
875  std::string(CTX::instance()->guiColorScheme ? "@B152@." : "@C5@.");
876  FlGui::instance()->addMessage((col + prefix + line).c_str());
877  FlGui::instance()->addMessage((col + prefix + title).c_str());
878  FlGui::instance()->addMessage((col + prefix + warn).c_str());
879  FlGui::instance()->addMessage((col + prefix + err).c_str());
880  FlGui::instance()->addMessage((col + prefix + help).c_str());
881  FlGui::instance()->addMessage((col + prefix + line).c_str());
882  if(GetErrorCount()) fl_beep();
883  }
884 #endif
885 
886  if(CTX::instance()->terminal){
887  const char *c0 = "", *c1 = "";
888  if(!streamIsFile(stderr) && streamIsVT100(stderr)){
889  c0 = GetErrorCount() ? "\33[1m\33[31m" : "\33[35m"; // bold red or magenta
890  c1 = "\33[0m";
891  }
892  fprintf(stderr, "%s%s\n%s\n%s\n%s\n%s\n%s%s\n", c0, (prefix + line).c_str(),
893  (prefix + title).c_str(), (prefix + warn).c_str(),
894  (prefix + err).c_str(), (prefix + help).c_str(),
895  (prefix + line).c_str(), c1);
896  fflush(stderr);
897  }
898 }
899 
900 double Msg::GetValue(const char *text, double defaultval)
901 {
902  // if a callback is given let's assume we don't want to be bothered
903  // with interactive stuff
904  if(CTX::instance()->noPopup || _callback) return defaultval;
905 
906 #if defined(HAVE_FLTK)
907  if(FlGui::available()){
908  char defaultstr[256];
909  sprintf(defaultstr, "%.16g", defaultval);
910  const char *ret = fl_input(text, defaultstr, "");
911  if(!ret)
912  return defaultval;
913  else
914  return atof(ret);
915  }
916 #endif
917 
918  printf("%s (default=%.16g): ", text, defaultval);
919  char str[256];
920  char *ret = fgets(str, sizeof(str), stdin);
921  if(!ret || !strlen(str) || !strcmp(str, "\n"))
922  return defaultval;
923  else
924  return atof(str);
925 }
926 
927 std::string Msg::GetString(const char *text, const std::string &defaultval)
928 {
929  // if a callback is given let's assume we don't want to be bothered
930  // with interactive stuff
931  if(CTX::instance()->noPopup || _callback) return defaultval;
932 
933 #if defined(HAVE_FLTK)
934  if(FlGui::available()){
935  const char *ret = fl_input(text, defaultval.c_str(), "");
936  if(!ret)
937  return defaultval;
938  else
939  return std::string(ret);
940  }
941 #endif
942 
943  printf("%s (default=%s): ", text, defaultval.c_str());
944  char str[256];
945  char *ret = fgets(str, sizeof(str), stdin);
946  if(!ret || !strlen(str) || !strcmp(str, "\n"))
947  return defaultval;
948  else
949  return std::string(str);
950 }
951 
952 int Msg::GetAnswer(const char *question, int defaultval, const char *zero,
953  const char *one, const char *two)
954 {
955  // if a callback is given let's assume we don't want to be bothered
956  // with interactive stuff
957  if(CTX::instance()->noPopup || _callback) return defaultval;
958 
959 #if defined(HAVE_FLTK)
960  if(FlGui::available())
961  return fl_choice(question, zero, one, two, "");
962 #endif
963 
964  if(two)
965  printf("%s\n\n0=[%s] 1=[%s] 2=[%s] (default=%d): ", question,
966  zero, one, two, defaultval);
967  else
968  printf("%s\n\n0=[%s] 1=[%s] (default=%d): ", question,
969  zero, one, defaultval);
970  char str[256];
971  char *ret = fgets(str, sizeof(str), stdin);
972  if(!ret || !strlen(str) || !strcmp(str, "\n"))
973  return defaultval;
974  else
975  return atoi(ret);
976 }
977 
979 {
980 #if defined(HAVE_ONELAB)
981  return _onelabClient ? true : false;
982 #else
983  return false;
984 #endif
985 }
986 
987 void Msg::SetOnelabNumber(const std::string &name, double val, bool visible,
988  bool persistent, bool readOnly, int changedValue)
989 {
990 #if defined(HAVE_ONELAB)
991  if(_onelabClient){
992  // get if first so we can keep its options
993  std::vector<onelab::number> numbers;
994  _onelabClient->get(numbers, name);
995  if(numbers.empty()){
996  numbers.resize(1);
997  numbers[0].setName(name);
998  }
999  numbers[0].setValue(val);
1000  if(!visible) numbers[0].setVisible(false);
1001  if(persistent) numbers[0].setAttribute("Persistent", "1");
1002  numbers[0].setReadOnly(readOnly);
1003  numbers[0].setChangedValue(changedValue);
1004  _onelabClient->set(numbers[0]);
1005  }
1006 #endif
1007 }
1008 
1009 void Msg::SetOnelabNumber(const std::string &name, const std::vector<double> &val,
1010  bool visible)
1011 {
1012 #if defined(HAVE_ONELAB)
1013  if(_onelabClient){
1014  onelab::number n(name, val);
1015  if(!visible) n.setVisible(false);
1016  _onelabClient->set(n);
1017  }
1018 #endif
1019 }
1020 
1021 void Msg::SetOnelabString(const std::string &name, const std::string &val,
1022  bool visible, bool persistent, bool readOnly,
1023  int changedValue, const std::string &kind)
1024 {
1025 #if defined(HAVE_ONELAB)
1026  if(_onelabClient){
1027  // get if first so we can keep its options
1028  std::vector<onelab::string> strings;
1029  _onelabClient->get(strings, name);
1030  if(strings.empty()){
1031  strings.resize(1);
1032  strings[0].setName(name);
1033  }
1034  strings[0].setValue(val);
1035  if(!visible) strings[0].setVisible(false);
1036  if(persistent) strings[0].setAttribute("Persistent", "1");
1037  strings[0].setReadOnly(readOnly);
1038  strings[0].setChangedValue(changedValue);
1039  if(kind.size()) strings[0].setKind(kind);
1040  _onelabClient->set(strings[0]);
1041  }
1042 #endif
1043 }
1044 
1045 void Msg::AddOnelabStringChoice(const std::string &name,
1046  const std::string &kind,
1047  const std::string &value, bool updateValue,
1048  bool readOnly, bool visible)
1049 {
1050 #if defined(HAVE_ONELAB)
1051  if(_onelabClient){
1052  std::vector<std::string> choices;
1053  std::vector<onelab::string> ps;
1054  _onelabClient->get(ps, name);
1055  if(ps.size()){
1056  choices = ps[0].getChoices();
1057  if(std::find(choices.begin(), choices.end(), value) == choices.end())
1058  choices.push_back(value);
1059  if(updateValue)
1060  ps[0].setValue(value);
1061  }
1062  else{
1063  ps.resize(1);
1064  ps[0].setName(name);
1065  ps[0].setKind(kind);
1066  ps[0].setValue(value);
1067  choices.push_back(value);
1068  }
1069  ps[0].setChoices(choices);
1070  if(readOnly){
1071  ps[0].setReadOnly(true);
1072  ps[0].setAttribute("AutoCheck", "0");
1073  }
1074  else{
1075  ps[0].setReadOnly(false);
1076  ps[0].setAttribute("AutoCheck", "1");
1077  }
1078  ps[0].setVisible(visible);
1079  _onelabClient->set(ps[0]);
1080  }
1081 #endif
1082 }
1083 
1084 double Msg::GetOnelabNumber(const std::string &name, double defaultValue,
1085  bool errorIfMissing)
1086 {
1087 #if defined(HAVE_ONELAB)
1088  if(_onelabClient){
1089  std::vector<onelab::number> numbers;
1090  _onelabClient->get(numbers, name);
1091  if(numbers.empty()){
1092  if(errorIfMissing)
1093  Msg::Error("Unknown ONELAB number parameter '%s'", name.c_str());
1094  return defaultValue;
1095  }
1096  else
1097  return numbers[0].getValue();
1098  }
1099 #endif
1100  if(errorIfMissing)
1101  Msg::Error("GetNumber requires a ONELAB client");
1102  return defaultValue;
1103 }
1104 
1105 std::string Msg::GetOnelabString(const std::string &name,
1106  const std::string &defaultValue,
1107  bool errorIfMissing)
1108 {
1109 #if defined(HAVE_ONELAB)
1110  if(_onelabClient){
1111  std::vector<onelab::string> strings;
1112  _onelabClient->get(strings, name);
1113  if(strings.empty()){
1114  if(errorIfMissing)
1115  Msg::Error("Unknown ONELAB string parameter '%s'", name.c_str());
1116  return defaultValue;
1117  }
1118  else
1119  return strings[0].getValue();
1120  }
1121 #endif
1122  if(errorIfMissing)
1123  Msg::Error("GetString requires a ONELAB client");
1124  return defaultValue;
1125 }
1126 
1127 #if defined(HAVE_ONELAB)
1128 class localGmsh : public onelab::localClient {
1129 public:
1130  localGmsh() : onelab::localClient("Gmsh") {}
1131  // redefinition of virtual onelab_client::sendMergeFileRequest
1132  void sendMergeFileRequest(const std::string &name)
1133  {
1134  if(name.find(".geo") != std::string::npos){
1137  GModel::current()->setFileName(name);
1138  }
1139  else if((name.find(".opt") != std::string::npos)){
1140  MergeFile(name);
1141  }
1142  else if((name.find(".macro") != std::string::npos)){
1143  MergeFile(name);
1144  }
1145  else
1148  }
1149  void sendInfo(const std::string &msg){ Msg::Info("%s", msg.c_str()); }
1150  void sendWarning(const std::string &msg){ Msg::Warning("%s", msg.c_str()); }
1151  void sendError(const std::string &msg){ Msg::Error("%s", msg.c_str()); }
1152 };
1153 #endif
1154 
1155 void Msg::InitializeOnelab(const std::string &name, const std::string &sockname)
1156 {
1157 #if defined(HAVE_ONELAB)
1158  if(_onelabClient) delete _onelabClient;
1159  if(sockname.empty()){
1160  _onelabClient = new localGmsh();
1161  if(name != "Gmsh"){ // load db from file:
1162  FILE *fp = Fopen(name.c_str(), "rb");
1163  if(fp){
1164  Msg::Info("Reading ONELAB database '%s'", name.c_str());
1165  _onelabClient->fromFile(fp);
1166  fclose(fp);
1167  }
1168  else
1169  Error("Error loading onelab database '%s'", name.c_str());
1170  }
1171  }
1172  else{
1174  _onelabClient = c;
1175  _client = c->getGmshClient();
1176 
1177  SetOnelabNumber(name + "/Use command line", 1, false);
1178  SetOnelabString(name + "/File extension", ".geo", false);
1179  SetOnelabString(name + "/9CheckCommand", "-", false);
1180  SetOnelabString(name + "/9ComputeCommand", "-3", false);
1181 
1182  std::vector<onelab::string> ps;
1183  _onelabClient->get(ps, name + "/Action");
1184  if(ps.size()){
1185  //removed message, as terminal is set to 1 when we get here
1186  //Info("Performing ONELAB '%s'", ps[0].getValue().c_str());
1187  if(ps[0].getValue() == "initialize") Exit(0);
1188  }
1189  }
1190 
1191  // default onelab button mode
1192  SetOnelabString("ONELAB/Button", "", false, true);
1193 #endif
1194 }
1195 
1197 {
1198 #if defined(HAVE_ONELAB)
1199  // kill any running clients
1200  for(auto it = onelab::server::instance()->firstClient();
1201  it != onelab::server::instance()->lastClient(); it++){
1202  (*it)->kill();
1203  }
1204  // delete local client
1205  if(_onelabClient){
1206  delete _onelabClient;
1207  _onelabClient = nullptr;
1208  _client = nullptr;
1209  }
1210 #endif
1211 }
1212 
1213 void Msg::SetOnelabAction(const std::string &action)
1214 {
1215 #if defined(HAVE_ONELAB)
1216  if(_onelabClient){
1217  onelab::string o(_onelabClient->getName() + "/Action", action);
1218  o.setVisible(false);
1219  o.setChangedValue(0);
1220  _onelabClient->set(o);
1221  }
1222 #endif
1223 }
1224 
1226 {
1227 #if defined(HAVE_ONELAB)
1228  if(_onelabClient){
1229  std::vector<onelab::string> ps;
1230  _onelabClient->get(ps, _onelabClient->getName() + "/Action");
1231  if(ps.size()) return ps[0].getValue();
1232  }
1233 #endif
1234  return "";
1235 }
1236 
1237 void Msg::LoadOnelabClient(const std::string &clientName, const std::string &sockName)
1238 {
1239 #if defined(HAVE_ONELAB)
1240  onelab::remoteNetworkClient *client = nullptr;
1241  client = new onelab::remoteNetworkClient(clientName, sockName);
1242  if(client){
1243  std::string action, cmd;
1244  std::vector<onelab::string> ps;
1245  client->get(ps, clientName + "/Action");
1246  if(ps.size() && ps[0].getValue().size())
1247  action.assign(ps[0].getValue());
1248  //cmd.assign("");
1249  if(!action.compare("compute")){
1250  std::vector<onelab::string> ps;
1251  client->get(ps,clientName+"/FullCmdLine");
1252  if(ps.size() && ps[0].getValue().size())
1253  cmd.assign(ps[0].getValue());
1254 
1255  if(cmd.size()){
1256  Msg::Info("Loader calls <%s>", cmd.c_str());
1257  //client->sendInfo(strcat("Loader calls",cmd.c_str()));
1258  std::cout << "Loader calls " << cmd << std::endl;
1259  SystemCall(cmd.c_str(), true); //true->blocking
1260  }
1261  else
1262  Msg::Info("No full command line found for <%s>",
1263  clientName.c_str());
1264  }
1265  Msg::Info("Stopping client <%s>", clientName.c_str());
1266  delete client;
1267  }
1268  exit(1);
1269 #endif
1270 }
1271 
1273 {
1274  return _client;
1275 }
1276 
1278 {
1279 #if defined(HAVE_ONELAB)
1281 #endif
1282  return 0;
1283 }
1284 
1285 #if defined(HAVE_ONELAB)
1286 static void _setStandardOptions(onelab::parameter *p,
1287  std::map<std::string, std::vector<double> > &fopt,
1288  std::map<std::string, std::vector<std::string> > &copt)
1289 {
1290  // strings
1291  if(copt.count("Label")) p->setLabel(copt["Label"][0]);
1292  if(copt.count("ShortHelp")) // for backward compatibility
1293  p->setLabel(copt["ShortHelp"][0]);
1294  if(copt.count("Help")) p->setHelp(copt["Help"][0]);
1295  if(copt.count("Highlight")) p->setAttribute("Highlight", copt["Highlight"][0]);
1296  if(copt.count("Macro")) p->setAttribute("Macro", copt["Macro"][0]);
1297  if(copt.count("GmshOption")) p->setAttribute("GmshOption", copt["GmshOption"][0]);
1298  if(copt.count("ServerAction")) p->setAttribute("ServerAction", copt["ServerAction"][0]);
1299  if(copt.count("Units")) p->setAttribute("Units", copt["Units"][0]);
1300  if(copt.count("AutoCheck")) // for backward compatibility
1301  p->setAttribute("AutoCheck", copt["AutoCheck"][0]);
1302 
1303  // numbers
1304  if(fopt.count("Visible")) p->setVisible(fopt["Visible"][0] ? true : false);
1305  if(fopt.count("ReadOnly")) p->setReadOnly(fopt["ReadOnly"][0] ? true : false);
1306  if(fopt.count("NeverChanged")) p->setNeverChanged(fopt["NeverChanged"][0] ? true : false);
1307  if(fopt.count("ChangedValue")) p->setChangedValue(fopt["ChangedValue"][0]);
1308  if(fopt.count("ReadOnlyRange"))
1309  p->setAttribute("ReadOnlyRange", fopt["ReadOnlyRange"][0] ? "1" : "0");
1310  if(fopt.count("AutoCheck"))
1311  p->setAttribute("AutoCheck", fopt["AutoCheck"][0] ? "1" : "0");
1312 }
1313 
1314 static void _setOtherAttributes(onelab::parameter *p,
1315  std::map<std::string, std::vector<std::string> > &copt)
1316 {
1317  for(auto it = copt.begin(); it != copt.end(); it++)
1318  if(p->getAttribute(it->first).empty() &&
1319  it->first.compare("Name") &&
1320  it->first.compare("Label") &&
1321  it->first.compare("ShortHelp") &&
1322  it->first.compare("Help") &&
1323  it->first.compare("Visible") &&
1324  it->first.compare("ReadOnly") &&
1325  it->first.compare("NeverChanged") &&
1326  it->first.compare("ChangedValue")) // Attribute 'it' was not already set
1327  p->setAttribute(it->first, it->second[0]);
1328 }
1329 
1330 static std::string _getParameterName(const std::string &key,
1331  std::map<std::string, std::vector<std::string> > &copt)
1332 {
1333  std::string name(key);
1334  if(copt.count("Path")){
1335  std::string path = copt["Path"][0];
1336  // if path ends with a number, assume it's for ordering purposes
1337  if(path.size() && path[path.size() - 1] >= '0' && path[path.size() - 1] <= '9')
1338  name = path + name;
1339  else if(path.size() && path[path.size() - 1] == '/')
1340  name = path + name;
1341  else
1342  name = path + "/" + name;
1343  }
1344  return name;
1345 }
1346 #endif
1347 
1348 void Msg::ExchangeOnelabParameter(const std::string &key,
1349  std::vector<double> &val,
1350  std::map<std::string, std::vector<double> > &fopt,
1351  std::map<std::string, std::vector<std::string> > &copt)
1352 {
1353 #if defined(HAVE_ONELAB)
1354  if(!_onelabClient) return;
1355 
1356  std::string name;
1357  if(copt.count("Name"))
1358  name = copt["Name"][0];
1359 
1360  if(name.empty()){
1361  if(copt.size() || fopt.size())
1362  Msg::Error("From now on you need to use the `Name' attribute to create a "
1363  "ONELAB parameter: `Name \"%s\"'",
1364  _getParameterName(key, copt).c_str());
1365  return;
1366  }
1367 
1368  std::vector<onelab::number> ps;
1369  _onelabClient->get(ps, name);
1370  bool noRange = true, noChoices = true, noLoop = true;
1371  bool noGraph = true, noClosed = true;
1372  if(ps.size()){
1373  bool useLocalValue = ps[0].getReadOnly();
1374  if(fopt.count("ReadOnly")) useLocalValue = fopt["ReadOnly"][0];
1375  if(useLocalValue)
1376  ps[0].setValues(val);
1377  else
1378  val = ps[0].getValues(); // use value from server
1379  // keep track of these attributes, which can be changed server-side (unless
1380  // they are not visible or, for the range/choices, when explicitly setting
1381  // these attributes as ReadOnly)
1382  if(ps[0].getVisible()){
1383  if(!(fopt.count("ReadOnlyRange") && fopt["ReadOnlyRange"][0])){
1384  if(ps[0].getMin() != -onelab::parameter::maxNumber() ||
1385  ps[0].getMax() != onelab::parameter::maxNumber() ||
1386  ps[0].getStep() != 0.) noRange = false;
1387  if(ps[0].getChoices().size()) noChoices = false;
1388  }
1389  if(ps[0].getAttribute("Loop").size()) noLoop = false;
1390  if(ps[0].getAttribute("Graph").size()) noGraph = false;
1391  if(ps[0].getAttribute("Closed").size()) noClosed = false;
1392  }
1393  }
1394  else{
1395  ps.resize(1);
1396  ps[0].setName(name);
1397  ps[0].setValues(val);
1398  }
1399  // send updated parameter to server
1400  if(noRange && fopt.count("Range") && fopt["Range"].size() == 2){
1401  ps[0].setMin(fopt["Range"][0]); ps[0].setMax(fopt["Range"][1]);
1402  }
1403  else if(noRange && fopt.count("Min") && fopt.count("Max")){
1404  ps[0].setMin(fopt["Min"][0]); ps[0].setMax(fopt["Max"][0]);
1405  }
1406  else if(noRange && fopt.count("Min")){
1407  ps[0].setMin(fopt["Min"][0]); ps[0].setMax(onelab::parameter::maxNumber());
1408  }
1409  else if(noRange && fopt.count("Max")){
1410  ps[0].setMax(fopt["Max"][0]); ps[0].setMin(-onelab::parameter::maxNumber());
1411  }
1412  if(noRange && fopt.count("Step")) ps[0].setStep(fopt["Step"][0]);
1413  // if no range/min/max/step info is provided, try to compute a reasonnable
1414  // range and step (this makes the gui much nicer to use)
1415  if(val.size() && noRange && !fopt.count("Range") && !fopt.count("Step") &&
1416  !fopt.count("Min") && !fopt.count("Max")){
1417  bool isInteger = (floor(val[0]) == val[0]);
1418  double fact = isInteger ? 5. : 20.;
1419  if(val[0] > 0){
1420  ps[0].setMin(val[0] / fact);
1421  ps[0].setMax(val[0] * fact);
1422  ps[0].setStep((ps[0].getMax() - ps[0].getMin()) / 100.);
1423  }
1424  else if(val[0] < 0){
1425  ps[0].setMin(val[0] * fact);
1426  ps[0].setMax(val[0] / fact);
1427  ps[0].setStep((ps[0].getMax() - ps[0].getMin()) / 100.);
1428  }
1429  if(val[0] && isInteger){
1430  ps[0].setMin((int)ps[0].getMin());
1431  ps[0].setMax((int)ps[0].getMax());
1432  ps[0].setStep((int)ps[0].getStep());
1433  }
1434  }
1435  if(noChoices && fopt.count("Choices")){
1436  ps[0].setChoices(fopt["Choices"]);
1437  if(copt.count("Choices")) ps[0].setChoiceLabels(copt["Choices"]);
1438  }
1439  if(noLoop && copt.count("Loop")) // for backward compatibity
1440  ps[0].setAttribute("Loop", copt["Loop"][0]);
1441  if(noLoop && fopt.count("Loop"))
1442  ps[0].setAttribute("Loop", (fopt["Loop"][0] == 3.) ? "3" :
1443  (fopt["Loop"][0] == 2.) ? "2" :
1444  (fopt["Loop"][0] == 1.) ? "1" : "");
1445  if(noGraph && copt.count("Graph")) ps[0].setAttribute("Graph", copt["Graph"][0]);
1446  if(noClosed && copt.count("Closed")) // for backward compatibility
1447  ps[0].setAttribute("Closed", copt["Closed"][0]);
1448  if(noClosed && fopt.count("Closed"))
1449  ps[0].setAttribute("Closed", fopt["Closed"][0] ? "1" : "0");
1450  if(copt.count("NumberFormat"))
1451  ps[0].setAttribute("NumberFormat", copt["NumberFormat"][0]);
1452  _setStandardOptions(&ps[0], fopt, copt);
1453  _setOtherAttributes(&ps[0], copt);
1454  _onelabClient->set(ps[0]);
1455 #endif
1456 }
1457 
1458 void Msg::ExchangeOnelabParameter(const std::string &key,
1459  std::string &val,
1460  std::map<std::string, std::vector<double> > &fopt,
1461  std::map<std::string, std::vector<std::string> > &copt)
1462 {
1463 #if defined(HAVE_ONELAB)
1464  if(!_onelabClient) return;
1465 
1466  std::string name;
1467  if(copt.count("Name"))
1468  name = copt["Name"][0];
1469 
1470  if(name.empty()){
1471  if(copt.size() || fopt.size())
1472  Msg::Error("From now on you need to use the `Name' attribute to create a "
1473  "ONELAB parameter: `Name \"%s\"'",
1474  _getParameterName(key, copt).c_str());
1475  return;
1476  }
1477 
1478  std::vector<onelab::string> ps;
1479  _onelabClient->get(ps, name);
1480  bool noChoices = true, noClosed = true, noMultipleSelection = true;
1481  if(ps.size()){
1482  bool useLocalValue = ps[0].getReadOnly();
1483  if(fopt.count("ReadOnly")) useLocalValue = fopt["ReadOnly"][0];
1484  if(useLocalValue)
1485  ps[0].setValue(val); // use local value
1486  else
1487  val = ps[0].getValue(); // use value from server
1488  // keep track of these attributes, which can be changed server-side (unless
1489  // they are not visible)
1490  if(ps[0].getVisible()){
1491  if(ps[0].getChoices().size()) noChoices = false;
1492  if(ps[0].getAttribute("Closed").size()) noClosed = false;
1493  if(ps[0].getAttribute("MultipleSelection").size()) noMultipleSelection = false;
1494  }
1495  }
1496  else{
1497  ps.resize(1);
1498  ps[0].setName(name);
1499  ps[0].setValue(val);
1500  }
1501  if(copt.count("Kind")) ps[0].setKind(copt["Kind"][0]);
1502  if(noChoices && copt.count("Choices")) ps[0].setChoices(copt["Choices"]);
1503  if(noClosed && copt.count("Closed")) // for backward compatibility
1504  ps[0].setAttribute("Closed", copt["Closed"][0]);
1505  if(noClosed && fopt.count("Closed"))
1506  ps[0].setAttribute("Closed", fopt["Closed"][0] ? "1" : "0");
1507  if(noMultipleSelection && copt.count("MultipleSelection"))
1508  ps[0].setAttribute("MultipleSelection", copt["MultipleSelection"][0]);
1509  _setStandardOptions(&ps[0], fopt, copt);
1510  _setOtherAttributes(&ps[0], copt);
1511  _onelabClient->set(ps[0]);
1512 #endif
1513 }
1514 
1515 void Msg::UndefineOnelabParameter(const std::string &name)
1516 {
1517 #if defined(HAVE_ONELAB)
1518  if(!_onelabClient) return;
1519  _onelabClient->clear(name);
1520 #endif
1521 }
1522 
1524 {
1525 #if defined(HAVE_ONELAB)
1526  if(_onelabClient){
1527  std::vector<onelab::number> oldn;
1528  _onelabClient->get(oldn, "Gmsh/Number of physical groups");
1529  int oldsize = 0;
1530  if(oldn.size()) oldsize = (int)oldn[0].getValue();
1531 
1532  std::map<int, std::vector<GEntity*> > groups[4];
1534  int size = 0;
1535  for(int dim = 0; dim <= 3; dim++)
1536  size += groups[dim].size();
1537  onelab::number n("Gmsh/Number of physical groups", size);
1538  n.setReadOnly(true);
1539  n.setChangedValue(1);
1540  n.setVisible(false);
1541  n.setAttribute("Closed", "1");
1542  _onelabClient->set(n);
1543 
1544  onelab::number nd("Gmsh/Model dimension", GModel::current()->getDim());
1545  nd.setReadOnly(true);
1546  nd.setChangedValue(1);
1547  nd.setVisible(false);
1548  nd.setAttribute("Closed", "1");
1549  _onelabClient->set(nd);
1550 
1551  int index = 1;
1552  for(int dim = 0; dim <= 3; dim++){
1553  for(auto it = groups[dim].begin();
1554  it != groups[dim].end(); it++){
1555  int num = it->first;
1556  std::string name = GModel::current()->getPhysicalName(dim, it->first);
1557  char tmp[256];
1558  if(name.empty()){
1559  sprintf(tmp, "Physical %s %d", (dim == 3) ? "Volume" : (dim == 2) ? "Surface" :
1560  (dim == 1) ? "Curve" : "Point", num);
1561  name = tmp;
1562  }
1563  sprintf(tmp, "Gmsh/Physical group %d/", index);
1564  std::string str = tmp;
1565  onelab::number n1(str + "Dimension", dim);
1566  n1.setReadOnly(true);
1567  n1.setChangedValue(1);
1568  n1.setVisible(false);
1569  _onelabClient->set(n1);
1570  onelab::number n2(str + "Number", num);
1571  n2.setReadOnly(true);
1572  n2.setChangedValue(1);
1573  n2.setVisible(false);
1574  _onelabClient->set(n2);
1575  onelab::string s(str + "Name", name);
1576  s.setReadOnly(true);
1577  s.setChangedValue(1);
1578  s.setVisible(false);
1579  _onelabClient->set(s);
1580  index++;
1581  }
1582  }
1583 
1584  // remove old ones
1585  for(int index = size + 1; index < oldsize + 1; index++){
1586  char tmp[256];
1587  sprintf(tmp, "Gmsh/Physical group %d/Dimension", index);
1588  _onelabClient->clear(tmp);
1589  sprintf(tmp, "Gmsh/Physical group %d/Number", index);
1590  _onelabClient->clear(tmp);
1591  sprintf(tmp, "Gmsh/Physical group %d/Name", index);
1592  _onelabClient->clear(tmp);
1593  }
1594 
1595 #if defined(HAVE_FLTK)
1596  if(FlGui::available()){
1597  FlGui::instance()->resetVisibility();
1598  FlGui::instance()->rebuildTree(false);
1599  }
1600 #endif
1601  }
1602 #endif
1603 }
1604 
1605 void Msg::RunOnelabClient(const std::string &name, const std::string &command)
1606 {
1607 #if defined(HAVE_ONELAB)
1608  onelabUtils::runClient(name, command);
1609 #endif
1610 }
1611 
1612 void Msg::SetOnelabChanged(int value, const std::string &client)
1613 {
1614 #if defined(HAVE_ONELAB)
1615  onelab::server::instance()->setChanged(value, client);
1616 #endif
1617 }
1618 
1620 {
1621 #if defined(HAVE_MPI)
1622  MPI_Barrier(MPI_COMM_WORLD);
1623 #endif
1624 }
1625 
1626 #if defined(_OPENMP)
1627 
1628 int Msg::GetNumThreads(){ return omp_get_num_threads(); }
1629 void Msg::SetNumThreads(int num){ omp_set_num_threads(num); }
1630 int Msg::GetMaxThreads(){ return omp_get_max_threads(); }
1631 int Msg::GetThreadNum(){ return omp_get_thread_num(); }
1632 
1633 #else
1634 
1635 int Msg::GetNumThreads(){ return 1; }
1636 void Msg::SetNumThreads(int num){ }
1637 int Msg::GetMaxThreads(){ return 1; }
1638 int Msg::GetThreadNum(){ return 0; }
1639 
1640 #endif
1641 
1643  : _totalElementToTreat(num), _currentI(0), _nextIToCheck(0),
1644  _initialTime(Cpu()), _lastTime(_initialTime), _lastPercentage(0),
1645  _progressMeterStep(Msg::GetProgressMeterStep())
1646 {
1649 }
1650 
1652 {
1656 }
1657 
1659 {
1660  if(Msg::GetCommRank() || Msg::GetNumThreads() > 1) return;
1661 
1662  ++_currentI;
1663  if (_currentI < _nextIToCheck) return;
1664 
1665  int currentPercentage = _currentI * 100 / _totalElementToTreat;
1666  // check every percentage only
1667  _nextIToCheck = (currentPercentage + 1) * _totalElementToTreat / 100 + 1;
1668 
1669  double currentTime = Cpu();
1670  if ((currentPercentage < 5 && currentTime - _lastTime > 15.) ||
1671  (currentPercentage > _lastPercentage + 4 && currentTime - _lastTime > 10.)) {
1672  _lastPercentage = currentPercentage;
1673  _lastTime = currentTime;
1674  const double remaining = (currentTime - _initialTime) / (_currentI + 1) *
1676  if (remaining < 60*2)
1677  Msg::ProgressMeter(_currentI - 1, true,
1678  "%d%% (remaining time ~%g seconds)",
1679  currentPercentage, remaining);
1680  else if (remaining < 60*60*2)
1681  Msg::ProgressMeter(_currentI - 1, true,
1682  "%d%% (remaining time ~%g minutes)",
1683  currentPercentage, remaining / 60);
1684  else
1685  Msg::ProgressMeter(_currentI - 1, true,
1686  "%d%% (remaining time ~%g hours)",
1687  currentPercentage, remaining / 3600);
1688  }
1689 }
onelab::server::instance
static server * instance(const std::string &address="")
Definition: onelab.h:1309
onelab::string
Definition: onelab.h:678
Msg::GetCallback
static GmshMessage * GetCallback()
Definition: GmshMessage.cpp:244
TimeOfDay
double TimeOfDay()
Definition: OS.cpp:399
onelab::localClient
Definition: onelab.h:1393
streamIsFile
static int streamIsFile(FILE *stream)
Definition: GmshMessage.cpp:393
Msg::SetOnelabAction
static void SetOnelabAction(const std::string &action)
Definition: GmshMessage.cpp:1213
SystemCall
int SystemCall(const std::string &command, bool blocking)
Definition: OS.cpp:637
SplitFileName
std::vector< std::string > SplitFileName(const std::string &fileName)
Definition: StringUtils.cpp:93
Msg::_progressMeterCurrent
static std::atomic< int > _progressMeterCurrent
Definition: GmshMessage.h:40
GmshSocket::Warning
void Warning(const char *str)
Definition: GmshSocket.h:199
Msg::_commRank
static int _commRank
Definition: GmshMessage.h:34
Msg::GetProgressMeterStep
static int GetProgressMeterStep()
Definition: GmshMessage.cpp:307
onelab::parameter::setLabel
void setLabel(const std::string &label)
Definition: onelab.h:91
Msg::GetCommandLineStrings
static std::map< std::string, std::string > & GetCommandLineStrings()
Definition: GmshMessage.cpp:297
Msg::GetVerbosity
static int GetVerbosity()
Definition: GmshMessage.cpp:254
gmshLocalNetworkClient.h
MergeFile
int MergeFile(const std::string &fileName, bool errorIfMissing, bool setBoundingBox, bool importPhysicalsInOnelab, int partitionToRead)
Definition: OpenFile.cpp:298
Msg::_atLeastOneErrorInRun
static int _atLeastOneErrorInRun
Definition: GmshMessage.h:52
Msg::SetInfoMem
static void SetInfoMem(bool val)
Definition: GmshMessage.cpp:335
Msg::GetFirstError
static std::string GetFirstError()
Definition: GmshMessage.cpp:357
Msg::Info
static void Info(const char *fmt,...)
Definition: GmshMessage.cpp:587
Msg::RunOnelabClient
static void RunOnelabClient(const std::string &name, const std::string &exe="")
Definition: GmshMessage.cpp:1605
OS.h
Msg::GetOnelabNumber
static double GetOnelabNumber(const std::string &name, double defaultValue=0., bool errorIfMissing=false)
Definition: GmshMessage.cpp:1084
Msg::Debug
static void Debug(const char *fmt,...)
Definition: GmshMessage.cpp:752
Msg::_infoCpu
static bool _infoCpu
Definition: GmshMessage.h:46
c
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
Definition: discreteFrechetDistance.cpp:15
MsgProgressStatus::next
void next()
Definition: GmshMessage.cpp:1658
Msg::_progressMeterStep
static int _progressMeterStep
Definition: GmshMessage.h:39
Msg::Warning
static void Warning(const char *fmt,...)
Definition: GmshMessage.cpp:543
Msg::_commandLineNumbers
static std::map< std::string, std::vector< double > > _commandLineNumbers
Definition: GmshMessage.h:60
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
Msg::StatusBar
static void StatusBar(bool log, const char *fmt,...)
Definition: GmshMessage.cpp:686
Msg::Timer
static double & Timer(const std::string &str)
Definition: GmshMessage.cpp:340
Msg::GetCommandLineFull
static std::string GetCommandLineFull()
Definition: GmshMessage.cpp:282
Msg::SetExecutableName
static void SetExecutableName(const std::string &name)
Definition: GmshMessage.cpp:367
Msg::ImportPhysicalGroupsInOnelab
static void ImportPhysicalGroupsInOnelab()
Definition: GmshMessage.cpp:1523
MsgProgressStatus::_lastTime
double _lastTime
Definition: GmshMessage.h:184
CTX::solver
struct CTX::@1 solver
Msg::SetProgressMeterStep
static void SetProgressMeterStep(int step)
Definition: GmshMessage.cpp:302
onelab::parameter::setVisible
void setVisible(bool visible)
Definition: onelab.h:109
Msg::GetGmshClient
static GmshClient * GetGmshClient()
Definition: GmshMessage.cpp:1272
onelab::parameter::setNeverChanged
void setNeverChanged(bool never)
Definition: onelab.h:105
Msg::StatusGl
static void StatusGl(const char *fmt,...)
Definition: GmshMessage.cpp:727
Msg::Initialize
static void Initialize(int argc, char **argv)
Definition: GmshMessage.cpp:125
onelab::client::sendError
virtual void sendError(const std::string &msg)
Definition: onelab.h:1229
Msg::_commandLineArgs
static std::vector< std::string > _commandLineArgs
Definition: GmshMessage.h:57
Msg::GetValue
static double GetValue(const char *text, double defaultval)
Definition: GmshMessage.cpp:900
GmshSocket.h
GmshMessage.h
Msg::PrintTimers
static void PrintTimers()
Definition: GmshMessage.cpp:828
Msg::ExchangeOnelabParameter
static void ExchangeOnelabParameter(const std::string &key, std::vector< double > &val, std::map< std::string, std::vector< double > > &fopt, std::map< std::string, std::vector< std::string > > &copt)
Definition: GmshMessage.cpp:1348
Msg::AddOnelabStringChoice
static void AddOnelabStringChoice(const std::string &name, const std::string &kind, const std::string &value, bool updateValue=true, bool readOnly=false, bool visible=true)
Definition: GmshMessage.cpp:1045
onelab::parameter::maxNumber
static double maxNumber()
Definition: onelab.h:204
MsgProgressStatus::MsgProgressStatus
MsgProgressStatus(int numElementToTreat)
Definition: GmshMessage.cpp:1642
onelab::remoteNetworkClient
Definition: onelab.h:1519
onelab::client::sendInfo
virtual void sendInfo(const std::string &msg)
Definition: onelab.h:1221
Fopen
FILE * Fopen(const char *f, const char *mode)
Definition: OS.cpp:273
Msg::SetCommSize
static void SetCommSize(int val)
Definition: GmshMessage.cpp:234
onelab::number
Definition: onelab.h:432
GmshClient
Definition: GmshSocket.h:261
Msg::GetThreadNum
static int GetThreadNum()
Definition: GmshMessage.cpp:1638
Msg::SetNumThreads
static void SetNumThreads(int num)
Definition: GmshMessage.cpp:1636
Msg::SetOnelabString
static void SetOnelabString(const std::string &name, const std::string &val, bool visible=true, bool persistent=false, bool readOnly=false, int changedValue=3, const std::string &kind="")
Definition: GmshMessage.cpp:1021
Msg::_errorCount
static int _errorCount
Definition: GmshMessage.h:52
CTX::instance
static CTX * instance()
Definition: Context.cpp:122
MergePostProcessingFile
int MergePostProcessingFile(const std::string &fileName, int showViews, bool showLastStep, bool errorIfMissing)
Definition: OpenFile.cpp:574
GModel::getPhysicalGroups
void getPhysicalGroups(std::map< int, std::vector< GEntity * > > groups[4]) const
Definition: GModel.cpp:837
addGmshPathToEnvironmentVar
static void addGmshPathToEnvironmentVar(const std::string &name)
Definition: GmshMessage.cpp:104
Msg::Finalize
static void Finalize()
Definition: GmshMessage.cpp:195
MsgProgressStatus::_nextIToCheck
int _nextIToCheck
Definition: GmshMessage.h:183
GModel::getPhysicalName
std::string getPhysicalName(int dim, int num) const
Definition: GModel.cpp:961
Msg::Barrier
static void Barrier()
Definition: GmshMessage.cpp:1619
Msg::_infoMem
static bool _infoMem
Definition: GmshMessage.h:48
CTX::autoShowLastStep
int autoShowLastStep
Definition: Context.h:335
Msg::UseOnelab
static bool UseOnelab()
Definition: GmshMessage.cpp:978
GModel::setFileName
void setFileName(const std::string &fileName)
Definition: GModel.cpp:123
onelab::remoteNetworkClient::get
virtual bool get(std::vector< number > &ps, const std::string &name="")
Definition: onelab.h:1675
Msg::InitializeOnelab
static void InitializeOnelab(const std::string &name, const std::string &sockname="")
Definition: GmshMessage.cpp:1155
Msg::GetCommRank
static int GetCommRank()
Definition: GmshMessage.cpp:219
Msg
Definition: GmshMessage.h:31
Msg::GetFirstWarning
static std::string GetFirstWarning()
Definition: GmshMessage.cpp:352
Msg::PrintErrorCounter
static void PrintErrorCounter(const char *title)
Definition: GmshMessage.cpp:859
Msg::GetString
static std::string GetString(const char *text, const std::string &defaultval)
Definition: GmshMessage.cpp:927
onelab::server
Definition: onelab.h:1295
onelab
Definition: GmshMessage.h:18
SetEnvironmentVar
void SetEnvironmentVar(const std::string &var, const std::string &val)
Definition: OS.cpp:305
Msg::StopProgressMeter
static void StopProgressMeter()
Definition: GmshMessage.cpp:318
Cpu
double Cpu()
Definition: OS.cpp:366
onelab.h
Msg::SetOnelabChanged
static void SetOnelabChanged(int value, const std::string &client="Gmsh")
Definition: GmshMessage.cpp:1612
Msg::GetMaxThreads
static int GetMaxThreads()
Definition: GmshMessage.cpp:1637
onelab::parameter::setHelp
void setHelp(const std::string &help)
Definition: onelab.h:92
Msg::SetCallback
static void SetCallback(GmshMessage *callback)
Definition: GmshMessage.cpp:239
Msg::_logFile
static FILE * _logFile
Definition: GmshMessage.h:72
Msg::SetWindowTitle
static void SetWindowTitle(const std::string &title)
Definition: GmshMessage.cpp:743
MsgProgressStatus::_currentI
int _currentI
Definition: GmshMessage.h:183
Msg::PrintResources
static std::string PrintResources(bool printDate, bool printWallTime, bool printCpu, bool printMem)
Definition: GmshMessage.cpp:436
Msg::_callback
static GmshMessage * _callback
Definition: GmshMessage.h:55
onelab::server::getNumClients
int getNumClients()
Definition: onelab.h:1332
GmshSocket::Info
void Info(const char *str)
Definition: GmshSocket.h:198
Msg::_execName
static std::string _execName
Definition: GmshMessage.h:69
GmshMessage
Definition: GmshMessage.h:23
onelabUtils.h
Msg::Exit
static void Exit(int level)
Definition: GmshMessage.cpp:384
GetEnvironmentVar
std::string GetEnvironmentVar(const std::string &var)
Definition: OS.cpp:284
onelab::parameter
Definition: onelab.h:48
Msg::GetCommSize
static int GetCommSize()
Definition: GmshMessage.cpp:224
streamIsVT100
static int streamIsVT100(FILE *stream)
Definition: GmshMessage.cpp:403
onelab::parameter::setAttribute
void setAttribute(const std::string &key, const std::string &value)
Definition: onelab.h:111
onelab::server::_server
static server * _server
Definition: onelab.h:1298
CTX::autoShowViews
int autoShowViews
Definition: Context.h:335
Msg::_commSize
static int _commSize
Definition: GmshMessage.h:34
Msg::_verbosity
static int _verbosity
Definition: GmshMessage.h:37
Msg::LoadOnelabClient
static void LoadOnelabClient(const std::string &name, const std::string &sockName)
Definition: GmshMessage.cpp:1237
GmshGlobal.h
GmshSocket::Progress
void Progress(const char *str)
Definition: GmshSocket.h:201
onelab::parameter::setReadOnly
void setReadOnly(bool readOnly)
Definition: onelab.h:110
onelab::client::sendMergeFileRequest
virtual void sendMergeFileRequest(const std::string &msg)
Definition: onelab.h:1237
StringUtils.h
MsgProgressStatus::_progressMeterStep
int _progressMeterStep
Definition: GmshMessage.h:186
Msg::GetLastError
static std::string GetLastError()
Definition: GmshMessage.cpp:362
Msg::FinalizeOnelab
static void FinalizeOnelab()
Definition: GmshMessage.cpp:1196
Msg::GetLaunchDate
static std::string GetLaunchDate()
Definition: GmshMessage.cpp:272
Msg::GetNumOnelabClients
static int GetNumOnelabClients()
Definition: GmshMessage.cpp:1277
Msg::ResetErrorCounter
static void ResetErrorCounter()
Definition: GmshMessage.cpp:850
Msg::GetWarningCount
static int GetWarningCount()
Definition: GmshMessage.cpp:342
Msg::_warningCount
static int _warningCount
Definition: GmshMessage.h:52
Msg::GetCommandLineNumbers
static std::map< std::string, std::vector< double > > & GetCommandLineNumbers()
Definition: GmshMessage.cpp:292
Msg::Direct
static void Direct(const char *fmt,...)
Definition: GmshMessage.cpp:634
Context.h
Msg::GetCommandLineArgs
static std::vector< std::string > & GetCommandLineArgs()
Definition: GmshMessage.cpp:277
Msg::_launchDate
static std::string _launchDate
Definition: GmshMessage.h:58
Msg::GetAnswer
static int GetAnswer(const char *question, int defaultval, const char *zero, const char *one, const char *two=nullptr)
Definition: GmshMessage.cpp:952
Msg::_startTime
static double _startTime
Definition: GmshMessage.h:50
MsgProgressStatus::_totalElementToTreat
int _totalElementToTreat
Definition: GmshMessage.h:183
onelab::client::sendWarning
virtual void sendWarning(const std::string &msg)
Definition: onelab.h:1225
Msg::StartProgressMeter
static void StartProgressMeter(int ntotal)
Definition: GmshMessage.cpp:312
Msg::_firstWarning
static std::string _firstWarning
Definition: GmshMessage.h:53
MsgProgressStatus::~MsgProgressStatus
~MsgProgressStatus()
Definition: GmshMessage.cpp:1651
onelab::server::lastClient
citer lastClient()
Definition: onelab.h:1331
MsgProgressStatus::_lastPercentage
int _lastPercentage
Definition: GmshMessage.h:185
Msg::GetNumThreads
static int GetNumThreads()
Definition: GmshMessage.cpp:1635
Msg::_progressMeterTotal
static int _progressMeterTotal
Definition: GmshMessage.h:42
Msg::SetVerbosity
static void SetVerbosity(int val)
Definition: GmshMessage.cpp:249
Options.h
onelabUtils::runClient
void runClient(const std::string &name="", const std::string &command="")
GModel.h
Msg::_lastError
static std::string _lastError
Definition: GmshMessage.h:53
Msg::_logFileName
static std::string _logFileName
Definition: GmshMessage.h:71
Msg::_firstError
static std::string _firstError
Definition: GmshMessage.h:53
CTX::exeFileName
std::string exeFileName
Definition: Context.h:145
GetMemoryUsage
long GetMemoryUsage()
Definition: OS.cpp:406
onelab::client
Definition: onelab.h:1201
Msg::_client
static GmshClient * _client
Definition: GmshMessage.h:63
line
Definition: shapeFunctions.h:342
Msg::SetOnelabNumber
static void SetOnelabNumber(const std::string &name, double val, bool visible=true, bool persistent=false, bool readOnly=false, int changedValue=3)
Definition: GmshMessage.cpp:987
GetExecutableFileName
std::string GetExecutableFileName()
Definition: OS.cpp:423
onelab::parameter::setChangedValue
void setChangedValue(int value)
Definition: onelab.h:104
Msg::RequestRender
static void RequestRender()
Definition: GmshMessage.cpp:629
onelab::parameter::getAttribute
std::string getAttribute(const std::string &key) const
Definition: onelab.h:192
Msg::_timers
static std::map< std::string, double > _timers
Definition: GmshMessage.h:44
CTX::terminal
int terminal
Definition: Context.h:167
Msg::ProgressMeter
static void ProgressMeter(int n, bool log, const char *fmt,...)
Definition: GmshMessage.cpp:783
Msg::Auto
static void Auto(const char *fmt,...)
Definition: GmshMessage.cpp:671
Msg::UndefineOnelabParameter
static void UndefineOnelabParameter(const std::string &name)
Definition: GmshMessage.cpp:1515
Msg::GetOnelabString
static std::string GetOnelabString(const std::string &name, const std::string &defaultValue="", bool errorIfMissing=false)
Definition: GmshMessage.cpp:1105
c1
const double c1
Definition: GaussQuadratureHex.cpp:16
GmshSocket::Error
void Error(const char *str)
Definition: GmshSocket.h:200
Msg::GetOnelabAction
static std::string GetOnelabAction()
Definition: GmshMessage.cpp:1225
OpenFile.h
Msg::GetErrorCount
static int GetErrorCount()
Definition: GmshMessage.cpp:347
Msg::GetExecutableName
static std::string GetExecutableName()
Definition: GmshMessage.cpp:372
onelab::server::setChanged
void setChanged(int changed, const std::string &client="")
Definition: onelab.h:1345
GModel::current
static GModel * current(int index=-1)
Definition: GModel.cpp:136
Msg::SetCommRank
static void SetCommRank(int val)
Definition: GmshMessage.cpp:229
Msg::SetLogFile
static void SetLogFile(const std::string &name)
Definition: GmshMessage.cpp:259
Msg::_commandLineStrings
static std::map< std::string, std::string > _commandLineStrings
Definition: GmshMessage.h:61
Msg::SetInfoCpu
static void SetInfoCpu(bool val)
Definition: GmshMessage.cpp:330
MsgProgressStatus::_initialTime
double _initialTime
Definition: GmshMessage.h:184